@cmts-dev/carmentis-sdk-core 1.4.1 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blockchain/virtualBlockchains/ApplicationLedgerVb.d.ts +3 -4
- package/dist/blockchain/virtualBlockchains/ApplicationLedgerVb.d.ts.map +1 -1
- package/dist/carmentis-sdk-core.cjs +3 -3
- package/dist/carmentis-sdk-core.d.ts +26 -0
- package/dist/carmentis-sdk-core.d.ts.map +1 -1
- package/dist/carmentis-sdk-core.js +4900 -3653
- package/dist/crypto/CryptoSchemeFactory.d.ts.map +1 -1
- package/dist/crypto/encoder/signature/dckf/DckfSignatureDecoder.d.ts +1 -0
- package/dist/crypto/encoder/signature/dckf/DckfSignatureDecoder.d.ts.map +1 -1
- package/dist/crypto/encoder/signature/dckf/DckfSignatureEncoder.d.ts.map +1 -1
- package/dist/crypto/encryption/public-key-encryption/MlKemPrivateDecryptionKey.d.ts +0 -1
- package/dist/crypto/encryption/public-key-encryption/MlKemPrivateDecryptionKey.d.ts.map +1 -1
- package/dist/crypto/encryption/public-key-encryption/MlKemPublicKeyEncryptionScheme.d.ts +3 -0
- package/dist/crypto/encryption/public-key-encryption/MlKemPublicKeyEncryptionScheme.d.ts.map +1 -1
- package/dist/crypto/signature/SignatureSchemeId.d.ts +2 -1
- package/dist/crypto/signature/SignatureSchemeId.d.ts.map +1 -1
- package/dist/crypto/signature/jwk/JwkBinaryEncoder.d.ts +27 -0
- package/dist/crypto/signature/jwk/JwkBinaryEncoder.d.ts.map +1 -0
- package/dist/crypto/signature/jwk/JwkPrivateSignatureKey.d.ts +122 -0
- package/dist/crypto/signature/jwk/JwkPrivateSignatureKey.d.ts.map +1 -0
- package/dist/crypto/signature/jwk/JwkPublicSignatureKey.d.ts +100 -0
- package/dist/crypto/signature/jwk/JwkPublicSignatureKey.d.ts.map +1 -0
- package/dist/crypto/signature/jwk/JwkSignatureAlgorithm.d.ts +159 -0
- package/dist/crypto/signature/jwk/JwkSignatureAlgorithm.d.ts.map +1 -0
- package/dist/crypto/signature/jwk/JwkSignatureBackend.d.ts +56 -0
- package/dist/crypto/signature/jwk/JwkSignatureBackend.d.ts.map +1 -0
- package/dist/crypto/signature/jwk/JwkSignatureScheme.d.ts +60 -0
- package/dist/crypto/signature/jwk/JwkSignatureScheme.d.ts.map +1 -0
- package/dist/crypto/signature/jwk/webcrypto.d.ts +12 -0
- package/dist/crypto/signature/jwk/webcrypto.d.ts.map +1 -0
- package/dist/crypto/signature/secp256k1/Secp256k1PrivateSignatureKey.d.ts.map +1 -1
- package/dist/crypto/signature/signer/binary/BinaryEncoder.d.ts +6 -0
- package/dist/crypto/signature/signer/binary/BinaryEncoder.d.ts.map +1 -0
- package/dist/crypto/signature/signer/binary/BinaryEndoding.d.ts +9 -0
- package/dist/crypto/signature/signer/binary/BinaryEndoding.d.ts.map +1 -0
- package/dist/crypto/signature/signer/binary/BinarySigner.d.ts +8 -0
- package/dist/crypto/signature/signer/binary/BinarySigner.d.ts.map +1 -0
- package/dist/crypto/signature/signer/binary/BinaryVerifier.d.ts +8 -0
- package/dist/crypto/signature/signer/binary/BinaryVerifier.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/JsonCanonicalUtf8Signature.d.ts +47 -0
- package/dist/crypto/signature/signer/json/JsonCanonicalUtf8Signature.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/JsonCanonicalUtf8Signer.d.ts +23 -0
- package/dist/crypto/signature/signer/json/JsonCanonicalUtf8Signer.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/JsonCanonicalizationMethod.d.ts +11 -0
- package/dist/crypto/signature/signer/json/JsonCanonicalizationMethod.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/JsonEncoder.d.ts +5 -0
- package/dist/crypto/signature/signer/json/JsonEncoder.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/JsonSignature.d.ts +9 -0
- package/dist/crypto/signature/signer/json/JsonSignature.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/JsonSignatureParser.d.ts +10 -0
- package/dist/crypto/signature/signer/json/JsonSignatureParser.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/JsonSignatureUtils.d.ts +9 -0
- package/dist/crypto/signature/signer/json/JsonSignatureUtils.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/JsonSignatureVerifier.d.ts +12 -0
- package/dist/crypto/signature/signer/json/JsonSignatureVerifier.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/JwsSignature.d.ts +27 -0
- package/dist/crypto/signature/signer/json/JwsSignature.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/JwsSigner.d.ts +15 -0
- package/dist/crypto/signature/signer/json/JwsSigner.d.ts.map +1 -0
- package/dist/crypto/signature/signer/json/SignatureVerificationUtils.d.ts +10 -0
- package/dist/crypto/signature/signer/json/SignatureVerificationUtils.d.ts.map +1 -0
- package/dist/tags/CertificateTagHandler.d.ts +8 -0
- package/dist/tags/CertificateTagHandler.d.ts.map +1 -0
- package/dist/type/JsonSignatureSchemas.d.ts +99 -0
- package/dist/type/JsonSignatureSchemas.d.ts.map +1 -0
- package/dist/type/Resolver.d.ts +2 -0
- package/dist/type/Resolver.d.ts.map +1 -1
- package/dist/type/tags/CertificateTag.d.ts +6 -0
- package/dist/type/tags/CertificateTag.d.ts.map +1 -0
- package/dist/type/tags/SignatureTag.d.ts +27 -0
- package/dist/type/tags/SignatureTag.d.ts.map +1 -0
- package/dist/wallet/ActorCrypto.d.ts +1 -0
- package/dist/wallet/ActorCrypto.d.ts.map +1 -1
- package/dist/wallet/WalletCrypto.d.ts +0 -42
- package/dist/wallet/WalletCrypto.d.ts.map +1 -1
- package/package.json +8 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},n=function(e){return e[e.CARMENTIS_ERROR=0]=`CARMENTIS_ERROR`,e[e.NODE_ERROR=1]=`NODE_ERROR`,e[e.NODE_NOT_AVAILABLE_DURING_SYNCHRONISATION_ERROR=2]=`NODE_NOT_AVAILABLE_DURING_SYNCHRONISATION_ERROR`,e[e.INTERNAL_ERROR=500]=`INTERNAL_ERROR`,e[e.TYPE_CHECKING_FAILURE_ERROR=501]=`TYPE_CHECKING_FAILURE_ERROR`,e[e.SERIALIZATION_ERROR=502]=`SERIALIZATION_ERROR`,e[e.PROOF_VERIFICATION_FAILURE=300]=`PROOF_VERIFICATION_FAILURE`,e[e.BLOCKCHAIN_ERROR=100]=`BLOCKCHAIN_ERROR`,e[e.ACCOUNT_NOT_FOUND=101]=`ACCOUNT_NOT_FOUND`,e[e.ACCOUNT_ALREADY_EXISTS=102]=`ACCOUNT_ALREADY_EXISTS`,e[e.ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY=103]=`ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY`,e[e.ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY_HASH=104]=`ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY_HASH`,e[e.ACCOUNT_ALREADY_EXISTS_FOR_PUBLIC_KEY=105]=`ACCOUNT_ALREADY_EXISTS_FOR_PUBLIC_KEY`,e[e.ACCOUNT_NOT_FOUND_FOR_ADDRESS=106]=`ACCOUNT_NOT_FOUND_FOR_ADDRESS`,e[e.ORGANIZATION_NOT_FOUND=107]=`ORGANIZATION_NOT_FOUND`,e[e.APPLICATION_NOT_FOUND=108]=`APPLICATION_NOT_FOUND`,e[e.APPLICATION_LEDGER_NOT_FOUND=109]=`APPLICATION_LEDGER_NOT_FOUND`,e[e.VALIDATOR_NODE_NOT_FOUND=110]=`VALIDATOR_NODE_NOT_FOUND`,e[e.VIRTUAL_BLOCKCHAIN_NOT_FOUND=111]=`VIRTUAL_BLOCKCHAIN_NOT_FOUND`,e[e.VIRTUAL_BLOCKCHAIN_ALREADY_EXISTS=112]=`VIRTUAL_BLOCKCHAIN_ALREADY_EXISTS`,e[e.MICROBLOCK_STRUCTURE_CHECKING_ERROR=113]=`MICROBLOCK_STRUCTURE_CHECKING_ERROR`,e[e.ECONOMICS_ERROR=200]=`ECONOMICS_ERROR`,e[e.INVALID_TOKEN_UNIT=201]=`INVALID_TOKEN_UNIT`,e[e.PROTOCOL_ERROR=400]=`PROTOCOL_ERROR`,e}({}),r=class extends Error{},i=class extends r{},a=class extends r{},o=class e extends Error{constructor(e,t=n.CARMENTIS_ERROR){super(`[error ${t}] ${e}`),this.code=t}getErrorCode(){return this.code}static isCarmentisError(t){return t instanceof e}},s=class extends o{constructor(e){super(`Microblock structure checking error: ${e??`Not specified`}`,n.MICROBLOCK_STRUCTURE_CHECKING_ERROR)}},c=class extends o{constructor(){super(`You are not authenticated`)}},l=class extends o{constructor(e=`Parsing failure`){super(e)}},u=class extends o{constructor(e){super(e,n.BLOCKCHAIN_ERROR)}},d=class extends o{},f=class extends d{constructor(e){super(e??`Decryption failure`)}},p=class extends f{constructor(e){super(e)}},m=class extends o{},h=class extends m{},g=class extends h{constructor(e){super(`Connection with node at ${e} refused`,n.NODE_ERROR)}},_=class extends h{constructor(){super(`Query rejected while catching up`,n.NODE_ERROR)}},v=class extends o{constructor(e,t=n.ECONOMICS_ERROR){super(e,t)}},y=class extends v{constructor(){super(`Invalid unit type`,n.INVALID_TOKEN_UNIT)}},b=class extends o{constructor(e,t=n.BLOCKCHAIN_ERROR){super(e,t)}},ee=class extends Error{constructor(){super(`No implemented`)}},x=class extends b{constructor(e,t){super(`MicroBlock in virtual blockchain ${e.encode()} not found at height ${t}`)}},te=class extends b{constructor(){super(`MicroBlock not found`)}},ne=class extends b{constructor(){super(`MicroBlock not found in block`)}},re=class extends r{constructor(e){super(`Actor '${e}' already defined`)}},ie=class extends r{constructor(e,t){super(`invalid actor ID ${e} (expected ID: ${t})`)}},ae=class extends r{constructor(e){super(`Channel '${e}' already defined`)}},oe=class extends r{constructor(e){super(`Unknown actor '${e}'`)}},se=class extends r{constructor(e){super(`Unknown channel '${e}'`)}},ce=class extends o{constructor(e,t,r){super(`Proof verification failed on channel ${e} (computed hash is ${t}, on-chain hash is ${r})`,n.PROOF_VERIFICATION_FAILURE)}},le=class extends r{constructor(e){super(`Cannot subscribe as undefined actor ${e}`)}},S=class extends r{constructor(e){super(`Actor ${e} is already subscribed`)}},ue=class extends r{constructor(e){super(`signature scheme of type ${e} is not allowed on this application ledger`)}},de=class extends r{constructor(e){super(`PKE scheme of type ${e} is not allowed on this application ledger`)}},fe=class extends r{constructor(e){super(`Invalid channel ID ${e}`)}},pe=class extends r{constructor(){super(`Current actor not found`)}},me=class extends b{},he=class extends b{constructor(e,t){super(`Actor ${e} has not been invited to channel ${t}`)}},ge=class extends b{constructor(e){super(`Account not found for public key`)}},_e=class extends b{constructor(e){super(`Account not found for account hash: ${e.encode()}`,n.ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY)}},ve=class extends b{constructor(e){super(`Organization not found for hash: ${e.encode()}`,n.ORGANIZATION_NOT_FOUND)}},ye=class extends b{constructor(e){super(`Application not found for id: ${e.encode()}`,n.APPLICATION_NOT_FOUND)}},be=class extends b{constructor(e){super(`Validator node not found for id: ${e.encode()}`,n.VALIDATOR_NODE_NOT_FOUND)}},xe=class extends b{constructor(e){super(`Account not found for public key hash: ${e.encode()}`,n.ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY_HASH)}},Se=class extends b{constructor(e){super(`Virtual blockchain not found: ${e.encode()}`,n.VIRTUAL_BLOCKCHAIN_NOT_FOUND)}},Ce=class extends Se{constructor(e){super(e)}},we=class extends o{constructor(e,t=n.PROTOCOL_ERROR){super(`/!\\ `+e,t)}},Te=class extends we{constructor(e,t){super(`Actor ${t} (id ${e}) has not subscribed to a public encryption key.`),this.actorId=e,this.actorName=t}getNotSubscribedActorName(){return this.actorName}},Ee=class extends we{constructor(){super(`Section not found`)}},De=class extends we{constructor(e,t){super(`No shared secret between host ${t} and guest ${e}`)}},Oe=class extends o{constructor(e){super(e,n.SERIALIZATION_ERROR)}},ke=9e15,Ae=1e9,je=`0123456789abcdef`,Me=`2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058`,Ne=`3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789`,Pe={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ke,maxE:ke,crypto:!1},Fe,Ie,C=!0,Le=`[DecimalError] `,Re=Le+`Invalid argument: `,ze=Le+`Precision limit exceeded`,Be=Le+`crypto unavailable`,Ve=`[object Decimal]`,He=Math.floor,Ue=Math.pow,We=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Ge=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Ke=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,qe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Je=1e7,w=7,Ye=9007199254740991,Xe=Me.length-1,Ze=Ne.length-1,T={toStringTag:Ve};T.absoluteValue=T.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),E(e)},T.ceil=function(){return E(new this.constructor(this),this.e+1,2)},T.clampedTo=T.clamp=function(e,t){var n,r=this,i=r.constructor;if(e=new i(e),t=new i(t),!e.s||!t.s)return new i(NaN);if(e.gt(t))throw Error(Re+t);return n=r.cmp(e),n<0?e:r.cmp(t)>0?t:new i(r)},T.comparedTo=T.cmp=function(e){var t,n,r,i,a=this,o=a.d,s=(e=new a.constructor(e)).d,c=a.s,l=e.s;if(!o||!s)return!c||!l?NaN:c===l?o===s?0:!o^c<0?1:-1:c;if(!o[0]||!s[0])return o[0]?c:s[0]?-l:0;if(c!==l)return c;if(a.e!==e.e)return a.e>e.e^c<0?1:-1;for(r=o.length,i=s.length,t=0,n=r<i?r:i;t<n;++t)if(o[t]!==s[t])return o[t]>s[t]^c<0?1:-1;return r===i?0:r>i^c<0?1:-1},T.cosine=T.cos=function(){var e,t,n=this,r=n.constructor;return n.d?n.d[0]?(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+w,r.rounding=1,n=nt(r,xt(r,n)),r.precision=e,r.rounding=t,E(Ie==2||Ie==3?n.neg():n,e,t,!0)):new r(1):new r(NaN)},T.cubeRoot=T.cbrt=function(){var e,t,n,r,i,a,o,s,c,l,u=this,d=u.constructor;if(!u.isFinite()||u.isZero())return new d(u);for(C=!1,a=u.s*Ue(u.s*u,1/3),!a||Math.abs(a)==1/0?(n=Qe(u.d),e=u.e,(a=(e-n.length+1)%3)&&(n+=a==1||a==-2?`0`:`00`),a=Ue(n,1/3),e=He((e+1)/3)-(e%3==(e<0?-1:2)),a==1/0?n=`5e`+e:(n=a.toExponential(),n=n.slice(0,n.indexOf(`e`)+1)+e),r=new d(n),r.s=u.s):r=new d(a.toString()),o=(e=d.precision)+3;;)if(s=r,c=s.times(s).times(s),l=c.plus(u),r=rt(l.plus(u).times(s),l.plus(c),o+2,1),Qe(s.d).slice(0,o)===(n=Qe(r.d)).slice(0,o))if(n=n.slice(o-3,o+1),n==`9999`||!i&&n==`4999`){if(!i&&(E(s,e+1,0),s.times(s).times(s).eq(u))){r=s;break}o+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)==`5`)&&(E(r,e+1,1),t=!r.times(r).times(r).eq(u));break}return C=!0,E(r,e,d.rounding,t)},T.decimalPlaces=T.dp=function(){var e,t=this.d,n=NaN;if(t){if(e=t.length-1,n=(e-He(this.e/w))*w,e=t[e],e)for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n},T.dividedBy=T.div=function(e){return rt(this,new this.constructor(e))},T.dividedToIntegerBy=T.divToInt=function(e){var t=this,n=t.constructor;return E(rt(t,new n(e),0,1,1),n.precision,n.rounding)},T.equals=T.eq=function(e){return this.cmp(e)===0},T.floor=function(){return E(new this.constructor(this),this.e+1,3)},T.greaterThan=T.gt=function(e){return this.cmp(e)>0},T.greaterThanOrEqualTo=T.gte=function(e){var t=this.cmp(e);return t==1||t===0},T.hyperbolicCosine=T.cosh=function(){var e,t,n,r,i,a=this,o=a.constructor,s=new o(1);if(!a.isFinite())return new o(a.s?1/0:NaN);if(a.isZero())return s;n=o.precision,r=o.rounding,o.precision=n+Math.max(a.e,a.sd())+4,o.rounding=1,i=a.d.length,i<32?(e=Math.ceil(i/3),t=(1/bt(4,e)).toString()):(e=16,t=`2.3283064365386962890625e-10`),a=yt(o,1,a.times(t),new o(1),!0);for(var c,l=e,u=new o(8);l--;)c=a.times(a),a=s.minus(c.times(u.minus(c.times(u))));return E(a,o.precision=n,o.rounding=r,!0)},T.hyperbolicSine=T.sinh=function(){var e,t,n,r,i=this,a=i.constructor;if(!i.isFinite()||i.isZero())return new a(i);if(t=a.precision,n=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,r=i.d.length,r<3)i=yt(a,2,i,i,!0);else{e=1.4*Math.sqrt(r),e=e>16?16:e|0,i=i.times(1/bt(5,e)),i=yt(a,2,i,i,!0);for(var o,s=new a(5),c=new a(16),l=new a(20);e--;)o=i.times(i),i=i.times(s.plus(o.times(c.times(o).plus(l))))}return a.precision=t,a.rounding=n,E(i,t,n,!0)},T.hyperbolicTangent=T.tanh=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+7,r.rounding=1,rt(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)},T.inverseCosine=T.acos=function(){var e=this,t=e.constructor,n=e.abs().cmp(1),r=t.precision,i=t.rounding;return n===-1?e.isZero()?st(t,r+4,i).times(.5):(t.precision=r+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=r,t.rounding=i,e.times(2)):n===0?e.isNeg()?st(t,r,i):new t(0):new t(NaN)},T.inverseHyperbolicCosine=T.acosh=function(){var e,t,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(e=r.precision,t=r.rounding,r.precision=e+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,C=!1,n=n.times(n).minus(1).sqrt().plus(n),C=!0,r.precision=e,r.rounding=t,n.ln()):new r(n)},T.inverseHyperbolicSine=T.asinh=function(){var e,t,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,C=!1,n=n.times(n).plus(1).sqrt().plus(n),C=!0,r.precision=e,r.rounding=t,n.ln())},T.inverseHyperbolicTangent=T.atanh=function(){var e,t,n,r,i=this,a=i.constructor;return i.isFinite()?i.e>=0?new a(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=a.precision,t=a.rounding,r=i.sd(),Math.max(r,e)<2*-i.e-1?E(new a(i),e,t,!0):(a.precision=n=r-i.e,i=rt(i.plus(1),new a(1).minus(i),n+e,1),a.precision=e+4,a.rounding=1,i=i.ln(),a.precision=e,a.rounding=t,i.times(.5))):new a(NaN)},T.inverseSine=T.asin=function(){var e,t,n,r,i=this,a=i.constructor;return i.isZero()?new a(i):(t=i.abs().cmp(1),n=a.precision,r=a.rounding,t===-1?(a.precision=n+6,a.rounding=1,i=i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(),a.precision=n,a.rounding=r,i.times(2)):t===0?(e=st(a,n+4,r).times(.5),e.s=i.s,e):new a(NaN))},T.inverseTangent=T.atan=function(){var e,t,n,r,i,a,o,s,c,l=this,u=l.constructor,d=u.precision,f=u.rounding;if(!l.isFinite()){if(!l.s)return new u(NaN);if(d+4<=Ze)return o=st(u,d+4,f).times(.5),o.s=l.s,o}else if(l.isZero())return new u(l);else if(l.abs().eq(1)&&d+4<=Ze)return o=st(u,d+4,f).times(.25),o.s=l.s,o;for(u.precision=s=d+10,u.rounding=1,n=Math.min(28,s/w+2|0),e=n;e;--e)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(C=!1,t=Math.ceil(s/w),r=1,c=l.times(l),o=new u(l),i=l;e!==-1;)if(i=i.times(c),a=o.minus(i.div(r+=2)),i=i.times(c),o=a.plus(i.div(r+=2)),o.d[t]!==void 0)for(e=t;o.d[e]===a.d[e]&&e--;);return n&&(o=o.times(2<<n-1)),C=!0,E(o,u.precision=d,u.rounding=f,!0)},T.isFinite=function(){return!!this.d},T.isInteger=T.isInt=function(){return!!this.d&&He(this.e/w)>this.d.length-2},T.isNaN=function(){return!this.s},T.isNegative=T.isNeg=function(){return this.s<0},T.isPositive=T.isPos=function(){return this.s>0},T.isZero=function(){return!!this.d&&this.d[0]===0},T.lessThan=T.lt=function(e){return this.cmp(e)<0},T.lessThanOrEqualTo=T.lte=function(e){return this.cmp(e)<1},T.logarithm=T.log=function(e){var t,n,r,i,a,o,s,c,l=this,u=l.constructor,d=u.precision,f=u.rounding,p=5;if(e==null)e=new u(10),t=!0;else{if(e=new u(e),n=e.d,e.s<0||!n||!n[0]||e.eq(1))return new u(NaN);t=e.eq(10)}if(n=l.d,l.s<0||!n||!n[0]||l.eq(1))return new u(n&&!n[0]?-1/0:l.s==1?n?0:1/0:NaN);if(t)if(n.length>1)a=!0;else{for(i=n[0];i%10==0;)i/=10;a=i!==1}if(C=!1,s=d+p,o=mt(l,s),r=t?ot(u,s+10):mt(e,s),c=rt(o,r,s,1),et(c.d,i=d,f))do if(s+=10,o=mt(l,s),r=t?ot(u,s+10):mt(e,s),c=rt(o,r,s,1),!a){+Qe(c.d).slice(i+1,i+15)+1==0x5af3107a4000&&(c=E(c,d+1,0));break}while(et(c.d,i+=10,f));return C=!0,E(c,d,f)},T.minus=T.sub=function(e){var t,n,r,i,a,o,s,c,l,u,d,f,p=this,m=p.constructor;if(e=new m(e),!p.d||!e.d)return!p.s||!e.s?e=new m(NaN):p.d?e.s=-e.s:e=new m(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(l=p.d,f=e.d,s=m.precision,c=m.rounding,!l[0]||!f[0]){if(f[0])e.s=-e.s;else if(l[0])e=new m(p);else return new m(c===3?-0:0);return C?E(e,s,c):e}if(n=He(e.e/w),u=He(p.e/w),l=l.slice(),a=u-n,a){for(d=a<0,d?(t=l,a=-a,o=f.length):(t=f,n=u,o=l.length),r=Math.max(Math.ceil(s/w),o)+2,a>r&&(a=r,t.length=1),t.reverse(),r=a;r--;)t.push(0);t.reverse()}else{for(r=l.length,o=f.length,d=r<o,d&&(o=r),r=0;r<o;r++)if(l[r]!=f[r]){d=l[r]<f[r];break}a=0}for(d&&(t=l,l=f,f=t,e.s=-e.s),o=l.length,r=f.length-o;r>0;--r)l[o++]=0;for(r=f.length;r>a;){if(l[--r]<f[r]){for(i=r;i&&l[--i]===0;)l[i]=Je-1;--l[i],l[r]+=Je}l[r]-=f[r]}for(;l[--o]===0;)l.pop();for(;l[0]===0;l.shift())--n;return l[0]?(e.d=l,e.e=at(l,n),C?E(e,s,c):e):new m(c===3?-0:0)},T.modulo=T.mod=function(e){var t,n=this,r=n.constructor;return e=new r(e),!n.d||!e.s||e.d&&!e.d[0]?new r(NaN):!e.d||n.d&&!n.d[0]?E(new r(n),r.precision,r.rounding):(C=!1,r.modulo==9?(t=rt(n,e.abs(),0,3,1),t.s*=e.s):t=rt(n,e,0,r.modulo,1),t=t.times(e),C=!0,n.minus(t))},T.naturalExponential=T.exp=function(){return pt(this)},T.naturalLogarithm=T.ln=function(){return mt(this)},T.negated=T.neg=function(){var e=new this.constructor(this);return e.s=-e.s,E(e)},T.plus=T.add=function(e){var t,n,r,i,a,o,s,c,l,u,d=this,f=d.constructor;if(e=new f(e),!d.d||!e.d)return!d.s||!e.s?e=new f(NaN):d.d||(e=new f(e.d||d.s===e.s?d:NaN)),e;if(d.s!=e.s)return e.s=-e.s,d.minus(e);if(l=d.d,u=e.d,s=f.precision,c=f.rounding,!l[0]||!u[0])return u[0]||(e=new f(d)),C?E(e,s,c):e;if(a=He(d.e/w),r=He(e.e/w),l=l.slice(),i=a-r,i){for(i<0?(n=l,i=-i,o=u.length):(n=u,r=a,o=l.length),a=Math.ceil(s/w),o=a>o?a+1:o+1,i>o&&(i=o,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for(o=l.length,i=u.length,o-i<0&&(i=o,n=u,u=l,l=n),t=0;i;)t=(l[--i]=l[i]+u[i]+t)/Je|0,l[i]%=Je;for(t&&(l.unshift(t),++r),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=at(l,r),C?E(e,s,c):e},T.precision=T.sd=function(e){var t,n=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Re+e);return n.d?(t=ct(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},T.round=function(){var e=this,t=e.constructor;return E(new t(e),e.e+1,t.rounding)},T.sine=T.sin=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+w,r.rounding=1,n=vt(r,xt(r,n)),r.precision=e,r.rounding=t,E(Ie>2?n.neg():n,e,t,!0)):new r(NaN)},T.squareRoot=T.sqrt=function(){var e,t,n,r,i,a,o=this,s=o.d,c=o.e,l=o.s,u=o.constructor;if(l!==1||!s||!s[0])return new u(!l||l<0&&(!s||s[0])?NaN:s?o:1/0);for(C=!1,l=Math.sqrt(+o),l==0||l==1/0?(t=Qe(s),(t.length+c)%2==0&&(t+=`0`),l=Math.sqrt(t),c=He((c+1)/2)-(c<0||c%2),l==1/0?t=`5e`+c:(t=l.toExponential(),t=t.slice(0,t.indexOf(`e`)+1)+c),r=new u(t)):r=new u(l.toString()),n=(c=u.precision)+3;;)if(a=r,r=a.plus(rt(o,a,n+2,1)).times(.5),Qe(a.d).slice(0,n)===(t=Qe(r.d)).slice(0,n))if(t=t.slice(n-3,n+1),t==`9999`||!i&&t==`4999`){if(!i&&(E(a,c+1,0),a.times(a).eq(o))){r=a;break}n+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)==`5`)&&(E(r,c+1,1),e=!r.times(r).eq(o));break}return C=!0,E(r,c,u.rounding,e)},T.tangent=T.tan=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+10,r.rounding=1,n=n.sin(),n.s=1,n=rt(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,E(Ie==2||Ie==4?n.neg():n,e,t,!0)):new r(NaN)},T.times=T.mul=function(e){var t,n,r,i,a,o,s,c,l,u=this,d=u.constructor,f=u.d,p=(e=new d(e)).d;if(e.s*=u.s,!f||!f[0]||!p||!p[0])return new d(!e.s||f&&!f[0]&&!p||p&&!p[0]&&!f?NaN:!f||!p?e.s/0:e.s*0);for(n=He(u.e/w)+He(e.e/w),c=f.length,l=p.length,c<l&&(a=f,f=p,p=a,o=c,c=l,l=o),a=[],o=c+l,r=o;r--;)a.push(0);for(r=l;--r>=0;){for(t=0,i=c+r;i>r;)s=a[i]+p[r]*f[i-r-1]+t,a[i--]=s%Je|0,t=s/Je|0;a[i]=(a[i]+t)%Je|0}for(;!a[--o];)a.pop();return t?++n:a.shift(),e.d=a,e.e=at(a,n),C?E(e,d.precision,d.rounding):e},T.toBinary=function(e,t){return St(this,2,e,t)},T.toDecimalPlaces=T.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:($e(e,0,Ae),t===void 0?t=r.rounding:$e(t,0,8),E(n,e+n.e+1,t))},T.toExponential=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=it(r,!0):($e(e,0,Ae),t===void 0?t=i.rounding:$e(t,0,8),r=E(new i(r),e+1,t),n=it(r,!0,e+1)),r.isNeg()&&!r.isZero()?`-`+n:n},T.toFixed=function(e,t){var n,r,i=this,a=i.constructor;return e===void 0?n=it(i):($e(e,0,Ae),t===void 0?t=a.rounding:$e(t,0,8),r=E(new a(i),e+i.e+1,t),n=it(r,!1,e+r.e+1)),i.isNeg()&&!i.isZero()?`-`+n:n},T.toFraction=function(e){var t,n,r,i,a,o,s,c,l,u,d,f,p=this,m=p.d,h=p.constructor;if(!m)return new h(p);if(l=n=new h(1),r=c=new h(0),t=new h(r),a=t.e=ct(m)-p.e-1,o=a%w,t.d[0]=Ue(10,o<0?w+o:o),e==null)e=a>0?t:l;else{if(s=new h(e),!s.isInt()||s.lt(l))throw Error(Re+s);e=s.gt(t)?a>0?t:l:s}for(C=!1,s=new h(Qe(m)),u=h.precision,h.precision=a=m.length*w*2;d=rt(s,t,0,1,1),i=n.plus(d.times(r)),i.cmp(e)!=1;)n=r,r=i,i=l,l=c.plus(d.times(i)),c=i,i=t,t=s.minus(d.times(i)),s=i;return i=rt(e.minus(n),r,0,1,1),c=c.plus(i.times(l)),n=n.plus(i.times(r)),c.s=l.s=p.s,f=rt(l,r,a,1).minus(p).abs().cmp(rt(c,n,a,1).minus(p).abs())<1?[l,r]:[c,n],h.precision=u,C=!0,f},T.toHexadecimal=T.toHex=function(e,t){return St(this,16,e,t)},T.toNearest=function(e,t){var n=this,r=n.constructor;if(n=new r(n),e==null){if(!n.d)return n;e=new r(1),t=r.rounding}else{if(e=new r(e),t===void 0?t=r.rounding:$e(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&=n.s,e}return e.d[0]?(C=!1,n=rt(n,e,0,t,1).times(e),C=!0,E(n)):(e.s=n.s,n=e),n},T.toNumber=function(){return+this},T.toOctal=function(e,t){return St(this,8,e,t)},T.toPower=T.pow=function(e){var t,n,r,i,a,o,s=this,c=s.constructor,l=+(e=new c(e));if(!s.d||!e.d||!s.d[0]||!e.d[0])return new c(Ue(+s,l));if(s=new c(s),s.eq(1))return s;if(r=c.precision,a=c.rounding,e.eq(1))return E(s,r,a);if(t=He(e.e/w),t>=e.d.length-1&&(n=l<0?-l:l)<=Ye)return i=ut(c,s,n,r),e.s<0?new c(1).div(i):E(i,r,a);if(o=s.s,o<0){if(t<e.d.length-1)return new c(NaN);if(e.d[t]&1||(o=1),s.e==0&&s.d[0]==1&&s.d.length==1)return s.s=o,s}return n=Ue(+s,l),t=n==0||!isFinite(n)?He(l*(Math.log(`0.`+Qe(s.d))/Math.LN10+s.e+1)):new c(n+``).e,t>c.maxE+1||t<c.minE-1?new c(t>0?o/0:0):(C=!1,c.rounding=s.s=1,n=Math.min(12,(t+``).length),i=pt(e.times(mt(s,r+n)),r),i.d&&(i=E(i,r+5,1),et(i.d,r,a)&&(t=r+10,i=E(pt(e.times(mt(s,t+n)),t),t+5,1),+Qe(i.d).slice(r+1,r+15)+1==0x5af3107a4000&&(i=E(i,r+1,0)))),i.s=o,C=!0,c.rounding=a,E(i,r,a))},T.toPrecision=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=it(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):($e(e,1,Ae),t===void 0?t=i.rounding:$e(t,0,8),r=E(new i(r),e,t),n=it(r,e<=r.e||r.e<=i.toExpNeg,e)),r.isNeg()&&!r.isZero()?`-`+n:n},T.toSignificantDigits=T.toSD=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):($e(e,1,Ae),t===void 0?t=r.rounding:$e(t,0,8)),E(new r(n),e,t)},T.toString=function(){var e=this,t=e.constructor,n=it(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?`-`+n:n},T.truncated=T.trunc=function(){return E(new this.constructor(this),this.e+1,1)},T.valueOf=T.toJSON=function(){var e=this,t=e.constructor,n=it(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?`-`+n:n};function Qe(e){var t,n,r,i=e.length-1,a=``,o=e[0];if(i>0){for(a+=o,t=1;t<i;t++)r=e[t]+``,n=w-r.length,n&&(a+=lt(n)),a+=r;o=e[t],r=o+``,n=w-r.length,n&&(a+=lt(n))}else if(o===0)return`0`;for(;o%10==0;)o/=10;return a+o}function $e(e,t,n){if(e!==~~e||e<t||e>n)throw Error(Re+e)}function et(e,t,n,r){var i,a,o,s;for(a=e[0];a>=10;a/=10)--t;return--t<0?(t+=w,i=0):(i=Math.ceil((t+1)/w),t%=w),a=Ue(10,w-t),s=e[i]%a|0,r==null?t<3?(t==0?s=s/100|0:t==1&&(s=s/10|0),o=n<4&&s==99999||n>3&&s==49999||s==5e4||s==0):o=(n<4&&s+1==a||n>3&&s+1==a/2)&&(e[i+1]/a/100|0)==Ue(10,t-2)-1||(s==a/2||s==0)&&(e[i+1]/a/100|0)==0:t<4?(t==0?s=s/1e3|0:t==1?s=s/100|0:t==2&&(s=s/10|0),o=(r||n<4)&&s==9999||!r&&n>3&&s==4999):o=((r||n<4)&&s+1==a||!r&&n>3&&s+1==a/2)&&(e[i+1]/a/1e3|0)==Ue(10,t-3)-1,o}function tt(e,t,n){for(var r,i=[0],a,o=0,s=e.length;o<s;){for(a=i.length;a--;)i[a]*=t;for(i[0]+=je.indexOf(e.charAt(o++)),r=0;r<i.length;r++)i[r]>n-1&&(i[r+1]===void 0&&(i[r+1]=0),i[r+1]+=i[r]/n|0,i[r]%=n)}return i.reverse()}function nt(e,t){var n,r,i;if(t.isZero())return t;r=t.d.length,r<32?(n=Math.ceil(r/3),i=(1/bt(4,n)).toString()):(n=16,i=`2.3283064365386962890625e-10`),e.precision+=n,t=yt(e,1,t.times(i),new e(1));for(var a=n;a--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=n,t}var rt=(function(){function e(e,t,n){var r,i=0,a=e.length;for(e=e.slice();a--;)r=e[a]*t+i,e[a]=r%n|0,i=r/n|0;return i&&e.unshift(i),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=+(e[n]<t[n]),e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;)e.shift()}return function(r,i,a,o,s,c){var l,u,d,f,p,m,h,g,_,v,y,b,ee,x,te,ne,re,ie,ae,oe,se=r.constructor,ce=r.s==i.s?1:-1,le=r.d,S=i.d;if(!le||!le[0]||!S||!S[0])return new se(!r.s||!i.s||(le?S&&le[0]==S[0]:!S)?NaN:le&&le[0]==0||!S?ce*0:ce/0);for(c?(p=1,u=r.e-i.e):(c=Je,p=w,u=He(r.e/p)-He(i.e/p)),ae=S.length,re=le.length,_=new se(ce),v=_.d=[],d=0;S[d]==(le[d]||0);d++);if(S[d]>(le[d]||0)&&u--,a==null?(x=a=se.precision,o=se.rounding):x=s?a+(r.e-i.e)+1:a,x<0)v.push(1),m=!0;else{if(x=x/p+2|0,d=0,ae==1){for(f=0,S=S[0],x++;(d<re||f)&&x--;d++)te=f*c+(le[d]||0),v[d]=te/S|0,f=te%S|0;m=f||d<re}else{for(f=c/(S[0]+1)|0,f>1&&(S=e(S,f,c),le=e(le,f,c),ae=S.length,re=le.length),ne=ae,y=le.slice(0,ae),b=y.length;b<ae;)y[b++]=0;oe=S.slice(),oe.unshift(0),ie=S[0],S[1]>=c/2&&++ie;do f=0,l=t(S,y,ae,b),l<0?(ee=y[0],ae!=b&&(ee=ee*c+(y[1]||0)),f=ee/ie|0,f>1?(f>=c&&(f=c-1),h=e(S,f,c),g=h.length,b=y.length,l=t(h,y,g,b),l==1&&(f--,n(h,ae<g?oe:S,g,c))):(f==0&&(l=f=1),h=S.slice()),g=h.length,g<b&&h.unshift(0),n(y,h,b,c),l==-1&&(b=y.length,l=t(S,y,ae,b),l<1&&(f++,n(y,ae<b?oe:S,b,c))),b=y.length):l===0&&(f++,y=[0]),v[d++]=f,l&&y[0]?y[b++]=le[ne]||0:(y=[le[ne]],b=1);while((ne++<re||y[0]!==void 0)&&x--);m=y[0]!==void 0}v[0]||v.shift()}if(p==1)_.e=u,Fe=m;else{for(d=1,f=v[0];f>=10;f/=10)d++;_.e=d+u*p-1,E(_,s?a+_.e+1:a,o,m)}return _}})();function E(e,t,n,r){var i,a,o,s,c,l,u,d,f,p=e.constructor;out:if(t!=null){if(d=e.d,!d)return e;for(i=1,s=d[0];s>=10;s/=10)i++;if(a=t-i,a<0)a+=w,o=t,u=d[f=0],c=u/Ue(10,i-o-1)%10|0;else if(f=Math.ceil((a+1)/w),s=d.length,f>=s)if(r){for(;s++<=f;)d.push(0);u=c=0,i=1,a%=w,o=a-w+1}else break out;else{for(u=s=d[f],i=1;s>=10;s/=10)i++;a%=w,o=a-w+i,c=o<0?0:u/Ue(10,i-o-1)%10|0}if(r=r||t<0||d[f+1]!==void 0||(o<0?u:u%Ue(10,i-o-1)),l=n<4?(c||r)&&(n==0||n==(e.s<0?3:2)):c>5||c==5&&(n==4||r||n==6&&(a>0?o>0?u/Ue(10,i-o):0:d[f-1])%10&1||n==(e.s<0?8:7)),t<1||!d[0])return d.length=0,l?(t-=e.e+1,d[0]=Ue(10,(w-t%w)%w),e.e=-t||0):d[0]=e.e=0,e;if(a==0?(d.length=f,s=1,f--):(d.length=f+1,s=Ue(10,w-a),d[f]=o>0?(u/Ue(10,i-o)%Ue(10,o)|0)*s:0),l)for(;;)if(f==0){for(a=1,o=d[0];o>=10;o/=10)a++;for(o=d[0]+=s,s=1;o>=10;o/=10)s++;a!=s&&(e.e++,d[0]==Je&&(d[0]=1));break}else{if(d[f]+=s,d[f]!=Je)break;d[f--]=0,s=1}for(a=d.length;d[--a]===0;)d.pop()}return C&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function it(e,t,n){if(!e.isFinite())return ht(e);var r,i=e.e,a=Qe(e.d),o=a.length;return t?(n&&(r=n-o)>0?a=a.charAt(0)+`.`+a.slice(1)+lt(r):o>1&&(a=a.charAt(0)+`.`+a.slice(1)),a=a+(e.e<0?`e`:`e+`)+e.e):i<0?(a=`0.`+lt(-i-1)+a,n&&(r=n-o)>0&&(a+=lt(r))):i>=o?(a+=lt(i+1-o),n&&(r=n-i-1)>0&&(a=a+`.`+lt(r))):((r=i+1)<o&&(a=a.slice(0,r)+`.`+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+=`.`),a+=lt(r))),a}function at(e,t){var n=e[0];for(t*=w;n>=10;n/=10)t++;return t}function ot(e,t,n){if(t>Xe)throw C=!0,n&&(e.precision=n),Error(ze);return E(new e(Me),t,1,!0)}function st(e,t,n){if(t>Ze)throw Error(ze);return E(new e(Ne),t,n,!0)}function ct(e){var t=e.length-1,n=t*w+1;if(t=e[t],t){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function lt(e){for(var t=``;e--;)t+=`0`;return t}function ut(e,t,n,r){var i,a=new e(1),o=Math.ceil(r/w+4);for(C=!1;;){if(n%2&&(a=a.times(t),Ct(a.d,o)&&(i=!0)),n=He(n/2),n===0){n=a.d.length-1,i&&a.d[n]===0&&++a.d[n];break}t=t.times(t),Ct(t.d,o)}return C=!0,a}function dt(e){return e.d[e.d.length-1]&1}function ft(e,t,n){for(var r,i,a=new e(t[0]),o=0;++o<t.length;){if(i=new e(t[o]),!i.s){a=i;break}r=a.cmp(i),(r===n||r===0&&a.s===n)&&(a=i)}return a}function pt(e,t){var n,r,i,a,o,s,c,l=0,u=0,d=0,f=e.constructor,p=f.rounding,m=f.precision;if(!e.d||!e.d[0]||e.e>17)return new f(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(t==null?(C=!1,c=m):c=t,s=new f(.03125);e.e>-2;)e=e.times(s),d+=5;for(r=Math.log(Ue(2,d))/Math.LN10*2+5|0,c+=r,n=a=o=new f(1),f.precision=c;;){if(a=E(a.times(e),c,1),n=n.times(++u),s=o.plus(rt(a,n,c,1)),Qe(s.d).slice(0,c)===Qe(o.d).slice(0,c)){for(i=d;i--;)o=E(o.times(o),c,1);if(t==null)if(l<3&&et(o.d,c-r,p,l))f.precision=c+=10,n=a=s=new f(1),u=0,l++;else return E(o,f.precision=m,p,C=!0);else return f.precision=m,o}o=s}}function mt(e,t){var n,r,i,a,o,s,c,l,u,d,f,p=1,m=10,h=e,g=h.d,_=h.constructor,v=_.rounding,y=_.precision;if(h.s<0||!g||!g[0]||!h.e&&g[0]==1&&g.length==1)return new _(g&&!g[0]?-1/0:h.s==1?g?0:h:NaN);if(t==null?(C=!1,u=y):u=t,_.precision=u+=m,n=Qe(g),r=n.charAt(0),Math.abs(a=h.e)<0x5543df729c000){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)h=h.times(e),n=Qe(h.d),r=n.charAt(0),p++;a=h.e,r>1?(h=new _(`0.`+n),a++):h=new _(r+`.`+n.slice(1))}else return l=ot(_,u+2,y).times(a+``),h=mt(new _(r+`.`+n.slice(1)),u-m).plus(l),_.precision=y,t==null?E(h,y,v,C=!0):h;for(d=h,c=o=h=rt(h.minus(1),h.plus(1),u,1),f=E(h.times(h),u,1),i=3;;){if(o=E(o.times(f),u,1),l=c.plus(rt(o,new _(i),u,1)),Qe(l.d).slice(0,u)===Qe(c.d).slice(0,u))if(c=c.times(2),a!==0&&(c=c.plus(ot(_,u+2,y).times(a+``))),c=rt(c,new _(p),u,1),t==null)if(et(c.d,u-m,v,s))_.precision=u+=m,l=o=h=rt(d.minus(1),d.plus(1),u,1),f=E(h.times(h),u,1),i=s=1;else return E(c,_.precision=y,v,C=!0);else return _.precision=y,c;c=l,i+=2}}function ht(e){return String(e.s*e.s/0)}function gt(e,t){var n,r,i;for((n=t.indexOf(`.`))>-1&&(t=t.replace(`.`,``)),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;r++);for(i=t.length;t.charCodeAt(i-1)===48;--i);if(t=t.slice(r,i),t){if(i-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%w,n<0&&(r+=w),r<i){for(r&&e.d.push(+t.slice(0,r)),i-=w;r<i;)e.d.push(+t.slice(r,r+=w));t=t.slice(r),r=w-t.length}else r-=i;for(;r--;)t+=`0`;e.d.push(+t),C&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function _t(e,t){var n,r,i,a,o,s,c,l,u;if(t.indexOf(`_`)>-1){if(t=t.replace(/(\d)_(?=\d)/g,`$1`),qe.test(t))return gt(e,t)}else if(t===`Infinity`||t===`NaN`)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(Ge.test(t))n=16,t=t.toLowerCase();else if(We.test(t))n=2;else if(Ke.test(t))n=8;else throw Error(Re+t);for(a=t.search(/p/i),a>0?(c=+t.slice(a+1),t=t.substring(2,a)):t=t.slice(2),a=t.indexOf(`.`),o=a>=0,r=e.constructor,o&&(t=t.replace(`.`,``),s=t.length,a=s-a,i=ut(r,new r(n),a,a*2)),l=tt(t,n,Je),u=l.length-1,a=u;l[a]===0;--a)l.pop();return a<0?new r(e.s*0):(e.e=at(l,u),e.d=l,C=!1,o&&(e=rt(e,i,s*4)),c&&(e=e.times(Math.abs(c)<54?Ue(2,c):fn.pow(2,c))),C=!0,e)}function vt(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:yt(e,2,t,t);n=1.4*Math.sqrt(r),n=n>16?16:n|0,t=t.times(1/bt(5,n)),t=yt(e,2,t,t);for(var i,a=new e(5),o=new e(16),s=new e(20);n--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}function yt(e,t,n,r,i){var a,o,s,c,l=1,u=e.precision,d=Math.ceil(u/w);for(C=!1,c=n.times(n),s=new e(r);;){if(o=rt(s.times(c),new e(t++*t++),u,1),s=i?r.plus(o):r.minus(o),r=rt(o.times(c),new e(t++*t++),u,1),o=s.plus(r),o.d[d]!==void 0){for(a=d;o.d[a]===s.d[a]&&a--;);if(a==-1)break}a=s,s=r,r=o,o=a,l++}return C=!0,o.d.length=d+1,o}function bt(e,t){for(var n=e;--t;)n*=e;return n}function xt(e,t){var n,r=t.s<0,i=st(e,e.precision,1),a=i.times(.5);if(t=t.abs(),t.lte(a))return Ie=r?4:1,t;if(n=t.divToInt(i),n.isZero())Ie=r?3:2;else{if(t=t.minus(n.times(i)),t.lte(a))return Ie=dt(n)?r?2:3:r?4:1,t;Ie=dt(n)?r?1:4:r?3:2}return t.minus(i).abs()}function St(e,t,n,r){var i,a,o,s,c,l,u,d,f,p=e.constructor,m=n!==void 0;if(m?($e(n,1,Ae),r===void 0?r=p.rounding:$e(r,0,8)):(n=p.precision,r=p.rounding),!e.isFinite())u=ht(e);else{for(u=it(e),o=u.indexOf(`.`),m?(i=2,t==16?n=n*4-3:t==8&&(n=n*3-2)):i=t,o>=0&&(u=u.replace(`.`,``),f=new p(1),f.e=u.length-o,f.d=tt(it(f),10,i),f.e=f.d.length),d=tt(u,10,i),a=c=d.length;d[--c]==0;)d.pop();if(!d[0])u=m?`0p+0`:`0`;else{if(o<0?a--:(e=new p(e),e.d=d,e.e=a,e=rt(e,f,n,r,0,i),d=e.d,a=e.e,l=Fe),o=d[n],s=i/2,l||=d[n+1]!==void 0,l=r<4?(o!==void 0||l)&&(r===0||r===(e.s<0?3:2)):o>s||o===s&&(r===4||l||r===6&&d[n-1]&1||r===(e.s<0?8:7)),d.length=n,l)for(;++d[--n]>i-1;)d[n]=0,n||(++a,d.unshift(1));for(c=d.length;!d[c-1];--c);for(o=0,u=``;o<c;o++)u+=je.charAt(d[o]);if(m){if(c>1)if(t==16||t==8){for(o=t==16?4:3,--c;c%o;c++)u+=`0`;for(d=tt(u,i,t),c=d.length;!d[c-1];--c);for(o=1,u=`1.`;o<c;o++)u+=je.charAt(d[o])}else u=u.charAt(0)+`.`+u.slice(1);u=u+(a<0?`p`:`p+`)+a}else if(a<0){for(;++a;)u=`0`+u;u=`0.`+u}else if(++a>c)for(a-=c;a--;)u+=`0`;else a<c&&(u=u.slice(0,a)+`.`+u.slice(a))}u=(t==16?`0x`:t==2?`0b`:t==8?`0o`:``)+u}return e.s<0?`-`+u:u}function Ct(e,t){if(e.length>t)return e.length=t,!0}function wt(e){return new this(e).abs()}function Tt(e){return new this(e).acos()}function Et(e){return new this(e).acosh()}function Dt(e,t){return new this(e).plus(t)}function Ot(e){return new this(e).asin()}function kt(e){return new this(e).asinh()}function At(e){return new this(e).atan()}function jt(e){return new this(e).atanh()}function Mt(e,t){e=new this(e),t=new this(t);var n,r=this.precision,i=this.rounding,a=r+4;return!e.s||!t.s?n=new this(NaN):!e.d&&!t.d?(n=st(this,a,1).times(t.s>0?.25:.75),n.s=e.s):!t.d||e.isZero()?(n=t.s<0?st(this,r,i):new this(0),n.s=e.s):!e.d||t.isZero()?(n=st(this,a,1).times(.5),n.s=e.s):t.s<0?(this.precision=a,this.rounding=1,n=this.atan(rt(e,t,a,1)),t=st(this,a,1),this.precision=r,this.rounding=i,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(rt(e,t,a,1)),n}function Nt(e){return new this(e).cbrt()}function Pt(e){return E(e=new this(e),e.e+1,2)}function Ft(e,t,n){return new this(e).clamp(t,n)}function It(e){if(!e||typeof e!=`object`)throw Error(Le+`Object expected`);var t,n,r,i=e.defaults===!0,a=[`precision`,1,Ae,`rounding`,0,8,`toExpNeg`,-ke,0,`toExpPos`,0,ke,`maxE`,0,ke,`minE`,-ke,0,`modulo`,0,9];for(t=0;t<a.length;t+=3)if(n=a[t],i&&(this[n]=Pe[n]),(r=e[n])!==void 0)if(He(r)===r&&r>=a[t+1]&&r<=a[t+2])this[n]=r;else throw Error(Re+n+`: `+r);if(n=`crypto`,i&&(this[n]=Pe[n]),(r=e[n])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<`u`&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(Be);else this[n]=!1;else throw Error(Re+n+`: `+r);return this}function Lt(e){return new this(e).cos()}function Rt(e){return new this(e).cosh()}function zt(e){var t,n,r;function i(e){var t,n,r,a=this;if(!(a instanceof i))return new i(e);if(a.constructor=i,Wt(e)){a.s=e.s,C?!e.d||e.e>i.maxE?(a.e=NaN,a.d=null):e.e<i.minE?(a.e=0,a.d=[0]):(a.e=e.e,a.d=e.d.slice()):(a.e=e.e,a.d=e.d?e.d.slice():e.d);return}if(r=typeof e,r===`number`){if(e===0){a.s=1/e<0?-1:1,a.e=0,a.d=[0];return}if(e<0?(e=-e,a.s=-1):a.s=1,e===~~e&&e<1e7){for(t=0,n=e;n>=10;n/=10)t++;C?t>i.maxE?(a.e=NaN,a.d=null):t<i.minE?(a.e=0,a.d=[0]):(a.e=t,a.d=[e]):(a.e=t,a.d=[e]);return}if(e*0!=0){e||(a.s=NaN),a.e=NaN,a.d=null;return}return gt(a,e.toString())}if(r===`string`)return(n=e.charCodeAt(0))===45?(e=e.slice(1),a.s=-1):(n===43&&(e=e.slice(1)),a.s=1),qe.test(e)?gt(a,e):_t(a,e);if(r===`bigint`)return e<0?(e=-e,a.s=-1):a.s=1,gt(a,e.toString());throw Error(Re+e)}if(i.prototype=T,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=It,i.clone=zt,i.isDecimal=Wt,i.abs=wt,i.acos=Tt,i.acosh=Et,i.add=Dt,i.asin=Ot,i.asinh=kt,i.atan=At,i.atanh=jt,i.atan2=Mt,i.cbrt=Nt,i.ceil=Pt,i.clamp=Ft,i.cos=Lt,i.cosh=Rt,i.div=Bt,i.exp=Vt,i.floor=Ht,i.hypot=Ut,i.ln=Gt,i.log=Kt,i.log10=Jt,i.log2=qt,i.max=Yt,i.min=Xt,i.mod=Zt,i.mul=Qt,i.pow=$t,i.random=en,i.round=tn,i.sign=nn,i.sin=rn,i.sinh=an,i.sqrt=on,i.sub=sn,i.sum=cn,i.tan=ln,i.tanh=un,i.trunc=dn,e===void 0&&(e={}),e&&e.defaults!==!0)for(r=[`precision`,`rounding`,`toExpNeg`,`toExpPos`,`maxE`,`minE`,`modulo`,`crypto`],t=0;t<r.length;)e.hasOwnProperty(n=r[t++])||(e[n]=this[n]);return i.config(e),i}function Bt(e,t){return new this(e).div(t)}function Vt(e){return new this(e).exp()}function Ht(e){return E(e=new this(e),e.e+1,3)}function Ut(){var e,t,n=new this(0);for(C=!1,e=0;e<arguments.length;)if(t=new this(arguments[e++]),t.d)n.d&&(n=n.plus(t.times(t)));else{if(t.s)return C=!0,new this(1/0);n=t}return C=!0,n.sqrt()}function Wt(e){return e instanceof fn||e&&e.toStringTag===Ve||!1}function Gt(e){return new this(e).ln()}function Kt(e,t){return new this(e).log(t)}function qt(e){return new this(e).log(2)}function Jt(e){return new this(e).log(10)}function Yt(){return ft(this,arguments,-1)}function Xt(){return ft(this,arguments,1)}function Zt(e,t){return new this(e).mod(t)}function Qt(e,t){return new this(e).mul(t)}function $t(e,t){return new this(e).pow(t)}function en(e){var t,n,r,i,a=0,o=new this(1),s=[];if(e===void 0?e=this.precision:$e(e,1,Ae),r=Math.ceil(e/w),!this.crypto)for(;a<r;)s[a++]=Math.random()*1e7|0;else if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));a<r;)i=t[a],i>=429e7?t[a]=crypto.getRandomValues(new Uint32Array(1))[0]:s[a++]=i%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);a<r;)i=t[a]+(t[a+1]<<8)+(t[a+2]<<16)+((t[a+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(t,a):(s.push(i%1e7),a+=4);a=r/4}else throw Error(Be);for(r=s[--a],e%=w,r&&e&&(i=Ue(10,w-e),s[a]=(r/i|0)*i);s[a]===0;a--)s.pop();if(a<0)n=0,s=[0];else{for(n=-1;s[0]===0;n-=w)s.shift();for(r=1,i=s[0];i>=10;i/=10)r++;r<w&&(n-=w-r)}return o.e=n,o.d=s,o}function tn(e){return E(e=new this(e),e.e+1,this.rounding)}function nn(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function rn(e){return new this(e).sin()}function an(e){return new this(e).sinh()}function on(e){return new this(e).sqrt()}function sn(e,t){return new this(e).sub(t)}function cn(){var e=0,t=arguments,n=new this(t[e]);for(C=!1;n.s&&++e<t.length;)n=n.plus(t[e]);return C=!0,E(n,this.precision,this.rounding)}function ln(e){return new this(e).tan()}function un(e){return new this(e).tanh()}function dn(e){return E(e=new this(e),e.e+1,1)}T[Symbol.for(`nodejs.util.inspect.custom`)]=T.toString,T[Symbol.toStringTag]=`Decimal`;var fn=T.constructor=zt(Pe);Me=new fn(Me),Ne=new fn(Ne);var pn=function(e){return e[e.TOKEN=1e5]=`TOKEN`,e[e.DECI_TOKEN=1e4]=`DECI_TOKEN`,e[e.CENTI_TOKEN=1e3]=`CENTI_TOKEN`,e[e.MILLI_TOKEN=100]=`MILLI_TOKEN`,e[e.MICRO_TOKEN=10]=`MICRO_TOKEN`,e[e.ATOMIC=1]=`ATOMIC`,e}({}),mn=function(e){return e.TOKEN=`CMTS`,e.DECI_TOKEN=`dCMTS`,e.CENTI_TOKEN=`cCMTS`,e.MILLI_TOKEN=`mCMTS`,e.MICRO_TOKEN=`μCMTS`,e.ATOMIC=`aCMTS`,e}({}),hn=class e{constructor(e){this.amount=e}static create(e,t=pn.TOKEN){if(t!=pn.TOKEN)throw new y;return this.createCMTS(e)}static createCMTS(e){return this.createSafeCmtsToken(fn(e),fn(pn.TOKEN))}static createDeciToken(e){return this.createSafeCmtsToken(fn(e),fn(pn.DECI_TOKEN))}static createMicroToken(e){return this.createSafeCmtsToken(fn(e),fn(pn.MICRO_TOKEN))}static createMilliToken(e){return this.createSafeCmtsToken(fn(e),fn(pn.MILLI_TOKEN))}static createCentiToken(e){return this.createSafeCmtsToken(fn(e),fn(pn.CENTI_TOKEN))}static createMillionToken(e){return this.createSafeCmtsToken(fn(e),fn(pn.MICRO_TOKEN))}static createAtomic(e){return this.createSafeCmtsToken(fn(e),fn(pn.ATOMIC))}static createSafeCmtsToken(t,n){let r=t.mul(n);if(r.isInteger())return new e(r);throw new v(`Invalid amount: An atomic token should be insecable: got ${r}`)}static zero(){return this.createAtomic(0)}static oneCMTS(){return this.createCMTS(1)}static parse(t){let n=t.trim().match(/^(\d+(?:\.\d+)?)\s*(\S+)$/);if(!n)throw new v(`Invalid token amount format: "${t}"`);let[,r,i]=n,a=parseFloat(r);switch(i){case mn.TOKEN:return e.createCMTS(a);case mn.DECI_TOKEN:return e.createDeciToken(a);case mn.CENTI_TOKEN:return e.createCentiToken(a);case mn.MILLI_TOKEN:return e.createMilliToken(a);case mn.MICRO_TOKEN:return e.createMicroToken(a);case mn.ATOMIC:return e.createAtomic(a);default:throw new y}}getAmount(e=pn.TOKEN){switch(e){case pn.TOKEN:return this.amount.div(fn(pn.TOKEN)).toNumber();case pn.CENTI_TOKEN:return this.amount.div(fn(pn.CENTI_TOKEN)).toNumber();case pn.MILLI_TOKEN:return this.amount.div(fn(pn.MILLI_TOKEN)).toNumber();case pn.DECI_TOKEN:return this.amount.div(fn(pn.DECI_TOKEN)).toNumber();case pn.MICRO_TOKEN:return this.amount.div(fn(pn.MICRO_TOKEN)).toNumber();case pn.ATOMIC:return this.amount.toNumber()}}getAmountAsAtomic(){return this.getAmount(pn.ATOMIC)}getAmountAsCMTS(){return this.getAmount(pn.TOKEN)}isPositive(){return this.amount.isPositive()||this.amount.isZero()}isPositiveStrict(){return this.isPositive()&&!this.isZero()}isNegative(){return this.amount.isNegative()}isZero(){return this.amount.isZero()}equals(e){return this.amount.equals(e.amount)}isGreaterThan(e){return this.amount.gt(e.amount)}isLessThan(e){return this.amount.lt(e.amount)}add(t){return e.createAtomic(this.getAmountAsAtomic()+t.getAmountAsAtomic())}sub(t){return e.createAtomic(this.getAmountAsAtomic()-t.getAmountAsAtomic())}mul(t){return e.createAtomic(this.getAmountAsAtomic()*t)}toString(t=pn.TOKEN,n={}){let r=this.getAmountAsCMTS();switch(n.locale=n.locale===`system`?void 0:n.locale||`en-EN`,t){case pn.TOKEN:return`${Intl.NumberFormat(n.locale,{minimumFractionDigits:n.decimalPlaces===void 0?0:n.decimalPlaces,maximumFractionDigits:n.decimalPlaces===void 0?8:n.decimalPlaces,useGrouping:n.grouping||!1}).format(r)} ${e.getUnitLabel(t)}`;case pn.ATOMIC:return`${r} ${e.getUnitLabel(t)}`;default:throw new y}}static getUnitLabel(e){switch(e){case pn.TOKEN:return mn.TOKEN;case pn.ATOMIC:return mn.ATOMIC;default:throw new y}}},gn=t({FORMAT:()=>28,HASHABLE:()=>1,HASHED:()=>8,MASKABLE:()=>2,MASKED:()=>16,PROPERTIES:()=>3,REDACTED:()=>4,TYPE_ARRAY:()=>1,TYPE_ARRAY_OF:()=>32,TYPE_BIN256:()=>13,TYPE_BINARY:()=>12,TYPE_BOOLEAN:()=>5,TYPE_HASH_STR:()=>14,TYPE_MAIN:()=>31,TYPE_NAMES:()=>Pn,TYPE_NULL:()=>6,TYPE_NUMBER:()=>4,TYPE_OBJECT:()=>2,TYPE_STRING:()=>3,TYPE_UINT16:()=>8,TYPE_UINT24:()=>9,TYPE_UINT32:()=>10,TYPE_UINT48:()=>11,TYPE_UINT8:()=>7,TYPE_UNKNOWN:()=>0}),_n=0,vn=1,yn=2,bn=3,xn=4,Sn=5,Cn=6,wn=7,Tn=8,En=9,Dn=10,On=11,kn=12,An=13,jn=14,Mn=31,Nn=32,Pn=[`unknown`,`array`,`object`,`string`,`number`,`boolean`,`null`,`uint8`,`uint16`,`uint24`,`uint32`,`uint48`,`binary`,`bin256`,`hashString`],Fn=1,In=2,Ln=3,Rn=4,zn=8,Bn=16,Vn=28,Hn=t({MAGIC_STRING:()=>Un,MAX_MICROBLOCK_FUTURE_DELAY:()=>120,MAX_MICROBLOCK_PAST_DELAY:()=>300,MB_STATUS_PREVIOUS_HASH_ERROR:()=>3,MB_STATUS_TIMESTAMP_ERROR:()=>2,MB_STATUS_UNRECOVERABLE_ERROR:()=>1,N_VIRTUAL_BLOCKCHAINS:()=>6,PROTOCOL_VERSION:()=>1,VB_ACCOUNT:()=>1,VB_APPLICATION:()=>4,VB_APP_LEDGER:()=>5,VB_NAME:()=>Qn,VB_ORGANIZATION:()=>3,VB_PROTOCOL:()=>0,VB_VALIDATOR_NODE:()=>2}),Un=`CMTS`,Wn=1,Gn=0,Kn=1,qn=2,Jn=3,Yn=4,Xn=5,Zn=6,Qn=[`protocol`,`account`,`validator node`,`organization`,`application`,`application ledger`],$n=300,er=120,tr=1,nr=2,rr=3,ir=t({ACCOUNT_ALLOWED_TRANSFERS:()=>Wr,ACCOUNT_BLOCK_FEES:()=>2,ACCOUNT_BURNT_TOKENS:()=>0,ACCOUNT_NAMES:()=>Ur,ACCOUNT_STANDARD:()=>1,BK_EARNED_BLOCK_FEES:()=>3,BK_EARNED_TX_FEES:()=>1,BK_NAMES:()=>zr,BK_PAID_BLOCK_FEES:()=>2,BK_PAID_TX_FEES:()=>0,BK_PLUS:()=>1,BK_PURCHASE:()=>7,BK_RECEIVED_ESCROW:()=>13,BK_RECEIVED_ESCROW_REFUND:()=>15,BK_RECEIVED_EXPIRED_ESCROW:()=>17,BK_RECEIVED_ISSUANCE:()=>5,BK_RECEIVED_PAYMENT:()=>9,BK_RECEIVED_SLASHED_TOKENS:()=>19,BK_RECEIVED_VESTING:()=>11,BK_REFERENCES:()=>Rr,BK_REF_BLOCK:()=>0,BK_REF_MICROBLOCK:()=>1,BK_REF_SECTION:()=>2,BK_SALE:()=>6,BK_SENT_ESCROW:()=>12,BK_SENT_ESCROW_REFUND:()=>14,BK_SENT_EXPIRED_ESCROW:()=>16,BK_SENT_ISSUANCE:()=>4,BK_SENT_PAYMENT:()=>8,BK_SENT_SLASHED_TOKENS:()=>18,BK_SENT_VESTING:()=>10,CENTITOKEN:()=>sr,GAS_ATOMS_PER_GAS:()=>pr,GAS_PER_BYTE:()=>1,INITIAL_OFFER:()=>lr,MAXIMUM_GAS_PRICE:()=>dr,MILLITOKEN:()=>100,MINIMUM_GAS_PRICE:()=>1,TOKEN:()=>or,TOKEN_NAME:()=>ar}),ar=`CMTS`,or=1e5,sr=1e3,cr=100,lr=1e9*or,ur=1,dr=2**29-1,fr=1,pr=1e5,mr=1,hr=0,gr=2,_r=4,vr=6,yr=8,br=10,xr=12,Sr=14,Cr=16,wr=18,Tr=1,Er=3,Dr=5,Or=7,kr=9,Ar=11,jr=13,Mr=15,Nr=17,Pr=19,Fr=0,Ir=1,Lr=2,Rr=[1,1,0,0,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0],zr=[`Paid TX fees`,`Earned TX fees`,`Paid block fees`,`Earned block fees`,`Sent initial token issuance`,`Received initial token issuance`,`Sale`,`Purchase`,`Sent payment`,`Received payment`,`Sent vesting`,`Received vesting`,`Sent escrow`,`Received escrow`,`Sent escrow refund`,`Received escrow refund`,`Sent expired escrow`,`Received expired escrow`,`Sent slashed tokens`,`Received slashed tokens`],Br=0,Vr=1,Hr=2,Ur=[`Burnt tokens account`,`Standard account`,`Block fees account`],Wr=[524800,524265,6],Gr=t({ACCOUNT_HISTORY:()=>ii,ACCOUNT_STATE:()=>ri,ALL_SCHEMAS:()=>ia,BLOCK_CONTENT:()=>ui,BLOCK_INFORMATION:()=>li,CONTRACT_PARAMETER_SCHEMA:()=>qr,CONTRACT_SCHEMA:()=>Jr,ERROR:()=>Kr,MICROBLOCK_BODY:()=>gi,MICROBLOCK_HEADER:()=>mi,MICROBLOCK_HEADER_BODY_HASH_OFFSET:()=>58,MICROBLOCK_HEADER_PREVIOUS_HASH_OFFSET:()=>13,MICROBLOCK_HEADER_SIZE:()=>122,MICROBLOCK_SECTION:()=>hi,MICROBLOCK_VB_INFORMATION:()=>_i,MSG_ACCOUNT_BY_PUBLIC_KEY_HASH:()=>22,MSG_ACCOUNT_HISTORY:()=>20,MSG_ACCOUNT_STATE:()=>18,MSG_AWAIT_MICROBLOCK_ANCHORING:()=>13,MSG_BLOCK_CONTENT:()=>6,MSG_BLOCK_INFORMATION:()=>4,MSG_CHAIN_INFORMATION:()=>2,MSG_ERROR:()=>0,MSG_GENESIS_SNAPSHOT:()=>28,MSG_GET_ACCOUNT_BY_PUBLIC_KEY_HASH:()=>21,MSG_GET_ACCOUNT_HISTORY:()=>19,MSG_GET_ACCOUNT_STATE:()=>17,MSG_GET_BLOCK_CONTENT:()=>5,MSG_GET_BLOCK_INFORMATION:()=>3,MSG_GET_CHAIN_INFORMATION:()=>1,MSG_GET_GENESIS_SNAPSHOT:()=>27,MSG_GET_MICROBLOCK_BODYS:()=>15,MSG_GET_MICROBLOCK_INFORMATION:()=>11,MSG_GET_OBJECT_LIST:()=>25,MSG_GET_VALIDATOR_NODE_BY_ADDRESS:()=>23,MSG_GET_VIRTUAL_BLOCKCHAIN_STATE:()=>7,MSG_GET_VIRTUAL_BLOCKCHAIN_UPDATE:()=>9,MSG_MICROBLOCK_ANCHORING:()=>14,MSG_MICROBLOCK_BODYS:()=>16,MSG_MICROBLOCK_INFORMATION:()=>12,MSG_OBJECT_LIST:()=>26,MSG_VALIDATOR_NODE_BY_ADDRESS:()=>24,MSG_VIRTUAL_BLOCKCHAIN_STATE:()=>8,MSG_VIRTUAL_BLOCKCHAIN_UPDATE:()=>10,NODE_MESSAGES:()=>D,PROTOCOL_VARIABLES:()=>oi,PROTOCOL_VB_STATE:()=>si,RECORD_DESCRIPTION:()=>ni,VB_STATES:()=>ci,VIRTUAL_BLOCKCHAIN_STATE:()=>ai,WIMSG_ANSWER:()=>5,WIMSG_CONNECTION_ACCEPTED:()=>7,WIMSG_CONNECTION_INFO:()=>6,WIMSG_CONNECTION_TOKEN:()=>2,WIMSG_FORWARDED_ANSWER:()=>3,WIMSG_FORWARDED_REQUEST:()=>8,WIMSG_GET_CONNECTION_INFO:()=>4,WIMSG_REQUEST:()=>0,WIMSG_UPDATE_QR:()=>1,WI_MESSAGES:()=>ra,WI_QR_CODE:()=>qi}),Kr={label:`Error`,definition:[{name:`type`,type:7},{name:`id`,type:7},{name:`arg`,type:35}]},qr={label:`contractParameter`,definition:[{name:`name`,type:3},{name:`type`,type:3},{name:`defaultValue`,type:3},{name:`modifiable`,type:5}]},Jr={label:`contract`,definition:[{name:`name`,type:3},{name:`parametersDefinition`,type:34,schema:qr}]},Yr={label:`RecordActor`,definition:[{name:`name`,type:3}]},Xr={label:`RecordChannel`,definition:[{name:`name`,type:3},{name:`public`,type:5}]},Zr={label:`RecordChannelAssignation`,definition:[{name:`fieldPath`,type:3},{name:`channelName`,type:3}]},Qr={label:`RecordActorAssignation`,definition:[{name:`actorName`,type:3},{name:`channelName`,type:3}]},$r={label:`RecordMaskedPart`,definition:[{name:`position`,type:10},{name:`length`,type:10},{name:`replacementString`,type:3}]},ei={label:`RecordMaskableField`,definition:[{name:`fieldPath`,type:3},{name:`maskedParts`,type:34,schema:$r}]},ti={label:`RecordHashableField`,definition:[{name:`fieldPath`,type:3}]},ni={label:`RecordDescription`,definition:[{name:`applicationId`,type:14},{name:`virtualBlockchainId`,type:14,optional:!0},{name:`data`,type:2,unspecifiedSchema:!0},{name:`actors`,type:34,optional:!0,schema:Yr},{name:`channels`,type:34,optional:!0,schema:Xr},{name:`channelAssignations`,type:34,optional:!0,schema:Zr},{name:`actorAssignations`,type:34,optional:!0,schema:Qr},{name:`hashableFields`,type:34,optional:!0,schema:ti},{name:`maskableFields`,type:34,optional:!0,schema:ei},{name:`author`,type:3},{name:`endorser`,type:3,optional:!0},{name:`approvalMessage`,type:3,optional:!0}]},ri={label:`AccountState`,definition:[{name:`height`,type:11},{name:`balance`,type:11},{name:`lastHistoryHash`,type:13},{name:`locks`,type:34,definition:[{name:`type`,type:7},{name:`amount`,type:11},{name:`parameters`,type:12}]}]},ii={label:`AccountHistory`,definition:[{name:`height`,type:11},{name:`previousHistoryHash`,type:13},{name:`type`,type:7},{name:`timestamp`,type:11},{name:`linkedAccount`,type:13},{name:`amount`,type:11},{name:`chainReference`,type:12}]},ai={label:`VirtualBlockchainState`,definition:[{name:`type`,type:7},{name:`expirationDay`,type:10},{name:`height`,type:11},{name:`lastMicroblockHash`,type:13},{name:`serializedInternalState`,type:12}]},oi={label:`PROTOCOL_VARIABLES`,definition:[{name:`protocolVersionName`,type:3},{name:`protocolVersion`,type:8},{name:`feesCalculationVersion`,type:8},{name:`globalStateUpdaterVersion`,type:8},{name:`applicationLedgerInternalStateUpdaterVersion`,type:8},{name:`applicationInternalStateUpdaterVersion`,type:8},{name:`organizationInternalStateUpdaterVersion`,type:8},{name:`validatorNodeInternalStateUpdaterVersion`,type:8},{name:`accountInternalStateUpdaterVersion`,type:8},{name:`protocolInternalStateUpdaterVersion`,type:8}]},si={label:`ProtocolVbState`,definition:[{name:`organizationId`,type:13},{name:`currentProtocolVariables`,type:2,schema:oi},{name:`protocolUpdates`,type:34,schema:{label:`PROTOCOL_UPDATE`,definition:[{name:`protocolVersion`,type:8},{name:`changeLog`,type:3},{name:`protocolVariables`,type:2,schema:oi},{name:`protocolVersionName`,type:3}]}}]},ci=[si,{label:`AccountVbState`,definition:[{name:`signatureSchemeId`,type:7},{name:`publicKeyHeight`,type:11}]},{label:`ValidatorNodeVbState`,definition:[{name:`organizationId`,type:13},{name:`descriptionHeight`,type:11},{name:`rpcEndpointHeight`,type:11},{name:`networkIntegrationHeight`,type:11}]},{label:`OrganizationVbState`,definition:[{name:`accountId`,type:13},{name:`descriptionHeight`,type:11}]},{label:`ApplicationVbState`,definition:[{name:`organizationId`,type:13},{name:`descriptionHeight`,type:11}]},{label:`AppLedgerVbState`,definition:[{name:`allowedSignatureSchemeIds`,type:39},{name:`allowedPkeSchemeIds`,type:39},{name:`applicationId`,type:13},{name:`channels`,type:34,definition:[{name:`name`,type:3},{name:`isPrivate`,type:5},{name:`creatorId`,type:7}]},{name:`actors`,type:34,definition:[{name:`name`,type:3},{name:`subscribed`,type:5},{name:`signatureKeyHeight`,type:11},{name:`pkeKeyHeight`,type:11},{name:`sharedSecrets`,type:34,definition:[{name:`peerActorId`,type:7},{name:`height`,type:11}]},{name:`invitations`,type:34,definition:[{name:`channelId`,type:7},{name:`height`,type:11}]}]}]}],li={label:`BlockInformation`,definition:[{name:`hash`,type:13},{name:`timestamp`,type:11},{name:`proposerAddress`,type:12},{name:`size`,type:11},{name:`microblockCount`,type:11}]},ui={label:`BlockContent`,definition:[{name:`microblocks`,type:34,definition:[{name:`hash`,type:13},{name:`vbIdentifier`,type:13},{name:`vbType`,type:7},{name:`height`,type:11},{name:`size`,type:11},{name:`sectionCount`,type:11}]}]},di=13,fi=58,pi=122,mi={label:`MicroblockHeader`,definition:[{name:`magicString`,type:3,size:4},{name:`protocolVersion`,type:8},{name:`microblockType`,type:7},{name:`height`,type:11},{name:`previousHash`,type:13},{name:`timestamp`,type:11},{name:`gas`,type:9},{name:`gasPrice`,type:10},{name:`bodyHash`,type:13},{name:`feesPayerAccount`,type:13}]},hi={label:`MicroblockSection`,definition:[{name:`type`,type:7},{name:`data`,type:12}]},gi={label:`MicroblockBody`,definition:[{name:`body`,type:34,schema:hi}]},_i={label:`MicroblockVbInformation`,definition:[{name:`virtualBlockchainType`,type:7},{name:`virtualBlockchainId`,type:13}]},vi=0,yi=1,bi=2,xi=3,Si=4,Ci=5,wi=6,Ti=7,Ei=8,Di=9,Oi=10,ki=11,Ai=12,ji=13,Mi=14,Ni=15,Pi=16,Fi=17,Ii=18,Li=19,Ri=20,zi=21,Bi=22,Vi=23,Hi=24,Ui=25,Wi=26,Gi=27,Ki=28,D=[];D[0]={label:`MessageError`,definition:[{name:`error`,type:3}]},D[1]={label:`MessageGetChainInformation`,definition:[]},D[2]={label:`MessageChainInformation`,definition:[{name:`height`,type:11},{name:`lastBlockTimestamp`,type:11},{name:`microblockCount`,type:11},{name:`objectCounts`,type:43,size:6}]},D[3]={label:`MessageGetBlockInformation`,definition:[{name:`height`,type:11}]},D[4]={label:`MessageBlockInformation`,definition:li.definition},D[5]={label:`MessageGetBlockContent`,definition:[{name:`height`,type:11}]},D[6]={label:`MessageBlockContent`,definition:ui.definition},D[7]={label:`MessageGetVirtualBlockchainState`,definition:[{name:`virtualBlockchainId`,type:13}]},D[8]={label:`MessageVirtualBlockchainState`,definition:[{name:`stateData`,type:12}]},D[9]={label:`MessageGetVirtualBlockchainUpdate`,definition:[{name:`virtualBlockchainId`,type:13},{name:`knownHeight`,type:11}]},D[10]={label:`MessageVirtualBlockchainUpdate`,definition:[{name:`exists`,type:5},{name:`changed`,type:5},{name:`stateData`,type:12},{name:`headers`,type:44}]},D[11]={label:`MessageGetMicroblockInformation`,definition:[{name:`hash`,type:13}]},D[12]={label:`MessageMicroblockInformation`,definition:[{name:`virtualBlockchainType`,type:7},{name:`virtualBlockchainId`,type:13},{name:`header`,type:12}]},D[13]={label:`MessageAwaitMicroblockAnchoring`,definition:[{name:`hash`,type:13}]},D[14]={label:`MessageMicroblockAnchoring`,definition:_i.definition},D[15]={label:`MessageGetMicroblockBodys`,definition:[{name:`hashes`,type:45}]},D[16]={label:`MessageMicroblockBodys`,definition:[{name:`list`,type:34,definition:[{name:`hash`,type:13},{name:`body`,type:12}]}]},D[17]={label:`MessageGetAccountState`,definition:[{name:`accountHash`,type:13}]},D[18]={label:`MessageAccountState`,definition:ri.definition},D[19]={label:`MessageGetAccountHistory`,definition:[{name:`accountHash`,type:13},{name:`lastHistoryHash`,type:13},{name:`maxRecords`,type:8}]},D[20]={label:`MessageAccountHistory`,definition:[{name:`list`,type:34,schema:ii}]},D[21]={label:`MessageGetAccountByPublicKeyHash`,definition:[{name:`publicKeyHash`,type:13}]},D[22]={label:`MessageAccountByPublicKeyHash`,definition:[{name:`accountHash`,type:13}]},D[23]={label:`MessageGetValidatorNodeByAddress`,definition:[{name:`address`,type:12}]},D[24]={label:`MessageValidatorNodeByAddress`,definition:[{name:`validatorNodeHash`,type:13}]},D[25]={label:`MessageGetObjectList`,definition:[{name:`type`,type:7}]},D[26]={label:`MessageObjectList`,definition:[{name:`list`,type:45}]},D[27]={label:`MessageGetGenesisSnapshot`,definition:[]},D[28]={label:`MessageGenesisSnapshot`,definition:[{name:`base64EncodedChunks`,type:35}]};var qi={label:`WiQrCode`,definition:[{name:`qrId`,type:13},{name:`timestamp`,type:11},{name:`serverUrl`,type:3,size:100}]},Ji=0,Yi=1,Xi=2,Zi=3,Qi=4,$i=5,ea=6,ta=7,na=8,ra=[];ra[0]={label:`WiMsgRequest`,definition:[{name:`requestType`,type:7},{name:`request`,type:12},{name:`deviceId`,type:13},{name:`withToken`,type:7}]},ra[1]={label:`WiMsgUpdateQr`,definition:[{name:`qrId`,type:13},{name:`timestamp`,type:11}]},ra[2]={label:`WiMsgConnectionToken`,definition:[{name:`token`,type:13}]},ra[3]={label:`WiMsgForwardedAnswer`,definition:[{name:`answerType`,type:7},{name:`answer`,type:12}]},ra[4]={label:`WiMsgGetConnectionInfo`,definition:[{name:`qrId`,type:13}]},ra[5]={label:`WiMsgAnswer`,definition:[{name:`answerType`,type:7},{name:`answer`,type:12}]},ra[6]={label:`WiMsgConnectionInfo`,definition:[]},ra[7]={label:`WiMsgConnectionAccepted`,definition:[{name:`qrId`,type:13}]},ra[8]={label:`WiMsgForwardedRequest`,definition:[{name:`requestType`,type:7},{name:`request`,type:12}]};var ia={singles:[Yr,Xr,Zr,Qr,$r,ei,ti,ni,mi,hi,gi,_i,qi],collections:[{label:`VbState`,list:ci},{label:`NodeMessage`,list:D},{label:`WiMessage`,list:ra}]},O=function(e){return e[e.AUXILIARY_SIGNATURE=126]=`AUXILIARY_SIGNATURE`,e[e.SIGNATURE=127]=`SIGNATURE`,e[e.ALLOWED_ADDITIONAL_WRITER=128]=`ALLOWED_ADDITIONAL_WRITER`,e[e.CUSTOM=129]=`CUSTOM`,e[e.PROTOCOL_CREATION=1]=`PROTOCOL_CREATION`,e[e.PROTOCOL_UPDATE=2]=`PROTOCOL_UPDATE`,e[e.PROTOCOL_VARIABLES=5]=`PROTOCOL_VARIABLES`,e[e.ACCOUNT_PUBLIC_KEY=17]=`ACCOUNT_PUBLIC_KEY`,e[e.ACCOUNT_TOKEN_ISSUANCE=18]=`ACCOUNT_TOKEN_ISSUANCE`,e[e.ACCOUNT_CREATION=19]=`ACCOUNT_CREATION`,e[e.ACCOUNT_TRANSFER=20]=`ACCOUNT_TRANSFER`,e[e.ACCOUNT_VESTING_TRANSFER=21]=`ACCOUNT_VESTING_TRANSFER`,e[e.ACCOUNT_ESCROW_TRANSFER=22]=`ACCOUNT_ESCROW_TRANSFER`,e[e.ACCOUNT_ESCROW_SETTLEMENT=23]=`ACCOUNT_ESCROW_SETTLEMENT`,e[e.ACCOUNT_STAKE=24]=`ACCOUNT_STAKE`,e[e.ACCOUNT_UNSTAKE=25]=`ACCOUNT_UNSTAKE`,e[e.VN_CREATION=33]=`VN_CREATION`,e[e.VN_COMETBFT_PUBLIC_KEY_DECLARATION=34]=`VN_COMETBFT_PUBLIC_KEY_DECLARATION`,e[e.VN_RPC_ENDPOINT=35]=`VN_RPC_ENDPOINT`,e[e.VN_APPROVAL=36]=`VN_APPROVAL`,e[e.VN_SLASHING_CANCELLATION=37]=`VN_SLASHING_CANCELLATION`,e[e.ORG_CREATION=52]=`ORG_CREATION`,e[e.ORG_DESCRIPTION=50]=`ORG_DESCRIPTION`,e[e.APP_CREATION=65]=`APP_CREATION`,e[e.APP_DESCRIPTION=66]=`APP_DESCRIPTION`,e[e.APP_LEDGER_ALLOWED_SIG_SCHEMES=80]=`APP_LEDGER_ALLOWED_SIG_SCHEMES`,e[e.APP_LEDGER_ALLOWED_PKE_SCHEMES=81]=`APP_LEDGER_ALLOWED_PKE_SCHEMES`,e[e.APP_LEDGER_CREATION=82]=`APP_LEDGER_CREATION`,e[e.APP_LEDGER_ACTOR_CREATION=83]=`APP_LEDGER_ACTOR_CREATION`,e[e.APP_LEDGER_CHANNEL_CREATION=84]=`APP_LEDGER_CHANNEL_CREATION`,e[e.APP_LEDGER_SHARED_SECRET=85]=`APP_LEDGER_SHARED_SECRET`,e[e.APP_LEDGER_CHANNEL_INVITATION=86]=`APP_LEDGER_CHANNEL_INVITATION`,e[e.APP_LEDGER_ACTOR_SUBSCRIPTION=87]=`APP_LEDGER_ACTOR_SUBSCRIPTION`,e[e.APP_LEDGER_PUBLIC_CHANNEL_DATA=88]=`APP_LEDGER_PUBLIC_CHANNEL_DATA`,e[e.APP_LEDGER_PRIVATE_CHANNEL_DATA=89]=`APP_LEDGER_PRIVATE_CHANNEL_DATA`,e[e.APP_LEDGER_AUTHOR=90]=`APP_LEDGER_AUTHOR`,e[e.APP_LEDGER_ENDORSEMENT_REQUEST=91]=`APP_LEDGER_ENDORSEMENT_REQUEST`,e}({}),aa=t({ACCOUNT_CREATION:()=>pa,ACCOUNT_ESCROW_SETTLEMENT:()=>_a,ACCOUNT_ESCROW_TRANSFER:()=>ga,ACCOUNT_PUBLIC_KEY:()=>da,ACCOUNT_STAKE:()=>va,ACCOUNT_TOKEN_ISSUANCE:()=>fa,ACCOUNT_TRANSFER:()=>ma,ACCOUNT_VESTING_TRANSFER:()=>ha,ALL_SECTIONS_SCHEMAS:()=>Wa,APP_CREATION:()=>Oa,APP_DESCRIPTION:()=>ka,APP_LEDGER_ACTOR_CREATION:()=>Pa,APP_LEDGER_ACTOR_SUBSCRIPTION:()=>Ra,APP_LEDGER_ALLOWED_PKE_SCHEMES:()=>Ma,APP_LEDGER_ALLOWED_SIG_SCHEMES:()=>ja,APP_LEDGER_AUTHOR:()=>Va,APP_LEDGER_CHANNEL_CREATION:()=>Fa,APP_LEDGER_CHANNEL_INVITATION:()=>La,APP_LEDGER_CREATION:()=>Na,APP_LEDGER_ENDORSEMENT_REQUEST:()=>Ha,APP_LEDGER_PRIVATE_CHANNEL_DATA:()=>Ba,APP_LEDGER_PUBLIC_CHANNEL_DATA:()=>za,APP_LEDGER_SHARED_SECRET:()=>Ia,DEF:()=>Ga,ORG_CREATION:()=>Ta,ORG_DESCRIPTION:()=>Ea,PROTOCOL_CREATION:()=>ca,PROTOCOL_UPDATE:()=>la,SIGNATURE:()=>oa,SIGNATURE_SCHEMA:()=>sa,VN_APPROVAL:()=>Ca,VN_COMETBFT_PUBLIC_KEY_DECLARATION:()=>xa,VN_CREATION:()=>ba,VN_RPC_ENDPOINT:()=>Sa}),oa=O.SIGNATURE,sa={label:`SIGNATURE`,definition:[{name:`schemeId`,type:7},{name:`signature`,type:12}]},ca=O.PROTOCOL_CREATION,la=O.PROTOCOL_UPDATE,ua=[];ua[ca]={label:`PROTOCOL_CREATION`,definition:[{name:`organizationId`,type:13}]},ua[la]={label:`PROTOCOL_VARIABLES_UPDATE`,definition:[{name:`protocolVersion`,type:8},{name:`protocolVersionName`,type:3},{name:`changeLog`,type:3},{name:`protocolVariables`,type:2,schema:oi}]};var da=O.ACCOUNT_PUBLIC_KEY,fa=O.ACCOUNT_TOKEN_ISSUANCE,pa=O.ACCOUNT_CREATION,ma=O.ACCOUNT_TRANSFER,ha=O.ACCOUNT_VESTING_TRANSFER,ga=O.ACCOUNT_ESCROW_TRANSFER,_a=O.ACCOUNT_ESCROW_SETTLEMENT,va=O.ACCOUNT_STAKE,ya=[];ya[da]={label:`ACCOUNT_PUBLIC_KEY`,definition:[{name:`publicKey`,type:12},{name:`schemeId`,type:7}]},ya[fa]={label:`ACCOUNT_TOKEN_ISSUANCE`,definition:[{name:`amount`,type:11}]},ya[pa]={label:`ACCOUNT_CREATION`,definition:[{name:`sellerAccount`,type:13},{name:`amount`,type:11}]},ya[ma]={label:`ACCOUNT_TRANSFER`,definition:[{name:`account`,type:13},{name:`amount`,type:11},{name:`publicReference`,type:3},{name:`privateReference`,type:3}]},ya[ha]={label:`ACCOUNT_VESTING_TRANSFER`,definition:[{name:`account`,type:13},{name:`amount`,type:11},{name:`publicReference`,type:3},{name:`privateReference`,type:3},{name:`cliffDurationDays`,type:8},{name:`vestingDurationDays`,type:8}]},ya[ga]={label:`ACCOUNT_ESCROW_TRANSFER`,definition:[{name:`account`,type:13},{name:`amount`,type:11},{name:`publicReference`,type:3},{name:`privateReference`,type:3},{name:`escrowIdentifier`,type:13},{name:`agentAccount`,type:13},{name:`durationDays`,type:8}]},ya[_a]={label:`ACCOUNT_ESCROW_SETTLEMENT`,definition:[{name:`confirmed`,type:5},{name:`escrowIdentifier`,type:13}]},ya[va]={label:`ACCOUNT_STAKE`,definition:[{name:`amount`,type:11},{name:`objectType`,type:7},{name:`objectIdentifier`,type:13}]};var ba=O.VN_CREATION,xa=O.VN_COMETBFT_PUBLIC_KEY_DECLARATION,Sa=O.VN_RPC_ENDPOINT,Ca=O.VN_APPROVAL,wa=[];wa[ba]={label:`VN_CREATION`,definition:[{name:`organizationId`,type:13}]},wa[xa]={label:`VN_COMETBFT_PUBLIC_KEY_DECLARATION`,definition:[{name:`cometPublicKeyType`,type:3},{name:`cometPublicKey`,type:3}]},wa[Sa]={label:`VN_RPC_ENDPOINT`,definition:[{name:`rpcEndpoint`,type:3}]},wa[Ca]={label:`VN_APPROVAL`,definition:[{name:`status`,type:5}]};var Ta=O.ORG_CREATION,Ea=O.ORG_DESCRIPTION,Da=[];Da[Ta]={label:`ORG_CREATION`,definition:[{name:`accountId`,type:13}]},Da[Ea]={label:`ORG_DESCRIPTION`,definition:[{name:`name`,type:3},{name:`city`,type:3},{name:`countryCode`,type:3,size:2},{name:`website`,type:3}]};var Oa=O.APP_CREATION,ka=O.APP_DESCRIPTION,Aa=[];Aa[Oa]={label:`APP_CREATION`,definition:[{name:`organizationId`,type:13}]},Aa[ka]={label:`APP_DESCRIPTION`,definition:[{name:`name`,type:3},{name:`logoUrl`,type:3},{name:`homepageUrl`,type:3},{name:`description`,type:3}]};var ja=O.APP_LEDGER_ALLOWED_SIG_SCHEMES,Ma=O.APP_LEDGER_ALLOWED_PKE_SCHEMES,Na=O.APP_LEDGER_CREATION,Pa=O.APP_LEDGER_ACTOR_CREATION,Fa=O.APP_LEDGER_CHANNEL_CREATION,Ia=O.APP_LEDGER_SHARED_SECRET,La=O.APP_LEDGER_CHANNEL_INVITATION,Ra=O.APP_LEDGER_ACTOR_SUBSCRIPTION,za=O.APP_LEDGER_PUBLIC_CHANNEL_DATA,Ba=O.APP_LEDGER_PRIVATE_CHANNEL_DATA,Va=O.APP_LEDGER_AUTHOR,Ha=O.APP_LEDGER_ENDORSEMENT_REQUEST,Ua=[];Ua[ja]={label:`APP_LEDGER_ALLOWED_SIG_SCHEMES`,definition:[{name:`schemeIds`,type:39}]},Ua[Ma]={label:`APP_LEDGER_ALLOWED_PKE_SCHEMES`,definition:[{name:`schemeIds`,type:39}]},Ua[Na]={label:`APP_LEDGER_CREATION`,definition:[{name:`applicationId`,type:13}]},Ua[Pa]={label:`APP_LEDGER_ACTOR_CREATION`,definition:[{name:`id`,type:7},{name:`type`,type:7},{name:`name`,type:3}]},Ua[Fa]={label:`APP_LEDGER_CHANNEL_CREATION`,definition:[{name:`id`,type:7},{name:`isPrivate`,type:5},{name:`creatorId`,type:7},{name:`name`,type:3}]},Ua[Ia]={label:`APP_LEDGER_SHARED_SECRET`,definition:[{name:`hostId`,type:7},{name:`guestId`,type:7},{name:`encryptedSharedKey`,type:12}]},Ua[La]={label:`APP_LEDGER_CHANNEL_INVITATION`,definition:[{name:`channelId`,type:7},{name:`hostId`,type:7},{name:`guestId`,type:7},{name:`encryptedChannelKey`,type:12}]},Ua[Ra]={label:`APP_LEDGER_ACTOR_SUBSCRIPTION`,definition:[{name:`actorId`,type:7},{name:`actorType`,type:7},{name:`organizationId`,type:13},{name:`signatureSchemeId`,type:7},{name:`signaturePublicKey`,type:12},{name:`pkeSchemeId`,type:7},{name:`pkePublicKey`,type:12}]},Ua[za]={label:`APP_LEDGER_PUBLIC_CHANNEL_DATA`,definition:[{name:`channelId`,type:7},{name:`data`,type:12}]},Ua[Ba]={label:`APP_LEDGER_PRIVATE_CHANNEL_DATA`,definition:[{name:`channelId`,type:7},{name:`merkleRootHash`,type:13},{name:`encryptedData`,type:12}]},Ua[Va]={label:`APP_LEDGER_AUTHOR`,definition:[{name:`authorId`,type:7}]},Ua[Ha]={label:`APP_LEDGER_ENDORSEMENT_REQUEST`,definition:[{name:`endorserId`,type:7},{name:`message`,type:3}]};var Wa={...ua,...ya,...wa,...Da,...Aa,...Ua},Ga=[ua,ya,wa,Da,Aa,Ua],Ka=t({WI_INVALID_SIGNATURE:()=>0}),qa=0,Ja=function(e){return e[e.SECP256K1=0]=`SECP256K1`,e[e.ML_DSA_65=1]=`ML_DSA_65`,e[e.PKMS_SECP256K1=2]=`PKMS_SECP256K1`,e[e.ED25519=3]=`ED25519`,e}({}),Ya=new TextEncoder,Xa=new TextDecoder,Za={encode:Qa,decode:$a};function Qa(e){return Ya.encode(e)}function $a(e){return Xa.decode(e)}var eo=class extends m{constructor(e){super(e,n.TYPE_CHECKING_FAILURE_ERROR)}},to=126,no=class{static getType(e){switch(typeof e){case`string`:return 3;case`number`:return 4;case`boolean`:return 5;case`object`:if(e===null)return 6;if(Array.isArray(e))return 1;if(e instanceof Uint8Array)return 12;if(Object.getPrototypeOf(e).isPrototypeOf(Object))return 2}return 0}static isJsonType(e){return to>>e&1}},ro=class{basicType;definition;value;constructor(e,t){this.definition=e,this.value=t,this.basicType=no.getType(t)}check(){let e=this.definition.type&31;switch(e){case 3:this.isString();break;case 4:this.isNumber();break;case 5:this.isBoolean();break;case 7:this.isUnsignedInteger(8);break;case 8:this.isUnsignedInteger(16);break;case 9:this.isUnsignedInteger(24);break;case 10:this.isUnsignedInteger(32);break;case 11:this.isUnsignedInteger(48);break;case 12:this.isBinary();break;case 13:this.isBinary(32);break;case 14:this.isHashString();break;default:throw`unexpected definition type ${e}`}}isString(){if(this.basicType!=3)throw`string expected`;if(this.definition.size){let e=Za.encode(this.value);this.checkSize(e.length,this.definition.size)}}isNumber(){if(this.basicType!=4)throw`number expected`}isBoolean(){if(this.basicType!=5)throw`Boolean value expected`}isInteger(){if(this.isNumber(),this.value%1)throw`integer expected`;if(this.value<-(2**53-1)||this.value>2**53-1)throw`value is outside the safe integer range`}isUnsignedInteger(e){if(this.isInteger(),this.value<0)throw new eo(`non-negative value expected`);if(this.value>=2**e)throw Error(`value is too big (${e}-bit value expected)`)}isBinary(e){if(this.basicType!=12)throw`Uint8Array expected`;this.checkSize(this.value.length,e||this.definition.size)}isHashString(){if(this.isString(),this.checkSize(this.value.length,64),/[^\da-f]/i.test(this.value))throw`hexadecimal string expected`}checkSize(e,t){if(t!==void 0&&e!=t)throw`invalid size (expecting ${t}, got ${e})`}};function io(e){return typeof e==`function`?e:ao(e)}function ao(e){if(e==null)return()=>!1;if(e===`fatal`)return e=>e.level===`fatal`;if(e===`error`)return e=>e.level===`fatal`||e.level===`error`;if(e===`warning`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`;if(e===`info`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`;if(e===`debug`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`||e.level===`debug`;if(e===`trace`)return()=>!0;throw TypeError(`Invalid log level: ${e}.`)}var oo=[`trace`,`debug`,`info`,`warning`,`error`,`fatal`];function so(e,t){let n=oo.indexOf(e);if(n<0)throw TypeError(`Invalid log level: ${JSON.stringify(e)}.`);let r=oo.indexOf(t);if(r<0)throw TypeError(`Invalid log level: ${JSON.stringify(t)}.`);return n-r}function co(e=[]){return uo.getLogger(e)}var lo=Symbol.for(`logtape.rootLogger`),uo=class e{parent;children;category;sinks;parentSinks=`inherit`;filters;lowestLevel=`trace`;contextLocalStorage;static getLogger(t=[]){let n=lo in globalThis?globalThis[lo]??null:null;return n??(n=new e(null,[]),globalThis[lo]=n),typeof t==`string`?n.getChild(t):t.length===0?n:n.getChild(t)}constructor(e,t){this.parent=e,this.children={},this.category=t,this.sinks=[],this.filters=[]}getChild(t){let n=typeof t==`string`?t:t[0],r=this.children[n],i=r instanceof e?r:r?.deref();return i??(i=new e(this,[...this.category,n]),this.children[n]=`WeakRef`in globalThis?new WeakRef(i):i),typeof t==`string`||t.length===1?i:i.getChild(t.slice(1))}reset(){for(;this.sinks.length>0;)this.sinks.shift();for(this.parentSinks=`inherit`;this.filters.length>0;)this.filters.shift();this.lowestLevel=`trace`}resetDescendants(){for(let t of Object.values(this.children))(t instanceof e?t:t.deref())?.resetDescendants();this.reset()}with(e){return new fo(this,{...e})}filter(e){for(let t of this.filters)if(!t(e))return!1;return this.filters.length<1?this.parent?.filter(e)??!0:!0}*getSinks(e){if(!(this.lowestLevel===null||so(e,this.lowestLevel)<0)){if(this.parent!=null&&this.parentSinks===`inherit`)for(let t of this.parent.getSinks(e))yield t;for(let e of this.sinks)yield e}}emit(e,t){let n=So(),r=`category`in e?e.category:this.category,i=n.length>0?[...n,...r]:r,a=Object.getOwnPropertyDescriptors(e);a.category={value:i,enumerable:!0,configurable:!0};let o=Object.defineProperties({},a);if(!(this.lowestLevel===null||so(o.level,this.lowestLevel)<0||!this.filter(o))){for(let e of this.getSinks(o.level))if(!t?.has(e))try{e(o)}catch(n){let r=new Set(t);r.add(e),po.log(`fatal`,`Failed to emit a log record to sink {sink}: {error}`,{sink:e,error:n,record:o},r)}}}log(e,t,n,r){let i=Co(),a,o=typeof n==`function`?{category:this.category,level:e,timestamp:Date.now(),get message(){return yo(t,this.properties)},rawMessage:t,get properties(){return a??={...i,...n()},a}}:{category:this.category,level:e,timestamp:Date.now(),message:yo(t,{...i,...n}),rawMessage:t,properties:{...i,...n}};this.emit(o,r)}logLazily(e,t,n={}){let r=Co(),i,a;function o(){if((a==null||i==null)&&(a=t((e,...t)=>(i=e,bo(e,t))),i==null))throw TypeError(`No log record was made.`);return[a,i]}this.emit({category:this.category,level:e,get message(){return o()[0]},get rawMessage(){return o()[1]},timestamp:Date.now(),properties:{...r,...n}})}logTemplate(e,t,n,r={}){let i=Co();this.emit({category:this.category,level:e,message:bo(t,n),rawMessage:t,timestamp:Date.now(),properties:{...i,...r}})}trace(e,...t){typeof e==`string`?this.log(`trace`,e,t[0]??{}):typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){typeof e==`string`?this.log(`debug`,e,t[0]??{}):typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){typeof e==`string`?this.log(`info`,e,t[0]??{}):typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}warn(e,...t){typeof e==`string`?this.log(`warning`,e,t[0]??{}):typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){this.warn(e,...t)}error(e,...t){typeof e==`string`?this.log(`error`,e,t[0]??{}):typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){typeof e==`string`?this.log(`fatal`,e,t[0]??{}):typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}},fo=class e{logger;properties;constructor(e,t){this.logger=e,this.properties=t}get category(){return this.logger.category}get parent(){return this.logger.parent}getChild(e){return this.logger.getChild(e).with(this.properties)}with(t){return new e(this.logger,{...this.properties,...t})}log(e,t,n,r){this.logger.log(e,t,typeof n==`function`?()=>({...this.properties,...n()}):{...this.properties,...n},r)}logLazily(e,t){this.logger.logLazily(e,t,this.properties)}logTemplate(e,t,n){this.logger.logTemplate(e,t,n,this.properties)}emit(e){let t={...e,properties:{...this.properties,...e.properties}};this.logger.emit(t)}trace(e,...t){typeof e==`string`?this.log(`trace`,e,t[0]??{}):typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){typeof e==`string`?this.log(`debug`,e,t[0]??{}):typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){typeof e==`string`?this.log(`info`,e,t[0]??{}):typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}warn(e,...t){typeof e==`string`?this.log(`warning`,e,t[0]??{}):typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){this.warn(e,...t)}error(e,...t){typeof e==`string`?this.log(`error`,e,t[0]??{}):typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){typeof e==`string`?this.log(`fatal`,e,t[0]??{}):typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}},po=uo.getLogger([`logtape`,`meta`]);function mo(e){return e.includes(`.`)||e.includes(`[`)||e.includes(`?.`)}function ho(e,t){if(!(t===`__proto__`||t===`prototype`||t===`constructor`)&&(typeof e==`object`||typeof e==`function`)&&e!==null)return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function go(e,t){let n=e.length,r=t;if(r>=n)return null;let i;if(e[r]===`[`){if(r++,r>=n)return null;if(e[r]===`"`||e[r]===`'`){let t=e[r];r++;let a=``;for(;r<n&&e[r]!==t;)if(e[r]===`\\`){if(r++,r<n){let t=e[r];switch(t){case`n`:a+=`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},n=function(e){return e[e.CARMENTIS_ERROR=0]=`CARMENTIS_ERROR`,e[e.NODE_ERROR=1]=`NODE_ERROR`,e[e.NODE_NOT_AVAILABLE_DURING_SYNCHRONISATION_ERROR=2]=`NODE_NOT_AVAILABLE_DURING_SYNCHRONISATION_ERROR`,e[e.INTERNAL_ERROR=500]=`INTERNAL_ERROR`,e[e.TYPE_CHECKING_FAILURE_ERROR=501]=`TYPE_CHECKING_FAILURE_ERROR`,e[e.SERIALIZATION_ERROR=502]=`SERIALIZATION_ERROR`,e[e.PROOF_VERIFICATION_FAILURE=300]=`PROOF_VERIFICATION_FAILURE`,e[e.BLOCKCHAIN_ERROR=100]=`BLOCKCHAIN_ERROR`,e[e.ACCOUNT_NOT_FOUND=101]=`ACCOUNT_NOT_FOUND`,e[e.ACCOUNT_ALREADY_EXISTS=102]=`ACCOUNT_ALREADY_EXISTS`,e[e.ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY=103]=`ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY`,e[e.ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY_HASH=104]=`ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY_HASH`,e[e.ACCOUNT_ALREADY_EXISTS_FOR_PUBLIC_KEY=105]=`ACCOUNT_ALREADY_EXISTS_FOR_PUBLIC_KEY`,e[e.ACCOUNT_NOT_FOUND_FOR_ADDRESS=106]=`ACCOUNT_NOT_FOUND_FOR_ADDRESS`,e[e.ORGANIZATION_NOT_FOUND=107]=`ORGANIZATION_NOT_FOUND`,e[e.APPLICATION_NOT_FOUND=108]=`APPLICATION_NOT_FOUND`,e[e.APPLICATION_LEDGER_NOT_FOUND=109]=`APPLICATION_LEDGER_NOT_FOUND`,e[e.VALIDATOR_NODE_NOT_FOUND=110]=`VALIDATOR_NODE_NOT_FOUND`,e[e.VIRTUAL_BLOCKCHAIN_NOT_FOUND=111]=`VIRTUAL_BLOCKCHAIN_NOT_FOUND`,e[e.VIRTUAL_BLOCKCHAIN_ALREADY_EXISTS=112]=`VIRTUAL_BLOCKCHAIN_ALREADY_EXISTS`,e[e.MICROBLOCK_STRUCTURE_CHECKING_ERROR=113]=`MICROBLOCK_STRUCTURE_CHECKING_ERROR`,e[e.ECONOMICS_ERROR=200]=`ECONOMICS_ERROR`,e[e.INVALID_TOKEN_UNIT=201]=`INVALID_TOKEN_UNIT`,e[e.PROTOCOL_ERROR=400]=`PROTOCOL_ERROR`,e}({}),r=class extends Error{},i=class extends r{},a=class extends r{},o=class e extends Error{constructor(e,t=n.CARMENTIS_ERROR){super(`[error ${t}] ${e}`),this.code=t}getErrorCode(){return this.code}static isCarmentisError(t){return t instanceof e}},s=class extends o{constructor(e){super(`Microblock structure checking error: ${e??`Not specified`}`,n.MICROBLOCK_STRUCTURE_CHECKING_ERROR)}},c=class extends o{constructor(){super(`You are not authenticated`)}},l=class extends o{constructor(e=`Parsing failure`){super(e)}},u=class extends o{constructor(e){super(e,n.BLOCKCHAIN_ERROR)}},d=class extends o{},f=class extends d{constructor(e){super(e??`Decryption failure`)}},p=class extends f{constructor(e){super(e)}},m=class extends o{},h=class extends m{},g=class extends h{constructor(e){super(`Connection with node at ${e} refused`,n.NODE_ERROR)}},_=class extends h{constructor(){super(`Query rejected while catching up`,n.NODE_ERROR)}},v=class extends o{constructor(e,t=n.ECONOMICS_ERROR){super(e,t)}},y=class extends v{constructor(){super(`Invalid unit type`,n.INVALID_TOKEN_UNIT)}},b=class extends o{constructor(e,t=n.BLOCKCHAIN_ERROR){super(e,t)}},ee=class extends Error{constructor(){super(`No implemented`)}},x=class extends b{constructor(e,t){super(`MicroBlock in virtual blockchain ${e.encode()} not found at height ${t}`)}},te=class extends b{constructor(){super(`MicroBlock not found`)}},ne=class extends b{constructor(){super(`MicroBlock not found in block`)}},re=class extends r{constructor(e){super(`Actor '${e}' already defined`)}},ie=class extends r{constructor(e,t){super(`invalid actor ID ${e} (expected ID: ${t})`)}},ae=class extends r{constructor(e){super(`Channel '${e}' already defined`)}},oe=class extends r{constructor(e){super(`Unknown actor '${e}'`)}},se=class extends r{constructor(e){super(`Unknown channel '${e}'`)}},ce=class extends o{constructor(e,t,r){super(`Proof verification failed on channel ${e} (computed hash is ${t}, on-chain hash is ${r})`,n.PROOF_VERIFICATION_FAILURE)}},le=class extends r{constructor(e){super(`Cannot subscribe as undefined actor ${e}`)}},S=class extends r{constructor(e){super(`Actor ${e} is already subscribed`)}},ue=class extends r{constructor(e){super(`signature scheme of type ${e} is not allowed on this application ledger`)}},de=class extends r{constructor(e){super(`PKE scheme of type ${e} is not allowed on this application ledger`)}},fe=class extends r{constructor(e){super(`Invalid channel ID ${e}`)}},pe=class extends r{constructor(){super(`Current actor not found`)}},me=class extends b{},he=class extends b{constructor(e,t){super(`Actor ${e} has not been invited to channel ${t}`)}},ge=class extends b{constructor(e){super(`Account not found for public key`)}},_e=class extends b{constructor(e){super(`Account not found for account hash: ${e.encode()}`,n.ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY)}},ve=class extends b{constructor(e){super(`Organization not found for hash: ${e.encode()}`,n.ORGANIZATION_NOT_FOUND)}},ye=class extends b{constructor(e){super(`Application not found for id: ${e.encode()}`,n.APPLICATION_NOT_FOUND)}},be=class extends b{constructor(e){super(`Validator node not found for id: ${e.encode()}`,n.VALIDATOR_NODE_NOT_FOUND)}},xe=class extends b{constructor(e){super(`Account not found for public key hash: ${e.encode()}`,n.ACCOUNT_NOT_FOUND_FOR_PUBLIC_KEY_HASH)}},Se=class extends b{constructor(e){super(`Virtual blockchain not found: ${e.encode()}`,n.VIRTUAL_BLOCKCHAIN_NOT_FOUND)}},Ce=class extends Se{constructor(e){super(e)}},we=class extends o{constructor(e,t=n.PROTOCOL_ERROR){super(`/!\\ `+e,t)}},Te=class extends we{constructor(e,t){super(`Actor ${t} (id ${e}) has not subscribed to a public encryption key.`),this.actorId=e,this.actorName=t}getNotSubscribedActorName(){return this.actorName}},Ee=class extends we{constructor(){super(`Section not found`)}},De=class extends we{constructor(e,t){super(`No shared secret between host ${t} and guest ${e}`)}},Oe=class extends o{constructor(e){super(e,n.SERIALIZATION_ERROR)}},ke=9e15,Ae=1e9,je=`0123456789abcdef`,Me=`2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058`,Ne=`3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789`,Pe={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ke,maxE:ke,crypto:!1},Fe,Ie,C=!0,Le=`[DecimalError] `,Re=Le+`Invalid argument: `,ze=Le+`Precision limit exceeded`,Be=Le+`crypto unavailable`,Ve=`[object Decimal]`,He=Math.floor,Ue=Math.pow,We=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Ge=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Ke=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,qe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Je=1e7,w=7,Ye=9007199254740991,Xe=Me.length-1,Ze=Ne.length-1,T={toStringTag:Ve};T.absoluteValue=T.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),E(e)},T.ceil=function(){return E(new this.constructor(this),this.e+1,2)},T.clampedTo=T.clamp=function(e,t){var n,r=this,i=r.constructor;if(e=new i(e),t=new i(t),!e.s||!t.s)return new i(NaN);if(e.gt(t))throw Error(Re+t);return n=r.cmp(e),n<0?e:r.cmp(t)>0?t:new i(r)},T.comparedTo=T.cmp=function(e){var t,n,r,i,a=this,o=a.d,s=(e=new a.constructor(e)).d,c=a.s,l=e.s;if(!o||!s)return!c||!l?NaN:c===l?o===s?0:!o^c<0?1:-1:c;if(!o[0]||!s[0])return o[0]?c:s[0]?-l:0;if(c!==l)return c;if(a.e!==e.e)return a.e>e.e^c<0?1:-1;for(r=o.length,i=s.length,t=0,n=r<i?r:i;t<n;++t)if(o[t]!==s[t])return o[t]>s[t]^c<0?1:-1;return r===i?0:r>i^c<0?1:-1},T.cosine=T.cos=function(){var e,t,n=this,r=n.constructor;return n.d?n.d[0]?(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+w,r.rounding=1,n=nt(r,xt(r,n)),r.precision=e,r.rounding=t,E(Ie==2||Ie==3?n.neg():n,e,t,!0)):new r(1):new r(NaN)},T.cubeRoot=T.cbrt=function(){var e,t,n,r,i,a,o,s,c,l,u=this,d=u.constructor;if(!u.isFinite()||u.isZero())return new d(u);for(C=!1,a=u.s*Ue(u.s*u,1/3),!a||Math.abs(a)==1/0?(n=Qe(u.d),e=u.e,(a=(e-n.length+1)%3)&&(n+=a==1||a==-2?`0`:`00`),a=Ue(n,1/3),e=He((e+1)/3)-(e%3==(e<0?-1:2)),a==1/0?n=`5e`+e:(n=a.toExponential(),n=n.slice(0,n.indexOf(`e`)+1)+e),r=new d(n),r.s=u.s):r=new d(a.toString()),o=(e=d.precision)+3;;)if(s=r,c=s.times(s).times(s),l=c.plus(u),r=rt(l.plus(u).times(s),l.plus(c),o+2,1),Qe(s.d).slice(0,o)===(n=Qe(r.d)).slice(0,o))if(n=n.slice(o-3,o+1),n==`9999`||!i&&n==`4999`){if(!i&&(E(s,e+1,0),s.times(s).times(s).eq(u))){r=s;break}o+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)==`5`)&&(E(r,e+1,1),t=!r.times(r).times(r).eq(u));break}return C=!0,E(r,e,d.rounding,t)},T.decimalPlaces=T.dp=function(){var e,t=this.d,n=NaN;if(t){if(e=t.length-1,n=(e-He(this.e/w))*w,e=t[e],e)for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n},T.dividedBy=T.div=function(e){return rt(this,new this.constructor(e))},T.dividedToIntegerBy=T.divToInt=function(e){var t=this,n=t.constructor;return E(rt(t,new n(e),0,1,1),n.precision,n.rounding)},T.equals=T.eq=function(e){return this.cmp(e)===0},T.floor=function(){return E(new this.constructor(this),this.e+1,3)},T.greaterThan=T.gt=function(e){return this.cmp(e)>0},T.greaterThanOrEqualTo=T.gte=function(e){var t=this.cmp(e);return t==1||t===0},T.hyperbolicCosine=T.cosh=function(){var e,t,n,r,i,a=this,o=a.constructor,s=new o(1);if(!a.isFinite())return new o(a.s?1/0:NaN);if(a.isZero())return s;n=o.precision,r=o.rounding,o.precision=n+Math.max(a.e,a.sd())+4,o.rounding=1,i=a.d.length,i<32?(e=Math.ceil(i/3),t=(1/bt(4,e)).toString()):(e=16,t=`2.3283064365386962890625e-10`),a=yt(o,1,a.times(t),new o(1),!0);for(var c,l=e,u=new o(8);l--;)c=a.times(a),a=s.minus(c.times(u.minus(c.times(u))));return E(a,o.precision=n,o.rounding=r,!0)},T.hyperbolicSine=T.sinh=function(){var e,t,n,r,i=this,a=i.constructor;if(!i.isFinite()||i.isZero())return new a(i);if(t=a.precision,n=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,r=i.d.length,r<3)i=yt(a,2,i,i,!0);else{e=1.4*Math.sqrt(r),e=e>16?16:e|0,i=i.times(1/bt(5,e)),i=yt(a,2,i,i,!0);for(var o,s=new a(5),c=new a(16),l=new a(20);e--;)o=i.times(i),i=i.times(s.plus(o.times(c.times(o).plus(l))))}return a.precision=t,a.rounding=n,E(i,t,n,!0)},T.hyperbolicTangent=T.tanh=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+7,r.rounding=1,rt(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)},T.inverseCosine=T.acos=function(){var e=this,t=e.constructor,n=e.abs().cmp(1),r=t.precision,i=t.rounding;return n===-1?e.isZero()?st(t,r+4,i).times(.5):(t.precision=r+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=r,t.rounding=i,e.times(2)):n===0?e.isNeg()?st(t,r,i):new t(0):new t(NaN)},T.inverseHyperbolicCosine=T.acosh=function(){var e,t,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(e=r.precision,t=r.rounding,r.precision=e+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,C=!1,n=n.times(n).minus(1).sqrt().plus(n),C=!0,r.precision=e,r.rounding=t,n.ln()):new r(n)},T.inverseHyperbolicSine=T.asinh=function(){var e,t,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,C=!1,n=n.times(n).plus(1).sqrt().plus(n),C=!0,r.precision=e,r.rounding=t,n.ln())},T.inverseHyperbolicTangent=T.atanh=function(){var e,t,n,r,i=this,a=i.constructor;return i.isFinite()?i.e>=0?new a(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=a.precision,t=a.rounding,r=i.sd(),Math.max(r,e)<2*-i.e-1?E(new a(i),e,t,!0):(a.precision=n=r-i.e,i=rt(i.plus(1),new a(1).minus(i),n+e,1),a.precision=e+4,a.rounding=1,i=i.ln(),a.precision=e,a.rounding=t,i.times(.5))):new a(NaN)},T.inverseSine=T.asin=function(){var e,t,n,r,i=this,a=i.constructor;return i.isZero()?new a(i):(t=i.abs().cmp(1),n=a.precision,r=a.rounding,t===-1?(a.precision=n+6,a.rounding=1,i=i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(),a.precision=n,a.rounding=r,i.times(2)):t===0?(e=st(a,n+4,r).times(.5),e.s=i.s,e):new a(NaN))},T.inverseTangent=T.atan=function(){var e,t,n,r,i,a,o,s,c,l=this,u=l.constructor,d=u.precision,f=u.rounding;if(!l.isFinite()){if(!l.s)return new u(NaN);if(d+4<=Ze)return o=st(u,d+4,f).times(.5),o.s=l.s,o}else if(l.isZero())return new u(l);else if(l.abs().eq(1)&&d+4<=Ze)return o=st(u,d+4,f).times(.25),o.s=l.s,o;for(u.precision=s=d+10,u.rounding=1,n=Math.min(28,s/w+2|0),e=n;e;--e)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(C=!1,t=Math.ceil(s/w),r=1,c=l.times(l),o=new u(l),i=l;e!==-1;)if(i=i.times(c),a=o.minus(i.div(r+=2)),i=i.times(c),o=a.plus(i.div(r+=2)),o.d[t]!==void 0)for(e=t;o.d[e]===a.d[e]&&e--;);return n&&(o=o.times(2<<n-1)),C=!0,E(o,u.precision=d,u.rounding=f,!0)},T.isFinite=function(){return!!this.d},T.isInteger=T.isInt=function(){return!!this.d&&He(this.e/w)>this.d.length-2},T.isNaN=function(){return!this.s},T.isNegative=T.isNeg=function(){return this.s<0},T.isPositive=T.isPos=function(){return this.s>0},T.isZero=function(){return!!this.d&&this.d[0]===0},T.lessThan=T.lt=function(e){return this.cmp(e)<0},T.lessThanOrEqualTo=T.lte=function(e){return this.cmp(e)<1},T.logarithm=T.log=function(e){var t,n,r,i,a,o,s,c,l=this,u=l.constructor,d=u.precision,f=u.rounding,p=5;if(e==null)e=new u(10),t=!0;else{if(e=new u(e),n=e.d,e.s<0||!n||!n[0]||e.eq(1))return new u(NaN);t=e.eq(10)}if(n=l.d,l.s<0||!n||!n[0]||l.eq(1))return new u(n&&!n[0]?-1/0:l.s==1?n?0:1/0:NaN);if(t)if(n.length>1)a=!0;else{for(i=n[0];i%10==0;)i/=10;a=i!==1}if(C=!1,s=d+p,o=mt(l,s),r=t?ot(u,s+10):mt(e,s),c=rt(o,r,s,1),et(c.d,i=d,f))do if(s+=10,o=mt(l,s),r=t?ot(u,s+10):mt(e,s),c=rt(o,r,s,1),!a){+Qe(c.d).slice(i+1,i+15)+1==0x5af3107a4000&&(c=E(c,d+1,0));break}while(et(c.d,i+=10,f));return C=!0,E(c,d,f)},T.minus=T.sub=function(e){var t,n,r,i,a,o,s,c,l,u,d,f,p=this,m=p.constructor;if(e=new m(e),!p.d||!e.d)return!p.s||!e.s?e=new m(NaN):p.d?e.s=-e.s:e=new m(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(l=p.d,f=e.d,s=m.precision,c=m.rounding,!l[0]||!f[0]){if(f[0])e.s=-e.s;else if(l[0])e=new m(p);else return new m(c===3?-0:0);return C?E(e,s,c):e}if(n=He(e.e/w),u=He(p.e/w),l=l.slice(),a=u-n,a){for(d=a<0,d?(t=l,a=-a,o=f.length):(t=f,n=u,o=l.length),r=Math.max(Math.ceil(s/w),o)+2,a>r&&(a=r,t.length=1),t.reverse(),r=a;r--;)t.push(0);t.reverse()}else{for(r=l.length,o=f.length,d=r<o,d&&(o=r),r=0;r<o;r++)if(l[r]!=f[r]){d=l[r]<f[r];break}a=0}for(d&&(t=l,l=f,f=t,e.s=-e.s),o=l.length,r=f.length-o;r>0;--r)l[o++]=0;for(r=f.length;r>a;){if(l[--r]<f[r]){for(i=r;i&&l[--i]===0;)l[i]=Je-1;--l[i],l[r]+=Je}l[r]-=f[r]}for(;l[--o]===0;)l.pop();for(;l[0]===0;l.shift())--n;return l[0]?(e.d=l,e.e=at(l,n),C?E(e,s,c):e):new m(c===3?-0:0)},T.modulo=T.mod=function(e){var t,n=this,r=n.constructor;return e=new r(e),!n.d||!e.s||e.d&&!e.d[0]?new r(NaN):!e.d||n.d&&!n.d[0]?E(new r(n),r.precision,r.rounding):(C=!1,r.modulo==9?(t=rt(n,e.abs(),0,3,1),t.s*=e.s):t=rt(n,e,0,r.modulo,1),t=t.times(e),C=!0,n.minus(t))},T.naturalExponential=T.exp=function(){return pt(this)},T.naturalLogarithm=T.ln=function(){return mt(this)},T.negated=T.neg=function(){var e=new this.constructor(this);return e.s=-e.s,E(e)},T.plus=T.add=function(e){var t,n,r,i,a,o,s,c,l,u,d=this,f=d.constructor;if(e=new f(e),!d.d||!e.d)return!d.s||!e.s?e=new f(NaN):d.d||(e=new f(e.d||d.s===e.s?d:NaN)),e;if(d.s!=e.s)return e.s=-e.s,d.minus(e);if(l=d.d,u=e.d,s=f.precision,c=f.rounding,!l[0]||!u[0])return u[0]||(e=new f(d)),C?E(e,s,c):e;if(a=He(d.e/w),r=He(e.e/w),l=l.slice(),i=a-r,i){for(i<0?(n=l,i=-i,o=u.length):(n=u,r=a,o=l.length),a=Math.ceil(s/w),o=a>o?a+1:o+1,i>o&&(i=o,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for(o=l.length,i=u.length,o-i<0&&(i=o,n=u,u=l,l=n),t=0;i;)t=(l[--i]=l[i]+u[i]+t)/Je|0,l[i]%=Je;for(t&&(l.unshift(t),++r),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=at(l,r),C?E(e,s,c):e},T.precision=T.sd=function(e){var t,n=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Re+e);return n.d?(t=ct(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},T.round=function(){var e=this,t=e.constructor;return E(new t(e),e.e+1,t.rounding)},T.sine=T.sin=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+w,r.rounding=1,n=vt(r,xt(r,n)),r.precision=e,r.rounding=t,E(Ie>2?n.neg():n,e,t,!0)):new r(NaN)},T.squareRoot=T.sqrt=function(){var e,t,n,r,i,a,o=this,s=o.d,c=o.e,l=o.s,u=o.constructor;if(l!==1||!s||!s[0])return new u(!l||l<0&&(!s||s[0])?NaN:s?o:1/0);for(C=!1,l=Math.sqrt(+o),l==0||l==1/0?(t=Qe(s),(t.length+c)%2==0&&(t+=`0`),l=Math.sqrt(t),c=He((c+1)/2)-(c<0||c%2),l==1/0?t=`5e`+c:(t=l.toExponential(),t=t.slice(0,t.indexOf(`e`)+1)+c),r=new u(t)):r=new u(l.toString()),n=(c=u.precision)+3;;)if(a=r,r=a.plus(rt(o,a,n+2,1)).times(.5),Qe(a.d).slice(0,n)===(t=Qe(r.d)).slice(0,n))if(t=t.slice(n-3,n+1),t==`9999`||!i&&t==`4999`){if(!i&&(E(a,c+1,0),a.times(a).eq(o))){r=a;break}n+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)==`5`)&&(E(r,c+1,1),e=!r.times(r).eq(o));break}return C=!0,E(r,c,u.rounding,e)},T.tangent=T.tan=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+10,r.rounding=1,n=n.sin(),n.s=1,n=rt(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,E(Ie==2||Ie==4?n.neg():n,e,t,!0)):new r(NaN)},T.times=T.mul=function(e){var t,n,r,i,a,o,s,c,l,u=this,d=u.constructor,f=u.d,p=(e=new d(e)).d;if(e.s*=u.s,!f||!f[0]||!p||!p[0])return new d(!e.s||f&&!f[0]&&!p||p&&!p[0]&&!f?NaN:!f||!p?e.s/0:e.s*0);for(n=He(u.e/w)+He(e.e/w),c=f.length,l=p.length,c<l&&(a=f,f=p,p=a,o=c,c=l,l=o),a=[],o=c+l,r=o;r--;)a.push(0);for(r=l;--r>=0;){for(t=0,i=c+r;i>r;)s=a[i]+p[r]*f[i-r-1]+t,a[i--]=s%Je|0,t=s/Je|0;a[i]=(a[i]+t)%Je|0}for(;!a[--o];)a.pop();return t?++n:a.shift(),e.d=a,e.e=at(a,n),C?E(e,d.precision,d.rounding):e},T.toBinary=function(e,t){return St(this,2,e,t)},T.toDecimalPlaces=T.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:($e(e,0,Ae),t===void 0?t=r.rounding:$e(t,0,8),E(n,e+n.e+1,t))},T.toExponential=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=it(r,!0):($e(e,0,Ae),t===void 0?t=i.rounding:$e(t,0,8),r=E(new i(r),e+1,t),n=it(r,!0,e+1)),r.isNeg()&&!r.isZero()?`-`+n:n},T.toFixed=function(e,t){var n,r,i=this,a=i.constructor;return e===void 0?n=it(i):($e(e,0,Ae),t===void 0?t=a.rounding:$e(t,0,8),r=E(new a(i),e+i.e+1,t),n=it(r,!1,e+r.e+1)),i.isNeg()&&!i.isZero()?`-`+n:n},T.toFraction=function(e){var t,n,r,i,a,o,s,c,l,u,d,f,p=this,m=p.d,h=p.constructor;if(!m)return new h(p);if(l=n=new h(1),r=c=new h(0),t=new h(r),a=t.e=ct(m)-p.e-1,o=a%w,t.d[0]=Ue(10,o<0?w+o:o),e==null)e=a>0?t:l;else{if(s=new h(e),!s.isInt()||s.lt(l))throw Error(Re+s);e=s.gt(t)?a>0?t:l:s}for(C=!1,s=new h(Qe(m)),u=h.precision,h.precision=a=m.length*w*2;d=rt(s,t,0,1,1),i=n.plus(d.times(r)),i.cmp(e)!=1;)n=r,r=i,i=l,l=c.plus(d.times(i)),c=i,i=t,t=s.minus(d.times(i)),s=i;return i=rt(e.minus(n),r,0,1,1),c=c.plus(i.times(l)),n=n.plus(i.times(r)),c.s=l.s=p.s,f=rt(l,r,a,1).minus(p).abs().cmp(rt(c,n,a,1).minus(p).abs())<1?[l,r]:[c,n],h.precision=u,C=!0,f},T.toHexadecimal=T.toHex=function(e,t){return St(this,16,e,t)},T.toNearest=function(e,t){var n=this,r=n.constructor;if(n=new r(n),e==null){if(!n.d)return n;e=new r(1),t=r.rounding}else{if(e=new r(e),t===void 0?t=r.rounding:$e(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&=n.s,e}return e.d[0]?(C=!1,n=rt(n,e,0,t,1).times(e),C=!0,E(n)):(e.s=n.s,n=e),n},T.toNumber=function(){return+this},T.toOctal=function(e,t){return St(this,8,e,t)},T.toPower=T.pow=function(e){var t,n,r,i,a,o,s=this,c=s.constructor,l=+(e=new c(e));if(!s.d||!e.d||!s.d[0]||!e.d[0])return new c(Ue(+s,l));if(s=new c(s),s.eq(1))return s;if(r=c.precision,a=c.rounding,e.eq(1))return E(s,r,a);if(t=He(e.e/w),t>=e.d.length-1&&(n=l<0?-l:l)<=Ye)return i=ut(c,s,n,r),e.s<0?new c(1).div(i):E(i,r,a);if(o=s.s,o<0){if(t<e.d.length-1)return new c(NaN);if(e.d[t]&1||(o=1),s.e==0&&s.d[0]==1&&s.d.length==1)return s.s=o,s}return n=Ue(+s,l),t=n==0||!isFinite(n)?He(l*(Math.log(`0.`+Qe(s.d))/Math.LN10+s.e+1)):new c(n+``).e,t>c.maxE+1||t<c.minE-1?new c(t>0?o/0:0):(C=!1,c.rounding=s.s=1,n=Math.min(12,(t+``).length),i=pt(e.times(mt(s,r+n)),r),i.d&&(i=E(i,r+5,1),et(i.d,r,a)&&(t=r+10,i=E(pt(e.times(mt(s,t+n)),t),t+5,1),+Qe(i.d).slice(r+1,r+15)+1==0x5af3107a4000&&(i=E(i,r+1,0)))),i.s=o,C=!0,c.rounding=a,E(i,r,a))},T.toPrecision=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=it(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):($e(e,1,Ae),t===void 0?t=i.rounding:$e(t,0,8),r=E(new i(r),e,t),n=it(r,e<=r.e||r.e<=i.toExpNeg,e)),r.isNeg()&&!r.isZero()?`-`+n:n},T.toSignificantDigits=T.toSD=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):($e(e,1,Ae),t===void 0?t=r.rounding:$e(t,0,8)),E(new r(n),e,t)},T.toString=function(){var e=this,t=e.constructor,n=it(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?`-`+n:n},T.truncated=T.trunc=function(){return E(new this.constructor(this),this.e+1,1)},T.valueOf=T.toJSON=function(){var e=this,t=e.constructor,n=it(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?`-`+n:n};function Qe(e){var t,n,r,i=e.length-1,a=``,o=e[0];if(i>0){for(a+=o,t=1;t<i;t++)r=e[t]+``,n=w-r.length,n&&(a+=lt(n)),a+=r;o=e[t],r=o+``,n=w-r.length,n&&(a+=lt(n))}else if(o===0)return`0`;for(;o%10==0;)o/=10;return a+o}function $e(e,t,n){if(e!==~~e||e<t||e>n)throw Error(Re+e)}function et(e,t,n,r){var i,a,o,s;for(a=e[0];a>=10;a/=10)--t;return--t<0?(t+=w,i=0):(i=Math.ceil((t+1)/w),t%=w),a=Ue(10,w-t),s=e[i]%a|0,r==null?t<3?(t==0?s=s/100|0:t==1&&(s=s/10|0),o=n<4&&s==99999||n>3&&s==49999||s==5e4||s==0):o=(n<4&&s+1==a||n>3&&s+1==a/2)&&(e[i+1]/a/100|0)==Ue(10,t-2)-1||(s==a/2||s==0)&&(e[i+1]/a/100|0)==0:t<4?(t==0?s=s/1e3|0:t==1?s=s/100|0:t==2&&(s=s/10|0),o=(r||n<4)&&s==9999||!r&&n>3&&s==4999):o=((r||n<4)&&s+1==a||!r&&n>3&&s+1==a/2)&&(e[i+1]/a/1e3|0)==Ue(10,t-3)-1,o}function tt(e,t,n){for(var r,i=[0],a,o=0,s=e.length;o<s;){for(a=i.length;a--;)i[a]*=t;for(i[0]+=je.indexOf(e.charAt(o++)),r=0;r<i.length;r++)i[r]>n-1&&(i[r+1]===void 0&&(i[r+1]=0),i[r+1]+=i[r]/n|0,i[r]%=n)}return i.reverse()}function nt(e,t){var n,r,i;if(t.isZero())return t;r=t.d.length,r<32?(n=Math.ceil(r/3),i=(1/bt(4,n)).toString()):(n=16,i=`2.3283064365386962890625e-10`),e.precision+=n,t=yt(e,1,t.times(i),new e(1));for(var a=n;a--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=n,t}var rt=(function(){function e(e,t,n){var r,i=0,a=e.length;for(e=e.slice();a--;)r=e[a]*t+i,e[a]=r%n|0,i=r/n|0;return i&&e.unshift(i),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=+(e[n]<t[n]),e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;)e.shift()}return function(r,i,a,o,s,c){var l,u,d,f,p,m,h,g,_,v,y,b,ee,x,te,ne,re,ie,ae,oe,se=r.constructor,ce=r.s==i.s?1:-1,le=r.d,S=i.d;if(!le||!le[0]||!S||!S[0])return new se(!r.s||!i.s||(le?S&&le[0]==S[0]:!S)?NaN:le&&le[0]==0||!S?ce*0:ce/0);for(c?(p=1,u=r.e-i.e):(c=Je,p=w,u=He(r.e/p)-He(i.e/p)),ae=S.length,re=le.length,_=new se(ce),v=_.d=[],d=0;S[d]==(le[d]||0);d++);if(S[d]>(le[d]||0)&&u--,a==null?(x=a=se.precision,o=se.rounding):x=s?a+(r.e-i.e)+1:a,x<0)v.push(1),m=!0;else{if(x=x/p+2|0,d=0,ae==1){for(f=0,S=S[0],x++;(d<re||f)&&x--;d++)te=f*c+(le[d]||0),v[d]=te/S|0,f=te%S|0;m=f||d<re}else{for(f=c/(S[0]+1)|0,f>1&&(S=e(S,f,c),le=e(le,f,c),ae=S.length,re=le.length),ne=ae,y=le.slice(0,ae),b=y.length;b<ae;)y[b++]=0;oe=S.slice(),oe.unshift(0),ie=S[0],S[1]>=c/2&&++ie;do f=0,l=t(S,y,ae,b),l<0?(ee=y[0],ae!=b&&(ee=ee*c+(y[1]||0)),f=ee/ie|0,f>1?(f>=c&&(f=c-1),h=e(S,f,c),g=h.length,b=y.length,l=t(h,y,g,b),l==1&&(f--,n(h,ae<g?oe:S,g,c))):(f==0&&(l=f=1),h=S.slice()),g=h.length,g<b&&h.unshift(0),n(y,h,b,c),l==-1&&(b=y.length,l=t(S,y,ae,b),l<1&&(f++,n(y,ae<b?oe:S,b,c))),b=y.length):l===0&&(f++,y=[0]),v[d++]=f,l&&y[0]?y[b++]=le[ne]||0:(y=[le[ne]],b=1);while((ne++<re||y[0]!==void 0)&&x--);m=y[0]!==void 0}v[0]||v.shift()}if(p==1)_.e=u,Fe=m;else{for(d=1,f=v[0];f>=10;f/=10)d++;_.e=d+u*p-1,E(_,s?a+_.e+1:a,o,m)}return _}})();function E(e,t,n,r){var i,a,o,s,c,l,u,d,f,p=e.constructor;out:if(t!=null){if(d=e.d,!d)return e;for(i=1,s=d[0];s>=10;s/=10)i++;if(a=t-i,a<0)a+=w,o=t,u=d[f=0],c=u/Ue(10,i-o-1)%10|0;else if(f=Math.ceil((a+1)/w),s=d.length,f>=s)if(r){for(;s++<=f;)d.push(0);u=c=0,i=1,a%=w,o=a-w+1}else break out;else{for(u=s=d[f],i=1;s>=10;s/=10)i++;a%=w,o=a-w+i,c=o<0?0:u/Ue(10,i-o-1)%10|0}if(r=r||t<0||d[f+1]!==void 0||(o<0?u:u%Ue(10,i-o-1)),l=n<4?(c||r)&&(n==0||n==(e.s<0?3:2)):c>5||c==5&&(n==4||r||n==6&&(a>0?o>0?u/Ue(10,i-o):0:d[f-1])%10&1||n==(e.s<0?8:7)),t<1||!d[0])return d.length=0,l?(t-=e.e+1,d[0]=Ue(10,(w-t%w)%w),e.e=-t||0):d[0]=e.e=0,e;if(a==0?(d.length=f,s=1,f--):(d.length=f+1,s=Ue(10,w-a),d[f]=o>0?(u/Ue(10,i-o)%Ue(10,o)|0)*s:0),l)for(;;)if(f==0){for(a=1,o=d[0];o>=10;o/=10)a++;for(o=d[0]+=s,s=1;o>=10;o/=10)s++;a!=s&&(e.e++,d[0]==Je&&(d[0]=1));break}else{if(d[f]+=s,d[f]!=Je)break;d[f--]=0,s=1}for(a=d.length;d[--a]===0;)d.pop()}return C&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function it(e,t,n){if(!e.isFinite())return ht(e);var r,i=e.e,a=Qe(e.d),o=a.length;return t?(n&&(r=n-o)>0?a=a.charAt(0)+`.`+a.slice(1)+lt(r):o>1&&(a=a.charAt(0)+`.`+a.slice(1)),a=a+(e.e<0?`e`:`e+`)+e.e):i<0?(a=`0.`+lt(-i-1)+a,n&&(r=n-o)>0&&(a+=lt(r))):i>=o?(a+=lt(i+1-o),n&&(r=n-i-1)>0&&(a=a+`.`+lt(r))):((r=i+1)<o&&(a=a.slice(0,r)+`.`+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+=`.`),a+=lt(r))),a}function at(e,t){var n=e[0];for(t*=w;n>=10;n/=10)t++;return t}function ot(e,t,n){if(t>Xe)throw C=!0,n&&(e.precision=n),Error(ze);return E(new e(Me),t,1,!0)}function st(e,t,n){if(t>Ze)throw Error(ze);return E(new e(Ne),t,n,!0)}function ct(e){var t=e.length-1,n=t*w+1;if(t=e[t],t){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function lt(e){for(var t=``;e--;)t+=`0`;return t}function ut(e,t,n,r){var i,a=new e(1),o=Math.ceil(r/w+4);for(C=!1;;){if(n%2&&(a=a.times(t),Ct(a.d,o)&&(i=!0)),n=He(n/2),n===0){n=a.d.length-1,i&&a.d[n]===0&&++a.d[n];break}t=t.times(t),Ct(t.d,o)}return C=!0,a}function dt(e){return e.d[e.d.length-1]&1}function ft(e,t,n){for(var r,i,a=new e(t[0]),o=0;++o<t.length;){if(i=new e(t[o]),!i.s){a=i;break}r=a.cmp(i),(r===n||r===0&&a.s===n)&&(a=i)}return a}function pt(e,t){var n,r,i,a,o,s,c,l=0,u=0,d=0,f=e.constructor,p=f.rounding,m=f.precision;if(!e.d||!e.d[0]||e.e>17)return new f(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(t==null?(C=!1,c=m):c=t,s=new f(.03125);e.e>-2;)e=e.times(s),d+=5;for(r=Math.log(Ue(2,d))/Math.LN10*2+5|0,c+=r,n=a=o=new f(1),f.precision=c;;){if(a=E(a.times(e),c,1),n=n.times(++u),s=o.plus(rt(a,n,c,1)),Qe(s.d).slice(0,c)===Qe(o.d).slice(0,c)){for(i=d;i--;)o=E(o.times(o),c,1);if(t==null)if(l<3&&et(o.d,c-r,p,l))f.precision=c+=10,n=a=s=new f(1),u=0,l++;else return E(o,f.precision=m,p,C=!0);else return f.precision=m,o}o=s}}function mt(e,t){var n,r,i,a,o,s,c,l,u,d,f,p=1,m=10,h=e,g=h.d,_=h.constructor,v=_.rounding,y=_.precision;if(h.s<0||!g||!g[0]||!h.e&&g[0]==1&&g.length==1)return new _(g&&!g[0]?-1/0:h.s==1?g?0:h:NaN);if(t==null?(C=!1,u=y):u=t,_.precision=u+=m,n=Qe(g),r=n.charAt(0),Math.abs(a=h.e)<0x5543df729c000){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)h=h.times(e),n=Qe(h.d),r=n.charAt(0),p++;a=h.e,r>1?(h=new _(`0.`+n),a++):h=new _(r+`.`+n.slice(1))}else return l=ot(_,u+2,y).times(a+``),h=mt(new _(r+`.`+n.slice(1)),u-m).plus(l),_.precision=y,t==null?E(h,y,v,C=!0):h;for(d=h,c=o=h=rt(h.minus(1),h.plus(1),u,1),f=E(h.times(h),u,1),i=3;;){if(o=E(o.times(f),u,1),l=c.plus(rt(o,new _(i),u,1)),Qe(l.d).slice(0,u)===Qe(c.d).slice(0,u))if(c=c.times(2),a!==0&&(c=c.plus(ot(_,u+2,y).times(a+``))),c=rt(c,new _(p),u,1),t==null)if(et(c.d,u-m,v,s))_.precision=u+=m,l=o=h=rt(d.minus(1),d.plus(1),u,1),f=E(h.times(h),u,1),i=s=1;else return E(c,_.precision=y,v,C=!0);else return _.precision=y,c;c=l,i+=2}}function ht(e){return String(e.s*e.s/0)}function gt(e,t){var n,r,i;for((n=t.indexOf(`.`))>-1&&(t=t.replace(`.`,``)),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;r++);for(i=t.length;t.charCodeAt(i-1)===48;--i);if(t=t.slice(r,i),t){if(i-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%w,n<0&&(r+=w),r<i){for(r&&e.d.push(+t.slice(0,r)),i-=w;r<i;)e.d.push(+t.slice(r,r+=w));t=t.slice(r),r=w-t.length}else r-=i;for(;r--;)t+=`0`;e.d.push(+t),C&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function _t(e,t){var n,r,i,a,o,s,c,l,u;if(t.indexOf(`_`)>-1){if(t=t.replace(/(\d)_(?=\d)/g,`$1`),qe.test(t))return gt(e,t)}else if(t===`Infinity`||t===`NaN`)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(Ge.test(t))n=16,t=t.toLowerCase();else if(We.test(t))n=2;else if(Ke.test(t))n=8;else throw Error(Re+t);for(a=t.search(/p/i),a>0?(c=+t.slice(a+1),t=t.substring(2,a)):t=t.slice(2),a=t.indexOf(`.`),o=a>=0,r=e.constructor,o&&(t=t.replace(`.`,``),s=t.length,a=s-a,i=ut(r,new r(n),a,a*2)),l=tt(t,n,Je),u=l.length-1,a=u;l[a]===0;--a)l.pop();return a<0?new r(e.s*0):(e.e=at(l,u),e.d=l,C=!1,o&&(e=rt(e,i,s*4)),c&&(e=e.times(Math.abs(c)<54?Ue(2,c):fn.pow(2,c))),C=!0,e)}function vt(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:yt(e,2,t,t);n=1.4*Math.sqrt(r),n=n>16?16:n|0,t=t.times(1/bt(5,n)),t=yt(e,2,t,t);for(var i,a=new e(5),o=new e(16),s=new e(20);n--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}function yt(e,t,n,r,i){var a,o,s,c,l=1,u=e.precision,d=Math.ceil(u/w);for(C=!1,c=n.times(n),s=new e(r);;){if(o=rt(s.times(c),new e(t++*t++),u,1),s=i?r.plus(o):r.minus(o),r=rt(o.times(c),new e(t++*t++),u,1),o=s.plus(r),o.d[d]!==void 0){for(a=d;o.d[a]===s.d[a]&&a--;);if(a==-1)break}a=s,s=r,r=o,o=a,l++}return C=!0,o.d.length=d+1,o}function bt(e,t){for(var n=e;--t;)n*=e;return n}function xt(e,t){var n,r=t.s<0,i=st(e,e.precision,1),a=i.times(.5);if(t=t.abs(),t.lte(a))return Ie=r?4:1,t;if(n=t.divToInt(i),n.isZero())Ie=r?3:2;else{if(t=t.minus(n.times(i)),t.lte(a))return Ie=dt(n)?r?2:3:r?4:1,t;Ie=dt(n)?r?1:4:r?3:2}return t.minus(i).abs()}function St(e,t,n,r){var i,a,o,s,c,l,u,d,f,p=e.constructor,m=n!==void 0;if(m?($e(n,1,Ae),r===void 0?r=p.rounding:$e(r,0,8)):(n=p.precision,r=p.rounding),!e.isFinite())u=ht(e);else{for(u=it(e),o=u.indexOf(`.`),m?(i=2,t==16?n=n*4-3:t==8&&(n=n*3-2)):i=t,o>=0&&(u=u.replace(`.`,``),f=new p(1),f.e=u.length-o,f.d=tt(it(f),10,i),f.e=f.d.length),d=tt(u,10,i),a=c=d.length;d[--c]==0;)d.pop();if(!d[0])u=m?`0p+0`:`0`;else{if(o<0?a--:(e=new p(e),e.d=d,e.e=a,e=rt(e,f,n,r,0,i),d=e.d,a=e.e,l=Fe),o=d[n],s=i/2,l||=d[n+1]!==void 0,l=r<4?(o!==void 0||l)&&(r===0||r===(e.s<0?3:2)):o>s||o===s&&(r===4||l||r===6&&d[n-1]&1||r===(e.s<0?8:7)),d.length=n,l)for(;++d[--n]>i-1;)d[n]=0,n||(++a,d.unshift(1));for(c=d.length;!d[c-1];--c);for(o=0,u=``;o<c;o++)u+=je.charAt(d[o]);if(m){if(c>1)if(t==16||t==8){for(o=t==16?4:3,--c;c%o;c++)u+=`0`;for(d=tt(u,i,t),c=d.length;!d[c-1];--c);for(o=1,u=`1.`;o<c;o++)u+=je.charAt(d[o])}else u=u.charAt(0)+`.`+u.slice(1);u=u+(a<0?`p`:`p+`)+a}else if(a<0){for(;++a;)u=`0`+u;u=`0.`+u}else if(++a>c)for(a-=c;a--;)u+=`0`;else a<c&&(u=u.slice(0,a)+`.`+u.slice(a))}u=(t==16?`0x`:t==2?`0b`:t==8?`0o`:``)+u}return e.s<0?`-`+u:u}function Ct(e,t){if(e.length>t)return e.length=t,!0}function wt(e){return new this(e).abs()}function Tt(e){return new this(e).acos()}function Et(e){return new this(e).acosh()}function Dt(e,t){return new this(e).plus(t)}function Ot(e){return new this(e).asin()}function kt(e){return new this(e).asinh()}function At(e){return new this(e).atan()}function jt(e){return new this(e).atanh()}function Mt(e,t){e=new this(e),t=new this(t);var n,r=this.precision,i=this.rounding,a=r+4;return!e.s||!t.s?n=new this(NaN):!e.d&&!t.d?(n=st(this,a,1).times(t.s>0?.25:.75),n.s=e.s):!t.d||e.isZero()?(n=t.s<0?st(this,r,i):new this(0),n.s=e.s):!e.d||t.isZero()?(n=st(this,a,1).times(.5),n.s=e.s):t.s<0?(this.precision=a,this.rounding=1,n=this.atan(rt(e,t,a,1)),t=st(this,a,1),this.precision=r,this.rounding=i,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(rt(e,t,a,1)),n}function Nt(e){return new this(e).cbrt()}function Pt(e){return E(e=new this(e),e.e+1,2)}function Ft(e,t,n){return new this(e).clamp(t,n)}function It(e){if(!e||typeof e!=`object`)throw Error(Le+`Object expected`);var t,n,r,i=e.defaults===!0,a=[`precision`,1,Ae,`rounding`,0,8,`toExpNeg`,-ke,0,`toExpPos`,0,ke,`maxE`,0,ke,`minE`,-ke,0,`modulo`,0,9];for(t=0;t<a.length;t+=3)if(n=a[t],i&&(this[n]=Pe[n]),(r=e[n])!==void 0)if(He(r)===r&&r>=a[t+1]&&r<=a[t+2])this[n]=r;else throw Error(Re+n+`: `+r);if(n=`crypto`,i&&(this[n]=Pe[n]),(r=e[n])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<`u`&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(Be);else this[n]=!1;else throw Error(Re+n+`: `+r);return this}function Lt(e){return new this(e).cos()}function Rt(e){return new this(e).cosh()}function zt(e){var t,n,r;function i(e){var t,n,r,a=this;if(!(a instanceof i))return new i(e);if(a.constructor=i,Wt(e)){a.s=e.s,C?!e.d||e.e>i.maxE?(a.e=NaN,a.d=null):e.e<i.minE?(a.e=0,a.d=[0]):(a.e=e.e,a.d=e.d.slice()):(a.e=e.e,a.d=e.d?e.d.slice():e.d);return}if(r=typeof e,r===`number`){if(e===0){a.s=1/e<0?-1:1,a.e=0,a.d=[0];return}if(e<0?(e=-e,a.s=-1):a.s=1,e===~~e&&e<1e7){for(t=0,n=e;n>=10;n/=10)t++;C?t>i.maxE?(a.e=NaN,a.d=null):t<i.minE?(a.e=0,a.d=[0]):(a.e=t,a.d=[e]):(a.e=t,a.d=[e]);return}if(e*0!=0){e||(a.s=NaN),a.e=NaN,a.d=null;return}return gt(a,e.toString())}if(r===`string`)return(n=e.charCodeAt(0))===45?(e=e.slice(1),a.s=-1):(n===43&&(e=e.slice(1)),a.s=1),qe.test(e)?gt(a,e):_t(a,e);if(r===`bigint`)return e<0?(e=-e,a.s=-1):a.s=1,gt(a,e.toString());throw Error(Re+e)}if(i.prototype=T,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=It,i.clone=zt,i.isDecimal=Wt,i.abs=wt,i.acos=Tt,i.acosh=Et,i.add=Dt,i.asin=Ot,i.asinh=kt,i.atan=At,i.atanh=jt,i.atan2=Mt,i.cbrt=Nt,i.ceil=Pt,i.clamp=Ft,i.cos=Lt,i.cosh=Rt,i.div=Bt,i.exp=Vt,i.floor=Ht,i.hypot=Ut,i.ln=Gt,i.log=Kt,i.log10=Jt,i.log2=qt,i.max=Yt,i.min=Xt,i.mod=Zt,i.mul=Qt,i.pow=$t,i.random=en,i.round=tn,i.sign=nn,i.sin=rn,i.sinh=an,i.sqrt=on,i.sub=sn,i.sum=cn,i.tan=ln,i.tanh=un,i.trunc=dn,e===void 0&&(e={}),e&&e.defaults!==!0)for(r=[`precision`,`rounding`,`toExpNeg`,`toExpPos`,`maxE`,`minE`,`modulo`,`crypto`],t=0;t<r.length;)e.hasOwnProperty(n=r[t++])||(e[n]=this[n]);return i.config(e),i}function Bt(e,t){return new this(e).div(t)}function Vt(e){return new this(e).exp()}function Ht(e){return E(e=new this(e),e.e+1,3)}function Ut(){var e,t,n=new this(0);for(C=!1,e=0;e<arguments.length;)if(t=new this(arguments[e++]),t.d)n.d&&(n=n.plus(t.times(t)));else{if(t.s)return C=!0,new this(1/0);n=t}return C=!0,n.sqrt()}function Wt(e){return e instanceof fn||e&&e.toStringTag===Ve||!1}function Gt(e){return new this(e).ln()}function Kt(e,t){return new this(e).log(t)}function qt(e){return new this(e).log(2)}function Jt(e){return new this(e).log(10)}function Yt(){return ft(this,arguments,-1)}function Xt(){return ft(this,arguments,1)}function Zt(e,t){return new this(e).mod(t)}function Qt(e,t){return new this(e).mul(t)}function $t(e,t){return new this(e).pow(t)}function en(e){var t,n,r,i,a=0,o=new this(1),s=[];if(e===void 0?e=this.precision:$e(e,1,Ae),r=Math.ceil(e/w),!this.crypto)for(;a<r;)s[a++]=Math.random()*1e7|0;else if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));a<r;)i=t[a],i>=429e7?t[a]=crypto.getRandomValues(new Uint32Array(1))[0]:s[a++]=i%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);a<r;)i=t[a]+(t[a+1]<<8)+(t[a+2]<<16)+((t[a+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(t,a):(s.push(i%1e7),a+=4);a=r/4}else throw Error(Be);for(r=s[--a],e%=w,r&&e&&(i=Ue(10,w-e),s[a]=(r/i|0)*i);s[a]===0;a--)s.pop();if(a<0)n=0,s=[0];else{for(n=-1;s[0]===0;n-=w)s.shift();for(r=1,i=s[0];i>=10;i/=10)r++;r<w&&(n-=w-r)}return o.e=n,o.d=s,o}function tn(e){return E(e=new this(e),e.e+1,this.rounding)}function nn(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function rn(e){return new this(e).sin()}function an(e){return new this(e).sinh()}function on(e){return new this(e).sqrt()}function sn(e,t){return new this(e).sub(t)}function cn(){var e=0,t=arguments,n=new this(t[e]);for(C=!1;n.s&&++e<t.length;)n=n.plus(t[e]);return C=!0,E(n,this.precision,this.rounding)}function ln(e){return new this(e).tan()}function un(e){return new this(e).tanh()}function dn(e){return E(e=new this(e),e.e+1,1)}T[Symbol.for(`nodejs.util.inspect.custom`)]=T.toString,T[Symbol.toStringTag]=`Decimal`;var fn=T.constructor=zt(Pe);Me=new fn(Me),Ne=new fn(Ne);var pn=function(e){return e[e.TOKEN=1e5]=`TOKEN`,e[e.DECI_TOKEN=1e4]=`DECI_TOKEN`,e[e.CENTI_TOKEN=1e3]=`CENTI_TOKEN`,e[e.MILLI_TOKEN=100]=`MILLI_TOKEN`,e[e.MICRO_TOKEN=10]=`MICRO_TOKEN`,e[e.ATOMIC=1]=`ATOMIC`,e}({}),mn=function(e){return e.TOKEN=`CMTS`,e.DECI_TOKEN=`dCMTS`,e.CENTI_TOKEN=`cCMTS`,e.MILLI_TOKEN=`mCMTS`,e.MICRO_TOKEN=`μCMTS`,e.ATOMIC=`aCMTS`,e}({}),hn=class e{constructor(e){this.amount=e}static create(e,t=pn.TOKEN){if(t!=pn.TOKEN)throw new y;return this.createCMTS(e)}static createCMTS(e){return this.createSafeCmtsToken(fn(e),fn(pn.TOKEN))}static createDeciToken(e){return this.createSafeCmtsToken(fn(e),fn(pn.DECI_TOKEN))}static createMicroToken(e){return this.createSafeCmtsToken(fn(e),fn(pn.MICRO_TOKEN))}static createMilliToken(e){return this.createSafeCmtsToken(fn(e),fn(pn.MILLI_TOKEN))}static createCentiToken(e){return this.createSafeCmtsToken(fn(e),fn(pn.CENTI_TOKEN))}static createMillionToken(e){return this.createSafeCmtsToken(fn(e),fn(pn.MICRO_TOKEN))}static createAtomic(e){return this.createSafeCmtsToken(fn(e),fn(pn.ATOMIC))}static createSafeCmtsToken(t,n){let r=t.mul(n);if(r.isInteger())return new e(r);throw new v(`Invalid amount: An atomic token should be insecable: got ${r}`)}static zero(){return this.createAtomic(0)}static oneCMTS(){return this.createCMTS(1)}static parse(t){let n=t.trim().match(/^(\d+(?:\.\d+)?)\s*(\S+)$/);if(!n)throw new v(`Invalid token amount format: "${t}"`);let[,r,i]=n,a=parseFloat(r);switch(i){case mn.TOKEN:return e.createCMTS(a);case mn.DECI_TOKEN:return e.createDeciToken(a);case mn.CENTI_TOKEN:return e.createCentiToken(a);case mn.MILLI_TOKEN:return e.createMilliToken(a);case mn.MICRO_TOKEN:return e.createMicroToken(a);case mn.ATOMIC:return e.createAtomic(a);default:throw new y}}getAmount(e=pn.TOKEN){switch(e){case pn.TOKEN:return this.amount.div(fn(pn.TOKEN)).toNumber();case pn.CENTI_TOKEN:return this.amount.div(fn(pn.CENTI_TOKEN)).toNumber();case pn.MILLI_TOKEN:return this.amount.div(fn(pn.MILLI_TOKEN)).toNumber();case pn.DECI_TOKEN:return this.amount.div(fn(pn.DECI_TOKEN)).toNumber();case pn.MICRO_TOKEN:return this.amount.div(fn(pn.MICRO_TOKEN)).toNumber();case pn.ATOMIC:return this.amount.toNumber()}}getAmountAsAtomic(){return this.getAmount(pn.ATOMIC)}getAmountAsCMTS(){return this.getAmount(pn.TOKEN)}isPositive(){return this.amount.isPositive()||this.amount.isZero()}isPositiveStrict(){return this.isPositive()&&!this.isZero()}isNegative(){return this.amount.isNegative()}isZero(){return this.amount.isZero()}equals(e){return this.amount.equals(e.amount)}isGreaterThan(e){return this.amount.gt(e.amount)}isLessThan(e){return this.amount.lt(e.amount)}add(t){return e.createAtomic(this.getAmountAsAtomic()+t.getAmountAsAtomic())}sub(t){return e.createAtomic(this.getAmountAsAtomic()-t.getAmountAsAtomic())}mul(t){return e.createAtomic(this.getAmountAsAtomic()*t)}toString(t=pn.TOKEN,n={}){let r=this.getAmountAsCMTS();switch(n.locale=n.locale===`system`?void 0:n.locale||`en-EN`,t){case pn.TOKEN:return`${Intl.NumberFormat(n.locale,{minimumFractionDigits:n.decimalPlaces===void 0?0:n.decimalPlaces,maximumFractionDigits:n.decimalPlaces===void 0?8:n.decimalPlaces,useGrouping:n.grouping||!1}).format(r)} ${e.getUnitLabel(t)}`;case pn.ATOMIC:return`${r} ${e.getUnitLabel(t)}`;default:throw new y}}static getUnitLabel(e){switch(e){case pn.TOKEN:return mn.TOKEN;case pn.ATOMIC:return mn.ATOMIC;default:throw new y}}},gn=t({FORMAT:()=>28,HASHABLE:()=>1,HASHED:()=>8,MASKABLE:()=>2,MASKED:()=>16,PROPERTIES:()=>3,REDACTED:()=>4,TYPE_ARRAY:()=>1,TYPE_ARRAY_OF:()=>32,TYPE_BIN256:()=>13,TYPE_BINARY:()=>12,TYPE_BOOLEAN:()=>5,TYPE_HASH_STR:()=>14,TYPE_MAIN:()=>31,TYPE_NAMES:()=>Pn,TYPE_NULL:()=>6,TYPE_NUMBER:()=>4,TYPE_OBJECT:()=>2,TYPE_STRING:()=>3,TYPE_UINT16:()=>8,TYPE_UINT24:()=>9,TYPE_UINT32:()=>10,TYPE_UINT48:()=>11,TYPE_UINT8:()=>7,TYPE_UNKNOWN:()=>0}),_n=0,vn=1,yn=2,bn=3,xn=4,Sn=5,Cn=6,wn=7,Tn=8,En=9,Dn=10,On=11,kn=12,An=13,jn=14,Mn=31,Nn=32,Pn=[`unknown`,`array`,`object`,`string`,`number`,`boolean`,`null`,`uint8`,`uint16`,`uint24`,`uint32`,`uint48`,`binary`,`bin256`,`hashString`],Fn=1,In=2,Ln=3,Rn=4,zn=8,Bn=16,Vn=28,Hn=t({MAGIC_STRING:()=>Un,MAX_MICROBLOCK_FUTURE_DELAY:()=>120,MAX_MICROBLOCK_PAST_DELAY:()=>300,MB_STATUS_PREVIOUS_HASH_ERROR:()=>3,MB_STATUS_TIMESTAMP_ERROR:()=>2,MB_STATUS_UNRECOVERABLE_ERROR:()=>1,N_VIRTUAL_BLOCKCHAINS:()=>6,PROTOCOL_VERSION:()=>1,VB_ACCOUNT:()=>1,VB_APPLICATION:()=>4,VB_APP_LEDGER:()=>5,VB_NAME:()=>Qn,VB_ORGANIZATION:()=>3,VB_PROTOCOL:()=>0,VB_VALIDATOR_NODE:()=>2}),Un=`CMTS`,Wn=1,Gn=0,Kn=1,qn=2,Jn=3,Yn=4,Xn=5,Zn=6,Qn=[`protocol`,`account`,`validator node`,`organization`,`application`,`application ledger`],$n=300,er=120,tr=1,nr=2,rr=3,ir=t({ACCOUNT_ALLOWED_TRANSFERS:()=>Wr,ACCOUNT_BLOCK_FEES:()=>2,ACCOUNT_BURNT_TOKENS:()=>0,ACCOUNT_NAMES:()=>Ur,ACCOUNT_STANDARD:()=>1,BK_EARNED_BLOCK_FEES:()=>3,BK_EARNED_TX_FEES:()=>1,BK_NAMES:()=>zr,BK_PAID_BLOCK_FEES:()=>2,BK_PAID_TX_FEES:()=>0,BK_PLUS:()=>1,BK_PURCHASE:()=>7,BK_RECEIVED_ESCROW:()=>13,BK_RECEIVED_ESCROW_REFUND:()=>15,BK_RECEIVED_EXPIRED_ESCROW:()=>17,BK_RECEIVED_ISSUANCE:()=>5,BK_RECEIVED_PAYMENT:()=>9,BK_RECEIVED_SLASHED_TOKENS:()=>19,BK_RECEIVED_VESTING:()=>11,BK_REFERENCES:()=>Rr,BK_REF_BLOCK:()=>0,BK_REF_MICROBLOCK:()=>1,BK_REF_SECTION:()=>2,BK_SALE:()=>6,BK_SENT_ESCROW:()=>12,BK_SENT_ESCROW_REFUND:()=>14,BK_SENT_EXPIRED_ESCROW:()=>16,BK_SENT_ISSUANCE:()=>4,BK_SENT_PAYMENT:()=>8,BK_SENT_SLASHED_TOKENS:()=>18,BK_SENT_VESTING:()=>10,CENTITOKEN:()=>sr,GAS_ATOMS_PER_GAS:()=>pr,GAS_PER_BYTE:()=>1,INITIAL_OFFER:()=>lr,MAXIMUM_GAS_PRICE:()=>dr,MILLITOKEN:()=>100,MINIMUM_GAS_PRICE:()=>1,TOKEN:()=>or,TOKEN_NAME:()=>ar}),ar=`CMTS`,or=1e5,sr=1e3,cr=100,lr=1e9*or,ur=1,dr=2**29-1,fr=1,pr=1e5,mr=1,hr=0,gr=2,_r=4,vr=6,yr=8,br=10,xr=12,Sr=14,Cr=16,wr=18,Tr=1,Er=3,Dr=5,Or=7,kr=9,Ar=11,jr=13,Mr=15,Nr=17,Pr=19,Fr=0,Ir=1,Lr=2,Rr=[1,1,0,0,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,0],zr=[`Paid TX fees`,`Earned TX fees`,`Paid block fees`,`Earned block fees`,`Sent initial token issuance`,`Received initial token issuance`,`Sale`,`Purchase`,`Sent payment`,`Received payment`,`Sent vesting`,`Received vesting`,`Sent escrow`,`Received escrow`,`Sent escrow refund`,`Received escrow refund`,`Sent expired escrow`,`Received expired escrow`,`Sent slashed tokens`,`Received slashed tokens`],Br=0,Vr=1,Hr=2,Ur=[`Burnt tokens account`,`Standard account`,`Block fees account`],Wr=[524800,524265,6],Gr=t({ACCOUNT_HISTORY:()=>ii,ACCOUNT_STATE:()=>ri,ALL_SCHEMAS:()=>ia,BLOCK_CONTENT:()=>ui,BLOCK_INFORMATION:()=>li,CONTRACT_PARAMETER_SCHEMA:()=>qr,CONTRACT_SCHEMA:()=>Jr,ERROR:()=>Kr,MICROBLOCK_BODY:()=>gi,MICROBLOCK_HEADER:()=>mi,MICROBLOCK_HEADER_BODY_HASH_OFFSET:()=>58,MICROBLOCK_HEADER_PREVIOUS_HASH_OFFSET:()=>13,MICROBLOCK_HEADER_SIZE:()=>122,MICROBLOCK_SECTION:()=>hi,MICROBLOCK_VB_INFORMATION:()=>_i,MSG_ACCOUNT_BY_PUBLIC_KEY_HASH:()=>22,MSG_ACCOUNT_HISTORY:()=>20,MSG_ACCOUNT_STATE:()=>18,MSG_AWAIT_MICROBLOCK_ANCHORING:()=>13,MSG_BLOCK_CONTENT:()=>6,MSG_BLOCK_INFORMATION:()=>4,MSG_CHAIN_INFORMATION:()=>2,MSG_ERROR:()=>0,MSG_GENESIS_SNAPSHOT:()=>28,MSG_GET_ACCOUNT_BY_PUBLIC_KEY_HASH:()=>21,MSG_GET_ACCOUNT_HISTORY:()=>19,MSG_GET_ACCOUNT_STATE:()=>17,MSG_GET_BLOCK_CONTENT:()=>5,MSG_GET_BLOCK_INFORMATION:()=>3,MSG_GET_CHAIN_INFORMATION:()=>1,MSG_GET_GENESIS_SNAPSHOT:()=>27,MSG_GET_MICROBLOCK_BODYS:()=>15,MSG_GET_MICROBLOCK_INFORMATION:()=>11,MSG_GET_OBJECT_LIST:()=>25,MSG_GET_VALIDATOR_NODE_BY_ADDRESS:()=>23,MSG_GET_VIRTUAL_BLOCKCHAIN_STATE:()=>7,MSG_GET_VIRTUAL_BLOCKCHAIN_UPDATE:()=>9,MSG_MICROBLOCK_ANCHORING:()=>14,MSG_MICROBLOCK_BODYS:()=>16,MSG_MICROBLOCK_INFORMATION:()=>12,MSG_OBJECT_LIST:()=>26,MSG_VALIDATOR_NODE_BY_ADDRESS:()=>24,MSG_VIRTUAL_BLOCKCHAIN_STATE:()=>8,MSG_VIRTUAL_BLOCKCHAIN_UPDATE:()=>10,NODE_MESSAGES:()=>D,PROTOCOL_VARIABLES:()=>oi,PROTOCOL_VB_STATE:()=>si,RECORD_DESCRIPTION:()=>ni,VB_STATES:()=>ci,VIRTUAL_BLOCKCHAIN_STATE:()=>ai,WIMSG_ANSWER:()=>5,WIMSG_CONNECTION_ACCEPTED:()=>7,WIMSG_CONNECTION_INFO:()=>6,WIMSG_CONNECTION_TOKEN:()=>2,WIMSG_FORWARDED_ANSWER:()=>3,WIMSG_FORWARDED_REQUEST:()=>8,WIMSG_GET_CONNECTION_INFO:()=>4,WIMSG_REQUEST:()=>0,WIMSG_UPDATE_QR:()=>1,WI_MESSAGES:()=>ra,WI_QR_CODE:()=>qi}),Kr={label:`Error`,definition:[{name:`type`,type:7},{name:`id`,type:7},{name:`arg`,type:35}]},qr={label:`contractParameter`,definition:[{name:`name`,type:3},{name:`type`,type:3},{name:`defaultValue`,type:3},{name:`modifiable`,type:5}]},Jr={label:`contract`,definition:[{name:`name`,type:3},{name:`parametersDefinition`,type:34,schema:qr}]},Yr={label:`RecordActor`,definition:[{name:`name`,type:3}]},Xr={label:`RecordChannel`,definition:[{name:`name`,type:3},{name:`public`,type:5}]},Zr={label:`RecordChannelAssignation`,definition:[{name:`fieldPath`,type:3},{name:`channelName`,type:3}]},Qr={label:`RecordActorAssignation`,definition:[{name:`actorName`,type:3},{name:`channelName`,type:3}]},$r={label:`RecordMaskedPart`,definition:[{name:`position`,type:10},{name:`length`,type:10},{name:`replacementString`,type:3}]},ei={label:`RecordMaskableField`,definition:[{name:`fieldPath`,type:3},{name:`maskedParts`,type:34,schema:$r}]},ti={label:`RecordHashableField`,definition:[{name:`fieldPath`,type:3}]},ni={label:`RecordDescription`,definition:[{name:`applicationId`,type:14},{name:`virtualBlockchainId`,type:14,optional:!0},{name:`data`,type:2,unspecifiedSchema:!0},{name:`actors`,type:34,optional:!0,schema:Yr},{name:`channels`,type:34,optional:!0,schema:Xr},{name:`channelAssignations`,type:34,optional:!0,schema:Zr},{name:`actorAssignations`,type:34,optional:!0,schema:Qr},{name:`hashableFields`,type:34,optional:!0,schema:ti},{name:`maskableFields`,type:34,optional:!0,schema:ei},{name:`author`,type:3},{name:`endorser`,type:3,optional:!0},{name:`approvalMessage`,type:3,optional:!0}]},ri={label:`AccountState`,definition:[{name:`height`,type:11},{name:`balance`,type:11},{name:`lastHistoryHash`,type:13},{name:`locks`,type:34,definition:[{name:`type`,type:7},{name:`amount`,type:11},{name:`parameters`,type:12}]}]},ii={label:`AccountHistory`,definition:[{name:`height`,type:11},{name:`previousHistoryHash`,type:13},{name:`type`,type:7},{name:`timestamp`,type:11},{name:`linkedAccount`,type:13},{name:`amount`,type:11},{name:`chainReference`,type:12}]},ai={label:`VirtualBlockchainState`,definition:[{name:`type`,type:7},{name:`expirationDay`,type:10},{name:`height`,type:11},{name:`lastMicroblockHash`,type:13},{name:`serializedInternalState`,type:12}]},oi={label:`PROTOCOL_VARIABLES`,definition:[{name:`protocolVersionName`,type:3},{name:`protocolVersion`,type:8},{name:`feesCalculationVersion`,type:8},{name:`globalStateUpdaterVersion`,type:8},{name:`applicationLedgerInternalStateUpdaterVersion`,type:8},{name:`applicationInternalStateUpdaterVersion`,type:8},{name:`organizationInternalStateUpdaterVersion`,type:8},{name:`validatorNodeInternalStateUpdaterVersion`,type:8},{name:`accountInternalStateUpdaterVersion`,type:8},{name:`protocolInternalStateUpdaterVersion`,type:8}]},si={label:`ProtocolVbState`,definition:[{name:`organizationId`,type:13},{name:`currentProtocolVariables`,type:2,schema:oi},{name:`protocolUpdates`,type:34,schema:{label:`PROTOCOL_UPDATE`,definition:[{name:`protocolVersion`,type:8},{name:`changeLog`,type:3},{name:`protocolVariables`,type:2,schema:oi},{name:`protocolVersionName`,type:3}]}}]},ci=[si,{label:`AccountVbState`,definition:[{name:`signatureSchemeId`,type:7},{name:`publicKeyHeight`,type:11}]},{label:`ValidatorNodeVbState`,definition:[{name:`organizationId`,type:13},{name:`descriptionHeight`,type:11},{name:`rpcEndpointHeight`,type:11},{name:`networkIntegrationHeight`,type:11}]},{label:`OrganizationVbState`,definition:[{name:`accountId`,type:13},{name:`descriptionHeight`,type:11}]},{label:`ApplicationVbState`,definition:[{name:`organizationId`,type:13},{name:`descriptionHeight`,type:11}]},{label:`AppLedgerVbState`,definition:[{name:`allowedSignatureSchemeIds`,type:39},{name:`allowedPkeSchemeIds`,type:39},{name:`applicationId`,type:13},{name:`channels`,type:34,definition:[{name:`name`,type:3},{name:`isPrivate`,type:5},{name:`creatorId`,type:7}]},{name:`actors`,type:34,definition:[{name:`name`,type:3},{name:`subscribed`,type:5},{name:`signatureKeyHeight`,type:11},{name:`pkeKeyHeight`,type:11},{name:`sharedSecrets`,type:34,definition:[{name:`peerActorId`,type:7},{name:`height`,type:11}]},{name:`invitations`,type:34,definition:[{name:`channelId`,type:7},{name:`height`,type:11}]}]}]}],li={label:`BlockInformation`,definition:[{name:`hash`,type:13},{name:`timestamp`,type:11},{name:`proposerAddress`,type:12},{name:`size`,type:11},{name:`microblockCount`,type:11}]},ui={label:`BlockContent`,definition:[{name:`microblocks`,type:34,definition:[{name:`hash`,type:13},{name:`vbIdentifier`,type:13},{name:`vbType`,type:7},{name:`height`,type:11},{name:`size`,type:11},{name:`sectionCount`,type:11}]}]},di=13,fi=58,pi=122,mi={label:`MicroblockHeader`,definition:[{name:`magicString`,type:3,size:4},{name:`protocolVersion`,type:8},{name:`microblockType`,type:7},{name:`height`,type:11},{name:`previousHash`,type:13},{name:`timestamp`,type:11},{name:`gas`,type:9},{name:`gasPrice`,type:10},{name:`bodyHash`,type:13},{name:`feesPayerAccount`,type:13}]},hi={label:`MicroblockSection`,definition:[{name:`type`,type:7},{name:`data`,type:12}]},gi={label:`MicroblockBody`,definition:[{name:`body`,type:34,schema:hi}]},_i={label:`MicroblockVbInformation`,definition:[{name:`virtualBlockchainType`,type:7},{name:`virtualBlockchainId`,type:13}]},vi=0,yi=1,bi=2,xi=3,Si=4,Ci=5,wi=6,Ti=7,Ei=8,Di=9,Oi=10,ki=11,Ai=12,ji=13,Mi=14,Ni=15,Pi=16,Fi=17,Ii=18,Li=19,Ri=20,zi=21,Bi=22,Vi=23,Hi=24,Ui=25,Wi=26,Gi=27,Ki=28,D=[];D[0]={label:`MessageError`,definition:[{name:`error`,type:3}]},D[1]={label:`MessageGetChainInformation`,definition:[]},D[2]={label:`MessageChainInformation`,definition:[{name:`height`,type:11},{name:`lastBlockTimestamp`,type:11},{name:`microblockCount`,type:11},{name:`objectCounts`,type:43,size:6}]},D[3]={label:`MessageGetBlockInformation`,definition:[{name:`height`,type:11}]},D[4]={label:`MessageBlockInformation`,definition:li.definition},D[5]={label:`MessageGetBlockContent`,definition:[{name:`height`,type:11}]},D[6]={label:`MessageBlockContent`,definition:ui.definition},D[7]={label:`MessageGetVirtualBlockchainState`,definition:[{name:`virtualBlockchainId`,type:13}]},D[8]={label:`MessageVirtualBlockchainState`,definition:[{name:`stateData`,type:12}]},D[9]={label:`MessageGetVirtualBlockchainUpdate`,definition:[{name:`virtualBlockchainId`,type:13},{name:`knownHeight`,type:11}]},D[10]={label:`MessageVirtualBlockchainUpdate`,definition:[{name:`exists`,type:5},{name:`changed`,type:5},{name:`stateData`,type:12},{name:`headers`,type:44}]},D[11]={label:`MessageGetMicroblockInformation`,definition:[{name:`hash`,type:13}]},D[12]={label:`MessageMicroblockInformation`,definition:[{name:`virtualBlockchainType`,type:7},{name:`virtualBlockchainId`,type:13},{name:`header`,type:12}]},D[13]={label:`MessageAwaitMicroblockAnchoring`,definition:[{name:`hash`,type:13}]},D[14]={label:`MessageMicroblockAnchoring`,definition:_i.definition},D[15]={label:`MessageGetMicroblockBodys`,definition:[{name:`hashes`,type:45}]},D[16]={label:`MessageMicroblockBodys`,definition:[{name:`list`,type:34,definition:[{name:`hash`,type:13},{name:`body`,type:12}]}]},D[17]={label:`MessageGetAccountState`,definition:[{name:`accountHash`,type:13}]},D[18]={label:`MessageAccountState`,definition:ri.definition},D[19]={label:`MessageGetAccountHistory`,definition:[{name:`accountHash`,type:13},{name:`lastHistoryHash`,type:13},{name:`maxRecords`,type:8}]},D[20]={label:`MessageAccountHistory`,definition:[{name:`list`,type:34,schema:ii}]},D[21]={label:`MessageGetAccountByPublicKeyHash`,definition:[{name:`publicKeyHash`,type:13}]},D[22]={label:`MessageAccountByPublicKeyHash`,definition:[{name:`accountHash`,type:13}]},D[23]={label:`MessageGetValidatorNodeByAddress`,definition:[{name:`address`,type:12}]},D[24]={label:`MessageValidatorNodeByAddress`,definition:[{name:`validatorNodeHash`,type:13}]},D[25]={label:`MessageGetObjectList`,definition:[{name:`type`,type:7}]},D[26]={label:`MessageObjectList`,definition:[{name:`list`,type:45}]},D[27]={label:`MessageGetGenesisSnapshot`,definition:[]},D[28]={label:`MessageGenesisSnapshot`,definition:[{name:`base64EncodedChunks`,type:35}]};var qi={label:`WiQrCode`,definition:[{name:`qrId`,type:13},{name:`timestamp`,type:11},{name:`serverUrl`,type:3,size:100}]},Ji=0,Yi=1,Xi=2,Zi=3,Qi=4,$i=5,ea=6,ta=7,na=8,ra=[];ra[0]={label:`WiMsgRequest`,definition:[{name:`requestType`,type:7},{name:`request`,type:12},{name:`deviceId`,type:13},{name:`withToken`,type:7}]},ra[1]={label:`WiMsgUpdateQr`,definition:[{name:`qrId`,type:13},{name:`timestamp`,type:11}]},ra[2]={label:`WiMsgConnectionToken`,definition:[{name:`token`,type:13}]},ra[3]={label:`WiMsgForwardedAnswer`,definition:[{name:`answerType`,type:7},{name:`answer`,type:12}]},ra[4]={label:`WiMsgGetConnectionInfo`,definition:[{name:`qrId`,type:13}]},ra[5]={label:`WiMsgAnswer`,definition:[{name:`answerType`,type:7},{name:`answer`,type:12}]},ra[6]={label:`WiMsgConnectionInfo`,definition:[]},ra[7]={label:`WiMsgConnectionAccepted`,definition:[{name:`qrId`,type:13}]},ra[8]={label:`WiMsgForwardedRequest`,definition:[{name:`requestType`,type:7},{name:`request`,type:12}]};var ia={singles:[Yr,Xr,Zr,Qr,$r,ei,ti,ni,mi,hi,gi,_i,qi],collections:[{label:`VbState`,list:ci},{label:`NodeMessage`,list:D},{label:`WiMessage`,list:ra}]},O=function(e){return e[e.AUXILIARY_SIGNATURE=126]=`AUXILIARY_SIGNATURE`,e[e.SIGNATURE=127]=`SIGNATURE`,e[e.ALLOWED_ADDITIONAL_WRITER=128]=`ALLOWED_ADDITIONAL_WRITER`,e[e.CUSTOM=129]=`CUSTOM`,e[e.PROTOCOL_CREATION=1]=`PROTOCOL_CREATION`,e[e.PROTOCOL_UPDATE=2]=`PROTOCOL_UPDATE`,e[e.PROTOCOL_VARIABLES=5]=`PROTOCOL_VARIABLES`,e[e.ACCOUNT_PUBLIC_KEY=17]=`ACCOUNT_PUBLIC_KEY`,e[e.ACCOUNT_TOKEN_ISSUANCE=18]=`ACCOUNT_TOKEN_ISSUANCE`,e[e.ACCOUNT_CREATION=19]=`ACCOUNT_CREATION`,e[e.ACCOUNT_TRANSFER=20]=`ACCOUNT_TRANSFER`,e[e.ACCOUNT_VESTING_TRANSFER=21]=`ACCOUNT_VESTING_TRANSFER`,e[e.ACCOUNT_ESCROW_TRANSFER=22]=`ACCOUNT_ESCROW_TRANSFER`,e[e.ACCOUNT_ESCROW_SETTLEMENT=23]=`ACCOUNT_ESCROW_SETTLEMENT`,e[e.ACCOUNT_STAKE=24]=`ACCOUNT_STAKE`,e[e.ACCOUNT_UNSTAKE=25]=`ACCOUNT_UNSTAKE`,e[e.VN_CREATION=33]=`VN_CREATION`,e[e.VN_COMETBFT_PUBLIC_KEY_DECLARATION=34]=`VN_COMETBFT_PUBLIC_KEY_DECLARATION`,e[e.VN_RPC_ENDPOINT=35]=`VN_RPC_ENDPOINT`,e[e.VN_APPROVAL=36]=`VN_APPROVAL`,e[e.VN_SLASHING_CANCELLATION=37]=`VN_SLASHING_CANCELLATION`,e[e.ORG_CREATION=52]=`ORG_CREATION`,e[e.ORG_DESCRIPTION=50]=`ORG_DESCRIPTION`,e[e.APP_CREATION=65]=`APP_CREATION`,e[e.APP_DESCRIPTION=66]=`APP_DESCRIPTION`,e[e.APP_LEDGER_ALLOWED_SIG_SCHEMES=80]=`APP_LEDGER_ALLOWED_SIG_SCHEMES`,e[e.APP_LEDGER_ALLOWED_PKE_SCHEMES=81]=`APP_LEDGER_ALLOWED_PKE_SCHEMES`,e[e.APP_LEDGER_CREATION=82]=`APP_LEDGER_CREATION`,e[e.APP_LEDGER_ACTOR_CREATION=83]=`APP_LEDGER_ACTOR_CREATION`,e[e.APP_LEDGER_CHANNEL_CREATION=84]=`APP_LEDGER_CHANNEL_CREATION`,e[e.APP_LEDGER_SHARED_SECRET=85]=`APP_LEDGER_SHARED_SECRET`,e[e.APP_LEDGER_CHANNEL_INVITATION=86]=`APP_LEDGER_CHANNEL_INVITATION`,e[e.APP_LEDGER_ACTOR_SUBSCRIPTION=87]=`APP_LEDGER_ACTOR_SUBSCRIPTION`,e[e.APP_LEDGER_PUBLIC_CHANNEL_DATA=88]=`APP_LEDGER_PUBLIC_CHANNEL_DATA`,e[e.APP_LEDGER_PRIVATE_CHANNEL_DATA=89]=`APP_LEDGER_PRIVATE_CHANNEL_DATA`,e[e.APP_LEDGER_AUTHOR=90]=`APP_LEDGER_AUTHOR`,e[e.APP_LEDGER_ENDORSEMENT_REQUEST=91]=`APP_LEDGER_ENDORSEMENT_REQUEST`,e}({}),aa=t({ACCOUNT_CREATION:()=>pa,ACCOUNT_ESCROW_SETTLEMENT:()=>_a,ACCOUNT_ESCROW_TRANSFER:()=>ga,ACCOUNT_PUBLIC_KEY:()=>da,ACCOUNT_STAKE:()=>va,ACCOUNT_TOKEN_ISSUANCE:()=>fa,ACCOUNT_TRANSFER:()=>ma,ACCOUNT_VESTING_TRANSFER:()=>ha,ALL_SECTIONS_SCHEMAS:()=>Wa,APP_CREATION:()=>Oa,APP_DESCRIPTION:()=>ka,APP_LEDGER_ACTOR_CREATION:()=>Pa,APP_LEDGER_ACTOR_SUBSCRIPTION:()=>Ra,APP_LEDGER_ALLOWED_PKE_SCHEMES:()=>Ma,APP_LEDGER_ALLOWED_SIG_SCHEMES:()=>ja,APP_LEDGER_AUTHOR:()=>Va,APP_LEDGER_CHANNEL_CREATION:()=>Fa,APP_LEDGER_CHANNEL_INVITATION:()=>La,APP_LEDGER_CREATION:()=>Na,APP_LEDGER_ENDORSEMENT_REQUEST:()=>Ha,APP_LEDGER_PRIVATE_CHANNEL_DATA:()=>Ba,APP_LEDGER_PUBLIC_CHANNEL_DATA:()=>za,APP_LEDGER_SHARED_SECRET:()=>Ia,DEF:()=>Ga,ORG_CREATION:()=>Ta,ORG_DESCRIPTION:()=>Ea,PROTOCOL_CREATION:()=>ca,PROTOCOL_UPDATE:()=>la,SIGNATURE:()=>oa,SIGNATURE_SCHEMA:()=>sa,VN_APPROVAL:()=>Ca,VN_COMETBFT_PUBLIC_KEY_DECLARATION:()=>xa,VN_CREATION:()=>ba,VN_RPC_ENDPOINT:()=>Sa}),oa=O.SIGNATURE,sa={label:`SIGNATURE`,definition:[{name:`schemeId`,type:7},{name:`signature`,type:12}]},ca=O.PROTOCOL_CREATION,la=O.PROTOCOL_UPDATE,ua=[];ua[ca]={label:`PROTOCOL_CREATION`,definition:[{name:`organizationId`,type:13}]},ua[la]={label:`PROTOCOL_VARIABLES_UPDATE`,definition:[{name:`protocolVersion`,type:8},{name:`protocolVersionName`,type:3},{name:`changeLog`,type:3},{name:`protocolVariables`,type:2,schema:oi}]};var da=O.ACCOUNT_PUBLIC_KEY,fa=O.ACCOUNT_TOKEN_ISSUANCE,pa=O.ACCOUNT_CREATION,ma=O.ACCOUNT_TRANSFER,ha=O.ACCOUNT_VESTING_TRANSFER,ga=O.ACCOUNT_ESCROW_TRANSFER,_a=O.ACCOUNT_ESCROW_SETTLEMENT,va=O.ACCOUNT_STAKE,ya=[];ya[da]={label:`ACCOUNT_PUBLIC_KEY`,definition:[{name:`publicKey`,type:12},{name:`schemeId`,type:7}]},ya[fa]={label:`ACCOUNT_TOKEN_ISSUANCE`,definition:[{name:`amount`,type:11}]},ya[pa]={label:`ACCOUNT_CREATION`,definition:[{name:`sellerAccount`,type:13},{name:`amount`,type:11}]},ya[ma]={label:`ACCOUNT_TRANSFER`,definition:[{name:`account`,type:13},{name:`amount`,type:11},{name:`publicReference`,type:3},{name:`privateReference`,type:3}]},ya[ha]={label:`ACCOUNT_VESTING_TRANSFER`,definition:[{name:`account`,type:13},{name:`amount`,type:11},{name:`publicReference`,type:3},{name:`privateReference`,type:3},{name:`cliffDurationDays`,type:8},{name:`vestingDurationDays`,type:8}]},ya[ga]={label:`ACCOUNT_ESCROW_TRANSFER`,definition:[{name:`account`,type:13},{name:`amount`,type:11},{name:`publicReference`,type:3},{name:`privateReference`,type:3},{name:`escrowIdentifier`,type:13},{name:`agentAccount`,type:13},{name:`durationDays`,type:8}]},ya[_a]={label:`ACCOUNT_ESCROW_SETTLEMENT`,definition:[{name:`confirmed`,type:5},{name:`escrowIdentifier`,type:13}]},ya[va]={label:`ACCOUNT_STAKE`,definition:[{name:`amount`,type:11},{name:`objectType`,type:7},{name:`objectIdentifier`,type:13}]};var ba=O.VN_CREATION,xa=O.VN_COMETBFT_PUBLIC_KEY_DECLARATION,Sa=O.VN_RPC_ENDPOINT,Ca=O.VN_APPROVAL,wa=[];wa[ba]={label:`VN_CREATION`,definition:[{name:`organizationId`,type:13}]},wa[xa]={label:`VN_COMETBFT_PUBLIC_KEY_DECLARATION`,definition:[{name:`cometPublicKeyType`,type:3},{name:`cometPublicKey`,type:3}]},wa[Sa]={label:`VN_RPC_ENDPOINT`,definition:[{name:`rpcEndpoint`,type:3}]},wa[Ca]={label:`VN_APPROVAL`,definition:[{name:`status`,type:5}]};var Ta=O.ORG_CREATION,Ea=O.ORG_DESCRIPTION,Da=[];Da[Ta]={label:`ORG_CREATION`,definition:[{name:`accountId`,type:13}]},Da[Ea]={label:`ORG_DESCRIPTION`,definition:[{name:`name`,type:3},{name:`city`,type:3},{name:`countryCode`,type:3,size:2},{name:`website`,type:3}]};var Oa=O.APP_CREATION,ka=O.APP_DESCRIPTION,Aa=[];Aa[Oa]={label:`APP_CREATION`,definition:[{name:`organizationId`,type:13}]},Aa[ka]={label:`APP_DESCRIPTION`,definition:[{name:`name`,type:3},{name:`logoUrl`,type:3},{name:`homepageUrl`,type:3},{name:`description`,type:3}]};var ja=O.APP_LEDGER_ALLOWED_SIG_SCHEMES,Ma=O.APP_LEDGER_ALLOWED_PKE_SCHEMES,Na=O.APP_LEDGER_CREATION,Pa=O.APP_LEDGER_ACTOR_CREATION,Fa=O.APP_LEDGER_CHANNEL_CREATION,Ia=O.APP_LEDGER_SHARED_SECRET,La=O.APP_LEDGER_CHANNEL_INVITATION,Ra=O.APP_LEDGER_ACTOR_SUBSCRIPTION,za=O.APP_LEDGER_PUBLIC_CHANNEL_DATA,Ba=O.APP_LEDGER_PRIVATE_CHANNEL_DATA,Va=O.APP_LEDGER_AUTHOR,Ha=O.APP_LEDGER_ENDORSEMENT_REQUEST,Ua=[];Ua[ja]={label:`APP_LEDGER_ALLOWED_SIG_SCHEMES`,definition:[{name:`schemeIds`,type:39}]},Ua[Ma]={label:`APP_LEDGER_ALLOWED_PKE_SCHEMES`,definition:[{name:`schemeIds`,type:39}]},Ua[Na]={label:`APP_LEDGER_CREATION`,definition:[{name:`applicationId`,type:13}]},Ua[Pa]={label:`APP_LEDGER_ACTOR_CREATION`,definition:[{name:`id`,type:7},{name:`type`,type:7},{name:`name`,type:3}]},Ua[Fa]={label:`APP_LEDGER_CHANNEL_CREATION`,definition:[{name:`id`,type:7},{name:`isPrivate`,type:5},{name:`creatorId`,type:7},{name:`name`,type:3}]},Ua[Ia]={label:`APP_LEDGER_SHARED_SECRET`,definition:[{name:`hostId`,type:7},{name:`guestId`,type:7},{name:`encryptedSharedKey`,type:12}]},Ua[La]={label:`APP_LEDGER_CHANNEL_INVITATION`,definition:[{name:`channelId`,type:7},{name:`hostId`,type:7},{name:`guestId`,type:7},{name:`encryptedChannelKey`,type:12}]},Ua[Ra]={label:`APP_LEDGER_ACTOR_SUBSCRIPTION`,definition:[{name:`actorId`,type:7},{name:`actorType`,type:7},{name:`organizationId`,type:13},{name:`signatureSchemeId`,type:7},{name:`signaturePublicKey`,type:12},{name:`pkeSchemeId`,type:7},{name:`pkePublicKey`,type:12}]},Ua[za]={label:`APP_LEDGER_PUBLIC_CHANNEL_DATA`,definition:[{name:`channelId`,type:7},{name:`data`,type:12}]},Ua[Ba]={label:`APP_LEDGER_PRIVATE_CHANNEL_DATA`,definition:[{name:`channelId`,type:7},{name:`merkleRootHash`,type:13},{name:`encryptedData`,type:12}]},Ua[Va]={label:`APP_LEDGER_AUTHOR`,definition:[{name:`authorId`,type:7}]},Ua[Ha]={label:`APP_LEDGER_ENDORSEMENT_REQUEST`,definition:[{name:`endorserId`,type:7},{name:`message`,type:3}]};var Wa={...ua,...ya,...wa,...Da,...Aa,...Ua},Ga=[ua,ya,wa,Da,Aa,Ua],Ka=t({WI_INVALID_SIGNATURE:()=>0}),qa=0,Ja=function(e){return e[e.SECP256K1=0]=`SECP256K1`,e[e.ML_DSA_65=1]=`ML_DSA_65`,e[e.PKMS_SECP256K1=2]=`PKMS_SECP256K1`,e[e.ED25519=3]=`ED25519`,e[e.JWK=4]=`JWK`,e}({}),Ya=new TextEncoder,Xa=new TextDecoder,Za={encode:Qa,decode:$a};function Qa(e){return Ya.encode(e)}function $a(e){return Xa.decode(e)}var eo=class extends m{constructor(e){super(e,n.TYPE_CHECKING_FAILURE_ERROR)}},to=126,no=class{static getType(e){switch(typeof e){case`string`:return 3;case`number`:return 4;case`boolean`:return 5;case`object`:if(e===null)return 6;if(Array.isArray(e))return 1;if(e instanceof Uint8Array)return 12;if(Object.getPrototypeOf(e).isPrototypeOf(Object))return 2}return 0}static isJsonType(e){return to>>e&1}},ro=class{basicType;definition;value;constructor(e,t){this.definition=e,this.value=t,this.basicType=no.getType(t)}check(){let e=this.definition.type&31;switch(e){case 3:this.isString();break;case 4:this.isNumber();break;case 5:this.isBoolean();break;case 7:this.isUnsignedInteger(8);break;case 8:this.isUnsignedInteger(16);break;case 9:this.isUnsignedInteger(24);break;case 10:this.isUnsignedInteger(32);break;case 11:this.isUnsignedInteger(48);break;case 12:this.isBinary();break;case 13:this.isBinary(32);break;case 14:this.isHashString();break;default:throw`unexpected definition type ${e}`}}isString(){if(this.basicType!=3)throw`string expected`;if(this.definition.size){let e=Za.encode(this.value);this.checkSize(e.length,this.definition.size)}}isNumber(){if(this.basicType!=4)throw`number expected`}isBoolean(){if(this.basicType!=5)throw`Boolean value expected`}isInteger(){if(this.isNumber(),this.value%1)throw`integer expected`;if(this.value<-(2**53-1)||this.value>2**53-1)throw`value is outside the safe integer range`}isUnsignedInteger(e){if(this.isInteger(),this.value<0)throw new eo(`non-negative value expected`);if(this.value>=2**e)throw Error(`value is too big (${e}-bit value expected)`)}isBinary(e){if(this.basicType!=12)throw`Uint8Array expected`;this.checkSize(this.value.length,e||this.definition.size)}isHashString(){if(this.isString(),this.checkSize(this.value.length,64),/[^\da-f]/i.test(this.value))throw`hexadecimal string expected`}checkSize(e,t){if(t!==void 0&&e!=t)throw`invalid size (expecting ${t}, got ${e})`}};function io(e){return typeof e==`function`?e:ao(e)}function ao(e){if(e==null)return()=>!1;if(e===`fatal`)return e=>e.level===`fatal`;if(e===`error`)return e=>e.level===`fatal`||e.level===`error`;if(e===`warning`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`;if(e===`info`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`;if(e===`debug`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`||e.level===`debug`;if(e===`trace`)return()=>!0;throw TypeError(`Invalid log level: ${e}.`)}var oo=[`trace`,`debug`,`info`,`warning`,`error`,`fatal`];function so(e,t){let n=oo.indexOf(e);if(n<0)throw TypeError(`Invalid log level: ${JSON.stringify(e)}.`);let r=oo.indexOf(t);if(r<0)throw TypeError(`Invalid log level: ${JSON.stringify(t)}.`);return n-r}function co(e=[]){return uo.getLogger(e)}var lo=Symbol.for(`logtape.rootLogger`),uo=class e{parent;children;category;sinks;parentSinks=`inherit`;filters;lowestLevel=`trace`;contextLocalStorage;static getLogger(t=[]){let n=lo in globalThis?globalThis[lo]??null:null;return n??(n=new e(null,[]),globalThis[lo]=n),typeof t==`string`?n.getChild(t):t.length===0?n:n.getChild(t)}constructor(e,t){this.parent=e,this.children={},this.category=t,this.sinks=[],this.filters=[]}getChild(t){let n=typeof t==`string`?t:t[0],r=this.children[n],i=r instanceof e?r:r?.deref();return i??(i=new e(this,[...this.category,n]),this.children[n]=`WeakRef`in globalThis?new WeakRef(i):i),typeof t==`string`||t.length===1?i:i.getChild(t.slice(1))}reset(){for(;this.sinks.length>0;)this.sinks.shift();for(this.parentSinks=`inherit`;this.filters.length>0;)this.filters.shift();this.lowestLevel=`trace`}resetDescendants(){for(let t of Object.values(this.children))(t instanceof e?t:t.deref())?.resetDescendants();this.reset()}with(e){return new fo(this,{...e})}filter(e){for(let t of this.filters)if(!t(e))return!1;return this.filters.length<1?this.parent?.filter(e)??!0:!0}*getSinks(e){if(!(this.lowestLevel===null||so(e,this.lowestLevel)<0)){if(this.parent!=null&&this.parentSinks===`inherit`)for(let t of this.parent.getSinks(e))yield t;for(let e of this.sinks)yield e}}emit(e,t){let n=So(),r=`category`in e?e.category:this.category,i=n.length>0?[...n,...r]:r,a=Object.getOwnPropertyDescriptors(e);a.category={value:i,enumerable:!0,configurable:!0};let o=Object.defineProperties({},a);if(!(this.lowestLevel===null||so(o.level,this.lowestLevel)<0||!this.filter(o))){for(let e of this.getSinks(o.level))if(!t?.has(e))try{e(o)}catch(n){let r=new Set(t);r.add(e),po.log(`fatal`,`Failed to emit a log record to sink {sink}: {error}`,{sink:e,error:n,record:o},r)}}}log(e,t,n,r){let i=Co(),a,o=typeof n==`function`?{category:this.category,level:e,timestamp:Date.now(),get message(){return yo(t,this.properties)},rawMessage:t,get properties(){return a??={...i,...n()},a}}:{category:this.category,level:e,timestamp:Date.now(),message:yo(t,{...i,...n}),rawMessage:t,properties:{...i,...n}};this.emit(o,r)}logLazily(e,t,n={}){let r=Co(),i,a;function o(){if((a==null||i==null)&&(a=t((e,...t)=>(i=e,bo(e,t))),i==null))throw TypeError(`No log record was made.`);return[a,i]}this.emit({category:this.category,level:e,get message(){return o()[0]},get rawMessage(){return o()[1]},timestamp:Date.now(),properties:{...r,...n}})}logTemplate(e,t,n,r={}){let i=Co();this.emit({category:this.category,level:e,message:bo(t,n),rawMessage:t,timestamp:Date.now(),properties:{...i,...r}})}trace(e,...t){typeof e==`string`?this.log(`trace`,e,t[0]??{}):typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){typeof e==`string`?this.log(`debug`,e,t[0]??{}):typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){typeof e==`string`?this.log(`info`,e,t[0]??{}):typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}warn(e,...t){typeof e==`string`?this.log(`warning`,e,t[0]??{}):typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){this.warn(e,...t)}error(e,...t){typeof e==`string`?this.log(`error`,e,t[0]??{}):typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){typeof e==`string`?this.log(`fatal`,e,t[0]??{}):typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}},fo=class e{logger;properties;constructor(e,t){this.logger=e,this.properties=t}get category(){return this.logger.category}get parent(){return this.logger.parent}getChild(e){return this.logger.getChild(e).with(this.properties)}with(t){return new e(this.logger,{...this.properties,...t})}log(e,t,n,r){this.logger.log(e,t,typeof n==`function`?()=>({...this.properties,...n()}):{...this.properties,...n},r)}logLazily(e,t){this.logger.logLazily(e,t,this.properties)}logTemplate(e,t,n){this.logger.logTemplate(e,t,n,this.properties)}emit(e){let t={...e,properties:{...this.properties,...e.properties}};this.logger.emit(t)}trace(e,...t){typeof e==`string`?this.log(`trace`,e,t[0]??{}):typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){typeof e==`string`?this.log(`debug`,e,t[0]??{}):typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){typeof e==`string`?this.log(`info`,e,t[0]??{}):typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}warn(e,...t){typeof e==`string`?this.log(`warning`,e,t[0]??{}):typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){this.warn(e,...t)}error(e,...t){typeof e==`string`?this.log(`error`,e,t[0]??{}):typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){typeof e==`string`?this.log(`fatal`,e,t[0]??{}):typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}},po=uo.getLogger([`logtape`,`meta`]);function mo(e){return e.includes(`.`)||e.includes(`[`)||e.includes(`?.`)}function ho(e,t){if(!(t===`__proto__`||t===`prototype`||t===`constructor`)&&(typeof e==`object`||typeof e==`function`)&&e!==null)return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function go(e,t){let n=e.length,r=t;if(r>=n)return null;let i;if(e[r]===`[`){if(r++,r>=n)return null;if(e[r]===`"`||e[r]===`'`){let t=e[r];r++;let a=``;for(;r<n&&e[r]!==t;)if(e[r]===`\\`){if(r++,r<n){let t=e[r];switch(t){case`n`:a+=`
|
|
2
2
|
`;break;case`t`:a+=` `;break;case`r`:a+=`\r`;break;case`b`:a+=`\b`;break;case`f`:a+=`\f`;break;case`v`:a+=`\v`;break;case`0`:a+=`\0`;break;case`\\`:a+=`\\`;break;case`"`:a+=`"`;break;case`'`:a+=`'`;break;case`u`:if(r+4<n){let n=e.slice(r+1,r+5),i=Number.parseInt(n,16);Number.isNaN(i)?a+=t:(a+=String.fromCharCode(i),r+=4)}else a+=t;break;default:a+=t}r++}}else a+=e[r],r++;if(r>=n)return null;i=a,r++}else{let t=r;for(;r<n&&e[r]!==`]`&&e[r]!==`'`&&e[r]!==`"`;)r++;if(r>=n)return null;let a=e.slice(t,r);if(a.length===0)return null;let o=Number(a);i=Number.isNaN(o)?a:o}for(;r<n&&e[r]!==`]`;)r++;r<n&&r++}else{let t=r;for(;r<n&&e[r]!==`.`&&e[r]!==`[`&&e[r]!==`?`&&e[r]!==`]`;)r++;if(i=e.slice(t,r),i.length===0)return null}return r<n&&e[r]===`.`&&r++,{segment:i,nextIndex:r}}function _o(e,t){if(typeof t==`string`)return ho(e,t);if(Array.isArray(e)&&t>=0&&t<e.length)return e[t]}function vo(e,t){if(e==null||t.length===0||t.endsWith(`.`))return;let n=e,r=0,i=t.length;for(;r<i;){if(t.slice(r,r+2)===`?.`){if(r+=2,n==null)return}else if(n==null)return;let e=go(t,r);if(e===null)return;let{segment:i,nextIndex:a}=e;if(r=a,n=_o(n,i),n===void 0)return}return n}function yo(e,t){let n=e.length;if(n===0)return[``];if(!e.includes(`{`))return[e];let r=[],i=0;for(let a=0;a<n;a++){let o=e[a];if(o===`{`){if((a+1<n?e[a+1]:``)===`{`){a++;continue}let o=e.indexOf(`}`,a+1);if(o===-1)continue;let s=e.slice(i,a);r.push(s.replace(/{{/g,`{`).replace(/}}/g,`}`));let c=e.slice(a+1,o),l,u=c.trim();u===`*`?l=c in t?t[c]:`*`in t?t[`*`]:t:(l=c===u||c in t?t[c]:t[u],l===void 0&&mo(u)&&(l=vo(t,u))),r.push(l),a=o,i=a+1}else o===`}`&&a+1<n&&e[a+1]===`}`&&a++}let a=e.slice(i);return r.push(a.replace(/{{/g,`{`).replace(/}}/g,`}`)),r}function bo(e,t){let n=[];for(let r=0;r<e.length;r++)n.push(e[r]),r<t.length&&n.push(t[r]);return n}var xo=Symbol.for(`logtape.categoryPrefix`);function So(){let e=uo.getLogger().contextLocalStorage?.getStore();if(e==null)return[];let t=e[xo];return Array.isArray(t)?t:[]}function Co(){let e=uo.getLogger().contextLocalStorage?.getStore();if(e==null)return{};let t={};for(let n of Object.keys(e))t[n]=e[n];return t}var wo=t({inspect:()=>To});function To(e,t){let n=t?.compact===!0?void 0:2;return JSON.stringify(e,null,n)}var Eo={trace:`TRC`,debug:`DBG`,info:`INF`,warning:`WRN`,error:`ERR`,fatal:`FTL`},Do=typeof document<`u`||typeof navigator<`u`&&navigator.product===`ReactNative`?e=>JSON.stringify(e):`Deno`in globalThis&&`inspect`in globalThis.Deno&&typeof globalThis.Deno.inspect==`function`?(e,t)=>globalThis.Deno.inspect(e,{strAbbreviateSize:1/0,iterableLimit:1/0,...t}):wo!=null&&`inspect`in wo&&typeof To==`function`?(e,t)=>To(e,{maxArrayLength:1/0,maxStringLength:1/0,...t}):e=>JSON.stringify(e);function Oo(e){return e<10?`0${e}`:`${e}`}function ko(e){return e<10?`00${e}`:e<100?`0${e}`:`${e}`}var Ao={"date-time-timezone":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${Oo(t.getUTCMonth()+1)}-${Oo(t.getUTCDate())} ${Oo(t.getUTCHours())}:${Oo(t.getUTCMinutes())}:${Oo(t.getUTCSeconds())}.${ko(t.getUTCMilliseconds())} +00:00`},"date-time-tz":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${Oo(t.getUTCMonth()+1)}-${Oo(t.getUTCDate())} ${Oo(t.getUTCHours())}:${Oo(t.getUTCMinutes())}:${Oo(t.getUTCSeconds())}.${ko(t.getUTCMilliseconds())} +00`},"date-time":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${Oo(t.getUTCMonth()+1)}-${Oo(t.getUTCDate())} ${Oo(t.getUTCHours())}:${Oo(t.getUTCMinutes())}:${Oo(t.getUTCSeconds())}.${ko(t.getUTCMilliseconds())}`},"time-timezone":e=>{let t=new Date(e);return`${Oo(t.getUTCHours())}:${Oo(t.getUTCMinutes())}:${Oo(t.getUTCSeconds())}.${ko(t.getUTCMilliseconds())} +00:00`},"time-tz":e=>{let t=new Date(e);return`${Oo(t.getUTCHours())}:${Oo(t.getUTCMinutes())}:${Oo(t.getUTCSeconds())}.${ko(t.getUTCMilliseconds())} +00`},time:e=>{let t=new Date(e);return`${Oo(t.getUTCHours())}:${Oo(t.getUTCMinutes())}:${Oo(t.getUTCSeconds())}.${ko(t.getUTCMilliseconds())}`},date:e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${Oo(t.getUTCMonth()+1)}-${Oo(t.getUTCDate())}`},rfc3339:e=>new Date(e).toISOString(),none:()=>null},jo={ABBR:Eo,abbr:{trace:`trc`,debug:`dbg`,info:`inf`,warning:`wrn`,error:`err`,fatal:`ftl`},FULL:{trace:`TRACE`,debug:`DEBUG`,info:`INFO`,warning:`WARNING`,error:`ERROR`,fatal:`FATAL`},full:{trace:`trace`,debug:`debug`,info:`info`,warning:`warning`,error:`error`,fatal:`fatal`},L:{trace:`T`,debug:`D`,info:`I`,warning:`W`,error:`E`,fatal:`F`},l:{trace:`t`,debug:`d`,info:`i`,warning:`w`,error:`e`,fatal:`f`}};function Mo(e={}){let t=(()=>{let t=e.timestamp;return t==null?Ao[`date-time-timezone`]:t===`disabled`?Ao.none:typeof t==`string`&&t in Ao?Ao[t]:t})(),n=e.category??`·`,r=e.value?t=>e.value(t,Do):Do,i=(()=>{let t=e.level;return t==null||t===`ABBR`?e=>jo.ABBR[e]:t===`abbr`?e=>jo.abbr[e]:t===`FULL`?e=>jo.FULL[e]:t===`full`?e=>jo.full[e]:t===`L`?e=>jo.L[e]:t===`l`?e=>jo.l[e]:t})(),a=e.format??(({timestamp:e,level:t,category:n,message:r})=>`${e?`${e} `:``}[${t}] ${n}: ${r}`);return e=>{let o=e.message,s=o.length,c;if(s===1)c=o[0];else if(s<=6){c=``;for(let e=0;e<s;e++)c+=e%2==0?o[e]:r(o[e])}else{let e=Array(s);for(let t=0;t<s;t++)e[t]=t%2==0?o[t]:r(o[t]);c=e.join(``)}return`${a({timestamp:t(e.timestamp),level:i(e.level),category:typeof n==`function`?n(e.category):e.category.join(n),message:c,record:e})}\n`}}Mo();var No=`\x1B[0m`,Po={black:`\x1B[30m`,red:`\x1B[31m`,green:`\x1B[32m`,yellow:`\x1B[33m`,blue:`\x1B[34m`,magenta:`\x1B[35m`,cyan:`\x1B[36m`,white:`\x1B[37m`},Fo={bold:`\x1B[1m`,dim:`\x1B[2m`,italic:`\x1B[3m`,underline:`\x1B[4m`,strikethrough:`\x1B[9m`},Io={trace:null,debug:`blue`,info:`green`,warning:`yellow`,error:`red`,fatal:`magenta`};function Lo(e={}){let t=e.format,n=e.timestampStyle===void 0?`dim`:e.timestampStyle,r=e.timestampColor??null,i=`${n==null?``:Fo[n]}${r==null?``:Po[r]}`,a=n==null&&r==null?``:No,o=e.levelStyle===void 0?`bold`:e.levelStyle,s=e.levelColors??Io,c=e.categoryStyle===void 0?`dim`:e.categoryStyle,l=e.categoryColor??null,u=`${c==null?``:Fo[c]}${l==null?``:Po[l]}`,d=c==null&&l==null?``:No;return Mo({timestamp:`date-time-tz`,value(e,t){return t(e,{colors:!0})},...e,format({timestamp:e,level:n,category:r,message:c,record:l}){let f=s[l.level];return e=`${i}${e}${a}`,n=`${o==null?``:Fo[o]}${f==null?``:Po[f]}${n}${o==null&&f==null?``:No}`,t==null?`${e} ${n} ${u}${r}:${d} ${c}`:t({timestamp:e,level:n,category:`${u}${r}${d}`,message:c,record:l})}})}Lo();function Ro(e={}){if(!e.categorySeparator&&!e.message&&!e.properties)return e=>{if(e.message.length===3)return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:e.message[0]+JSON.stringify(e.message[1])+e.message[2],logger:e.category.join(`.`),properties:e.properties})+`
|
|
3
3
|
`;if(e.message.length===1)return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:e.message[0],logger:e.category.join(`.`),properties:e.properties})+`
|
|
4
4
|
`;let t=e.message[0];for(let n=1;n<e.message.length;n++)t+=n&1?JSON.stringify(e.message[n]):e.message[n];return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:t,logger:e.category.join(`.`),properties:e.properties})+`
|
|
5
5
|
`};let t=e.message===`template`,n=e.properties??`nest:properties`,r;if(typeof e.categorySeparator==`function`)r=e.categorySeparator;else{let t=e.categorySeparator??`.`;r=e=>e.join(t)}let i;if(n===`flatten`)i=e=>e;else if(n.startsWith(`prepend:`)){let e=n.substring(8);if(e===``)throw TypeError(`Invalid properties option: ${JSON.stringify(n)}. It must be of the form "prepend:<prefix>" where <prefix> is a non-empty string.`);i=t=>{let n={};for(let r in t)n[`${e}${r}`]=t[r];return n}}else if(n.startsWith(`nest:`)){let e=n.substring(5);i=t=>({[e]:t})}else throw TypeError(`Invalid properties option: ${JSON.stringify(n)}. It must be "flatten", "prepend:<prefix>", or "nest:<key>".`);let a;return a=t?e=>{if(typeof e.rawMessage==`string`)return e.rawMessage;let t=``;for(let n=0;n<e.rawMessage.length;n++)t+=n%2<1?e.rawMessage[n]:`{}`;return t}:e=>{let t=e.message.length;if(t===1)return e.message[0];let n=``;for(let r=0;r<t;r++)n+=r%2<1?e.message[r]:JSON.stringify(e.message[r]);return n},e=>JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:a(e),logger:r(e.category),...i(e.properties)})+`
|
|
6
|
-
`}Ro();var zo={trace:`background-color: gray; color: white;`,debug:`background-color: gray; color: white;`,info:`background-color: white; color: black;`,warning:`background-color: orange; color: black;`,error:`background-color: red; color: white;`,fatal:`background-color: maroon; color: white;`};function Bo(e){let t=``,n=[];for(let r=0;r<e.message.length;r++)r%2==0?t+=e.message[r]:(t+=`%o`,n.push(e.message[r]));let r=new Date(e.timestamp);return[`%c${`${r.getUTCHours().toString().padStart(2,`0`)}:${r.getUTCMinutes().toString().padStart(2,`0`)}:${r.getUTCSeconds().toString().padStart(2,`0`)}.${r.getUTCMilliseconds().toString().padStart(3,`0`)}`} %c${Eo[e.level]}%c %c${e.category.join(`·`)} %c${t}`,`color: gray;`,zo[e.level],`background-color: default;`,`color: gray;`,`color: default;`,...n]}function Vo(e={}){let t=e.formatter??Bo,n={trace:`debug`,debug:`debug`,info:`info`,warning:`warn`,error:`error`,fatal:`error`,...e.levelMap??{}},r=e.console??globalThis.console,i=e=>{let i=t(e),a=n[e.level];if(a===void 0)throw TypeError(`Invalid log level: ${e.level}.`);if(typeof i==`string`){let e=i.replace(/\r?\n$/,``);r[a](e)}else r[a](...i)};if(!e.nonBlocking)return i;let a=e.nonBlocking===!0?{}:e.nonBlocking,o=a.bufferSize??100,s=a.flushInterval??100,c=[],l=null,u=!1,d=!1,f=o*2;function p(){if(c.length===0)return;let e=c.splice(0);for(let t of e)try{i(t)}catch{}}function m(){d||(d=!0,setTimeout(()=>{d=!1,p()},0))}function h(){l!==null||u||(l=setInterval(()=>{p()},s))}let g=e=>{u||(c.length>=f&&c.shift(),c.push(e),c.length>=o?m():l===null&&h())};return g[Symbol.dispose]=()=>{u=!0,l!==null&&(clearInterval(l),l=null),p()},g}var Ho=null,Uo=new Set,Wo=new Set,Go=new Set;function Ko(e){return e.category.length===0||e.category.length===1&&e.category[0]===`logtape`||e.category.length===2&&e.category[0]===`logtape`&&e.category[1]===`meta`}function qo(e){if(Ho!=null&&!e.reset)throw new $o(`Already configured; if you want to reset, turn on the reset flag.`);if(Go.size>0)throw new $o(`Previously configured async disposables are still active. Use configure() instead or explicitly dispose them using dispose().`);Yo();try{Jo(e,!1)}catch(e){throw e instanceof $o&&Yo(),e}}function Jo(e,t){Ho=e;let n=!1,r=new Set;for(let t of e.loggers){Ko(t)&&(n=!0);let i=Array.isArray(t.category)?JSON.stringify(t.category):JSON.stringify([t.category]);if(r.has(i))throw new $o(`Duplicate logger configuration for category: ${i}. Each category can only be configured once.`);r.add(i);let a=uo.getLogger(t.category);for(let n of t.sinks??[]){let t=e.sinks[n];if(!t)throw new $o(`Sink not found: ${n}.`);a.sinks.push(t)}a.parentSinks=t.parentSinks??`inherit`,t.lowestLevel!==void 0&&(a.lowestLevel=t.lowestLevel);for(let n of t.filters??[]){let t=e.filters?.[n];if(t===void 0)throw new $o(`Filter not found: ${n}.`);a.filters.push(io(t))}Uo.add(a)}uo.getLogger().contextLocalStorage=e.contextLocalStorage;for(let n of Object.values(e.sinks)){if(Symbol.asyncDispose in n)if(t)Go.add(n);else throw new $o(`Async disposables cannot be used with configureSync().`);Symbol.dispose in n&&Wo.add(n)}for(let n of Object.values(e.filters??{}))if(!(n==null||typeof n==`string`)){if(Symbol.asyncDispose in n)if(t)Go.add(n);else throw new $o(`Async disposables cannot be used with configureSync().`);Symbol.dispose in n&&Wo.add(n)}if(typeof globalThis.EdgeRuntime!=`string`&&`process`in globalThis&&!(`Deno`in globalThis)){let e=globalThis.process,n=e?.on;typeof n==`function`&&n.call(e,`exit`,t?Zo:Qo)}else addEventListener(`unload`,t?Zo:Qo);let i=uo.getLogger([`logtape`,`meta`]);n||i.sinks.push(Vo()),i.info(`LogTape loggers are configured. Note that LogTape itself uses the meta logger, which has category {metaLoggerCategory}. The meta logger purposes to log internal errors such as sink exceptions. If you are seeing this message, the meta logger is automatically configured. It's recommended to configure the meta logger with a separate sink so that you can easily notice if logging itself fails or is misconfigured. To turn off this message, configure the meta logger with higher log levels than {dismissLevel}. See also <https://logtape.org/manual/categories#meta-logger>.`,{metaLoggerCategory:[`logtape`,`meta`],dismissLevel:`info`})}function Yo(){Qo(),Xo()}function Xo(){let e=uo.getLogger([]);e.resetDescendants(),delete e.contextLocalStorage,Uo.clear(),Ho=null}async function Zo(){Qo();let e=[];for(let t of Go)e.push(t[Symbol.asyncDispose]()),Go.delete(t);await Promise.all(e)}function Qo(){for(let e of Wo)e[Symbol.dispose]();Wo.clear()}var $o=class extends Error{constructor(e){super(e),this.name=`ConfigureError`}},k=class{static getLogger(e=[]){return co([`@cmts-dev/carmentis-sdk-core`,...e])}static getProviderLogger(){return this.getLogger([`provider`])}static getMemoryProviderLogger(){return this.getLogger([`provider`,`memory`])}static async enableLogs(){this.enableLogsSync()}static enableLogsSync(){qo({sinks:{console:Vo()},loggers:[{category:`@cmts-dev/carmentis-sdk-core`,lowestLevel:`debug`,sinks:[`console`]}]})}static getNetworkProviderLogger(){return this.getLogger([`provider`,`network`])}static getMicroblockLogger(){return this.getLogger([`microblock`])}static getVirtualBlockchainLogger(){return this.getLogger([`virtual-blockchain`])}static getInternalStateUpdaterLogger(e){return this.getLogger([`internal-state-updater`,e])}static getAbstractProviderLogger(e){return this.getLogger([`provider`,e])}static getMicroblockStructureCheckerLogger(){return this.getLogger([`microblock`,`structure-checker`])}},A={numberToHexa:ts,truncateString:ns,truncateStringMiddle:rs,getNullHash:is,getTimestampInSeconds:as,encodeDay:ss,decodeDay:cs,dateToDay:ls,dayToDate:us,addDaysToTimestamp:ds,timestampDifferenceInDays:fs,bufferToUint8Array:ps,binaryToHexa:ms,binaryFromHexa:hs,binaryFrom:gs,binaryIsEqual:_s,binaryCompare:vs,intToByteArray:ys,byteArrayToInt:bs,getGenesisEpochInTimestamp:os,jsonPrettify:xs},es=k.getLogger([`utils`]);function ts(e,t){return e.toString(16).toUpperCase().padStart(t||1,`0`)}function ns(e,t){return e.slice(0,t)+(e.length>t?`(...)`:``)}function rs(e,t,n){return e.length<=t+n?e:e.slice(0,t)+`(...)`+e.slice(e.length-n)}function is(){return new Uint8Array(32)}function as(){return Math.floor(Date.now()/1e3)}function os(){return 0}function ss(e,t,n){return e<<9|t<<5|n}function cs(e){let t=e&31,n=e>>5&15;return[e>>>9,n,t]}function ls(e){let t=e.getDate(),n=e.getMonth()+1;return ss(e.getFullYear(),n,t)}function us(e){let[t,n,r]=cs(e);return new Date(Date.UTC(t,n-1,r))}function ds(e,t){let n=new Date(e*1e3);return Math.floor(Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()+t)/1e3)}function fs(e,t){return Math.round((t-e)/86400)}function ps(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT)}function ms(e){return[...e].map(e=>e.toString(16).toUpperCase().padStart(2,`0`)).join(``)}function hs(e){if(typeof e!=`string`)throw new i(`Expecting hex-string value: received ${typeof e}`);if(!e.match(/^([\da-f]{2})*$/gi))throw new i(`Expecting hex-string value: received '${e}'`);let t=(e.match(/../g)||[]).map(e=>parseInt(e,16));return new Uint8Array(t)}function gs(...e){let t=Array(e.length),n=Array(e.length),r=0;e.forEach((i,a)=>{let o=no.getType(i);switch(o){case 4:n[a]=new Uint8Array(ys(i));break;case 3:n[a]=Za.encode(i);break;case 12:n[a]=i;break;default:{let t=e.length,n=e.map(e=>Pn[no.getType(e)]).join(`, `);throw Error(`unsupported type '${Pn[o]}' for Utils.binaryFrom(): got ${t} arguments of type ${n}`)}}t[a]=r,r+=n[a].length});let i=new Uint8Array(r);return t.forEach((e,t)=>{i.set(n[t],e)}),i}function _s(e,t){if(!(e instanceof Uint8Array))throw Error(`Excepted Uint8array, got ${typeof e}`);if(!(t instanceof Uint8Array))throw Error(`Excepted Uint8array, got ${typeof t}`);let n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(n.byteLength!==r.byteLength)return es.debug(`Comparison result is false (distinct length): ${n.byteLength} != ${r.byteLength}`),!1;for(let e=0;e<n.byteLength;e++)if(n[e]!==r[e])return es.debug(`Comparison result is false (distinct value): ${n[e]} != ${r[e]}`),!1;return es.debug(`Comparison result is true`),!0}function vs(e,t){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array)||e.length!=t.length)throw`cannot compare`;for(let n in e)if(e[n]<t[n])return-1;else if(e[n]>t[n])return 1;return 0}function ys(e,t=1){let n=[],r=e,i=t;for(;r>0||i>0;)n.push(r&255),r=Math.floor(r/256),i--;return n.reverse()}function bs(e){return e.reduce((e,t)=>e*256+t,0)}function xs(e,t=2){return JSON.stringify(e,(e,t)=>{if(t instanceof Uint8Array){let e=t.length>32,n=ms(t.slice(0,e?24:32)),r=e?`(...)`+ms(t.slice(-8)):``;return`Uint8Array[${t.length}]:${n}${r}`}return t},t)}var Ss=typeof globalThis==`object`&&`crypto`in globalThis?globalThis.crypto:void 0;function Cs(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function ws(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got `+e)}function Ts(e,...t){if(!Cs(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function Es(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash should be wrapped by utils.createHasher`);ws(e.outputLen),ws(e.blockLen)}function Ds(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function Os(e,t){Ts(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function ks(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function As(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function js(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ms(e,t){return e<<32-t|e>>>t}function j(e,t){return e<<t|e>>>32-t>>>0}var Ns=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Ps(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Fs(e){for(let t=0;t<e.length;t++)e[t]=Ps(e[t]);return e}var Is=Ns?e=>e:Fs,Ls=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,Rs={_0:48,_9:57,A:65,F:70,a:97,f:102};function zs(e){if(e>=Rs._0&&e<=Rs._9)return e-Rs._0;if(e>=Rs.A&&e<=Rs.F)return e-(Rs.A-10);if(e>=Rs.a&&e<=Rs.f)return e-(Rs.a-10)}function Bs(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(Ls)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=zs(e.charCodeAt(i)),a=zs(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function Vs(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function Hs(e){return typeof e==`string`&&(e=Vs(e)),Ts(e),e}function Us(e){return typeof e==`string`&&(e=Vs(e)),Ts(e),e}function Ws(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];Ts(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}function Gs(e,t){if(t!==void 0&&{}.toString.call(t)!==`[object Object]`)throw Error(`options should be object or undefined`);return Object.assign(e,t)}var Ks=class{};function qs(e){let t=t=>e().update(Hs(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Js(e){let t=(t,n)=>e(n).update(Hs(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}function Ys(e=32){if(Ss&&typeof Ss.getRandomValues==`function`)return Ss.getRandomValues(new Uint8Array(e));if(Ss&&typeof Ss.randomBytes==`function`)return Uint8Array.from(Ss.randomBytes(e));throw Error(`crypto.getRandomValues must be defined`)}var Xs={getBytes:Zs,getInteger:Qs,getKey256:$s};function Zs(e){return Ys(e)}function Qs(e){let t=Zs(6),n=0;for(let e=0;e<6;e++)n=n*256+t[e];return Math.floor(n/2**48*e)}function $s(){let e=Zs(32);return A.binaryToHexa(e)}function ec(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}function tc(e,t,n){return e&t^~e&n}function nc(e,t,n){return e&t^e&n^t&n}var rc=class extends Ks{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=js(this.buffer)}update(e){Ds(this),e=Hs(e),Ts(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=js(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ds(this),Os(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,As(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;ec(n,r-8,BigInt(this.length*8),i),this.process(n,0);let o=js(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},ic=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ac=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),oc=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),sc=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),cc=BigInt(2**32-1),lc=BigInt(32);function uc(e,t=!1){return t?{h:Number(e&cc),l:Number(e>>lc&cc)}:{h:Number(e>>lc&cc)|0,l:Number(e&cc)|0}}function dc(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=uc(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}var fc=(e,t,n)=>e>>>n,pc=(e,t,n)=>e<<32-n|t>>>n,mc=(e,t,n)=>e>>>n|t<<32-n,hc=(e,t,n)=>e<<32-n|t>>>n,gc=(e,t,n)=>e<<64-n|t>>>n-32,_c=(e,t,n)=>e>>>n-32|t<<64-n,vc=(e,t,n)=>e<<n|t>>>32-n,yc=(e,t,n)=>t<<n|e>>>32-n,bc=(e,t,n)=>t<<n-32|e>>>64-n,xc=(e,t,n)=>e<<n-32|t>>>64-n;function Sc(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}var Cc=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),wc=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Tc=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),Ec=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,Dc=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),Oc=(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0,kc=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ac=new Uint32Array(64),jc=class extends rc{constructor(e=32){super(64,e,8,!1),this.A=ic[0]|0,this.B=ic[1]|0,this.C=ic[2]|0,this.D=ic[3]|0,this.E=ic[4]|0,this.F=ic[5]|0,this.G=ic[6]|0,this.H=ic[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)Ac[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=Ac[e-15],n=Ac[e-2],r=Ms(t,7)^Ms(t,18)^t>>>3;Ac[e]=(Ms(n,17)^Ms(n,19)^n>>>10)+Ac[e-7]+r+Ac[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=Ms(o,6)^Ms(o,11)^Ms(o,25),u=l+t+tc(o,s,c)+kc[e]+Ac[e]|0,d=(Ms(n,2)^Ms(n,13)^Ms(n,22))+nc(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){As(Ac)}destroy(){this.set(0,0,0,0,0,0,0,0),As(this.buffer)}},Mc=class extends jc{constructor(){super(28),this.A=ac[0]|0,this.B=ac[1]|0,this.C=ac[2]|0,this.D=ac[3]|0,this.E=ac[4]|0,this.F=ac[5]|0,this.G=ac[6]|0,this.H=ac[7]|0}},Nc=dc(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map(e=>BigInt(e))),Pc=Nc[0],Fc=Nc[1],Ic=new Uint32Array(80),Lc=new Uint32Array(80),Rc=class extends rc{constructor(e=64){super(128,e,16,!1),this.Ah=sc[0]|0,this.Al=sc[1]|0,this.Bh=sc[2]|0,this.Bl=sc[3]|0,this.Ch=sc[4]|0,this.Cl=sc[5]|0,this.Dh=sc[6]|0,this.Dl=sc[7]|0,this.Eh=sc[8]|0,this.El=sc[9]|0,this.Fh=sc[10]|0,this.Fl=sc[11]|0,this.Gh=sc[12]|0,this.Gl=sc[13]|0,this.Hh=sc[14]|0,this.Hl=sc[15]|0}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=s|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=m|0,this.Hl=h|0}process(e,t){for(let n=0;n<16;n++,t+=4)Ic[n]=e.getUint32(t),Lc[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=Ic[e-15]|0,n=Lc[e-15]|0,r=mc(t,n,1)^mc(t,n,8)^fc(t,n,7),i=hc(t,n,1)^hc(t,n,8)^pc(t,n,7),a=Ic[e-2]|0,o=Lc[e-2]|0,s=mc(a,o,19)^gc(a,o,61)^fc(a,o,6),c=Tc(i,hc(a,o,19)^_c(a,o,61)^pc(a,o,6),Lc[e-7],Lc[e-16]);Ic[e]=Ec(c,r,s,Ic[e-7],Ic[e-16])|0,Lc[e]=c|0}let{Ah:n,Al:r,Bh:i,Bl:a,Ch:o,Cl:s,Dh:c,Dl:l,Eh:u,El:d,Fh:f,Fl:p,Gh:m,Gl:h,Hh:g,Hl:_}=this;for(let e=0;e<80;e++){let t=mc(u,d,14)^mc(u,d,18)^gc(u,d,41),v=hc(u,d,14)^hc(u,d,18)^_c(u,d,41),y=u&f^~u&m,b=d&p^~d&h,ee=Dc(_,v,b,Fc[e],Lc[e]),x=Oc(ee,g,t,y,Pc[e],Ic[e]),te=ee|0,ne=mc(n,r,28)^gc(n,r,34)^gc(n,r,39),re=hc(n,r,28)^_c(n,r,34)^_c(n,r,39),ie=n&i^n&o^i&o,ae=r&a^r&s^a&s;g=m|0,_=h|0,m=f|0,h=p|0,f=u|0,p=d|0,{h:u,l:d}=Sc(c|0,l|0,x|0,te|0),c=o|0,l=s|0,o=i|0,s=a|0,i=n|0,a=r|0;let oe=Cc(te,re,ae);n=wc(oe,x,ne,ie),r=oe|0}({h:n,l:r}=Sc(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:a}=Sc(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:s}=Sc(this.Ch|0,this.Cl|0,o|0,s|0),{h:c,l}=Sc(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=Sc(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=Sc(this.Fh|0,this.Fl|0,f|0,p|0),{h:m,l:h}=Sc(this.Gh|0,this.Gl|0,m|0,h|0),{h:g,l:_}=Sc(this.Hh|0,this.Hl|0,g|0,_|0),this.set(n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)}roundClean(){As(Ic,Lc)}destroy(){As(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},zc=class extends Rc{constructor(){super(48),this.Ah=oc[0]|0,this.Al=oc[1]|0,this.Bh=oc[2]|0,this.Bl=oc[3]|0,this.Ch=oc[4]|0,this.Cl=oc[5]|0,this.Dh=oc[6]|0,this.Dl=oc[7]|0,this.Eh=oc[8]|0,this.El=oc[9]|0,this.Fh=oc[10]|0,this.Fl=oc[11]|0,this.Gh=oc[12]|0,this.Gl=oc[13]|0,this.Hh=oc[14]|0,this.Hl=oc[15]|0}},Bc=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),Vc=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]),Hc=class extends Rc{constructor(){super(28),this.Ah=Bc[0]|0,this.Al=Bc[1]|0,this.Bh=Bc[2]|0,this.Bl=Bc[3]|0,this.Ch=Bc[4]|0,this.Cl=Bc[5]|0,this.Dh=Bc[6]|0,this.Dl=Bc[7]|0,this.Eh=Bc[8]|0,this.El=Bc[9]|0,this.Fh=Bc[10]|0,this.Fl=Bc[11]|0,this.Gh=Bc[12]|0,this.Gl=Bc[13]|0,this.Hh=Bc[14]|0,this.Hl=Bc[15]|0}},Uc=class extends Rc{constructor(){super(32),this.Ah=Vc[0]|0,this.Al=Vc[1]|0,this.Bh=Vc[2]|0,this.Bl=Vc[3]|0,this.Ch=Vc[4]|0,this.Cl=Vc[5]|0,this.Dh=Vc[6]|0,this.Dl=Vc[7]|0,this.Eh=Vc[8]|0,this.El=Vc[9]|0,this.Fh=Vc[10]|0,this.Fl=Vc[11]|0,this.Gh=Vc[12]|0,this.Gl=Vc[13]|0,this.Hh=Vc[14]|0,this.Hl=Vc[15]|0}},Wc=qs(()=>new jc),Gc=qs(()=>new Mc),Kc=qs(()=>new Rc),qc=qs(()=>new zc),Jc=qs(()=>new Uc),Yc=qs(()=>new Hc),Xc=Kc,Zc={sha256AsBinary:Qc,sha256:$c,sha512AsBinary:el,sha512:tl};k.getLogger([`utils`,`crypto`]);function Qc(e){if(!(e instanceof Uint8Array))throw new m(`Argument passed to compute sha256 is not an instance of Uint8Array: got ${typeof e}`);return Wc(e)}function $c(e){return A.binaryToHexa(Qc(e))}function el(e){if(!(e instanceof Uint8Array))throw`Argument passed to compute sha512 is not an instance of Uint8Array`;return Xc(e)}function tl(e){return A.binaryToHexa(el(e))}function nl(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function rl(e){if(typeof e!=`boolean`)throw Error(`boolean expected, not ${e}`)}function il(e,...t){if(!nl(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function al(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function ol(e,t){il(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function sl(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function cl(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ll(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function ul(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var dl=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,fl=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,pl=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function ml(e){if(il(e),fl)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=pl[e[n]];return t}var hl={_0:48,_9:57,A:65,F:70,a:97,f:102};function gl(e){if(e>=hl._0&&e<=hl._9)return e-hl._0;if(e>=hl.A&&e<=hl.F)return e-(hl.A-10);if(e>=hl.a&&e<=hl.f)return e-(hl.a-10)}function _l(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(fl)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=gl(e.charCodeAt(i)),a=gl(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function vl(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function yl(e){return new TextDecoder().decode(e)}function bl(e){if(typeof e==`string`)e=vl(e);else if(nl(e))e=Dl(e);else throw Error(`Uint8Array expected, got `+typeof e);return e}function xl(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}var Sl=(e,t)=>{function n(n,...r){if(il(n),!dl)throw Error(`Non little-endian hardware is not yet supported`);if(e.nonceLength!==void 0){let t=r[0];if(!t)throw Error(`nonce / iv required`);e.varSizeNonce?il(t):il(t,e.nonceLength)}let i=e.tagLength;i&&r[1]!==void 0&&il(r[1]);let a=t(n,...r),o=(e,t)=>{if(t!==void 0){if(e!==2)throw Error(`cipher output not supported`);il(t)}},s=!1;return{encrypt(e,t){if(s)throw Error(`cannot encrypt() twice with same key + nonce`);return s=!0,il(e),o(a.encrypt.length,t),a.encrypt(e,t)},decrypt(e,t){if(il(e),i&&e.length<i)throw Error(`invalid ciphertext length: smaller than tagLength=`+i);return o(a.decrypt.length,t),a.decrypt(e,t)}}}return Object.assign(n,e),n};function Cl(e,t,n=!0){if(t===void 0)return new Uint8Array(e);if(t.length!==e)throw Error(`invalid output length, expected `+e+`, got: `+t.length);if(n&&!El(t))throw Error(`invalid output, must be aligned`);return t}function wl(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}function Tl(e,t,n){rl(n);let r=new Uint8Array(16),i=ul(r);return wl(i,0,BigInt(t),n),wl(i,8,BigInt(e),n),r}function El(e){return e.byteOffset%4==0}function Dl(e){return Uint8Array.from(e)}var Ol=16,kl=new Uint8Array(16),Al=cl(kl),jl=225,Ml=(e,t,n,r)=>{let i=r&1;return{s3:n<<31|r>>>1,s2:t<<31|n>>>1,s1:e<<31|t>>>1,s0:e>>>1^jl<<24&-(i&1)}},Nl=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255|0;function Pl(e){e.reverse();let t=e[15]&1,n=0;for(let t=0;t<e.length;t++){let r=e[t];e[t]=r>>>1|n,n=(r&1)<<7}return e[0]^=-t&225,e}var Fl=e=>e>64*1024?8:e>1024?4:2,Il=class{constructor(e,t){this.blockLen=Ol,this.outputLen=Ol,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,e=bl(e),il(e,16);let n=ul(e),r=n.getUint32(0,!1),i=n.getUint32(4,!1),a=n.getUint32(8,!1),o=n.getUint32(12,!1),s=[];for(let e=0;e<128;e++)s.push({s0:Nl(r),s1:Nl(i),s2:Nl(a),s3:Nl(o)}),{s0:r,s1:i,s2:a,s3:o}=Ml(r,i,a,o);let c=Fl(t||1024);if(![1,2,4,8].includes(c))throw Error(`ghash: invalid window size, expected 2, 4 or 8`);this.W=c;let l=128/c,u=this.windowSize=2**c,d=[];for(let e=0;e<l;e++)for(let t=0;t<u;t++){let n=0,r=0,i=0,a=0;for(let o=0;o<c;o++){if(!(t>>>c-o-1&1))continue;let{s0:l,s1:u,s2:d,s3:f}=s[c*e+o];n^=l,r^=u,i^=d,a^=f}d.push({s0:n,s1:r,s2:i,s3:a})}this.t=d}_updateBlock(e,t,n,r){e^=this.s0,t^=this.s1,n^=this.s2,r^=this.s3;let{W:i,t:a,windowSize:o}=this,s=0,c=0,l=0,u=0,d=(1<<i)-1,f=0;for(let p of[e,t,n,r])for(let e=0;e<4;e++){let t=p>>>8*e&255;for(let e=8/i-1;e>=0;e--){let n=t>>>i*e&d,{s0:r,s1:p,s2:m,s3:h}=a[f*o+n];s^=r,c^=p,l^=m,u^=h,f+=1}}this.s0=s,this.s1=c,this.s2=l,this.s3=u}update(e){al(this),e=bl(e),il(e);let t=cl(e),n=Math.floor(e.length/Ol),r=e.length%Ol;for(let e=0;e<n;e++)this._updateBlock(t[e*4+0],t[e*4+1],t[e*4+2],t[e*4+3]);return r&&(kl.set(e.subarray(n*Ol)),this._updateBlock(Al[0],Al[1],Al[2],Al[3]),ll(Al)),this}destroy(){let{t:e}=this;for(let t of e)t.s0=0,t.s1=0,t.s2=0,t.s3=0}digestInto(e){al(this),ol(e,this),this.finished=!0;let{s0:t,s1:n,s2:r,s3:i}=this,a=cl(e);return a[0]=t,a[1]=n,a[2]=r,a[3]=i,e}digest(){let e=new Uint8Array(Ol);return this.digestInto(e),this.destroy(),e}},Ll=class extends Il{constructor(e,t){e=bl(e),il(e);let n=Pl(Dl(e));super(n,t),ll(n)}update(e){e=bl(e),al(this);let t=cl(e),n=e.length%Ol,r=Math.floor(e.length/Ol);for(let e=0;e<r;e++)this._updateBlock(Nl(t[e*4+3]),Nl(t[e*4+2]),Nl(t[e*4+1]),Nl(t[e*4+0]));return n&&(kl.set(e.subarray(r*Ol)),this._updateBlock(Nl(Al[3]),Nl(Al[2]),Nl(Al[1]),Nl(Al[0])),ll(Al)),this}digestInto(e){al(this),ol(e,this),this.finished=!0;let{s0:t,s1:n,s2:r,s3:i}=this,a=cl(e);return a[0]=t,a[1]=n,a[2]=r,a[3]=i,e.reverse()}};function Rl(e){let t=(t,n)=>e(n,t.length).update(bl(t)).digest(),n=e(new Uint8Array(16),0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=(t,n)=>e(t,n),t}var zl=Rl((e,t)=>new Il(e,t));Rl((e,t)=>new Ll(e,t));var Bl=16,Vl=4,Hl=new Uint8Array(Bl),Ul=283;function Wl(e){return e<<1^Ul&-(e>>7)}function Gl(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(t&1),e=Wl(e);return n}var Kl=(()=>{let e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=Wl(n))e[t]=n;let t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=(r^r>>4^r>>5^r>>6^r>>7^99)&255}return ll(e),t})(),ql=e=>e<<24|e>>>8,Jl=e=>e<<8|e>>>24;function Yl(e,t){if(e.length!==256)throw Error(`Wrong sbox length`);let n=new Uint32Array(256).map((n,r)=>t(e[r])),r=n.map(Jl),i=r.map(Jl),a=i.map(Jl),o=new Uint32Array(256*256),s=new Uint32Array(256*256),c=new Uint16Array(256*256);for(let t=0;t<256;t++)for(let l=0;l<256;l++){let u=t*256+l;o[u]=n[t]^r[l],s[u]=i[t]^a[l],c[u]=e[t]<<8|e[l]}return{sbox:e,sbox2:c,T0:n,T1:r,T2:i,T3:a,T01:o,T23:s}}var Xl=Yl(Kl,e=>Gl(e,3)<<24|e<<16|e<<8|Gl(e,2)),Zl=(()=>{let e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=Wl(n))e[t]=n;return e})();function Ql(e){il(e);let t=e.length;if(![16,24,32].includes(t))throw Error(`aes: invalid key size, should be 16, 24 or 32, got `+t);let{sbox2:n}=Xl,r=[];El(e)||r.push(e=Dl(e));let i=cl(e),a=i.length,o=e=>eu(n,e,e,e,e),s=new Uint32Array(t+28);s.set(i);for(let e=a;e<s.length;e++){let t=s[e-1];e%a===0?t=o(ql(t))^Zl[e/a-1]:a>6&&e%a===4&&(t=o(t)),s[e]=s[e-a]^t}return ll(...r),s}function $l(e,t,n,r,i,a){return e[n<<8&65280|r>>>8&255]^t[i>>>8&65280|a>>>24&255]}function eu(e,t,n,r,i){return e[t&255|n&65280]|e[r>>>16&255|i>>>16&65280]<<16}function tu(e,t,n,r,i){let{sbox2:a,T01:o,T23:s}=Xl,c=0;t^=e[c++],n^=e[c++],r^=e[c++],i^=e[c++];let l=e.length/4-2;for(let a=0;a<l;a++){let a=e[c++]^$l(o,s,t,n,r,i),l=e[c++]^$l(o,s,n,r,i,t),u=e[c++]^$l(o,s,r,i,t,n),d=e[c++]^$l(o,s,i,t,n,r);t=a,n=l,r=u,i=d}return{s0:e[c++]^eu(a,t,n,r,i),s1:e[c++]^eu(a,n,r,i,t),s2:e[c++]^eu(a,r,i,t,n),s3:e[c++]^eu(a,i,t,n,r)}}function nu(e,t,n,r,i){il(n,Bl),il(r),i=Cl(r.length,i);let a=n,o=cl(a),s=ul(a),c=cl(r),l=cl(i),u=t?0:12,d=r.length,f=s.getUint32(u,t),{s0:p,s1:m,s2:h,s3:g}=tu(e,o[0],o[1],o[2],o[3]);for(let n=0;n+4<=c.length;n+=4)l[n+0]=c[n+0]^p,l[n+1]=c[n+1]^m,l[n+2]=c[n+2]^h,l[n+3]=c[n+3]^g,f=f+1>>>0,s.setUint32(u,f,t),{s0:p,s1:m,s2:h,s3:g}=tu(e,o[0],o[1],o[2],o[3]);let _=Bl*Math.floor(c.length/Vl);if(_<d){let e=new Uint32Array([p,m,h,g]),t=sl(e);for(let e=_,n=0;e<d;e++,n++)i[e]=r[e]^t[n];ll(e)}return i}function ru(e,t,n,r,i){let a=i?i.length:0,o=e.create(n,r.length+a);i&&o.update(i);let s=Tl(8*r.length,8*a,t);o.update(r),o.update(s);let c=o.digest();return ll(s),c}var iu=Sl({blockSize:16,nonceLength:12,tagLength:16,varSizeNonce:!0},function(e,t,n){if(t.length<8)throw Error(`aes/gcm: invalid nonce length`);function r(e,t,r){let i=ru(zl,!1,e,r,n);for(let e=0;e<t.length;e++)i[e]^=t[e];return i}function i(){let n=Ql(e),r=Hl.slice(),i=Hl.slice();if(nu(n,!1,i,i,r),t.length===12)i.set(t);else{let e=Hl.slice();wl(ul(e),8,BigInt(t.length*8),!1);let n=zl.create(r).update(t).update(e);n.digestInto(i),n.destroy()}return{xk:n,authKey:r,counter:i,tagMask:nu(n,!1,i,Hl)}}return{encrypt(e){let{xk:t,authKey:n,counter:a,tagMask:o}=i(),s=new Uint8Array(e.length+16),c=[t,n,a,o];El(e)||c.push(e=Dl(e)),nu(t,!1,a,e,s.subarray(0,e.length));let l=r(n,o,s.subarray(0,s.length-16));return c.push(l),s.set(l,e.length),ll(...c),s},decrypt(e){let{xk:t,authKey:n,counter:a,tagMask:o}=i(),s=[t,n,o,a];El(e)||s.push(e=Dl(e));let c=e.subarray(0,-16),l=e.subarray(-16),u=r(n,o,c);if(s.push(u),!xl(u,l))throw Error(`aes/gcm: invalid ghash tag`);let d=nu(t,!1,a,c);return ll(...s),d}}}),au=k.getLogger([`crypto`,`aes-gcm`]),ou={encryptGcm:su,decryptGcm:cu};function su(e,t,n){return iu(e,n).encrypt(t)}function cu(e,t,n){try{return iu(e,n).decrypt(t)}catch(e){throw au.warn(`{e}`,{e}),new f}}var lu=BigInt(0),uu=BigInt(1),du=BigInt(2),fu=BigInt(7),pu=BigInt(256),mu=BigInt(113),hu=[],gu=[],_u=[];for(let e=0,t=uu,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],hu.push(2*(5*r+n)),gu.push((e+1)*(e+2)/2%64);let i=lu;for(let e=0;e<7;e++)t=(t<<uu^(t>>fu)*mu)%pu,t&du&&(i^=uu<<(uu<<BigInt(e))-uu);_u.push(i)}var vu=dc(_u,!0),yu=vu[0],bu=vu[1],xu=(e,t,n)=>n>32?bc(e,t,n):vc(e,t,n),Su=(e,t,n)=>n>32?xc(e,t,n):yc(e,t,n);function Cu(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,i=(t+2)%10,a=n[i],o=n[i+1],s=xu(a,o,1)^n[r],c=Su(a,o,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=s,e[t+n+1]^=c}let t=e[2],i=e[3];for(let n=0;n<24;n++){let r=gu[n],a=xu(t,i,r),o=Su(t,i,r),s=hu[n];t=e[s],i=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=yu[r],e[1]^=bu[r]}As(n)}var wu=class e extends Ks{constructor(e,t,n,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=i,ws(n),!(0<e&&e<200))throw Error(`only keccak-f1600 function is supported`);this.state=new Uint8Array(200),this.state32=ks(this.state)}clone(){return this._cloneInto()}keccak(){Is(this.state32),Cu(this.state32,this.rounds),Is(this.state32),this.posOut=0,this.pos=0}update(e){Ds(this),e=Hs(e),Ts(e);let{blockLen:t,state:n}=this,r=e.length;for(let i=0;i<r;){let a=Math.min(t-this.pos,r-i);for(let t=0;t<a;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){Ds(this,!1),Ts(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not possible for this instance`);return this.writeInto(e)}xof(e){return ws(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Os(e,this),this.finished)throw Error(`digest() was already called`);return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,As(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}},Tu=(e,t,n)=>qs(()=>new wu(t,e,n)),Eu=Tu(6,144,224/8),Du=Tu(6,136,256/8),Ou=Tu(6,104,384/8),ku=Tu(6,72,512/8);Tu(1,144,224/8),Tu(1,136,256/8),Tu(1,104,384/8),Tu(1,72,512/8);var Au=(e,t,n)=>Js((r={})=>new wu(t,e,r.dkLen===void 0?n:r.dkLen,!0)),ju=Au(31,168,128/8),Mu=Au(31,136,256/8),Nu=Ts,Pu=Ys;function Fu(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function Iu(...e){let t=e=>typeof e==`number`?e:e.bytesLen,n=e.reduce((e,n)=>e+t(n),0);return{bytesLen:n,encode:r=>{let i=new Uint8Array(n);for(let n=0,a=0;n<e.length;n++){let o=e[n],s=t(o),c=typeof o==`number`?r[n]:o.encode(r[n]);Nu(c,s),i.set(c,a),typeof o!=`number`&&c.fill(0),a+=s}return i},decode:r=>{Nu(r,n);let i=[];for(let n of e){let e=t(n),a=r.subarray(0,e);i.push(typeof n==`number`?a:n.decode(a)),r=r.subarray(e)}return i}}}function Lu(e,t){let n=t*e.bytesLen;return{bytesLen:n,encode:r=>{if(r.length!==t)throw Error(`vecCoder.encode: wrong length=${r.length}. Expected: ${t}`);let i=new Uint8Array(n);for(let t=0,n=0;t<r.length;t++){let a=e.encode(r[t]);i.set(a,n),a.fill(0),n+=a.length}return i},decode:t=>{Nu(t,n);let r=[];for(let n=0;n<t.length;n+=e.bytesLen)r.push(e.decode(t.subarray(n,n+e.bytesLen)));return r}}}function Ru(...e){for(let t of e)if(Array.isArray(t))for(let e of t)e.fill(0);else t.fill(0)}function zu(e){return(1<<e)-1}var Bu=new Uint8Array;function Vu(e,t=Bu){if(Nu(e),Nu(t),t.length>255)throw Error(`context should be less than 255 bytes`);return Ws(new Uint8Array([0,t.length]),t,e)}var Hu={"SHA2-256":{oid:Bs(`0609608648016503040201`),hash:Wc},"SHA2-384":{oid:Bs(`0609608648016503040202`),hash:qc},"SHA2-512":{oid:Bs(`0609608648016503040203`),hash:Kc},"SHA2-224":{oid:Bs(`0609608648016503040204`),hash:Gc},"SHA2-512/224":{oid:Bs(`0609608648016503040205`),hash:Yc},"SHA2-512/256":{oid:Bs(`0609608648016503040206`),hash:Jc},"SHA3-224":{oid:Bs(`0609608648016503040207`),hash:Eu},"SHA3-256":{oid:Bs(`0609608648016503040208`),hash:Du},"SHA3-384":{oid:Bs(`0609608648016503040209`),hash:Ou},"SHA3-512":{oid:Bs(`060960864801650304020A`),hash:ku},"SHAKE-128":{oid:Bs(`060960864801650304020B`),hash:e=>ju(e,{dkLen:32})},"SHAKE-256":{oid:Bs(`060960864801650304020C`),hash:e=>Mu(e,{dkLen:64})}};function Uu(e,t,n=Bu){if(Nu(t),Nu(n),n.length>255)throw Error(`context should be less than 255 bytes`);if(!Hu[e])throw Error(`unknown hash: `+e);let{oid:r,hash:i}=Hu[e],a=i(t);return Ws(new Uint8Array([1,n.length]),n,r,a)}function Wu(e,t=8){let n=e.toString(2).padStart(8,`0`).slice(-t).padStart(7,`0`).split(``).reverse().join(``);return Number.parseInt(n,2)}var Gu=e=>{let{newPoly:t,N:n,Q:r,F:i,ROOT_OF_UNITY:a,brvBits:o,isKyber:s}=e,c=(e,t=r)=>{let n=e%t|0;return(n>=0?n|0:t+n|0)|0},l=(e,t=r)=>{let n=c(e,t)|0;return(n>t>>1?n-t|0:n)|0};function u(){let e=t(n);for(let t=0;t<n;t++){let n=Wu(t,o),i=BigInt(a)**BigInt(n)%BigInt(r);e[t]=Number(i)|0}return e}let d=u(),f=s?128:n,p=+!!s;return{mod:c,smod:l,nttZetas:d,NTT:{encode:e=>{for(let t=1,r=128;r>p;r>>=1)for(let i=0;i<n;i+=2*r){let n=d[t++];for(let t=i;t<i+r;t++){let i=c(n*e[t+r]);e[t+r]=c(e[t]-i)|0,e[t]=c(e[t]+i)|0}}return e},decode:e=>{for(let t=f-1,r=1+p;r<f+p;r<<=1)for(let i=0;i<n;i+=2*r){let n=d[t--];for(let t=i;t<i+r;t++){let i=e[t];e[t]=c(i+e[t+r]),e[t+r]=c(n*(e[t+r]-i))}}for(let t=0;t<e.length;t++)e[t]=c(i*e[t]);return e}},bitsCoder:(e,r)=>{let i=zu(e),a=n/8*e;return{bytesLen:a,encode:t=>{let n=new Uint8Array(a);for(let a=0,o=0,s=0,c=0;a<t.length;a++)for(o|=(r.encode(t[a])&i)<<s,s+=e;s>=8;s-=8,o>>=8)n[c++]=o&zu(s);return n},decode:a=>{let o=t(n);for(let t=0,n=0,s=0,c=0;t<a.length;t++)for(n|=a[t]<<s,s+=8;s>=e;s-=e,n>>=e)o[c++]=r.decode(n&i);return o}}}}},Ku=e=>(t,n)=>{n||=e.blockLen;let r=new Uint8Array(t.length+2);r.set(t);let i=t.length,a=new Uint8Array(n),o=e.create({}),s=0,c=0;return{stats:()=>({calls:s,xofs:c}),get:(t,n)=>(r[i+0]=t,r[i+1]=n,o.destroy(),o=e.create({}).update(r),s++,()=>(c++,o.xofInto(a))),clean:()=>{o.destroy(),a.fill(0),r.fill(0)}}},qu=Ku(ju),Ju=Ku(Mu),Yu=256,Xu=8380417,Zu=1753,Qu=8347681,$u=13,ed=Math.floor((Xu-1)/88)|0,td=Math.floor((Xu-1)/32)|0,nd={2:{K:4,L:4,D:$u,GAMMA1:2**17,GAMMA2:ed,TAU:39,ETA:2,OMEGA:80},3:{K:6,L:5,D:$u,GAMMA1:2**19,GAMMA2:td,TAU:49,ETA:4,OMEGA:55},5:{K:8,L:7,D:$u,GAMMA1:2**19,GAMMA2:td,TAU:60,ETA:2,OMEGA:75}},rd=e=>new Int32Array(e),{mod:id,smod:ad,NTT:od,bitsCoder:sd}=Gu({N:Yu,Q:Xu,F:Qu,ROOT_OF_UNITY:Zu,newPoly:rd,isKyber:!1,brvBits:8}),cd=e=>e,ld=(e,t=cd,n=cd)=>sd(e,{encode:e=>t(n(e)),decode:e=>n(t(e))}),ud=(e,t)=>{for(let n=0;n<e.length;n++)e[n]=id(e[n]+t[n]);return e},dd=(e,t)=>{for(let n=0;n<e.length;n++)e[n]=id(e[n]-t[n]);return e},fd=e=>{for(let t=0;t<Yu;t++)e[t]<<=$u;return e},pd=(e,t)=>{for(let n=0;n<Yu;n++)if(Math.abs(ad(e[n]))>=t)return!0;return!1},md=(e,t)=>{let n=rd(Yu);for(let r=0;r<e.length;r++)n[r]=id(e[r]*t[r]);return n};function hd(e){let t=rd(Yu);for(let n=0;n<Yu;){let r=e();if(r.length%3)throw Error(`RejNTTPoly: unaligned block`);for(let e=0;n<Yu&&e<=r.length-3;e+=3){let i=(r[e+0]|r[e+1]<<8|r[e+2]<<16)&8388607;i<Xu&&(t[n++]=i)}}return t}function gd(e){let{K:t,L:n,GAMMA1:r,GAMMA2:i,TAU:a,ETA:o,OMEGA:s}=e,{CRH_BYTES:c,TR_BYTES:l,C_TILDE_BYTES:u,XOF128:d,XOF256:f}=e;if(![2,4].includes(o))throw Error(`Wrong ETA`);if(![1<<17,1<<19].includes(r))throw Error(`Wrong GAMMA1`);if(![ed,td].includes(i))throw Error(`Wrong GAMMA2`);let p=a*o,m=e=>{let t=id(e),n=ad(t,2*i)|0;return t-n===Xu-1?{r1:0,r0:n-1|0}:{r1:Math.floor((t-n)/(2*i))|0,r0:n}},h=e=>m(e).r1,g=e=>m(e).r0,_=(e,t)=>e<=i||e>Xu-i||e===Xu-i&&t===0?0:1,v=(e,t)=>{let n=Math.floor((Xu-1)/(2*i)),{r1:r,r0:a}=m(t);return e===1?a>0?id(r+1,n)|0:id(r-1,n)|0:r|0},y=e=>{let t=id(e),n=ad(t,2**$u)|0;return{r1:Math.floor((t-n)/2**$u)|0,r0:n}},b={bytesLen:s+t,encode:e=>{if(e===!1)throw Error(`hint.encode: hint is false`);let n=new Uint8Array(s+t);for(let r=0,i=0;r<t;r++){for(let t=0;t<Yu;t++)e[r][t]!==0&&(n[i++]=t);n[s+r]=i}return n},decode:e=>{let n=[],r=0;for(let i=0;i<t;i++){let t=rd(Yu);if(e[s+i]<r||e[s+i]>s)return!1;for(let n=r;n<e[s+i];n++){if(n>r&&e[n]<=e[n-1])return!1;t[e[n]]=1}r=e[s+i],n.push(t)}for(let t=r;t<s;t++)if(e[t]!==0)return!1;return n}},ee=ld(o===2?3:4,e=>o-e,e=>{if(!(-o<=e&&e<=o))throw Error(`malformed key s1/s3 ${e} outside of ETA range [${-o}, ${o}]`);return e}),x=ld(13,e=>(1<<$u-1)-e),te=ld(10),ne=ld(r===1<<17?18:20,e=>ad(r-e)),re=Lu(ld(i===ed?6:4),t),ie=Iu(32,Lu(te,t)),ae=Iu(32,32,l,Lu(ee,n),Lu(ee,t),Lu(x,t)),oe=Iu(u,Lu(ne,n),b),se=o===2?e=>e<15?2-e%5:!1:e=>e<9?4-e:!1;function ce(e){let t=rd(Yu);for(let n=0;n<Yu;){let r=e();for(let e=0;n<Yu&&e<r.length;e+=1){let i=se(r[e]&15),a=se(r[e]>>4&15);i!==!1&&(t[n++]=i),n<Yu&&a!==!1&&(t[n++]=a)}}return t}let le=e=>{let t=rd(Yu),n=Mu.create({}).update(e),r=new Uint8Array(Mu.blockLen);n.xofInto(r);let i=r.slice(0,8);for(let e=Yu-a,o=8,s=0,c=0;e<Yu;e++){let a=e+1;for(;a>e;)a=r[o++],!(o<Mu.blockLen)&&(n.xofInto(r),o=0);t[e]=t[a],t[a]=1-((i[s]>>c++&1)<<1),c>=8&&(s++,c=0)}return t},S=e=>{let t=rd(Yu),n=rd(Yu);for(let r=0;r<e.length;r++){let{r0:i,r1:a}=y(e[r]);t[r]=i,n[r]=a}return{r0:t,r1:n}},ue=(e,t)=>{for(let n=0;n<Yu;n++)e[n]=v(t[n],e[n]);return e},de=(e,t)=>{let n=rd(Yu),r=0;for(let i=0;i<Yu;i++){let a=_(e[i],t[i]);n[i]=a,r+=a}return{v:n,cnt:r}},fe=Iu(32,64,32),pe={signRandBytes:32,keygen:e=>{let r=new Uint8Array(34),i=e===void 0;i&&(e=Pu(32)),Nu(e,32),r.set(e),i&&e.fill(0),r[32]=t,r[33]=n;let[a,o,s]=fe.decode(Mu(r,{dkLen:fe.bytesLen})),c=f(o),u=[];for(let e=0;e<n;e++)u.push(ce(c.get(e&255,e>>8&255)));let p=[];for(let e=n;e<n+t;e++)p.push(ce(c.get(e&255,e>>8&255)));let m=u.map(e=>od.encode(e.slice())),h=[],g=[],_=d(a),v=rd(Yu);for(let e=0;e<t;e++){v.fill(0);for(let t=0;t<n;t++)ud(v,md(hd(_.get(t,e)),m[t]));od.decode(v);let{r0:t,r1:r}=S(ud(v,p[e]));h.push(t),g.push(r)}let y=ie.encode([a,g]),b=Mu(y,{dkLen:l}),ee=ae.encode([a,s,b,u,p,h]);return _.clean(),c.clean(),Ru(a,o,s,u,p,m,v,h,g,b,r),{publicKey:y,secretKey:ee}},sign:(e,a,o,l=!1)=>{let[m,_,v,y,b,ee]=ae.decode(e),x=[],te=d(m);for(let e=0;e<t;e++){let t=[];for(let r=0;r<n;r++)t.push(hd(te.get(r,e)));x.push(t)}te.clean();for(let e=0;e<n;e++)od.encode(y[e]);for(let e=0;e<t;e++)od.encode(b[e]),od.encode(ee[e]);let ie=l?a:Mu.create({dkLen:c}).update(v).update(a).digest(),se=o||new Uint8Array(32);Nu(se);let ce=Mu.create({dkLen:c}).update(_).update(se).update(ie).digest();Nu(ce,c);let S=f(ce,ne.bytesLen);main_loop:for(let e=0;;){let a=[];for(let t=0;t<n;t++,e++)a.push(ne.decode(S.get(e&255,e>>8)()));let o=a.map(e=>od.encode(e.slice())),c=[];for(let e=0;e<t;e++){let t=rd(Yu);for(let r=0;r<n;r++)ud(t,md(x[e][r],o[r]));od.decode(t),c.push(t)}let l=c.map(e=>e.map(h)),d=Mu.create({dkLen:u}).update(ie).update(re.encode(l)).digest(),f=od.encode(le(d)),m=y.map(e=>md(e,f));for(let e=0;e<n;e++)if(ud(od.decode(m[e]),a[e]),pd(m[e],r-p))continue main_loop;let _=0,v=[];for(let e=0;e<t;e++){let t=od.decode(md(b[e],f)),n=dd(c[e],t).map(g);if(pd(n,i-p))continue main_loop;let r=od.decode(md(ee[e],f));if(pd(r,i))continue main_loop;ud(n,r);let a=de(n,l[e]);v.push(a.v),_+=a.cnt}if(_>s)continue;S.clean();let te=oe.encode([d,m,v]);return Ru(d,m,v,f,l,c,o,a,ce,ie,y,b,ee,...x),te}throw Error(`Unreachable code path reached, report this error`)},verify:(e,i,a,o=!1)=>{let[f,m]=ie.decode(e),h=Mu(e,{dkLen:l});if(a.length!==oe.bytesLen)return!1;let[g,_,v]=oe.decode(a);if(v===!1)return!1;for(let e=0;e<n;e++)if(pd(_[e],r-p))return!1;let y=o?i:Mu.create({dkLen:c}).update(h).update(i).digest(),b=od.encode(le(g)),ee=_.map(e=>e.slice());for(let e=0;e<n;e++)od.encode(ee[e]);let x=[],te=d(f);for(let e=0;e<t;e++){let t=md(od.encode(fd(m[e])),b),r=rd(Yu);for(let t=0;t<n;t++)ud(r,md(hd(te.get(t,e)),ee[t]));let i=od.decode(dd(r,t));x.push(ue(i,v[e]))}te.clean();let ne=Mu.create({dkLen:u}).update(y).update(re.encode(x)).digest();for(let e of v)if(!(e.reduce((e,t)=>e+t,0)<=s))return!1;for(let e of _)if(pd(e,r-p))return!1;return Fu(g,ne)}};return{internal:pe,keygen:pe.keygen,signRandBytes:pe.signRandBytes,sign:(e,t,n=Bu,r)=>{let i=Vu(t,n),a=pe.sign(e,i,r);return i.fill(0),a},verify:(e,t,n,r=Bu)=>pe.verify(e,Vu(t,r),n),prehash:e=>({sign:(t,n,r=Bu,i)=>{let a=Uu(e,n,r),o=pe.sign(t,a,i);return a.fill(0),o},verify:(t,n,r,i=Bu)=>pe.verify(t,Uu(e,n,i),r)})}}({...nd[2]});var _d=gd({...nd[3],CRH_BYTES:64,TR_BYTES:64,C_TILDE_BYTES:48,XOF128:qu,XOF256:Ju});({...nd[5]});var vd={generateKeyPair:yd,sign:bd,verify:xd};function yd(e){e??=Pu(32);let t=_d.keygen(e);return{publicKey:t.publicKey,privateKey:t.secretKey}}function bd(e,t){return _d.sign(e,t)}function xd(e,t,n){return _d.verify(e,t,n)}var Sd=256,Cd=3329,{mod:wd,nttZetas:Td,NTT:Ed,bitsCoder:Dd}=Gu({N:Sd,Q:Cd,F:3303,ROOT_OF_UNITY:17,newPoly:e=>new Uint16Array(e),brvBits:7,isKyber:!0}),Od={512:{N:Sd,Q:Cd,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:Sd,Q:Cd,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:Sd,Q:Cd,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},kd=e=>{if(e>=12)return{encode:e=>e,decode:e=>e};let t=2**(e-1);return{encode:t=>((t<<e)+Cd/2)/Cd,decode:n=>n*Cd+t>>>e}},Ad=e=>Dd(e,kd(e));function jd(e,t){for(let n=0;n<Sd;n++)e[n]=wd(e[n]+t[n])}function Md(e,t){for(let n=0;n<Sd;n++)e[n]=wd(e[n]-t[n])}function Nd(e,t,n,r,i){return{c0:wd(t*r*i+e*n),c1:wd(e*r+t*n)}}function Pd(e,t){for(let n=0;n<Sd/2;n++){let r=Td[64+(n>>1)];n&1&&(r=-r);let{c0:i,c1:a}=Nd(e[2*n+0],e[2*n+1],t[2*n+0],t[2*n+1],r);e[2*n+0]=i,e[2*n+1]=a}return e}function Fd(e){let t=new Uint16Array(Sd);for(let n=0;n<Sd;){let r=e();if(r.length%3)throw Error(`SampleNTT: unaligned block`);for(let e=0;n<Sd&&e+3<=r.length;e+=3){let i=(r[e+0]>>0|r[e+1]<<8)&4095,a=(r[e+1]>>4|r[e+2]<<4)&4095;i<Cd&&(t[n++]=i),n<Sd&&a<Cd&&(t[n++]=a)}}return t}function Id(e,t,n,r){let i=e(r*Sd/4,t,n),a=new Uint16Array(Sd),o=ks(i),s=0;for(let e=0,t=0,n=0,i=0;e<o.length;e++){let c=o[e];for(let e=0;e<32;e++)n+=c&1,c>>=1,s+=1,s===r?(i=n,n=0):s===2*r&&(a[t++]=wd(i-n),n=0,s=0)}if(s)throw Error(`sampleCBD: leftover bits: ${s}`);return a}var Ld=e=>{let{K:t,PRF:n,XOF:r,HASH512:i,ETA1:a,ETA2:o,du:s,dv:c}=e,l=Ad(1),u=Ad(c),d=Ad(s),f=Iu(Lu(Ad(12),t),32),p=Lu(Ad(12),t),m=Iu(Lu(d,t),u),h=Iu(32,32);return{secretCoder:p,secretKeyLen:p.bytesLen,publicKeyLen:f.bytesLen,cipherTextLen:m.bytesLen,keygen:e=>{Nu(e,32);let o=new Uint8Array(33);o.set(e),o[32]=t;let s=i(o),[c,l]=h.decode(s),u=[],d=[];for(let e=0;e<t;e++)u.push(Ed.encode(Id(n,l,e,a)));let m=r(c);for(let e=0;e<t;e++){let r=Ed.encode(Id(n,l,t+e,a));for(let n=0;n<t;n++)jd(r,Pd(Fd(m.get(n,e)),u[n]));d.push(r)}m.clean();let g={publicKey:f.encode([d,c]),secretKey:p.encode(u)};return Ru(c,l,u,d,o,s),g},encrypt:(e,i,s)=>{let[c,u]=f.decode(e),d=[];for(let e=0;e<t;e++)d.push(Ed.encode(Id(n,s,e,a)));let p=r(u),h=new Uint16Array(Sd),g=[];for(let e=0;e<t;e++){let r=Id(n,s,t+e,o),i=new Uint16Array(Sd);for(let n=0;n<t;n++)jd(i,Pd(Fd(p.get(e,n)),d[n]));jd(r,Ed.decode(i)),g.push(r),jd(h,Pd(c[e],d[e])),i.fill(0)}p.clean();let _=Id(n,s,2*t,o);jd(_,Ed.decode(h));let v=l.decode(i);return jd(v,_),Ru(c,d,h,_),m.encode([g,v])},decrypt:(e,n)=>{let[r,i]=m.decode(e),a=p.decode(n),o=new Uint16Array(Sd);for(let e=0;e<t;e++)jd(o,Pd(a[e],Ed.encode(r[e])));return Md(i,Ed.decode(o)),Ru(o,a,r),l.encode(i)}}};function Rd(e){let t=Ld(e),{HASH256:n,HASH512:r,KDF:i}=e,{secretCoder:a,cipherTextLen:o}=t,s=t.publicKeyLen,c=Iu(t.secretKeyLen,t.publicKeyLen,32,32),l=c.bytesLen;return{publicKeyLen:s,msgLen:32,keygen:(e=Pu(64))=>{Nu(e,64);let{publicKey:r,secretKey:i}=t.keygen(e.subarray(0,32)),a=n(r),o=c.encode([i,r,a,e.subarray(32)]);return Ru(i,a),{publicKey:r,secretKey:o}},encapsulate:(i,o=Pu(32))=>{Nu(i,s),Nu(o,32);let c=i.subarray(0,384*e.K),l=a.encode(a.decode(c.slice()));if(!Fu(l,c))throw Ru(l),Error(`ML-KEM.encapsulate: wrong publicKey modulus`);Ru(l);let u=r.create().update(o).update(n(i)).digest(),d=t.encrypt(i,o,u.subarray(32,64));return u.subarray(32).fill(0),{cipherText:d,sharedSecret:u.subarray(0,32)}},decapsulate:(e,n)=>{Nu(n,l),Nu(e,o);let[a,s,u,d]=c.decode(n),f=t.decrypt(e,a),p=r.create().update(f).update(u).digest(),m=p.subarray(0,32),h=t.encrypt(s,f,p.subarray(32,64)),g=Fu(e,h),_=i.create({dkLen:32}).update(d).update(e).digest();return Ru(f,h,g?_:m),g?m:_}}}function zd(e,t,n){return Mu.create({dkLen:e}).update(t).update(new Uint8Array([n])).digest()}var Bd={HASH256:Du,HASH512:ku,KDF:Mu,XOF:qu,PRF:zd};({...Bd,...Od[512]});var Vd=Rd({...Bd,...Od[768]});({...Bd,...Od[1024]});var Hd={generateKeyPair:Ud,encapsulate:Wd,decapsulate:Gd};function Ud(e){return e??=Pu(64),Vd.keygen(e)}function Wd(e){return Vd.encapsulate(e)}function Gd(e,t){return Vd.decapsulate(e,t)}var Kd=Wc,qd=class extends Ks{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Es(e);let n=Hs(t);if(this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),As(i)}update(e){return Ds(this),this.iHash.update(e),this}digestInto(e){Ds(this),Ts(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Jd=(e,t,n)=>new qd(e,t).update(n).digest();Jd.create=(e,t)=>new qd(e,t);var{p:Yd,n:Xd,Gx:Zd,Gy:Qd,b:$d}={p:115792089237316195423570985008687907853269984665640564039457584007908834671663n,n:115792089237316195423570985008687907852837564279074904382605163141518161494337n,h:1n,a:0n,b:7n,Gx:55066263022277343669578718895168534326250603453777594175500187360389116729240n,Gy:32670510020758816978083085130507043184471273380659243275938904335757337482424n},ef=32,tf=64,nf=(e=``)=>{throw Error(e)},rf=e=>typeof e==`bigint`,af=e=>typeof e==`string`,of=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`,sf=(e,t)=>!of(e)||typeof t==`number`&&t>0&&e.length!==t?nf(`Uint8Array expected`):e,cf=e=>new Uint8Array(e),lf=e=>Uint8Array.from(e),uf=(e,t)=>e.toString(16).padStart(t,`0`),df=e=>Array.from(sf(e)).map(e=>uf(e,2)).join(``),ff={_0:48,_9:57,A:65,F:70,a:97,f:102},pf=e=>{if(e>=ff._0&&e<=ff._9)return e-ff._0;if(e>=ff.A&&e<=ff.F)return e-(ff.A-10);if(e>=ff.a&&e<=ff.f)return e-(ff.a-10)},mf=e=>{let t=`hex invalid`;if(!af(e))return nf(t);let n=e.length,r=n/2;if(n%2)return nf(t);let i=cf(r);for(let n=0,a=0;n<r;n++,a+=2){let r=pf(e.charCodeAt(a)),o=pf(e.charCodeAt(a+1));if(r===void 0||o===void 0)return nf(t);i[n]=r*16+o}return i},hf=(e,t)=>sf(af(e)?mf(e):lf(sf(e)),t),gf=()=>globalThis?.crypto,_f=()=>gf()?.subtle??nf(`crypto.subtle must be defined`),vf=(...e)=>{let t=cf(e.reduce((e,t)=>e+sf(t).length,0)),n=0;return e.forEach(e=>{t.set(e,n),n+=e.length}),t},yf=(e=ef)=>gf().getRandomValues(cf(e)),bf=BigInt,xf=(e,t,n,r=`bad number: out of range`)=>rf(e)&&t<=e&&e<n?e:nf(r),M=(e,t=Yd)=>{let n=e%t;return n>=0n?n:t+n},Sf=e=>M(e,Xd),Cf=(e,t)=>{(e===0n||t<=0n)&&nf(`no inverse n=`+e+` mod=`+t);let n=M(e,t),r=t,i=0n,a=1n,o=1n,s=0n;for(;n!==0n;){let e=r/n,t=r%n,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}return r===1n?M(i,t):nf(`no inverse`)},wf=e=>{let t=ip[e];return typeof t!=`function`&&nf(`hashes.`+e+` not set`),t},Tf=e=>e instanceof Pf?e:nf(`Point expected`),Ef=e=>M(M(e*e)*e+$d),Df=e=>xf(e,0n,Yd),Of=e=>xf(e,1n,Yd),kf=e=>xf(e,1n,Xd),Af=e=>(e&1n)==0n,jf=e=>Uint8Array.of(e),Mf=e=>jf(Af(e)?2:3),Nf=e=>{let t=Ef(Of(e)),n=1n;for(let e=t,r=(Yd+1n)/4n;r>0n;r>>=1n)r&1n&&(n=n*e%Yd),e=e*e%Yd;return M(n*n)===t?n:nf(`sqrt invalid`)},Pf=class e{static BASE;static ZERO;px;py;pz;constructor(e,t,n){this.px=Df(e),this.py=Of(t),this.pz=Df(n),Object.freeze(this)}static fromBytes(t){sf(t);let n,r=t[0],i=t.subarray(1),a=zf(i,0,ef),o=t.length;if(o===ef+1&&[2,3].includes(r)){let t=Nf(a),i=Af(t);Af(bf(r))!==i&&(t=M(-t)),n=new e(a,t,1n)}return o===tf+1&&r===4&&(n=new e(a,zf(i,ef,tf),1n)),n?n.assertValidity():nf(`bad point: not on curve`)}equals(e){let{px:t,py:n,pz:r}=this,{px:i,py:a,pz:o}=Tf(e),s=M(t*o),c=M(i*r),l=M(n*o),u=M(a*r);return s===c&&l===u}is0(){return this.equals(If)}negate(){return new e(this.px,M(-this.py),this.pz)}double(){return this.add(this)}add(t){let{px:n,py:r,pz:i}=this,{px:a,py:o,pz:s}=Tf(t),c=0n,l=$d,u=0n,d=0n,f=0n,p=M(l*3n),m=M(n*a),h=M(r*o),g=M(i*s),_=M(n+r),v=M(a+o);_=M(_*v),v=M(m+h),_=M(_-v),v=M(n+i);let y=M(a+s);return v=M(v*y),y=M(m+g),v=M(v-y),y=M(r+i),u=M(o+s),y=M(y*u),u=M(h+g),y=M(y-u),f=M(c*v),u=M(p*g),f=M(u+f),u=M(h-f),f=M(h+f),d=M(u*f),h=M(m+m),h=M(h+m),g=M(c*g),v=M(p*v),h=M(h+g),g=M(m-g),g=M(c*g),v=M(v+g),m=M(h*v),d=M(d+m),m=M(y*v),u=M(_*u),u=M(u-m),m=M(_*h),f=M(y*f),f=M(f+m),new e(u,d,f)}multiply(e,t=!0){if(!t&&e===0n)return If;if(kf(e),e===1n)return this;if(this.equals(Ff))return fp(e).p;let n=If,r=Ff;for(let i=this;e>0n;i=i.double(),e>>=1n)e&1n?n=n.add(i):t&&(r=r.add(i));return n}toAffine(){let{px:e,py:t,pz:n}=this;if(this.equals(If))return{x:0n,y:0n};if(n===1n)return{x:e,y:t};let r=Cf(n,Yd);return M(n*r)!==1n&&nf(`inverse invalid`),{x:M(e*r),y:M(t*r)}}assertValidity(){let{x:e,y:t}=this.toAffine();return Of(e),Of(t),M(t*t)===Ef(e)?this:nf(`bad point: not on curve`)}toBytes(e=!0){let{x:t,y:n}=this.assertValidity().toAffine(),r=Vf(t);return e?vf(Mf(n),r):vf(jf(4),r,Vf(n))}static fromAffine(t){let{x:n,y:r}=t;return n===0n&&r===0n?If:new e(n,r,1n)}toHex(e){return df(this.toBytes(e))}static fromPrivateKey(e){return Ff.multiply(Hf(e))}static fromHex(t){return e.fromBytes(hf(t))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}toRawBytes(e){return this.toBytes(e)}},Ff=new Pf(Zd,Qd,1n),If=new Pf(0n,1n,0n);Pf.BASE=Ff,Pf.ZERO=If;var Lf=(e,t,n)=>Ff.multiply(t,!1).add(e.multiply(n,!1)).assertValidity(),Rf=e=>bf(`0x`+(df(e)||`0`)),zf=(e,t,n)=>Rf(e.subarray(t,n)),Bf=2n**256n,Vf=e=>mf(uf(xf(e,0n,Bf),tf)),Hf=e=>xf(rf(e)?e:Rf(hf(e,ef)),1n,Xd,`private key invalid 3`),Uf=e=>e>Xd>>1n,Wf=(e,t=!0)=>Ff.multiply(Hf(e)).toBytes(t),Gf=class e{r;s;recovery;constructor(e,t,n){this.r=kf(e),this.s=kf(t),n!=null&&(this.recovery=n),Object.freeze(this)}static fromBytes(t){return sf(t,tf),new e(zf(t,0,ef),zf(t,ef,tf))}toBytes(){let{r:e,s:t}=this;return vf(Vf(e),Vf(t))}addRecoveryBit(t){return new e(this.r,this.s,t)}hasHighS(){return Uf(this.s)}toCompactRawBytes(){return this.toBytes()}toCompactHex(){return df(this.toBytes())}recoverPublicKey(e){return ep(this,e)}static fromCompact(t){return e.fromBytes(hf(t,tf))}assertValidity(){return this}normalizeS(){let{r:t,s:n,recovery:r}=this;return Uf(n)?new e(t,Sf(-n),r):this}},Kf=e=>{let t=e.length*8-256;t>1024&&nf(`msg invalid`);let n=Rf(e);return t>0?n>>bf(t):n},qf=e=>Sf(Kf(sf(e))),Jf={lowS:!0},Yf={lowS:!0},Xf=(e,t,n=Jf)=>{[`der`,`recovered`,`canonical`].some(e=>e in n)&&nf(`option not supported`);let{lowS:r,extraEntropy:i}=n;r??=!0;let a=Vf,o=qf(hf(e)),s=a(o),c=Hf(t),l=[a(c),s];i&&l.push(i===!0?yf(ef):hf(i));let u=o,d=e=>{let t=Kf(e);if(!(1n<=t&&t<Xd))return;let n=Ff.multiply(t).toAffine(),i=Sf(n.x);if(i===0n)return;let a=Sf(Cf(t,Xd)*Sf(u+Sf(c*i)));if(a===0n)return;let o=a,s=(n.x===i?0:2)|Number(n.y&1n);return r&&Uf(a)&&(o=Sf(-a),s^=1),new Gf(i,o,s)};return{seed:vf(...l),k2sig:d}},Zf=e=>{let t=cf(ef),n=cf(ef),r=0,i=cf(0),a=()=>{t.fill(1),n.fill(0),r=0},o=1e3,s=`drbg: tried 1000 values`;if(e){let e=(...e)=>ip.hmacSha256Async(n,t,...e),c=async(r=i)=>{n=await e(jf(0),r),t=await e(),r.length!==0&&(n=await e(jf(1),r),t=await e())},l=async()=>(r++>=o&&nf(s),t=await e(),t);return async(e,t)=>{a(),await c(e);let n;for(;!(n=t(await l()));)await c();return a(),n}}else{let e=(...e)=>wf(`hmacSha256Sync`)(n,t,...e),c=(r=i)=>{n=e(jf(0),r),t=e(),r.length!==0&&(n=e(jf(1),r),t=e())},l=()=>(r++>=o&&nf(s),t=e(),t);return(e,t)=>{a(),c(e);let n;for(;!(n=t(l()));)c();return a(),n}}},Qf=(e,t,n=Jf)=>{let{seed:r,k2sig:i}=Xf(e,t,n);return Zf(!1)(r,i)},$f=(e,t,n,r=Yf)=>{let{lowS:i}=r;i??=!0,`strict`in r&&nf(`option not supported`);let a,o=e&&typeof e==`object`&&`r`in e;!o&&hf(e).length!==tf&&nf(`signature must be 64 bytes`);try{a=o?new Gf(e.r,e.s):Gf.fromCompact(e);let r=qf(hf(t)),s=Pf.fromBytes(hf(n)),{r:c,s:l}=a;if(i&&Uf(l))return!1;let u=Cf(l,Xd);return Sf(Lf(s,Sf(r*u),Sf(c*u)).toAffine().x)===c}catch{return!1}},ep=(e,t)=>{let{r:n,s:r,recovery:i}=e;[0,1,2,3].includes(i)||nf(`recovery id invalid`);let a=qf(hf(t,ef)),o=i===2||i===3?n+Xd:n;Of(o);let s=vf(Mf(bf(i)),Vf(o)),c=Pf.fromBytes(s),l=Cf(o,Xd);return Lf(c,Sf(-a*l),Sf(r*l))},tp=e=>(e=hf(e),(e.length<ef+8||e.length>1024)&&nf(`expected 40-1024b`),Vf(M(Rf(e),Xd-1n)+1n)),np=()=>tp(yf(ef+16)),rp=`SHA-256`,ip={hexToBytes:mf,bytesToHex:df,concatBytes:vf,bytesToNumberBE:Rf,numberToBytesBE:Vf,mod:M,invert:Cf,hmacSha256Async:async(e,...t)=>{let n=_f(),r=`HMAC`,i=await n.importKey(`raw`,e,{name:r,hash:{name:rp}},!1,[`sign`]);return cf(await n.sign(r,i,vf(...t)))},hmacSha256Sync:void 0,hashToPrivateKey:tp,randomBytes:yf},ap={normPrivateKeyToScalar:Hf,isValidPrivateKey:e=>{try{return!!Hf(e)}catch{return!1}},randomPrivateKey:np,precompute:(e=8,t=Ff)=>(t.multiply(3n),t)},op=8,sp=Math.ceil(256/op)+1,cp=2**(op-1),lp=()=>{let e=[],t=Ff,n=t;for(let r=0;r<sp;r++){n=t,e.push(n);for(let r=1;r<cp;r++)n=n.add(t),e.push(n);t=n.double()}return e},up=void 0,dp=(e,t)=>{let n=t.negate();return e?n:t},fp=e=>{let t=up||=lp(),n=If,r=Ff,i=2**op,a=i,o=bf(i-1),s=bf(op);for(let i=0;i<sp;i++){let c=Number(e&o);e>>=s,c>cp&&(c-=a,e+=1n);let l=i*cp,u=l,d=l+Math.abs(c)-1,f=i%2!=0,p=c<0;c===0?r=r.add(dp(f,t[u])):n=n.add(dp(p,t[d]))}return{p:n,f:r}};ip.hmacSha256Sync=(e,...t)=>Jd(Kd,e,ip.concatBytes(...t));var pp={publicKeyFromPrivateKey:mp,sign:hp,verify:gp};function mp(e){return Wf(e)}function hp(e,t){return Qf(Kd(t),e).toCompactRawBytes()}function gp(e,t,n){return $f(n,Kd(t),e)}var _p={SECP256K1:0,ML_DSA:1},vp=[{name:`SECP256K1`,signatureSectionSize:65},{name:`ML_DSA`,signatureSectionSize:3311}],yp={ML_KEM:0},bp=[{name:`ML-KEM`}],xp={..._p,SIG_SCHEMES:vp,...yp,KEM_SCHEMES:bp,Random:Xs,Hashes:Zc,Aes:ou,MLDsa:vd,MLKem:Hd,Secp256k1:pp},Sp;function Cp(e){return{lang:e?.lang??Sp?.lang,message:e?.message,abortEarly:e?.abortEarly??Sp?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Sp?.abortPipeEarly}}var wp;function Tp(e){return wp?.get(e)}var Ep;function Dp(e){return Ep?.get(e)}var Op;function kp(e,t){return Op?.get(e)?.get(t)}function Ap(e){let t=typeof e;return t===`string`?`"${e}"`:t===`number`||t===`bigint`||t===`boolean`?`${e}`:t===`object`||t===`function`?(e&&Object.getPrototypeOf(e)?.constructor?.name)??`null`:t}function jp(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??Ap(a),c={kind:e.kind,type:e.type,input:a,expected:o,received:s,message:`Invalid ${t}: ${o?`Expected ${o} but r`:`R`}eceived ${s}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=e.kind===`schema`,u=i?.message??e.message??kp(e.reference,c.lang)??(l?Dp(c.lang):null)??r.message??Tp(c.lang);u!==void 0&&(c.message=typeof u==`function`?u(c):u),l&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}function Mp(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},Cp())}}}function Np(e,t){return Object.hasOwn(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function Pp(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}var Fp=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function Ip(e){return{kind:`validation`,type:`integer`,reference:Ip,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&jp(this,`integer`,e,t),e}}}function Lp(e,t){return{kind:`validation`,type:`max_length`,reference:Lp,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length>this.requirement&&jp(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function Rp(e,t){return{kind:`validation`,type:`max_value`,reference:Rp,async:!1,expects:`<=${e instanceof Date?e.toJSON():Ap(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value<=this.requirement)&&jp(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():Ap(e.value)}),e}}}function zp(e){return{kind:`metadata`,type:`metadata`,reference:zp,metadata:e}}function Bp(e,t){return{kind:`validation`,type:`min_value`,reference:Bp,async:!1,expects:`>=${e instanceof Date?e.toJSON():Ap(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value>=this.requirement)&&jp(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():Ap(e.value)}),e}}}function Vp(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function Hp(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function Up(e,t){return!e[`~run`]({value:t},{abortEarly:!0}).issues}function Wp(){return{kind:`schema`,type:`any`,reference:Wp,expects:`any`,async:!1,get"~standard"(){return Mp(this)},"~run"(e){return e.typed=!0,e}}}function N(e,t){return{kind:`schema`,type:`array`,reference:N,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return Mp(this)},"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){let i=n[r],a=this.item[`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else jp(this,`type`,e,t);return e}}}function Gp(e){return{kind:`schema`,type:`boolean`,reference:Gp,expects:`boolean`,async:!1,message:e,get"~standard"(){return Mp(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:jp(this,`type`,e,t),e}}}function Kp(e,t){return{kind:`schema`,type:`custom`,reference:Kp,expects:`unknown`,async:!1,check:e,message:t,get"~standard"(){return Mp(this)},"~run"(e,t){return this.check(e.value)?e.typed=!0:jp(this,`type`,e,t),e}}}function qp(e,t){return{kind:`schema`,type:`instance`,reference:qp,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return Mp(this)},"~run"(e,t){return e.value instanceof this.class?e.typed=!0:jp(this,`type`,e,t),e}}}function Jp(e,t){if(typeof e==typeof t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{value:e};if(e&&t&&e.constructor===Object&&t.constructor===Object){for(let n in t)if(n in e){let r=Jp(e[n],t[n]);if(r.issue)return r;e[n]=r.value}else e[n]=t[n];return{value:e}}if(Array.isArray(e)&&Array.isArray(t)&&e.length===t.length){for(let n=0;n<e.length;n++){let r=Jp(e[n],t[n]);if(r.issue)return r;e[n]=r.value}return{value:e}}}return{issue:!0}}function Yp(e,t){return{kind:`schema`,type:`intersect`,reference:Yp,expects:Pp(e.map(e=>e.expects),`&`),async:!1,options:e,message:t,get"~standard"(){return Mp(this)},"~run"(e,t){if(this.options.length){let n=e.value,r;e.typed=!0;for(let i of this.options){let a=i[`~run`]({value:n},t);if(a.issues&&(e.issues?e.issues.push(...a.issues):e.issues=a.issues,t.abortEarly)){e.typed=!1;break}a.typed||(e.typed=!1),e.typed&&(r?r.push(a.value):r=[a.value])}if(e.typed){e.value=r[0];for(let n=1;n<r.length;n++){let i=Jp(e.value,r[n]);if(i.issue){jp(this,`type`,e,t,{received:`unknown`});break}e.value=i.value}}}else jp(this,`type`,e,t);return e}}}function Xp(e){return{kind:`schema`,type:`lazy`,reference:Xp,expects:`unknown`,async:!1,getter:e,get"~standard"(){return Mp(this)},"~run"(e,t){return this.getter(e.value)[`~run`](e,t)}}}function P(e,t){return{kind:`schema`,type:`literal`,reference:P,expects:Ap(e),async:!1,literal:e,message:t,get"~standard"(){return Mp(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:jp(this,`type`,e,t),e}}}function Zp(e){return{kind:`schema`,type:`null`,reference:Zp,expects:`null`,async:!1,message:e,get"~standard"(){return Mp(this)},"~run"(e,t){return e.value===null?e.typed=!0:jp(this,`type`,e,t),e}}}function F(e){return{kind:`schema`,type:`number`,reference:F,expects:`number`,async:!1,message:e,get"~standard"(){return Mp(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:jp(this,`type`,e,t),e}}}function I(e,t){return{kind:`schema`,type:`object`,reference:I,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return Mp(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:Hp(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=Vp(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(jp(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}}else jp(this,`type`,e,t);return e}}}function Qp(e,t,n){return{kind:`schema`,type:`object_with_rest`,reference:Qp,expects:`Object`,async:!1,entries:e,rest:t,message:n,get"~standard"(){return Mp(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:Hp(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=Vp(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(jp(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}if(!e.issues||!t.abortEarly){for(let r in n)if(Np(n,r)&&!(r in this.entries)){let i=this.rest[`~run`]({value:n[r]},t);if(i.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:n[r]};for(let t of i.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=i.issues,t.abortEarly){e.typed=!1;break}}i.typed||(e.typed=!1),e.value[r]=i.value}}}else jp(this,`type`,e,t);return e}}}function $p(e,t){return{kind:`schema`,type:`optional`,reference:$p,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return Mp(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=Hp(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function em(e,t){return{kind:`schema`,type:`picklist`,reference:em,expects:Pp(e.map(Ap),`|`),async:!1,options:e,message:t,get"~standard"(){return Mp(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:jp(this,`type`,e,t),e}}}function tm(e,t,n){return{kind:`schema`,type:`record`,reference:tm,expects:`Object`,async:!1,key:e,value:t,message:n,get"~standard"(){return Mp(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in n)if(Np(n,r)){let i=n[r],a=this.key[`~run`]({value:r},t);if(a.issues){let o={type:`object`,origin:`key`,input:n,key:r,value:i};for(let t of a.issues)t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}let o=this.value[`~run`]({value:i},t);if(o.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:i};for(let t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}(!a.typed||!o.typed)&&(e.typed=!1),a.typed&&(e.value[a.value]=o.value)}}else jp(this,`type`,e,t);return e}}}function L(e){return{kind:`schema`,type:`string`,reference:L,expects:`string`,async:!1,message:e,get"~standard"(){return Mp(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:jp(this,`type`,e,t),e}}}function nm(e){let t;if(e)for(let n of e)t?t.push(...n.issues):t=n.issues;return t}function rm(e,t){return{kind:`schema`,type:`union`,reference:rm,expects:Pp(e.map(e=>e.expects),`|`),async:!1,options:e,message:t,get"~standard"(){return Mp(this)},"~run"(e,t){let n,r,i;for(let a of this.options){let o=a[`~run`]({value:e.value},t);if(o.typed)if(o.issues)r?r.push(o):r=[o];else{n=o;break}else i?i.push(o):i=[o]}if(n)return n;if(r){if(r.length===1)return r[0];jp(this,`type`,e,t,{issues:nm(r)}),e.typed=!0}else if(i?.length===1)return i[0];else jp(this,`type`,e,t,{issues:nm(i)});return e}}}function im(){return{kind:`schema`,type:`unknown`,reference:im,expects:`unknown`,async:!1,get"~standard"(){return Mp(this)},"~run"(e){return e.typed=!0,e}}}function am(e,t,n){return{kind:`schema`,type:`variant`,reference:am,expects:`Object`,async:!1,key:e,options:t,message:n,get"~standard"(){return Mp(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){let r,i=0,a=this.key,o=[],s=(e,c)=>{for(let l of e.options){if(l.type===`variant`)s(l,new Set(c).add(l.key));else{let e=!0,s=0;for(let t of c){let r=l.entries[t];if(t in n?r[`~run`]({typed:!1,value:n[t]},{abortEarly:!0}).issues:r.type!==`exact_optional`&&r.type!==`optional`&&r.type!==`nullish`){e=!1,a!==t&&(i<s||i===s&&t in n&&!(a in n))&&(i=s,a=t,o=[]),a===t&&o.push(l.entries[t].expects);break}s++}if(e){let e=l[`~run`]({value:n},t);(!r||!r.typed&&e.typed)&&(r=e)}}if(r&&!r.issues)break}};if(s(this,new Set([this.key])),r)return r;jp(this,`type`,e,t,{input:n[a],expected:Pp(o,`|`),path:[{type:`object`,origin:`value`,input:n,key:a,value:n[a]}]})}else jp(this,`type`,e,t);return e}}}function R(e,t,n){let r=e[`~run`]({value:t},Cp(n));if(r.issues)throw new Fp(r.issues);return r.value}function z(...e){return{...e[0],pipe:e,get"~standard"(){return Mp(this)},"~run"(t,n){for(let r of e)if(r.kind!==`metadata`){if(t.issues&&(r.kind===`schema`||r.kind===`transformation`)){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r[`~run`](t,n))}return t}}}function om(e,t,n){let r=e[`~run`]({value:t},Cp(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var sm=0,cm=1,lm=2,um=3,dm=4,fm=5,pm=6,mm=7,hm=8,gm=9,_m=10,vm=11,ym=12,bm=13;function xm(e){return z(N(e.items),zp({typeId:0,elementSchema:e.items,...e}))}function Sm(e={}){let t=e&&e.size||-1;return z(L(),Kp(e=>typeof e==`string`&&(t===-1||e.length===t),`Expected size is ${t} bytes`),zp({typeId:2,size:t,...e}))}function Cm(e={}){return z(F(),zp({typeId:3,...e}))}function wm(e={}){return z(Gp(),zp({typeId:4,...e}))}function Tm(e,t,n){return z(F(),Ip(),Bp(0),Rp(2**t-1),zp({typeId:e,...n}))}function Em(e={}){return Tm(6,8,e)}function Dm(e={}){return Tm(7,16,e)}function Om(e={}){return Tm(8,24,e)}function km(e={}){return Tm(9,32,e)}function Am(e={}){return Tm(10,48,e)}function jm(e={}){let t=e&&e.size||-1;return z(qp(Uint8Array),Kp(e=>e instanceof Uint8Array&&(t===-1||e.length===t),`Expected size is ${t} bytes`),zp({typeId:11,...e}))}function Mm(e={}){return z(qp(Uint8Array),Kp(e=>e instanceof Uint8Array&&e.length===32,`Expected Uint8Array of 32 bytes`),zp({typeId:12,...e}))}function B(){return qp(Uint8Array)}function Nm(){return B()}function Pm(){return V()}function V(){return z(F(),Ip(),Bp(0))}function Fm(){return z(F(),Ip(),Bp(1))}function Im(){return z(F(),Ip(),Bp(0))}var Lm=I({magicString:P(Un),microblockType:V(),height:V(),previousHash:B(),timestamp:V(),gas:V(),gasPrice:V(),bodyHash:B(),feesPayerAccount:B()}),Rm=I({retentionRatio:F(),maximumNumberOfDays:F(),dayDivisor:F()}),zm=N(Rm),Bm=I({numberOfDays:F(),retentionRatio:F(),costInGasAtoms:F()}),Vm=I({protocolVersionName:L(),protocolVersion:Fm(),feesCalculationVersion:Fm(),fixedGasCost:V(),secp256k1SignatureGasCost:V(),mlDsa65SignatureGasCost:V(),pkmsSecp256k1SignatureGasCost:V(),globalStateUpdaterVersion:Fm(),applicationLedgerInternalStateUpdaterVersion:Fm(),applicationInternalStateUpdaterVersion:Fm(),organizationInternalStateUpdaterVersion:Fm(),validatorNodeInternalStateUpdaterVersion:Fm(),accountInternalStateUpdaterVersion:Fm(),protocolInternalStateUpdaterVersion:Fm(),minimumNodeStakingAmountInAtomics:Fm(),maximumNodeStakingAmountInAtomics:Fm(),unstakingDelayInDays:V(),maxBlockSizeInBytes:Fm(),retentionPolicy:zm,abciVersion:Fm(),maxMicroblocksPerBlock:Fm()}),Hm=I({protocolVersion:F(),protocolVersionName:L(),changeLog:L(),protocolVariables:Vm}),Um=Qp({type:P(O.CUSTOM)},im()),Wm=I({type:P(O.SIGNATURE),signature:B(),schemeId:Em()}),Gm=I({type:P(O.AUXILIARY_SIGNATURE),tag:Sm(),signature:B(),schemeId:Em()}),Km=I({type:P(O.ALLOWED_ADDITIONAL_WRITER),allowedWriterAccountId:B()}),qm=I({type:P(O.PROTOCOL_CREATION),organizationId:Nm()}),Jm=I({type:P(O.PROTOCOL_UPDATE),...Hm.entries}),Ym=I({type:P(O.PROTOCOL_VARIABLES),protocolVariables:Wp()}),Xm=I({type:P(O.ACCOUNT_PUBLIC_KEY),publicKey:B(),schemeId:Em()}),Zm=I({type:P(O.ACCOUNT_TOKEN_ISSUANCE),amount:V()}),Qm=I({type:P(O.ACCOUNT_CREATION),sellerAccount:Nm(),amount:V()}),$m=I({type:P(O.ACCOUNT_TRANSFER),account:Nm(),amount:V(),publicReference:Sm(),privateReference:Sm()}),eh=I({type:P(O.ACCOUNT_VESTING_TRANSFER),account:Nm(),amount:V(),publicReference:Sm(),privateReference:Sm(),cliffDurationDays:V(),vestingDurationDays:V()}),th=I({type:P(O.ACCOUNT_ESCROW_TRANSFER),account:Nm(),amount:V(),publicReference:Sm(),privateReference:Sm(),escrowIdentifier:Nm(),agentAccount:Nm(),durationDays:V()}),nh=I({type:P(O.ACCOUNT_ESCROW_SETTLEMENT),escrowIdentifier:Nm(),confirmed:wm()}),rh=I({type:P(O.ACCOUNT_STAKE),amount:V(),objectType:V(),objectIdentifier:Nm()}),ih=I({type:P(O.ACCOUNT_UNSTAKE),amount:V(),objectType:V(),objectIdentifier:Nm()}),ah=I({type:P(O.VN_CREATION),organizationId:Nm()}),oh=I({type:P(O.VN_COMETBFT_PUBLIC_KEY_DECLARATION),cometPublicKeyType:Sm(),cometPublicKey:Sm()}),sh=I({type:P(O.VN_RPC_ENDPOINT),rpcEndpoint:Sm()}),ch=I({type:P(O.VN_APPROVAL),status:wm()}),lh=I({type:P(O.VN_SLASHING_CANCELLATION),reason:Sm()}),uh=I({type:P(O.ORG_CREATION),accountId:Nm()}),dh=I({type:P(O.ORG_DESCRIPTION),name:Sm(),city:Sm(),countryCode:Sm(),website:Sm(),misc:$p(tm(L(),L()))}),fh=I({type:P(O.APP_CREATION),organizationId:Nm()}),ph=I({type:P(O.APP_DESCRIPTION),name:Sm(),logoUrl:Sm(),homepageUrl:Sm(),description:Sm(),misc:$p(tm(L(),L()))}),mh=I({type:P(O.APP_LEDGER_ALLOWED_SIG_SCHEMES),schemeIds:N(Em())}),hh=I({type:P(O.APP_LEDGER_ALLOWED_PKE_SCHEMES),schemeIds:N(Em())}),gh=I({type:P(O.APP_LEDGER_CREATION),applicationId:Nm()}),_h=I({type:P(O.APP_LEDGER_ACTOR_CREATION),id:V(),actorType:V(),name:Sm()}),vh=I({type:P(O.APP_LEDGER_CHANNEL_CREATION),id:V(),isPrivate:wm(),creatorId:V(),name:Sm()}),yh=I({type:P(O.APP_LEDGER_SHARED_SECRET),hostId:V(),guestId:V(),encryptedSharedKey:B()}),bh=I({type:P(O.APP_LEDGER_CHANNEL_INVITATION),channelId:V(),hostId:V(),guestId:V(),encryptedChannelKey:B()}),xh=I({type:P(O.APP_LEDGER_ACTOR_SUBSCRIPTION),actorId:V(),actorType:V(),organizationId:Nm(),signatureSchemeId:Em(),signaturePublicKey:B(),pkeSchemeId:Em(),pkePublicKey:B()}),Sh=I({type:P(O.APP_LEDGER_PUBLIC_CHANNEL_DATA),channelId:V(),data:B()}),Ch=I({type:P(O.APP_LEDGER_PRIVATE_CHANNEL_DATA),channelId:V(),merkleRootHash:Nm(),encryptedData:B()}),wh=I({type:P(O.APP_LEDGER_AUTHOR),authorId:V()}),Th=I({type:P(O.APP_LEDGER_ENDORSEMENT_REQUEST),endorserId:V(),message:Sm()}),Eh=am(`type`,[Gm,Wm,Km,Um,qm,Jm,Ym,Xm,Zm,Qm,$m,eh,th,nh,rh,ih,ah,oh,sh,ch,lh,uh,dh,fh,ph,mh,hh,gh,_h,vh,yh,bh,xh,Sh,Ch,wh,Th]),Dh=I({sections:N(Eh)}),H=function(e){return e[e.ACCOUNT_VIRTUAL_BLOCKCHAIN=1]=`ACCOUNT_VIRTUAL_BLOCKCHAIN`,e[e.NODE_VIRTUAL_BLOCKCHAIN=2]=`NODE_VIRTUAL_BLOCKCHAIN`,e[e.APPLICATION_VIRTUAL_BLOCKCHAIN=4]=`APPLICATION_VIRTUAL_BLOCKCHAIN`,e[e.ORGANIZATION_VIRTUAL_BLOCKCHAIN=3]=`ORGANIZATION_VIRTUAL_BLOCKCHAIN`,e[e.APP_LEDGER_VIRTUAL_BLOCKCHAIN=5]=`APP_LEDGER_VIRTUAL_BLOCKCHAIN`,e[e.PROTOCOL_VIRTUAL_BLOCKCHAIN=0]=`PROTOCOL_VIRTUAL_BLOCKCHAIN`,e}({}),Oh=I({organizationId:Nm(),currentProtocolVariables:Vm,protocolUpdates:N(Hm)}),kh=I({signatureSchemeId:Cm(),publicKeyHeight:Pm()}),Ah=I({accountId:Nm(),descriptionHeight:Pm()}),jh=I({organizationId:Nm(),cometbftPublicKeyDeclarationHeight:Pm(),rpcEndpointHeight:Pm(),lastKnownApprovalStatus:wm()}),Mh=I({organizationId:Nm(),descriptionHeight:Pm()}),Nh=I({name:Sm(),isPrivate:wm(),creatorId:Cm()}),Ph=I({channelId:Cm(),height:Pm()}),Fh=I({peerActorId:Cm(),height:Pm()}),Ih=I({name:Sm(),subscribed:wm(),signatureKeyHeight:Cm(),pkeKeyHeight:Cm(),sharedSecrets:N(Fh),invitations:N(Ph)}),Lh=I({allowedAdditionalWriters:N(Nm()),allowedSignatureSchemeIds:N(Cm()),allowedPkeSchemeIds:N(Cm()),applicationId:Nm(),channels:N(Nh),actors:N(Ih)}),Rh=I({height:Cm(),expirationDay:Cm(),lastMicroblockHash:B(),merkleRootHash:B()}),zh=I({type:P(H.ACCOUNT_VIRTUAL_BLOCKCHAIN),...Rh.entries,internalState:kh}),Bh=I({type:P(H.ORGANIZATION_VIRTUAL_BLOCKCHAIN),...Rh.entries,internalState:Ah}),Vh=I({type:P(H.NODE_VIRTUAL_BLOCKCHAIN),...Rh.entries,internalState:jh}),Hh=I({type:P(H.APPLICATION_VIRTUAL_BLOCKCHAIN),...Rh.entries,internalState:Mh}),Uh=I({type:P(H.APP_LEDGER_VIRTUAL_BLOCKCHAIN),...Rh.entries,internalState:Lh}),Wh=I({type:P(H.PROTOCOL_VIRTUAL_BLOCKCHAIN),...Rh.entries,internalState:Oh}),Gh=am(`type`,[zh,Bh,Vh,Hh,Uh,Wh]),Kh=I({virtualBlockchainType:F(),virtualBlockchainId:Nm()}),qh=I({virtualBlockchainId:B(),virtualBlockchainType:F(),header:Lm}),Jh=function(e){return e[e.BLOCK=0]=`BLOCK`,e[e.MICROBLOCK=1]=`MICROBLOCK`,e[e.SECTION=2]=`SECTION`,e}({}),Yh=I({type:P(Jh.BLOCK),height:F()}),Xh=I({type:P(Jh.MICROBLOCK),microblockHash:Mm()}),Zh=I({type:P(Jh.SECTION),microblockHash:Mm(),sectionIndex:F()}),Qh=am(`type`,[Yh,Xh,Zh]),$h=3,eg=function(e){return e[e.Escrow=0]=`Escrow`,e[e.Vesting=1]=`Vesting`,e[e.NodeStaking=2]=`NodeStaking`,e}({}),tg=I({escrowIdentifier:B(),fundEmitterAccountId:B(),transferAuthorizerAccountId:B(),startTimestamp:F(),durationDays:F()}),ng=I({type:P(eg.Escrow),lockedAmountInAtomics:F(),parameters:tg}),rg=I({initialVestedAmountInAtomics:F(),cliffStartTimestamp:F(),cliffDurationDays:F(),vestingDurationDays:F()}),ig=I({type:P(eg.Vesting),lockedAmountInAtomics:F(),parameters:rg}),ag=I({validatorNodeId:B(),plannedUnlockAmountInAtomics:F(),plannedUnlockTimestamp:F(),slashed:Gp(),plannedSlashingAmountInAtomics:F(),plannedSlashingTimestamp:F()}),og=I({type:P(eg.NodeStaking),lockedAmountInAtomics:F(),parameters:ag}),sg=am(`type`,[ng,ig,og]),cg=I({balance:F(),escrowed:F(),vested:F(),releasable:F(),staked:F(),stakeable:F(),locked:F(),spendable:F()}),lg=I({height:F(),balance:F(),lastHistoryHash:B(),locks:N(sg)}),ug=I({type:F(),exists:Gp(),state:lg}),dg=I({height:z(F(),Ip(),Bp(0)),previousHistoryHash:Mm(),type:z(F(),Ip(),Bp(0),Rp(255)),publicReference:L(),privateReference:L(),timestamp:z(F(),Ip(),Bp(0)),linkedAccount:Mm(),amount:z(F(),Ip(),Bp(0)),chainReference:Qh}),fg=N(dg),pg=I({accountHash:B(),lastKnownHistoryHash:B(),firstHistoryHash:$p(B())}),mg=I({accountHash:B(),currentState:lg,historyUpdate:fg}),hg=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`,gg=hg+`+/=`,_g={BASE64:gg,URL:hg+`-_=`,encodeString:vg,decodeString:yg,encodeBinary:bg,decodeBinary:xg};function vg(e,t=gg,n=!1){return bg(Za.encode(e),t,n)}function yg(e,t=gg){return Za.decode(xg(e,t))}function bg(e,t=gg,n=!1){let r=e.length%3,i=0,a=``;for(let n=0;n<e.length||n%3;)if(i=i<<8|e[n++],!(n%3)){for(let e=4;e--;)a+=t[i>>e*6&63];i=0}return r?a.slice(0,r-3)+t[64].repeat(n?3-r:0):a}function xg(e,t=gg){let n=0,r=0,i=[];e+=t[64].repeat(-e.length&3);for(let a=0;a<e.length;){let o=t.indexOf(e[a++]);o==64&&n++,r=r<<6|o,a&3||i.push(r>>16&255,r>>8&255,r&255)}return new Uint8Array(n?i.slice(0,-n):i)}var Sg=class{static defaultBytesToStringEncoder(){return new wg}static bytesToBase64Encoder(){return new Cg}static bytesToHexEncoder(){return new wg}},Cg=class{static decode(e){return _g.decodeBinary(e,_g.BASE64)}static encode(e){return _g.encodeBinary(e,_g.BASE64,!0)}decode(e){return _g.decodeBinary(e,_g.BASE64)}encode(e){return _g.encodeBinary(e,_g.BASE64,!0)}},wg=class{decode(e){return _l(e)}encode(e){if(!(e instanceof Uint8Array))throw TypeError(`Encoding data must be a Uint8Array, got ${typeof e}`);return ml(e)}},Tg=class{keys;value;constructor(e,t){this.keys=e,this.value=t}matchesKeys(...e){return e.length===this.keys.length?e.every((e,t)=>e===this.keys[t]):!1}getKeys(){return[...this.keys]}getValue(){return this.value}},Eg=class{static encode(...e){if(e.length<2)throw Error(`At least one key and one value must be provided`);let t=e.slice(0,-1),n=e[e.length-1];return`${t.join(`:`)}${n?`{${n}}`:`{}`}`}static decode(e){let t=e.match(/^(.*?)(?:\{(.*)\})?$/);if(!t)throw Error(`Invalid encoded string format`);let n=t[1],r=t[2]||``;return new Tg(n?n.split(`:`):[],r)}},Dg={},Og={};Og.byteLength=Ig,Og.toByteArray=Rg,Og.fromByteArray=Vg;for(var kg=[],Ag=[],jg=typeof Uint8Array<`u`?Uint8Array:Array,Mg=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Ng=0,Pg=Mg.length;Ng<Pg;++Ng)kg[Ng]=Mg[Ng],Ag[Mg.charCodeAt(Ng)]=Ng;Ag[45]=62,Ag[95]=63;function Fg(e){var t=e.length;if(t%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var n=e.indexOf(`=`);n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function Ig(e){var t=Fg(e),n=t[0],r=t[1];return(n+r)*3/4-r}function Lg(e,t,n){return(t+n)*3/4-n}function Rg(e){var t,n=Fg(e),r=n[0],i=n[1],a=new jg(Lg(e,r,i)),o=0,s=i>0?r-4:r,c;for(c=0;c<s;c+=4)t=Ag[e.charCodeAt(c)]<<18|Ag[e.charCodeAt(c+1)]<<12|Ag[e.charCodeAt(c+2)]<<6|Ag[e.charCodeAt(c+3)],a[o++]=t>>16&255,a[o++]=t>>8&255,a[o++]=t&255;return i===2&&(t=Ag[e.charCodeAt(c)]<<2|Ag[e.charCodeAt(c+1)]>>4,a[o++]=t&255),i===1&&(t=Ag[e.charCodeAt(c)]<<10|Ag[e.charCodeAt(c+1)]<<4|Ag[e.charCodeAt(c+2)]>>2,a[o++]=t>>8&255,a[o++]=t&255),a}function zg(e){return kg[e>>18&63]+kg[e>>12&63]+kg[e>>6&63]+kg[e&63]}function Bg(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(zg(r));return i.join(``)}function Vg(e){for(var t,n=e.length,r=n%3,i=[],a=16383,o=0,s=n-r;o<s;o+=a)i.push(Bg(e,o,o+a>s?s:o+a));return r===1?(t=e[n-1],i.push(kg[t>>2]+kg[t<<4&63]+`==`)):r===2&&(t=(e[n-2]<<8)+e[n-1],i.push(kg[t>>10]+kg[t>>4&63]+kg[t<<2&63]+`=`)),i.join(``)}var Hg={};Hg.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else if(a===c)return o?NaN:(p?-1:1)*(1/0);else o+=2**r,a-=l;return(p?-1:1)*o*2**(a-r)},Hg.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=+(t<0||t===0&&1/t<0);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128},(function(e){let t=Og,n=Hg,r=typeof Symbol==`function`&&typeof Symbol.for==`function`?Symbol.for(`nodejs.util.inspect.custom`):null;e.Buffer=u,e.SlowBuffer=ee,e.INSPECT_MAX_BYTES=50;let i=2147483647;e.kMaxLength=i;let{Uint8Array:a,ArrayBuffer:o,SharedArrayBuffer:s}=globalThis;u.TYPED_ARRAY_SUPPORT=c(),!u.TYPED_ARRAY_SUPPORT&&typeof console<`u`&&typeof console.error==`function`&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function c(){try{let e=new a(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,a.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,`parent`,{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,`offset`,{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function l(e){if(e>i)throw RangeError(`The value "`+e+`" is invalid for option "size"`);let t=new a(e);return Object.setPrototypeOf(t,u.prototype),t}function u(e,t,n){if(typeof e==`number`){if(typeof t==`string`)throw TypeError(`The "string" argument must be of type string. Received type number`);return m(e)}return d(e,t,n)}u.poolSize=8192;function d(e,t,n){if(typeof e==`string`)return h(e,t);if(o.isView(e))return _(e);if(e==null)throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e);if(Le(e,o)||e&&Le(e.buffer,o)||s!==void 0&&(Le(e,s)||e&&Le(e.buffer,s)))return v(e,t,n);if(typeof e==`number`)throw TypeError(`The "value" argument must not be of type number. Received type number`);let r=e.valueOf&&e.valueOf();if(r!=null&&r!==e)return u.from(r,t,n);let i=y(e);if(i)return i;if(typeof Symbol<`u`&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]==`function`)return u.from(e[Symbol.toPrimitive](`string`),t,n);throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e)}u.from=function(e,t,n){return d(e,t,n)},Object.setPrototypeOf(u.prototype,a.prototype),Object.setPrototypeOf(u,a);function f(e){if(typeof e!=`number`)throw TypeError(`"size" argument must be of type number`);if(e<0)throw RangeError(`The value "`+e+`" is invalid for option "size"`)}function p(e,t,n){return f(e),e<=0||t===void 0?l(e):typeof n==`string`?l(e).fill(t,n):l(e).fill(t)}u.alloc=function(e,t,n){return p(e,t,n)};function m(e){return f(e),l(e<0?0:b(e)|0)}u.allocUnsafe=function(e){return m(e)},u.allocUnsafeSlow=function(e){return m(e)};function h(e,t){if((typeof t!=`string`||t===``)&&(t=`utf8`),!u.isEncoding(t))throw TypeError(`Unknown encoding: `+t);let n=x(e,t)|0,r=l(n),i=r.write(e,t);return i!==n&&(r=r.slice(0,i)),r}function g(e){let t=e.length<0?0:b(e.length)|0,n=l(t);for(let r=0;r<t;r+=1)n[r]=e[r]&255;return n}function _(e){if(Le(e,a)){let t=new a(e);return v(t.buffer,t.byteOffset,t.byteLength)}return g(e)}function v(e,t,n){if(t<0||e.byteLength<t)throw RangeError(`"offset" is outside of buffer bounds`);if(e.byteLength<t+(n||0))throw RangeError(`"length" is outside of buffer bounds`);let r;return r=t===void 0&&n===void 0?new a(e):n===void 0?new a(e,t):new a(e,t,n),Object.setPrototypeOf(r,u.prototype),r}function y(e){if(u.isBuffer(e)){let t=b(e.length)|0,n=l(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!=`number`||Re(e.length)?l(0):g(e);if(e.type===`Buffer`&&Array.isArray(e.data))return g(e.data)}function b(e){if(e>=i)throw RangeError(`Attempt to allocate Buffer larger than maximum size: 0x`+i.toString(16)+` bytes`);return e|0}function ee(e){return+e!=e&&(e=0),u.alloc(+e)}u.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==u.prototype},u.compare=function(e,t){if(Le(e,a)&&(e=u.from(e,e.offset,e.byteLength)),Le(t,a)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(e)||!u.isBuffer(t))throw TypeError(`The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array`);if(e===t)return 0;let n=e.length,r=t.length;for(let i=0,a=Math.min(n,r);i<a;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:+(r<n)},u.isEncoding=function(e){switch(String(e).toLowerCase()){case`hex`:case`utf8`:case`utf-8`:case`ascii`:case`latin1`:case`binary`:case`base64`:case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return!0;default:return!1}},u.concat=function(e,t){if(!Array.isArray(e))throw TypeError(`"list" argument must be an Array of Buffers`);if(e.length===0)return u.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let r=u.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){let t=e[n];if(Le(t,a))i+t.length>r.length?(u.isBuffer(t)||(t=u.from(t)),t.copy(r,i)):a.prototype.set.call(r,t,i);else if(u.isBuffer(t))t.copy(r,i);else throw TypeError(`"list" argument must be an Array of Buffers`);i+=t.length}return r};function x(e,t){if(u.isBuffer(e))return e.length;if(o.isView(e)||Le(e,o))return e.byteLength;if(typeof e!=`string`)throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type `+typeof e);let n=e.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let i=!1;for(;;)switch(t){case`ascii`:case`latin1`:case`binary`:return n;case`utf8`:case`utf-8`:return Ne(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return Ie(e).length;default:if(i)return r?-1:Ne(e).length;t=(``+t).toLowerCase(),i=!0}}u.byteLength=x;function te(e,t,n){let r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return``;for(e||=`utf8`;;)switch(e){case`hex`:return he(this,t,n);case`utf8`:case`utf-8`:return ue(this,t,n);case`ascii`:return pe(this,t,n);case`latin1`:case`binary`:return me(this,t,n);case`base64`:return S(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return ge(this,t,n);default:if(r)throw TypeError(`Unknown encoding: `+e);e=(e+``).toLowerCase(),r=!0}}u.prototype._isBuffer=!0;function ne(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}u.prototype.swap16=function(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let t=0;t<e;t+=2)ne(this,t,t+1);return this},u.prototype.swap32=function(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let t=0;t<e;t+=4)ne(this,t,t+3),ne(this,t+1,t+2);return this},u.prototype.swap64=function(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let t=0;t<e;t+=8)ne(this,t,t+7),ne(this,t+1,t+6),ne(this,t+2,t+5),ne(this,t+3,t+4);return this},u.prototype.toString=function(){let e=this.length;return e===0?``:arguments.length===0?ue(this,0,e):te.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(e){if(!u.isBuffer(e))throw TypeError(`Argument must be a Buffer`);return this===e?!0:u.compare(this,e)===0},u.prototype.inspect=function(){let t=``,n=e.INSPECT_MAX_BYTES;return t=this.toString(`hex`,0,n).replace(/(.{2})/g,`$1 `).trim(),this.length>n&&(t+=` ... `),`<Buffer `+t+`>`},r&&(u.prototype[r]=u.prototype.inspect),u.prototype.compare=function(e,t,n,r,i){if(Le(e,a)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(e))throw TypeError(`The "target" argument must be one of type Buffer or Uint8Array. Received type `+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw RangeError(`out of range index`);if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;let o=i-r,s=n-t,c=Math.min(o,s),l=this.slice(r,i),d=e.slice(t,n);for(let e=0;e<c;++e)if(l[e]!==d[e]){o=l[e],s=d[e];break}return o<s?-1:+(s<o)};function re(e,t,n,r,i){if(e.length===0)return-1;if(typeof n==`string`?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Re(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0)if(i)n=0;else return-1;if(typeof t==`string`&&(t=u.from(t,r)),u.isBuffer(t))return t.length===0?-1:ie(e,t,n,r,i);if(typeof t==`number`)return t&=255,typeof a.prototype.indexOf==`function`?i?a.prototype.indexOf.call(e,t,n):a.prototype.lastIndexOf.call(e,t,n):ie(e,[t],n,r,i);throw TypeError(`val must be string, number or Buffer`)}function ie(e,t,n,r,i){let a=1,o=e.length,s=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r===`ucs2`||r===`ucs-2`||r===`utf16le`||r===`utf-16le`)){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,n/=2}function c(e,t){return a===1?e[t]:e.readUInt16BE(t*a)}let l;if(i){let r=-1;for(l=n;l<o;l++)if(c(e,l)===c(t,r===-1?0:l-r)){if(r===-1&&(r=l),l-r+1===s)return r*a}else r!==-1&&(l-=l-r),r=-1}else for(n+s>o&&(n=o-s),l=n;l>=0;l--){let n=!0;for(let r=0;r<s;r++)if(c(e,l+r)!==c(t,r)){n=!1;break}if(n)return l}return-1}u.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},u.prototype.indexOf=function(e,t,n){return re(this,e,t,n,!0)},u.prototype.lastIndexOf=function(e,t,n){return re(this,e,t,n,!1)};function ae(e,t,n,r){n=Number(n)||0;let i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;let a=t.length;r>a/2&&(r=a/2);let o;for(o=0;o<r;++o){let r=parseInt(t.substr(o*2,2),16);if(Re(r))return o;e[n+o]=r}return o}function oe(e,t,n,r){return C(Ne(t,e.length-n),e,n,r)}function se(e,t,n,r){return C(Pe(t),e,n,r)}function ce(e,t,n,r){return C(Ie(t),e,n,r)}function le(e,t,n,r){return C(Fe(t,e.length-n),e,n,r)}u.prototype.write=function(e,t,n,r){if(t===void 0)r=`utf8`,n=this.length,t=0;else if(n===void 0&&typeof t==`string`)r=t,n=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(n)?(n>>>=0,r===void 0&&(r=`utf8`)):(r=n,n=void 0);else throw Error(`Buffer.write(string, encoding, offset[, length]) is no longer supported`);let i=this.length-t;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw RangeError(`Attempt to write outside buffer bounds`);r||=`utf8`;let a=!1;for(;;)switch(r){case`hex`:return ae(this,e,t,n);case`utf8`:case`utf-8`:return oe(this,e,t,n);case`ascii`:case`latin1`:case`binary`:return se(this,e,t,n);case`base64`:return ce(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return le(this,e,t,n);default:if(a)throw TypeError(`Unknown encoding: `+r);r=(``+r).toLowerCase(),a=!0}},u.prototype.toJSON=function(){return{type:`Buffer`,data:Array.prototype.slice.call(this._arr||this,0)}};function S(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function ue(e,t,n){n=Math.min(e.length,n);let r=[],i=t;for(;i<n;){let t=e[i],a=null,o=t>239?4:t>223?3:t>191?2:1;if(i+o<=n){let n,r,s,c;switch(o){case 1:t<128&&(a=t);break;case 2:n=e[i+1],(n&192)==128&&(c=(t&31)<<6|n&63,c>127&&(a=c));break;case 3:n=e[i+1],r=e[i+2],(n&192)==128&&(r&192)==128&&(c=(t&15)<<12|(n&63)<<6|r&63,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:n=e[i+1],r=e[i+2],s=e[i+3],(n&192)==128&&(r&192)==128&&(s&192)==128&&(c=(t&15)<<18|(n&63)<<12|(r&63)<<6|s&63,c>65535&&c<1114112&&(a=c))}}a===null?(a=65533,o=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),i+=o}return fe(r)}let de=4096;function fe(e){let t=e.length;if(t<=de)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=de));return n}function pe(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]&127);return r}function me(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function he(e,t,n){let r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);let i=``;for(let r=t;r<n;++r)i+=ze[e[r]];return i}function ge(e,t,n){let r=e.slice(t,n),i=``;for(let e=0;e<r.length-1;e+=2)i+=String.fromCharCode(r[e]+r[e+1]*256);return i}u.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let r=this.subarray(e,t);return Object.setPrototypeOf(r,u.prototype),r};function _e(e,t,n){if(e%1!=0||e<0)throw RangeError(`offset is not uint`);if(e+t>n)throw RangeError(`Trying to access beyond buffer length`)}u.prototype.readUintLE=u.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||_e(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return r},u.prototype.readUintBE=u.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||_e(e,t,this.length);let r=this[e+--t],i=1;for(;t>0&&(i*=256);)r+=this[e+--t]*i;return r},u.prototype.readUint8=u.prototype.readUInt8=function(e,t){return e>>>=0,t||_e(e,1,this.length),this[e]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,t){return e>>>=0,t||_e(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,t){return e>>>=0,t||_e(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,t){return e>>>=0,t||_e(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(e,t){return e>>>=0,t||_e(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readBigUInt64LE=Be(function(e){e>>>=0,ke(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ae(e,this.length-8);let r=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),u.prototype.readBigUInt64BE=Be(function(e){e>>>=0,ke(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ae(e,this.length-8);let r=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),u.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||_e(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return i*=128,r>=i&&(r-=2**(8*t)),r},u.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||_e(e,t,this.length);let r=t,i=1,a=this[e+--r];for(;r>0&&(i*=256);)a+=this[e+--r]*i;return i*=128,a>=i&&(a-=2**(8*t)),a},u.prototype.readInt8=function(e,t){return e>>>=0,t||_e(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},u.prototype.readInt16LE=function(e,t){e>>>=0,t||_e(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},u.prototype.readInt16BE=function(e,t){e>>>=0,t||_e(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},u.prototype.readInt32LE=function(e,t){return e>>>=0,t||_e(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return e>>>=0,t||_e(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readBigInt64LE=Be(function(e){e>>>=0,ke(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ae(e,this.length-8);let r=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),u.prototype.readBigInt64BE=Be(function(e){e>>>=0,ke(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ae(e,this.length-8);let r=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)}),u.prototype.readFloatLE=function(e,t){return e>>>=0,t||_e(e,4,this.length),n.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return e>>>=0,t||_e(e,4,this.length),n.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return e>>>=0,t||_e(e,8,this.length),n.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return e>>>=0,t||_e(e,8,this.length),n.read(this,e,!1,52,8)};function ve(e,t,n,r,i,a){if(!u.isBuffer(e))throw TypeError(`"buffer" argument must be a Buffer instance`);if(t>i||t<a)throw RangeError(`"value" argument is out of bounds`);if(n+r>e.length)throw RangeError(`Index out of range`)}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;ve(this,e,t,n,r,0)}let i=1,a=0;for(this[t]=e&255;++a<n&&(i*=256);)this[t+a]=e/i&255;return t+n},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;ve(this,e,t,n,r,0)}let i=n-1,a=1;for(this[t+i]=e&255;--i>=0&&(a*=256);)this[t+i]=e/a&255;return t+n},u.prototype.writeUint8=u.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||ve(this,e,t,1,255,0),this[t]=e&255,t+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||ve(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||ve(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||ve(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||ve(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function ye(e,t,n,r,i){Oe(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,n}function be(e,t,n,r,i){Oe(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n+7]=a,a>>=8,e[n+6]=a,a>>=8,e[n+5]=a,a>>=8,e[n+4]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=o,o>>=8,e[n+2]=o,o>>=8,e[n+1]=o,o>>=8,e[n]=o,n+8}u.prototype.writeBigUInt64LE=Be(function(e,t=0){return ye(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),u.prototype.writeBigUInt64BE=Be(function(e,t=0){return be(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),u.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);ve(this,e,t,n,r-1,-r)}let i=0,a=1,o=0;for(this[t]=e&255;++i<n&&(a*=256);)e<0&&o===0&&this[t+i-1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},u.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);ve(this,e,t,n,r-1,-r)}let i=n-1,a=1,o=0;for(this[t+i]=e&255;--i>=0&&(a*=256);)e<0&&o===0&&this[t+i+1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},u.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||ve(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},u.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||ve(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},u.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||ve(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},u.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||ve(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},u.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||ve(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},u.prototype.writeBigInt64LE=Be(function(e,t=0){return ye(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),u.prototype.writeBigInt64BE=Be(function(e,t=0){return be(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function xe(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function Se(e,t,r,i,a){return t=+t,r>>>=0,a||xe(e,t,r,4),n.write(e,t,r,i,23,4),r+4}u.prototype.writeFloatLE=function(e,t,n){return Se(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return Se(this,e,t,!1,n)};function Ce(e,t,r,i,a){return t=+t,r>>>=0,a||xe(e,t,r,8),n.write(e,t,r,i,52,8),r+8}u.prototype.writeDoubleLE=function(e,t,n){return Ce(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return Ce(this,e,t,!1,n)},u.prototype.copy=function(e,t,n,r){if(!u.isBuffer(e))throw TypeError(`argument should be a Buffer`);if(n||=0,!r&&r!==0&&(r=this.length),t>=e.length&&(t=e.length),t||=0,r>0&&r<n&&(r=n),r===n||e.length===0||this.length===0)return 0;if(t<0)throw RangeError(`targetStart out of bounds`);if(n<0||n>=this.length)throw RangeError(`Index out of range`);if(r<0)throw RangeError(`sourceEnd out of bounds`);r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);let i=r-n;return this===e&&typeof a.prototype.copyWithin==`function`?this.copyWithin(t,n,r):a.prototype.set.call(e,this.subarray(n,r),t),i},u.prototype.fill=function(e,t,n,r){if(typeof e==`string`){if(typeof t==`string`?(r=t,t=0,n=this.length):typeof n==`string`&&(r=n,n=this.length),r!==void 0&&typeof r!=`string`)throw TypeError(`encoding must be a string`);if(typeof r==`string`&&!u.isEncoding(r))throw TypeError(`Unknown encoding: `+r);if(e.length===1){let t=e.charCodeAt(0);(r===`utf8`&&t<128||r===`latin1`)&&(e=t)}}else typeof e==`number`?e&=255:typeof e==`boolean`&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw RangeError(`Out of range index`);if(n<=t)return this;t>>>=0,n=n===void 0?this.length:n>>>0,e||=0;let i;if(typeof e==`number`)for(i=t;i<n;++i)this[i]=e;else{let a=u.isBuffer(e)?e:u.from(e,r),o=a.length;if(o===0)throw TypeError(`The value "`+e+`" is invalid for argument "value"`);for(i=0;i<n-t;++i)this[i+t]=a[i%o]}return this};let we={};function Te(e,t,n){we[e]=class extends n{constructor(){super(),Object.defineProperty(this,`message`,{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,`code`,{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}Te(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),Te(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),Te(`ERR_OUT_OF_RANGE`,function(e,t,n){let r=`The value of "${e}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=Ee(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=Ee(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function Ee(e){let t=``,n=e.length,r=+(e[0]===`-`);for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function De(e,t,n){ke(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&Ae(t,e.length-(n+1))}function Oe(e,t,n,r,i,a){if(e>n||e<t){let r=typeof t==`bigint`?`n`:``,i;throw i=a>3?t===0||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${(a+1)*8}${r}`:`>= -(2${r} ** ${(a+1)*8-1}${r}) and < 2 ** ${(a+1)*8-1}${r}`:`>= ${t}${r} and <= ${n}${r}`,new we.ERR_OUT_OF_RANGE(`value`,i,e)}De(r,i,a)}function ke(e,t){if(typeof e!=`number`)throw new we.ERR_INVALID_ARG_TYPE(t,`number`,e)}function Ae(e,t,n){throw Math.floor(e)===e?t<0?new we.ERR_BUFFER_OUT_OF_BOUNDS:new we.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(ke(e,n),new we.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}let je=/[^+/0-9A-Za-z-_]/g;function Me(e){if(e=e.split(`=`)[0],e=e.trim().replace(je,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function Ne(e,t){t||=1/0;let n,r=e.length,i=null,a=[];for(let o=0;o<r;++o){if(n=e.charCodeAt(o),n>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(o+1===r){(t-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if(--t<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw Error(`Invalid code point`)}return a}function Pe(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function Fe(e,t){let n,r,i,a=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),r=n>>8,i=n%256,a.push(i),a.push(r);return a}function Ie(e){return t.toByteArray(Me(e))}function C(e,t,n,r){let i;for(i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function Le(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Re(e){return e!==e}let ze=(function(){let e=`0123456789abcdef`,t=Array(256);for(let n=0;n<16;++n){let r=n*16;for(let i=0;i<16;++i)t[r+i]=e[n]+e[i]}return t})();function Be(e){return typeof BigInt>`u`?Ve:e}function Ve(){throw Error(`BigInt not supported`)}})(Dg);var Ug=Dg.Buffer;Dg.Blob,Dg.BlobOptions,Dg.Buffer,Dg.File,Dg.FileOptions,Dg.INSPECT_MAX_BYTES,Dg.SlowBuffer,Dg.TranscodeEncoding,Dg.atob,Dg.btoa,Dg.constants,Dg.isAscii,Dg.isUtf8,Dg.kMaxLength,Dg.kStringMaxLength,Dg.resolveObjectURL,Dg.transcode;var Wg=function(e){return e[e.AES_256_GCM=0]=`AES_256_GCM`,e}({}),Gg=class e{static KEY_LENGTH_IN_BYTES=32;getSymmetricEncryptionSchemeId(){return Wg.AES_256_GCM}getSupportedKeyLengths(){return[e.KEY_LENGTH_IN_BYTES]}getDefaultKeyLength(){return e.KEY_LENGTH_IN_BYTES}},Kg=class e{constructor(e){this.key=e}static async generate(){let t=new Uint8Array(32);return crypto.getRandomValues(t),new e(t)}static createFromBytes(t){return new e(t)}getRawSecretKey(){return this.key}getSymmetricEncryptionSchemeId(){return Wg.AES_256_GCM}async encrypt(e){let t=new Uint8Array(12);crypto.getRandomValues(t);let n=iu(this.key,t).encrypt(e),r=new Uint8Array(t.length+n.length);return r.set(t),r.set(n,t.length),r}async decrypt(e){try{let t=e.slice(0,12),n=e.slice(12);return iu(this.key,t).decrypt(n)}catch(e){throw o.isCarmentisError(e)?new f:e}}},qg=class{constructor(e){this.wrappedKey=e}async encryptString(e){let t=new TextEncoder().encode(e),n=await this.encrypt(t);return Ug.from(n).toString(`base64`)}async decryptString(e){let t=Ug.from(e,`base64`),n=await this.decrypt(t);return new TextDecoder().decode(n)}getSymmetricEncryptionSchemeId(){return this.wrappedKey.getSymmetricEncryptionSchemeId()}async encrypt(e){return this.wrappedKey.encrypt(e)}async decrypt(e){return this.wrappedKey.decrypt(e)}getRawSecretKey(){return this.wrappedKey.getRawSecretKey()}},Jg=function(e){return e[e.ML_KEM=0]=`ML_KEM`,e}({}),Yg=class{getPrivateKeyAsString(e=Sg.defaultBytesToStringEncoder()){return e.encode(this.getPrivateKeyAsBytes())}getSignatureSchemeId(){return this.getScheme().getSignatureSchemeId()}getSignatureSize(){return this.getScheme().getSignatureSize()}getSignatureAlgorithmId(){return this.getSignatureSchemeId()}},Xg=class{async getPublicKeyAsString(e=Sg.defaultBytesToStringEncoder()){return e.encode(await this.getPublicKeyAsBytes())}getSignatureSize(){return this.getScheme().getSignatureSize()}getSignatureSchemeId(){return this.getScheme().getSignatureSchemeId()}getSignatureAlgorithmId(){return this.getSignatureSchemeId()}},Zg=class e{static SIGNATURE_SIZE=3311;getSignatureSchemeId(){return Ja.ML_DSA_65}getSignatureSize(){return e.SIGNATURE_SIZE}getSignatureAlgorithmId(){return this.getSignatureSchemeId()}expectedSeedSize(){return 32}},Qg=class extends Xg{constructor(e){super(),this.publicKey=e}async getPublicKeyAsString(e=Sg.defaultBytesToStringEncoder()){return e.encode(await this.getPublicKeyAsBytes())}async verify(e,t){return _d.verify(this.publicKey,e,t)}async getPublicKeyAsBytes(){return this.publicKey}getScheme(){return new Zg}},$g=class e extends Yg{static async gen(){return new e(Pu(32))}verificationKey;signatureKey;getPrivateKeyAsString(e){return e.encode(this.getPrivateKeyAsBytes())}constructor(e){super(),this.seed=e;let t=_d.keygen(e);this.signatureKey=t.secretKey,this.verificationKey=t.publicKey}async getPublicKey(){return new Qg(this.verificationKey)}getPrivateKeyAsBytes(){return this.seed}async sign(e){return _d.sign(this.signatureKey,e)}getScheme(){return new Zg}},e_={p:57896044618658097711785492504343953926634992332820282019728792003956564819949n,n:7237005577332262213973186563042994240857116359379907606001950938285454250989n,h:8n,a:57896044618658097711785492504343953926634992332820282019728792003956564819948n,d:37095705934669439343138083508754565189542113879843219016388785533085940283555n,Gx:15112221349535400772501151409588531511454012693041857206046113283949847762202n,Gy:46316835694926478169428394003475163141307993866256225615783033603165251855960n},{p:t_,n:n_,Gx:r_,Gy:i_,a:a_,d:o_,h:s_}=e_,c_=32,l_=(...e)=>{`captureStackTrace`in Error&&typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(...e)},u_=(e=``)=>{let t=Error(e);throw l_(t,u_),t},d_=e=>typeof e==`bigint`,f_=e=>typeof e==`string`,p_=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`,m_=(e,t,n=``)=>{let r=p_(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`;u_(o+`expected Uint8Array`+s+`, got `+c)}return e},h_=e=>new Uint8Array(e),g_=e=>Uint8Array.from(e),__=(e,t)=>e.toString(16).padStart(t,`0`),v_=e=>Array.from(m_(e)).map(e=>__(e,2)).join(``),y_={_0:48,_9:57,A:65,F:70,a:97,f:102},b_=e=>{if(e>=y_._0&&e<=y_._9)return e-y_._0;if(e>=y_.A&&e<=y_.F)return e-(y_.A-10);if(e>=y_.a&&e<=y_.f)return e-(y_.a-10)},x_=e=>{let t=`hex invalid`;if(!f_(e))return u_(t);let n=e.length,r=n/2;if(n%2)return u_(t);let i=h_(r);for(let n=0,a=0;n<r;n++,a+=2){let r=b_(e.charCodeAt(a)),o=b_(e.charCodeAt(a+1));if(r===void 0||o===void 0)return u_(t);i[n]=r*16+o}return i},S_=()=>globalThis?.crypto,C_=()=>S_()?.subtle??u_(`crypto.subtle must be defined, consider polyfill`),w_=(...e)=>{let t=h_(e.reduce((e,t)=>e+m_(t).length,0)),n=0;return e.forEach(e=>{t.set(e,n),n+=e.length}),t},T_=(e=c_)=>S_().getRandomValues(h_(e)),E_=BigInt,D_=(e,t,n,r=`bad number: out of range`)=>d_(e)&&t<=e&&e<n?e:u_(r),O_=(e,t=t_)=>{let n=e%t;return n>=0n?n:t+n},k_=(1n<<255n)-1n,U=e=>{e<0n&&u_(`negative coordinate`);let t=(e>>255n)*19n+(e&k_);return t=(t>>255n)*19n+(t&k_),t%t_},A_=e=>O_(e,n_),j_=(e,t)=>{(e===0n||t<=0n)&&u_(`no inverse n=`+e+` mod=`+t);let n=O_(e,t),r=t,i=0n,a=1n,o=1n,s=0n;for(;n!==0n;){let e=r/n,t=r%n,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}return r===1n?O_(i,t):u_(`no inverse`)},M_=e=>{let t=rv[e];return typeof t!=`function`&&u_(`hashes.`+e+` not set`),t},N_=e=>e instanceof F_?e:u_(`Point expected`),P_=2n**256n,F_=class e{static BASE;static ZERO;X;Y;Z;T;constructor(e,t,n,r){let i=P_;this.X=D_(e,0n,i),this.Y=D_(t,0n,i),this.Z=D_(n,1n,i),this.T=D_(r,0n,i),Object.freeze(this)}static CURVE(){return e_}static fromAffine(t){return new e(t.x,t.y,1n,U(t.x*t.y))}static fromBytes(t,n=!1){let r=o_,i=g_(m_(t,c_)),a=t[31];i[31]=a&-129;let o=z_(i);D_(o,0n,n?P_:t_);let s=U(o*o),{isValid:c,value:l}=U_(O_(s-1n),U(r*s+1n));c||u_(`bad point: y not sqrt`);let u=(l&1n)==1n,d=(a&128)!=0;return!n&&l===0n&&d&&u_(`bad point: x==0, isLastByteOdd`),d!==u&&(l=O_(-l)),new e(l,o,1n,U(l*o))}static fromHex(t,n){return e.fromBytes(x_(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){let e=a_,t=o_,n=this;if(n.is0())return u_(`bad point: ZERO`);let{X:r,Y:i,Z:a,T:o}=n,s=U(r*r),c=U(i*i),l=U(a*a),u=U(l*l);return U(l*(U(s*e)+c))===O_(u+U(t*U(s*c)))?U(r*i)===U(a*o)?this:u_(`bad point: equation left != right (2)`):u_(`bad point: equation left != right (1)`)}equals(e){let{X:t,Y:n,Z:r}=this,{X:i,Y:a,Z:o}=N_(e),s=U(t*o),c=U(i*r),l=U(n*o),u=U(a*r);return s===c&&l===u}is0(){return this.equals(L_)}negate(){return new e(O_(-this.X),this.Y,this.Z,O_(-this.T))}double(){let{X:t,Y:n,Z:r}=this,i=a_,a=U(t*t),o=U(n*n),s=U(2n*r*r),c=U(i*a),l=O_(t+n),u=O_(U(l*l)-a-o),d=O_(c+o),f=O_(d-s),p=O_(c-o),m=U(u*f),h=U(d*p),g=U(u*p);return new e(m,h,U(f*d),g)}add(t){let{X:n,Y:r,Z:i,T:a}=this,{X:o,Y:s,Z:c,T:l}=N_(t),u=a_,d=o_,f=U(n*o),p=U(r*s),m=U(U(a*d)*l),h=U(i*c),g=O_(U(O_(n+r)*O_(o+s))-f-p),_=O_(h-m),v=O_(h+m),y=O_(p-U(u*f)),b=U(g*_),ee=U(v*y),x=U(g*y);return new e(b,ee,U(_*v),x)}subtract(e){return this.add(N_(e).negate())}multiply(e,t=!0){if(!t&&(e===0n||this.is0()))return L_;if(D_(e,1n,n_),e===1n)return this;if(this.equals(I_))return dv(e).p;let n=L_,r=I_;for(let i=this;e>0n;i=i.double(),e>>=1n)e&1n?n=n.add(i):t&&(r=r.add(i));return n}multiplyUnsafe(e){return this.multiply(e,!1)}toAffine(){let{X:e,Y:t,Z:n}=this;if(this.equals(L_))return{x:0n,y:1n};let r=j_(n,t_);return U(n*r)!==1n&&u_(`invalid inverse`),{x:U(e*r),y:U(t*r)}}toBytes(){let{x:e,y:t}=this.toAffine(),n=R_(t);return n[31]|=e&1n?128:0,n}toHex(){return v_(this.toBytes())}clearCofactor(){return this.multiply(E_(s_),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.multiply(n_/2n,!1).double();return n_%2n&&(e=e.add(this)),e.is0()}},I_=new F_(r_,i_,1n,O_(r_*i_)),L_=new F_(0n,1n,1n,0n);F_.BASE=I_,F_.ZERO=L_;var R_=e=>x_(__(D_(e,0n,P_),64)).reverse(),z_=e=>E_(`0x`+v_(g_(m_(e)).reverse())),B_=(e,t)=>{let n=e;for(;t-- >0n;)n=U(n*n);return n},V_=e=>{let t=U(U(e*e)*e),n=U(B_(U(B_(t,2n)*t),1n)*e),r=U(B_(n,5n)*n),i=U(B_(r,10n)*r),a=U(B_(i,20n)*i),o=U(B_(a,40n)*a);return{pow_p_5_8:U(B_(U(B_(U(B_(U(B_(o,80n)*o),80n)*o),10n)*r),2n)*e),b2:t}},H_=19681161376707505956807079304988542015446066515923890162744021073123829784752n,U_=(e,t)=>{let n=U(t*U(t*t)),r=V_(U(e*U(U(n*n)*t))).pow_p_5_8,i=U(e*U(n*r)),a=U(t*U(i*i)),o=i,s=U(i*H_),c=a===e,l=a===O_(-e),u=a===O_(-e*H_);return c&&(i=o),(l||u)&&(i=s),(O_(i)&1n)==1n&&(i=O_(-i)),{isValid:c||l,value:i}},W_=e=>A_(z_(e)),G_=(...e)=>rv.sha512Async(w_(...e)),K_=(...e)=>M_(`sha512`)(w_(...e)),q_=e=>{let t=e.slice(0,32);t[0]&=248,t[31]&=127,t[31]|=64;let n=e.slice(32,64),r=W_(t),i=I_.multiply(r);return{head:t,prefix:n,scalar:r,point:i,pointBytes:i.toBytes()}},J_=e=>G_(m_(e,c_)).then(q_),Y_=e=>q_(K_(m_(e,c_))),X_=e=>Y_(e).pointBytes,Z_=e=>e.finish(K_(e.hashable)),Q_=(e,t,n)=>{let{pointBytes:r,scalar:i}=e,a=W_(t),o=I_.multiply(a).toBytes();return{hashable:w_(o,r,n),finish:e=>m_(w_(o,R_(A_(a+W_(e)*i))),64)}},$_=(e,t)=>{let n=m_(e),r=Y_(t);return Z_(Q_(r,K_(r.prefix,n),n))},ev={zip215:!0},tv=(e,t,n,r=ev)=>{e=m_(e,64),t=m_(t),n=m_(n,c_);let{zip215:i}=r,a=e.subarray(0,c_),o=z_(e.subarray(c_,c_*2)),s,c,l,u=Uint8Array.of(),d=!1;try{s=F_.fromBytes(n,i),c=F_.fromBytes(a,i),l=I_.multiply(o,!1),u=w_(c.toBytes(),s.toBytes(),t),d=!0}catch{}return{hashable:u,finish:e=>{if(!d||!i&&s.isSmallOrder())return!1;let t=W_(e);return c.add(s.multiply(t,!1)).subtract(l).clearCofactor().is0()}}},nv=(e,t,n,r=ev)=>Z_(tv(e,t,n,r)),rv={sha512Async:async e=>{let t=C_(),n=w_(e);return h_(await t.digest(`SHA-512`,n.buffer))},sha512:void 0},iv={getExtendedPublicKeyAsync:J_,getExtendedPublicKey:Y_,randomSecretKey:(e=T_(c_))=>e},av=8,ov=Math.ceil(256/av)+1,sv=2**(av-1),cv=()=>{let e=[],t=I_,n=t;for(let r=0;r<ov;r++){n=t,e.push(n);for(let r=1;r<sv;r++)n=n.add(t),e.push(n);t=n.double()}return e},lv=void 0,uv=(e,t)=>{let n=t.negate();return e?n:t},dv=e=>{let t=lv||=cv(),n=L_,r=I_,i=2**av,a=i,o=E_(i-1),s=E_(av);for(let i=0;i<ov;i++){let c=Number(e&o);e>>=s,c>sv&&(c-=a,e+=1n);let l=i*sv,u=l,d=l+Math.abs(c)-1,f=i%2!=0,p=c<0;c===0?r=r.add(uv(f,t[u])):n=n.add(uv(p,t[d]))}return e!==0n&&u_(`invalid wnaf`),{p:n,f:r}};rv.sha512=Kc;var fv=function(e){return e[e.SHA256=0]=`SHA256`,e}({}),pv=class{getHashSchemeId(){return fv.SHA256}hash(e){return Wc(e)}};function mv(e,t,n,r){Es(e);let{c:i,dkLen:a,asyncTick:o}=Gs({dkLen:32,asyncTick:10},r);if(ws(i),ws(a),ws(o),i<1)throw Error(`iterations (c) should be >= 1`);let s=Us(t),c=Us(n),l=new Uint8Array(a),u=Jd.create(e,s);return{c:i,dkLen:a,asyncTick:o,DK:l,PRF:u,PRFSalt:u._cloneInto().update(c)}}function hv(e,t,n,r,i){return e.destroy(),t.destroy(),r&&r.destroy(),As(i),n}function gv(e,t,n,r){let{c:i,dkLen:a,DK:o,PRF:s,PRFSalt:c}=mv(e,t,n,r),l,u=new Uint8Array(4),d=js(u),f=new Uint8Array(s.outputLen);for(let e=1,t=0;t<a;e++,t+=s.outputLen){let n=o.subarray(t,t+s.outputLen);d.setInt32(0,e,!1),(l=c._cloneInto(l)).update(u).digestInto(f),n.set(f.subarray(0,n.length));for(let e=1;e<i;e++){s._cloneInto(l).update(f).digestInto(f);for(let e=0;e<n.length;e++)n[e]^=f[e]}}return hv(s,c,o,l,f)}var _v=function(e){return e[e.PBKDF2=0]=`PBKDF2`,e[e.SCRYPT=1]=`SCRYPT`,e}({}),vv=class{deriveKeyNoSalt(e,t){return this.deriveKey(e,``,t)}},yv=class extends vv{getKeyDerivationFunctionSchemeId(){return _v.PBKDF2}deriveKey(e,t,n){return gv(Wc,e,t,{c:1e5,dkLen:n})}};function bv(e,t,n){return Es(e),n===void 0&&(n=new Uint8Array(e.outputLen)),Jd(e,Hs(n),Hs(t))}var xv=Uint8Array.from([0]),Sv=Uint8Array.of();function Cv(e,t,n,r=32){Es(e),ws(r);let i=e.outputLen;if(r>255*i)throw Error(`Length should be <= 255*HashLen`);let a=Math.ceil(r/i);n===void 0&&(n=Sv);let o=new Uint8Array(a*i),s=Jd.create(e,t),c=s._cloneInto(),l=new Uint8Array(s.outputLen);for(let e=0;e<a;e++)xv[0]=e+1,c.update(e===0?Sv:l).update(n).update(xv).digestInto(l),o.set(l,i*e),s._cloneInto(c);return s.destroy(),c.destroy(),As(l,xv),o.slice(0,r)}var wv=(e,t,n,r,i)=>Cv(e,bv(e,t,n),r,i),Tv=class{deriveKeyNoSalt(e,t,n){let r=new Uint8Array;return this.deriveKey(e,r,t,n)}},Ev=function(e){return e[e.HKDF=0]=`HKDF`,e}({}),Dv=class extends Tv{getKeyDerivationFunctionSchemeId(){return Ev.HKDF}deriveKey(e,t,n,r){return wv(Wc,e,t,n,r)}},Ov=function(e){return e[e.ML_KEM_768_AES_256_GCM=0]=`ML_KEM_768_AES_256_GCM`,e}({}),kv=function(e){return e[e.ML_KEM_768_AES_256_GCM=0]=`ML_KEM_768_AES_256_GCM`,e}({}),Av=class{},jv=class{async encode(e=Sg.defaultBytesToStringEncoder()){return e.encode(await this.getRawPublicKey())}getSchemeId(){return this.getScheme().getSchemeId()}},Mv=class{encode(e=Sg.defaultBytesToStringEncoder()){return e.encode(this.getRawPrivateKey())}},Nv=class extends Av{getSchemeId(){return Ov.ML_KEM_768_AES_256_GCM}getSupportedSeedLength(){return[32]}},Pv=128,Fv=96,Iv=32,Lv=64,Rv=7,zv=8,Bv=class{byteStream;constructor(){this.clear()}clear(){this.byteStream=[]}getByteStream(){return new Uint8Array(this.byteStream)}writeJsonValue(e,t){switch(e){case 3:this.writeString(t);break;case 4:this.writeNumber(t);break;case 5:this.writeBoolean(t);break;case 6:break;default:throw`Type ${e} is not a JSON type`}}writeSchemaValue(e,t,n){switch(e){case 3:this.writeString(t,n);break;case 4:this.writeNumber(t);break;case 5:this.writeBoolean(t);break;case 6:break;case 7:this.writeUint8(t);break;case 8:this.writeUint16(t);break;case 9:this.writeUint24(t);break;case 10:this.writeUint32(t);break;case 11:this.writeUint48(t);break;case 12:this.writeBinary(t,n);break;case 13:this.writeByteArray(t);break;case 14:this.writeHashString(t);break;default:throw`Unexpected type ${e}`}}writeByte(e){this.byteStream.push(e&255)}writeUnsigned(e,t){for(;t--;)this.writeByte(e/2**(t*8))}writeUint8(e){this.writeUnsigned(e,1)}writeUint16(e){this.writeUnsigned(e,2)}writeUint24(e){this.writeUnsigned(e,3)}writeUint32(e){this.writeUnsigned(e,4)}writeUint48(e){this.writeUnsigned(e,6)}writeBinary(e,t=-1){t==-1&&this.writeVarUint(e.length),this.writeByteArray(e)}writeHashString(e){this.writeByteArray(A.binaryFromHexa(e))}writeByteArray(e){for(let t of e)this.writeByte(t)}writeString(e,t=-1){let n=Za.encode(e);t==-1&&this.writeVarUint(n.length),this.writeByteArray(n)}writeVarUint(e){if(e==0)this.writeByte(0);else{if(e<0||e%1||e>2**53-1)throw`Invalid varUint ${e}`;for(;e;)this.writeByte(e%128|(e>127)<<7),e=Math.floor(e/128)}}writeBoolean(e){this.writeByte(e?255:0)}writeNumber(e){let t=!(e%1);if(t&&e>=-64&&e<64){this.writeByte(Pv|e&127);return}for(let n=1,r=256;n<=6;n++,r*=256){if(t&&e>=-r&&e<r){let t=e<0;this.writeByte(t<<3|n),this.writeUnsigned(t?-e-1:e,n);return}if(n==4){let t=new Float32Array([e]);if(+t[0].toPrecision(7)===e){this.writeByte(Iv),this.writeByteArray(new Uint8Array(t.buffer));return}}}this.writeByte(Lv),this.writeByteArray(new Uint8Array(new Float64Array([e]).buffer))}},Vv=class{byteStream;lastPointer;pointer;constructor(e){this.byteStream=e,this.pointer=0}readJsonValue(e){switch(this.lastPointer=this.pointer,e){case 3:return this.readString();case 4:return this.readNumber();case 5:return this.readBoolean();case 6:return null;default:throw`Type ${e} is not a JSON type`}}readSchemaValue(e,t){switch(this.lastPointer=this.pointer,e){case 3:return this.readString(t);case 4:return this.readNumber();case 5:return this.readBoolean();case 6:return null;case 7:return this.readUint8();case 8:return this.readUint16();case 9:return this.readUint24();case 10:return this.readUint32();case 11:return this.readUint48();case 12:return this.readBinary(t);case 13:return this.readByteArray(32);case 14:return this.readHashString()}}getPointer(){return this.pointer}extractFrom(e){return this.byteStream.slice(e,this.pointer)}getLastField(){return this.byteStream.slice(this.lastPointer,this.pointer)}readByte(){return this.byteStream[this.pointer++]}readUnsigned(e){let t=0;for(;e--;)t=t*256+this.readByte();return t}readUint8(){return this.readUnsigned(1)}readUint16(){return this.readUnsigned(2)}readUint24(){return this.readUnsigned(3)}readUint32(){return this.readUnsigned(4)}readUint48(){return this.readUnsigned(6)}readBinary(e=-1){return this.readByteArray(e==-1?this.readVarUint():e)}readHashString(){return A.binaryToHexa(this.readByteArray(32))}readByteArray(e){return this.byteStream.slice(this.pointer,this.pointer+=e)}readString(e=-1){let t=this.readByteArray(e==-1?this.readVarUint():e);return Za.decode(t)}readVarUint(){let e=[],t;do t=this.readByte(),e.push(t&127);while(t&128);return e.reduceRight((e,t)=>e*128+t,0)}readBoolean(){return!!this.readByte()}readNumber(){let e=this.readByte();if(e&Pv)return(e&127^64)-64;switch(e&Fv){case Iv:return+new Float32Array(this.readByteArray(4).buffer)[0].toPrecision(7);case Lv:return new Float64Array(this.readByteArray(8).buffer)[0];default:{let t=this.readUnsigned(e&Rv);return e&zv?-t-1:t}}}},Hv=class{schema;stream;constructor(e){this.schema=e}serialize(e){if(this.schema===void 0)throw new Oe(`Provided schema is undefined: this should not happen`);return this.stream=new Bv,this.serializeObject(this.schema.definition,e),this.stream.getByteStream()}serializeObject(e,t,n=``){for(let r of e){let e=n+(n&&`.`)+r.name,i=t[r.name];if(i===void 0)throw new Oe(`field '${e}' is missing`);if(r.type&32){if(no.getType(i)!=1)throw new Oe(`'${e}' is not an array`);if(r.size!==void 0){if(i.length!=r.size)throw new Oe(`invalid size for '${e}' (expecting ${r.size} entries, got ${i.length})`)}else this.stream.writeVarUint(i.length);for(let t in i)this.serializeItem(r,i[t],e+`[${t}]`)}else this.serializeItem(r,i,e)}}serializeItem(e,t,n){let r=e.type&31;if(r==2){if(no.getType(t)!=2)throw new Oe(`'${n}' is not an object`);if(e.definition)this.serializeObject(e.definition,t,n);else if(e.schema)this.serializeObject(e.schema.definition,t,n);else throw new Oe(`missing definition in schema`)}else{let i=new ro(e,t);try{i.check()}catch(e){throw new Oe(`Error on field '${n}': ${e}`)}this.stream.writeSchemaValue(r,t,e.size)}}},Uv=class{schema;stream;constructor(e){this.schema=e}unserialize(e){this.stream=new Vv(e);let t=this.unserializeObject(this.schema.definition),n=this.stream.getPointer(),r=e.length;if(n!=r)throw console.error(A.binaryToHexa(e)),new o(`Invalid stream length (decoded ${n} bytes, actual length is ${r} bytes)`);return t}unserializeObject(e){let t={};for(let n of e){let e;if(n.type&32){let t=n.size===void 0?this.stream.readVarUint():n.size;for(e=[];t--;)e.push(this.unserializeItem(n))}else e=this.unserializeItem(n);t[n.name]=e}return t}unserializeItem(e){let t=e.type&31;if(t==2){if(e.definition)return this.unserializeObject(e.definition);if(e.schema)return this.unserializeObject(e.schema.definition);throw`missing definition in schema`}return this.stream.readSchemaValue(t,e.size)}},Wv=class e{static schema={label:`PKE_ML_KEM_CIPHERTEXT`,definition:[{name:`encryptedSharedSecret`,type:12},{name:`encryptedMessage`,type:12}]};serializer=new Hv(e.schema);deserializer=new Uv(e.schema);encode(e,t){return this.serializer.serialize({encryptedSharedSecret:e,encryptedMessage:t})}decode(e){return this.deserializer.unserialize(e)}},Gv=class extends jv{static encoder=Sg.bytesToBase64Encoder();constructor(e){super(),this.publicKey=e}async encrypt(e){let{cipherText:t,sharedSecret:n}=Vd.encapsulate(this.publicKey),r=await Kg.createFromBytes(n).encrypt(e);return new Wv().encode(t,r)}async getRawPublicKey(){return this.publicKey}getScheme(){return new Nv}},Kv=class e extends Mv{static async genFromSeed(t){if(t.length!==64)throw Error(`Seed must be 64 bytes long: got length: ${t?.length} bytes`);return new e(t)}static async gen(){return new e(Pu(64))}privateKey;publicKey;constructor(e){super(),this.seed=e;let{secretKey:t,publicKey:n}=Vd.keygen(e);this.privateKey=t,this.publicKey=n}getSupportedSeedLength(){return[64]}getScheme(){return new Nv}async getPublicKey(){return new Gv(this.publicKey)}getRawPrivateKey(){return this.privateKey}async decrypt(e){try{let{encryptedMessage:t,encryptedSharedSecret:n}=new Wv().decode(e),r=Vd.decapsulate(n,this.privateKey);return Kg.createFromBytes(r).decrypt(t)}catch(e){throw o.isCarmentisError(e)?new f:e}}},qv=class e{static SIGNATURE_SIZE=65;getSignatureSchemeId(){return Ja.SECP256K1}getSignatureSize(){return e.SIGNATURE_SIZE}expectedSeedSize(){return 32}},Jv=class extends Xg{constructor(e){super(),this.publicKey=e}async getPublicKeyAsBytes(){return this.publicKey}async verify(e,t){return $f(t,Wc(e),this.publicKey)}getScheme(){return new qv}},Yv=class e extends Yg{constructor(e){super(),this.privateKey=e}getPrivateKeyAsString(e){return e.encode(this.getPrivateKeyAsBytes())}static gen(){return new e(ap.randomPrivateKey())}static genFromSeed(t){return new e(ip.bytesToHex(t))}async getPublicKey(){if(this.privateKey instanceof Uint8Array)return new Jv(Wf(this.privateKey));throw Error(`Invalid private key format: expected Uint8Array, got `+typeof this.privateKey+` instead.`)}getPrivateKeyAsBytes(){if(this.privateKey instanceof Uint8Array)return this.privateKey;throw Error(`Invalid private key format: expected Uint8Array, got `+typeof this.privateKey+` instead.`)}async sign(e){return Qf(Wc(e),this.privateKey).toCompactRawBytes()}getScheme(){return new qv}},Xv=class e{static SIGNATURE_SIZE=65;getSignatureSchemeId(){return Ja.ED25519}getSignatureSize(){return e.SIGNATURE_SIZE}expectedSeedSize(){return 32}},Zv=class extends Xg{constructor(e){super(),this.publicKey=e}async getPublicKeyAsBytes(){return this.publicKey}async verify(e,t){return nv(t,Wc(e),this.publicKey)}getScheme(){return new Xv}};rv.sha512=Kc;var Qv=class e extends Yg{constructor(e){super(),this.privateKey=e}getPrivateKeyAsString(e){return e.encode(this.getPrivateKeyAsBytes())}static gen(){return new e(iv.randomSecretKey())}static genFromSeed(t){return new e(t)}async getPublicKey(){if(this.privateKey instanceof Uint8Array)return new Zv(X_(this.privateKey));throw Error(`Invalid private key format: expected Uint8Array, got `+typeof this.privateKey+` instead.`)}getPrivateKeyAsBytes(){if(this.privateKey instanceof Uint8Array)return this.privateKey;throw Error(`Invalid private key format: expected Uint8Array, got `+typeof this.privateKey+` instead.`)}async sign(e){return $_(Wc(e),this.privateKey)}getScheme(){return new Xv}},$v=class e{static createPrivateSignatureKey(e,t){switch(e){case Ja.SECP256K1:return new Yv(t);case Ja.ML_DSA_65:return new $g(t);case Ja.ED25519:return new Qv(t.slice(0,32));default:throw`Not supported signature scheme ID: ${e}`}}static createVirtualBlockchainPrivateSignature(e,t,n,r){let i=new Uint8Array([...n,...r]),a=new TextEncoder,o=e.deriveKeyNoSalt(i,a.encode(`VB_ACTOR_KEY`),32);switch(t){case Ja.ML_DSA_65:return new $g(o);case Ja.SECP256K1:return Yv.genFromSeed(o);case Ja.ED25519:return new Qv(o.slice(0,32));default:throw`Not supported signature scheme ID: ${t}`}}static deriveKeyFromPassword(t,n=_v.PBKDF2,r=Wg.AES_256_GCM){let i=e.createSymmetricEncryptionKeyScheme(r).getDefaultKeyLength(),a=e.createDefaultPBKDF().deriveKeyNoSalt(t,i);return e.createSymmetricEncryptionKey(r,a)}createDecapsulationKey(e,t){switch(e){default:throw`Not supported encryption scheme ID: ${e}`}}createVirtualBlockchainDecapsulationKey(e,t,n){switch(e){default:throw`Not supported encryption scheme ID: ${e}`}}async createPublicSignatureKey(t,n){return e.createPublicSignatureKey(t,n)}static async createPublicSignatureKey(e,t){switch(e){case Ja.SECP256K1:return new Jv(t);case Ja.ML_DSA_65:return new Qg(t);case Ja.ED25519:return new Zv(t);default:throw Error(`Not supported signature scheme ID: ${e}`)}}static async createPublicEncryptionKey(e,t){switch(e){case Ov.ML_KEM_768_AES_256_GCM:return new Gv(t);default:throw Error(`Not supported scheme ID: ${e}`)}}static async createPrivateDecryptionKey(e,t){switch(e){case Ov.ML_KEM_768_AES_256_GCM:return await Kv.genFromSeed(t);default:throw Error(`Not supported scheme ID: ${e}`)}}createSymmetricEncryptionKey(t,n){return e.createSymmetricEncryptionKey(t,n)}static createSymmetricEncryptionKey(e,t){switch(e){case Wg.AES_256_GCM:return Kg.createFromBytes(t);default:throw`Not supported encryption scheme ID: ${e}`}}static createSymmetricEncryptionKeyScheme(e){switch(e){case Wg.AES_256_GCM:return new Gg;default:throw`Not supported encryption scheme ID: ${e}`}}static createCryptographicHash(e){switch(e){case fv.SHA256:return new pv;default:throw`Not supported hash scheme ID: ${e}`}}static createDefaultCryptographicHash(){return new pv}static createDefaultPBKDF(){return new yv}static createDefaultKDF(){return new Dv}static createSignatureScheme(e){switch(e){case Ja.SECP256K1:return new qv;case Ja.ML_DSA_65:return new Zg;case Ja.ED25519:return new Xv;default:throw Error(`Not supported signature scheme ID: ${e}`)}}},ey=class e{static PKE_KEY=`PKE`;static SK_PKE_KEY=`SK`;static PK_PKE_KEY=`PK`;static PKE_SCHEMES=[{algoId:Ov.ML_KEM_768_AES_256_GCM,label:`MLKEM768AES256GCM`}];static createHexHCVPkeEncoder(){return new e(Sg.bytesToHexEncoder())}static createBase64HCVPkeEncoder(){return new e(Sg.bytesToBase64Encoder())}constructor(e){this.stringEncoder=e}async decodePrivateDecryptionKey(t){let n=Eg.decode(t);for(let{algoId:t,label:r}of e.PKE_SCHEMES)if(n.matchesKeys(e.PKE_KEY,r,e.SK_PKE_KEY))return await $v.createPrivateDecryptionKey(t,this.stringEncoder.decode(n.getValue()));throw Error(`Invalid private key format: no scheme key found`)}async decodePublicEncryptionKey(t){let n=Eg.decode(t);for(let{algoId:t,label:r}of e.PKE_SCHEMES)if(n.matchesKeys(e.PKE_KEY,r,e.PK_PKE_KEY))return $v.createPublicEncryptionKey(t,this.stringEncoder.decode(n.getValue()));throw Error(`Invalid private key format: no scheme key found`)}async encodePrivateDecryptionKey(t){return Eg.encode(e.PKE_KEY,`MLKEM768AES256GCM`,e.SK_PKE_KEY,this.stringEncoder.encode(t.getRawPrivateKey()))}async encodePublicEncryptionKey(t){return Eg.encode(e.PKE_KEY,`MLKEM768AES256GCM`,e.PK_PKE_KEY,this.stringEncoder.encode(await t.getRawPublicKey()))}};function ty(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var ny={exports:{}},ry=ny.exports={},iy,ay;function oy(){throw Error(`setTimeout has not been defined`)}function sy(){throw Error(`clearTimeout has not been defined`)}(function(){try{iy=typeof setTimeout==`function`?setTimeout:oy}catch{iy=oy}try{ay=typeof clearTimeout==`function`?clearTimeout:sy}catch{ay=sy}})();function cy(e){if(iy===setTimeout)return setTimeout(e,0);if((iy===oy||!iy)&&setTimeout)return iy=setTimeout,setTimeout(e,0);try{return iy(e,0)}catch{try{return iy.call(null,e,0)}catch{return iy.call(this,e,0)}}}function ly(e){if(ay===clearTimeout)return clearTimeout(e);if((ay===sy||!ay)&&clearTimeout)return ay=clearTimeout,clearTimeout(e);try{return ay(e)}catch{try{return ay.call(null,e)}catch{return ay.call(this,e)}}}var uy=[],dy=!1,fy,py=-1;function my(){!dy||!fy||(dy=!1,fy.length?uy=fy.concat(uy):py=-1,uy.length&&hy())}function hy(){if(!dy){var e=cy(my);dy=!0;for(var t=uy.length;t;){for(fy=uy,uy=[];++py<t;)fy&&fy[py].run();py=-1,t=uy.length}fy=null,dy=!1,ly(e)}}ry.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];uy.push(new gy(e,t)),uy.length===1&&!dy&&cy(hy)};function gy(e,t){this.fun=e,this.array=t}gy.prototype.run=function(){this.fun.apply(null,this.array)},ry.title=`browser`,ry.browser=!0,ry.env={},ry.argv=[],ry.version=``,ry.versions={};function _y(){}ry.on=_y,ry.addListener=_y,ry.once=_y,ry.off=_y,ry.removeListener=_y,ry.removeAllListeners=_y,ry.emit=_y,ry.prependListener=_y,ry.prependOnceListener=_y,ry.listeners=function(e){return[]},ry.binding=function(e){throw Error(`process.binding is not supported`)},ry.cwd=function(){return`/`},ry.chdir=function(e){throw Error(`process.chdir is not supported`)},ry.umask=function(){return 0};var vy=ny.exports,yy=ty(vy),by=class{async getPkmsCredential(){let e=yy.env.PKMS_API_KEY;if(e===void 0)throw Error(`PKMS_API_KEY environment variable is not set.`);return e}},xy=`https://pkms.admin.carmentis.io`,Sy=class e{static createFromKeyId(t){return new e(t)}credentialProvider=new by;constructor(e,t={host:xy}){this.keyId=e,this.options=t}getKeyId(){return this.keyId}getPrivateKeyAsBytes(){throw Error(`Private key material cannot be exported.`)}async getPublicKey(){let e=await fetch(`${this.options.host}/api/keys/${this.keyId}/pk`,{method:`GET`,headers:{"Content-Type":`application/json`}});if(!e.ok)throw Error(`Failed to fetch public key with id ${this.keyId} at ${this.options.host}: ${e.statusText}.`);let t=(await e.json()).publicKey;if(t===void 0)throw Error(`Failed to fetch public key: no "publicKey" field found in response body.`);return new Jv(new Uint8Array(Ug.from(t,`base64`)))}getScheme(){return new qv}getSignatureSchemeId(){return Ja.PKMS_SECP256K1}getSignatureSize(){return this.getScheme().getSignatureSize()}setCredentialProvider(e){this.credentialProvider=e}async sign(e){let t=await this.credentialProvider.getPkmsCredential();try{let n=await fetch(`${this.options.host}/api/sign`,{method:`POST`,headers:{authorization:`Bearer ${t}`,"Content-Type":`application/json`},body:JSON.stringify({keyId:this.keyId,base64EncodedData:Ug.from(e).toString(`base64`)})});if(n.ok){let e=await n.json();return Ug.from(e.signature,`base64`)}else throw Error(`Failed to sign data.`)}catch(e){throw e}}},Cy=class extends Jv{getSignatureSchemeId(){return Ja.PKMS_SECP256K1}},wy=`sig`,Ty=`secp256k1`,Ey=`mldsa65`,Dy=`pkms`,Oy=`pk`,ky=`sk`,Ay=class{bytesEncoder=Sg.bytesToHexEncoder();async isAcceptingPublicKeyEncodingRequest(e){return this.getPublicKeySchemeTags(e).length>0}async isAcceptingPrivateKeyEncodingRequest(e){return this.getPrivateKeySchemeTags(e).length>0}async encodePublicKey(e){if(!this.isAcceptingPublicKeyEncodingRequest(e))throw Error(`unexpected public key type`);let t=this.getPublicKeySchemeTags(e),n=await this.getPublicKeyPayload(e);return[`sig`,...t,`pk`,n].join(`:`)}async encodePrivateKey(e){if(!this.isAcceptingPrivateKeyEncodingRequest(e))throw Error(`unexpected private key type`);let t=this.getPrivateKeySchemeTags(e),n=await this.getPrivateKeyPayload(e);return[`sig`,...t,`sk`,n].join(`:`)}async getPublicKeyPayload(e){return this.bytesEncoder.encode(await e.getPublicKeyAsBytes())}async getPrivateKeyPayload(e){return e instanceof Sy?e.getKeyId():this.bytesEncoder.encode(e.getPrivateKeyAsBytes())}getPublicKeySchemeTags(e){return e instanceof Jv?[Ty]:e instanceof Qg?[Ey]:e instanceof Cy?[Dy,Ty]:[]}getPrivateKeySchemeTags(e){return e instanceof Yv?[Ty]:e instanceof $g?[Ey]:e instanceof Sy?[Dy,Ty]:[]}},jy=`SIG`,My=`SK`,Ny=`PK`,Py=class e{static logger=k.getLogger([`HCVSignatureDecoder`]);bytesEncoder=Sg.bytesToHexEncoder();constructor(e){this.labels=e}async isAcceptingPrivateKeyDecodingRequest(t){try{let n=Eg.decode(t);return e.logger.debug(`Attempt to decode private key for ${this.labels}: found ${n.getKeys()}`),n.matchesKeys(jy,...this.labels,My)}catch(t){return e.logger.debug(`Fail to decode private key for ${this.labels}: ${t}`),!1}}async isAcceptingPublicKeyDecodingRequest(e){try{return Eg.decode(e).matchesKeys(jy,...this.labels,Ny)}catch{return!1}}static getSignatureKey(){return jy}static getSkSignatureKey(){return My}static getPkSignatureKey(){return Ny}},Fy=class extends Py{async decodePrivateKey(e){let t=Eg.decode(e),n=this.bytesEncoder.decode(t.getValue());return this.bootstrapPrivateKey(n)}async decodePublicKey(e){let t=Eg.decode(e),n=this.bytesEncoder.decode(t.getValue());return this.bootstrapPublicKey(n)}},Iy=class e extends Fy{static label=`SECP256K1`;constructor(){super([e.label])}bootstrapPrivateKey(e){return new Yv(e)}bootstrapPublicKey(e){return new Jv(e)}},Ly=class e extends Fy{static ML_DSA65_SIGNATURE_KEY=`MLDSA65`;constructor(){super([e.ML_DSA65_SIGNATURE_KEY])}bootstrapPrivateKey(e){return new $g(e)}bootstrapPublicKey(e){return new Qg(e)}},Ry=class e extends Py{static label=[`PKMS`,`SECP256K1`];constructor(){super(e.label)}async decodePrivateKey(e){return new Sy(Eg.decode(e).getValue())}async decodePublicKey(e){let t=Eg.decode(e);return new Cy(this.bytesEncoder.decode(t.getValue()))}},zy=class e{bytesEncoder=Sg.bytesToHexEncoder();static getAcceptedSchemeTags(){return[[Ty],[Ey],[Dy,Ty]]}async isAcceptingPublicKeyDecodingRequest(e){let t=this.getKeyParts(e);return t!==null&&t.typeTag===`pk`}async isAcceptingPrivateKeyDecodingRequest(e){let t=this.getKeyParts(e);return t!==null&&t.typeTag===`sk`}async decodePublicKey(e){let t=this.getKeyParts(e);if(t===null)throw Error(`invalid key format`);if(t.typeTag!==`pk`)throw Error(`not a public key format`);switch(t.schemeTags[0]){case Ty:return new Jv(this.bytesEncoder.decode(t.payload));case Ey:return new Qg(this.bytesEncoder.decode(t.payload));case Dy:if(t.schemeTags[1]===`secp256k1`)return new Cy(this.bytesEncoder.decode(t.payload));break}throw Error(`unsupported key format`)}async decodePrivateKey(e){let t=this.getKeyParts(e);if(t===null)throw Error(`invalid key format`);if(t.typeTag!==`sk`)throw Error(`not a private key format`);switch(t.schemeTags[0]){case Ty:return new Yv(this.bytesEncoder.decode(t.payload));case Ey:return new $g(this.bytesEncoder.decode(t.payload));case Dy:if(t.schemeTags[1]===`secp256k1`){let e=t.payload;return new Sy(e)}break}throw Error(`unsupported key format`)}getKeyParts(t){let n=t.split(`:`),r=0;if(n[r++]!==`sig`)return null;let i=[],a=n[r++];if(i.push(a),a===`pkms`&&i.push(n[r++]),!e.getAcceptedSchemeTags().some(e=>i.length===e.length&&i.every((t,n)=>e[n]===t)))return null;let o=n[r++];if(o!==`pk`&&o!==`sk`)return null;let s=n[r++];return s===void 0||n[r]!==void 0?null:{schemeTags:i,typeTag:o,payload:s}}},By=class e{static createEmpty(){let t=new e;return t.clear(),t}encoders=[new Ay];decoders=[new zy,new Iy,new Ly,new Ry];constructor(e=Sg.bytesToHexEncoder()){this.bytesEncoder=e}registerEncoder(e){this.encoders.push(e)}registerDecoder(e){this.decoders.push(e)}decodeMessage(e){return this.bytesEncoder.decode(e)}async decodePrivateKey(e){for(let t of this.decoders)if(await t.isAcceptingPrivateKeyDecodingRequest(e))return await t.decodePrivateKey(e);throw Error(`Invalid private key format: no decoder found`)}async decodePublicKey(e){for(let t of this.decoders)if(await t.isAcceptingPublicKeyDecodingRequest(e))return await t.decodePublicKey(e);throw Error(`Invalid private key format: no decoder found`)}decodeSignature(e){return this.bytesEncoder.decode(e)}encodeMessage(e){return this.bytesEncoder.encode(e)}async encodePrivateKey(e){for(let t of this.encoders)if(await t.isAcceptingPrivateKeyEncodingRequest(e))return await t.encodePrivateKey(e);throw Error(`No encoder found`)}async encodePublicKey(e){for(let t of this.encoders)if(await t.isAcceptingPublicKeyEncodingRequest(e))return await t.encodePublicKey(e);throw Error(`No encoder found`)}encodeSignature(e){return this.bytesEncoder.encode(e)}clear(){this.clearEncoders(),this.clearDecoders()}clearEncoders(){this.encoders=[]}clearDecoders(){this.decoders=[]}},Vy;try{Vy=new TextDecoder}catch{}var W,Hy,G=0,Uy=[],Wy=105,Gy=57342,Ky=57343,qy=57337,Jy=6,Yy={},Xy=11281e4,Zy=1681e4,Qy=Uy,$y=0,K={},eb,tb,nb=0,rb=0,ib,ab,ob=[],sb=[],cb,lb,ub,db={useRecords:!1,mapsAsObjects:!0},fb=!1,pb=2;try{Function(``)}catch{pb=1/0}var mb=class e{constructor(e){if(e&&((e.keyMap||e._keyMap)&&!e.useRecords&&(e.useRecords=!1,e.mapsAsObjects=!0),e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.getStructures&&(e.getShared=e.getStructures),e.getShared&&!e.structures&&((e.structures=[]).uninitialized=!0),e.keyMap)){this.mapKey=new Map;for(let[t,n]of Object.entries(e.keyMap))this.mapKey.set(n,t)}Object.assign(this,e)}decodeKey(e){return this.keyMap&&this.mapKey.get(e)||e}encodeKey(e){return this.keyMap&&this.keyMap.hasOwnProperty(e)?this.keyMap[e]:e}encodeKeys(e){if(!this._keyMap)return e;let t=new Map;for(let[n,r]of Object.entries(e))t.set(this._keyMap.hasOwnProperty(n)?this._keyMap[n]:n,r);return t}decodeKeys(e){if(!this._keyMap||e.constructor.name!=`Map`)return e;if(!this._mapKey){this._mapKey=new Map;for(let[e,t]of Object.entries(this._keyMap))this._mapKey.set(t,e)}let t={};return e.forEach((e,n)=>t[vb(this._mapKey.has(n)?this._mapKey.get(n):n)]=e),t}mapDecode(e,t){let n=this.decode(e);if(this._keyMap)switch(n.constructor.name){case`Array`:return n.map(e=>this.decodeKeys(e))}return n}decode(t,n){if(W)return Hb(()=>(Ub(),this?this.decode(t,n):e.prototype.decode.call(db,t,n)));Hy=n>-1?n:t.length,G=0,$y=0,rb=0,tb=null,Qy=Uy,ib=null,W=t;try{lb=t.dataView||=new DataView(t.buffer,t.byteOffset,t.byteLength)}catch(e){throw W=null,t instanceof Uint8Array?e:Error(`Source must be a Uint8Array or Buffer but was a `+(t&&typeof t==`object`?t.constructor.name:typeof t))}if(this instanceof e){if(K=this,cb=this.sharedValues&&(this.pack?Array(this.maxPrivatePackedValues||16).concat(this.sharedValues):this.sharedValues),this.structures)return eb=this.structures,hb();(!eb||eb.length>0)&&(eb=[])}else K=db,(!eb||eb.length>0)&&(eb=[]),cb=null;return hb()}decodeMultiple(e,t){let n,r=0;try{let i=e.length;fb=!0;let a=this?this.decode(e,i):Gb.decode(e,i);if(t){if(t(a)===!1)return;for(;G<i;)if(r=G,t(hb())===!1)return}else{for(n=[a];G<i;)r=G,n.push(hb());return n}}catch(e){throw e.lastPosition=r,e.values=n,e}finally{fb=!1,Ub()}}};function hb(){try{let e=q();if(ib){if(G>=ib.postBundlePosition){let e=Error(`Unexpected bundle position`);throw e.incomplete=!0,e}G=ib.postBundlePosition,ib=null}if(G==Hy)eb=null,W=null,ab&&=null;else if(G>Hy){let e=Error(`Unexpected end of CBOR data`);throw e.incomplete=!0,e}else if(!fb)throw Error(`Data read, but end of buffer not reached`);return e}catch(e){throw Ub(),(e instanceof RangeError||e.message.startsWith(`Unexpected end of buffer`))&&(e.incomplete=!0),e}}function q(){let e=W[G++],t=e>>5;if(e&=31,e>23)switch(e){case 24:e=W[G++];break;case 25:if(t==7)return Db();e=lb.getUint16(G),G+=2;break;case 26:if(t==7){let e=lb.getFloat32(G);if(K.useFloat32>2){let t=Wb[(W[G]&127)<<1|W[G+1]>>7];return G+=4,(t*e+(e>0?.5:-.5)>>0)/t}return G+=4,e}if(e=lb.getUint32(G),G+=4,t===1)return-1-e;break;case 27:if(t==7){let e=lb.getFloat64(G);return G+=8,e}if(t>1){if(lb.getUint32(G)>0)throw Error(`JavaScript does not support arrays, maps, or strings with length over 4294967295`);e=lb.getUint32(G+4)}else K.int64AsNumber?(e=lb.getUint32(G)*4294967296,e+=lb.getUint32(G+4)):e=lb.getBigUint64(G);G+=8;break;case 31:switch(t){case 2:case 3:throw Error(`Indefinite length not supported for byte or text strings`);case 4:let e=[],n,r=0;for(;(n=q())!=Yy;){if(r>=Xy)throw Error(`Array length exceeds ${Xy}`);e[r++]=n}return t==4?e:t==3?e.join(``):Ug.concat(e);case 5:let i;if(K.mapsAsObjects){let e={},t=0;if(K.keyMap)for(;(i=q())!=Yy;){if(t++>=Zy)throw Error(`Property count exceeds ${Zy}`);e[vb(K.decodeKey(i))]=q()}else for(;(i=q())!=Yy;){if(t++>=Zy)throw Error(`Property count exceeds ${Zy}`);e[vb(i)]=q()}return e}else{ub&&=(K.mapsAsObjects=!0,!1);let e=new Map;if(K.keyMap){let t=0;for(;(i=q())!=Yy;){if(t++>=Zy)throw Error(`Map size exceeds ${Zy}`);e.set(K.decodeKey(i),q())}}else{let t=0;for(;(i=q())!=Yy;){if(t++>=Zy)throw Error(`Map size exceeds ${Zy}`);e.set(i,q())}}return e}case 7:return Yy;default:throw Error(`Invalid major type for indefinite length `+t)}default:throw Error(`Unknown token `+e)}switch(t){case 0:return e;case 1:return~e;case 2:return wb(e);case 3:if(rb>=G)return tb.slice(G-nb,(G+=e)-nb);if(rb==0&&Hy<140&&e<32){let t=e<16?Cb(e):Sb(e);if(t!=null)return t}return yb(e);case 4:if(e>=Xy)throw Error(`Array length exceeds ${Xy}`);let t=Array(e);for(let n=0;n<e;n++)t[n]=q();return t;case 5:if(e>=Zy)throw Error(`Map size exceeds ${Xy}`);if(K.mapsAsObjects){let t={};if(K.keyMap)for(let n=0;n<e;n++)t[vb(K.decodeKey(q()))]=q();else for(let n=0;n<e;n++)t[vb(q())]=q();return t}else{ub&&=(K.mapsAsObjects=!0,!1);let t=new Map;if(K.keyMap)for(let n=0;n<e;n++)t.set(K.decodeKey(q()),q());else for(let n=0;n<e;n++)t.set(q(),q());return t}case 6:if(e>=qy){let t=eb[e&8191];if(t)return t.read||=_b(t),t.read();if(e<65536){if(e==Ky){let e=Bb(),t=q(),n=q();kb(t,n);let r={};if(K.keyMap)for(let t=2;t<e;t++){let e=K.decodeKey(n[t-2]);r[vb(e)]=q()}else for(let t=2;t<e;t++){let e=n[t-2];r[vb(e)]=q()}return r}else if(e==Gy){let e=Bb(),t=q();for(let n=2;n<e;n++)kb(t++,q());return q()}else if(e==qy)return zb();if(K.getShared&&(Vb(),t=eb[e&8191],t))return t.read||=_b(t),t.read()}}let n=ob[e];if(n)return n.handlesRead?n(q):n(q());{let t=q();for(let n=0;n<sb.length;n++){let r=sb[n](e,t);if(r!==void 0)return r}return new Ob(t,e)}case 7:switch(e){case 20:return!1;case 21:return!0;case 22:return null;case 23:return;default:let t=(cb||Nb())[e];if(t!==void 0)return t;throw Error(`Unknown token `+e)}default:if(isNaN(e)){let e=Error(`Unexpected end of CBOR data`);throw e.incomplete=!0,e}throw Error(`Unknown CBOR token `+e)}}var gb=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function _b(e){if(!e)throw Error(`Structure is required in record definition`);function t(){let e=W[G++];if(e&=31,e>23)switch(e){case 24:e=W[G++];break;case 25:e=lb.getUint16(G),G+=2;break;case 26:e=lb.getUint32(G),G+=4;break;default:throw Error(`Expected array header, but got `+W[G-1])}let t=this.compiledReader;for(;t;){if(t.propertyCount===e)return t(q);t=t.next}if(this.slowReads++>=pb){let n=this.length==e?this:this.slice(0,e);return t=K.keyMap?Function(`r`,`return {`+n.map(e=>K.decodeKey(e)).map(e=>gb.test(e)?vb(e)+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`}`):Function(`r`,`return {`+n.map(e=>gb.test(e)?vb(e)+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`}`),this.compiledReader&&(t.next=this.compiledReader),t.propertyCount=e,this.compiledReader=t,t(q)}let n={};if(K.keyMap)for(let t=0;t<e;t++)n[vb(K.decodeKey(this[t]))]=q();else for(let t=0;t<e;t++)n[vb(this[t])]=q();return n}return e.slowReads=0,t}function vb(e){if(typeof e==`string`)return e===`__proto__`?`__proto_`:e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return e.toString();if(e==null)return e+``;throw Error(`Invalid property name type `+typeof e)}var yb=bb;function bb(e){let t;if(e<16&&(t=Cb(e)))return t;if(e>64&&Vy)return Vy.decode(W.subarray(G,G+=e));let n=G+e,r=[];for(t=``;G<n;){let e=W[G++];if(!(e&128))r.push(e);else if((e&224)==192){let t=W[G++]&63,n=(e&31)<<6|t;n<128?r.push(65533):r.push(n)}else if((e&240)==224){let t=W[G++]&63,n=W[G++]&63,i=(e&31)<<12|t<<6|n;i<2048||i>=55296&&i<=57343?r.push(65533):r.push(i)}else if((e&248)==240){let t=W[G++]&63,n=W[G++]&63,i=W[G++]&63,a=(e&7)<<18|t<<12|n<<6|i;a<65536||a>1114111?r.push(65533):a>65535?(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023,r.push(a)):r.push(a)}else r.push(65533);r.length>=4096&&(t+=xb.apply(String,r),r.length=0)}return r.length>0&&(t+=xb.apply(String,r)),t}var xb=String.fromCharCode;function Sb(e){let t=G,n=Array(e);for(let r=0;r<e;r++){let e=W[G++];if((e&128)>0){G=t;return}n[r]=e}return xb.apply(String,n)}function Cb(e){if(e<4)if(e<2){if(e===0)return``;{let e=W[G++];if((e&128)>1){--G;return}return xb(e)}}else{let t=W[G++],n=W[G++];if((t&128)>0||(n&128)>0){G-=2;return}if(e<3)return xb(t,n);let r=W[G++];if((r&128)>0){G-=3;return}return xb(t,n,r)}else{let t=W[G++],n=W[G++],r=W[G++],i=W[G++];if((t&128)>0||(n&128)>0||(r&128)>0||(i&128)>0){G-=4;return}if(e<6){if(e===4)return xb(t,n,r,i);{let e=W[G++];if((e&128)>0){G-=5;return}return xb(t,n,r,i,e)}}else if(e<8){let a=W[G++],o=W[G++];if((a&128)>0||(o&128)>0){G-=6;return}if(e<7)return xb(t,n,r,i,a,o);let s=W[G++];if((s&128)>0){G-=7;return}return xb(t,n,r,i,a,o,s)}else{let a=W[G++],o=W[G++],s=W[G++],c=W[G++];if((a&128)>0||(o&128)>0||(s&128)>0||(c&128)>0){G-=8;return}if(e<10){if(e===8)return xb(t,n,r,i,a,o,s,c);{let e=W[G++];if((e&128)>0){G-=9;return}return xb(t,n,r,i,a,o,s,c,e)}}else if(e<12){let l=W[G++],u=W[G++];if((l&128)>0||(u&128)>0){G-=10;return}if(e<11)return xb(t,n,r,i,a,o,s,c,l,u);let d=W[G++];if((d&128)>0){G-=11;return}return xb(t,n,r,i,a,o,s,c,l,u,d)}else{let l=W[G++],u=W[G++],d=W[G++],f=W[G++];if((l&128)>0||(u&128)>0||(d&128)>0||(f&128)>0){G-=12;return}if(e<14){if(e===12)return xb(t,n,r,i,a,o,s,c,l,u,d,f);{let e=W[G++];if((e&128)>0){G-=13;return}return xb(t,n,r,i,a,o,s,c,l,u,d,f,e)}}else{let p=W[G++],m=W[G++];if((p&128)>0||(m&128)>0){G-=14;return}if(e<15)return xb(t,n,r,i,a,o,s,c,l,u,d,f,p,m);let h=W[G++];if((h&128)>0){G-=15;return}return xb(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}}}}}function wb(e){return K.copyBuffers?Uint8Array.prototype.slice.call(W,G,G+=e):W.subarray(G,G+=e)}var Tb=new Float32Array(1),Eb=new Uint8Array(Tb.buffer,0,4);function Db(){let e=W[G++],t=W[G++],n=(e&127)>>2;if(n===31)return t||e&3?NaN:e&128?-1/0:1/0;if(n===0){let n=((e&3)<<8|t)/(1<<24);return e&128?-n:n}return Eb[3]=e&128|(n>>1)+56,Eb[2]=(e&7)<<5|t>>3,Eb[1]=t<<5,Eb[0]=0,Tb[0]}Array(4096);var Ob=class{constructor(e,t){this.value=e,this.tag=t}};ob[0]=e=>new Date(e),ob[1]=e=>new Date(Math.round(e*1e3)),ob[2]=e=>{let t=BigInt(0);for(let n=0,r=e.byteLength;n<r;n++)t=BigInt(e[n])+(t<<BigInt(8));return t},ob[3]=e=>BigInt(-1)-ob[2](e),ob[4]=e=>+(e[1]+`e`+e[0]),ob[5]=e=>e[1]*Math.exp(e[0]*Math.log(2));var kb=(e,t)=>{e-=57344;let n=eb[e];n&&n.isShared&&((eb.restoreStructures||=[])[e]=n),eb[e]=t,t.read=_b(t)};ob[Wy]=e=>{let t=e.length,n=e[1];kb(e[0],n);let r={};for(let i=2;i<t;i++){let t=n[i-2];r[vb(t)]=e[i]}return r},ob[14]=e=>ib?ib[0].slice(ib.position0,ib.position0+=e):new Ob(e,14),ob[15]=e=>ib?ib[1].slice(ib.position1,ib.position1+=e):new Ob(e,15);var Ab={Error,RegExp};ob[27]=e=>(Ab[e[0]]||Error)(e[1],e[2]);var jb=e=>{if(W[G++]!=132){let e=Error(`Packed values structure must be followed by a 4 element array`);throw W.length<G&&(e.incomplete=!0),e}let t=e();if(!t||!t.length){let e=Error(`Packed values structure must be followed by a 4 element array`);throw e.incomplete=!0,e}return cb=cb?t.concat(cb.slice(t.length)):t,cb.prefixes=e(),cb.suffixes=e(),e()};jb.handlesRead=!0,ob[51]=jb,ob[Jy]=e=>{if(!cb)if(K.getShared)Vb();else return new Ob(e,Jy);if(typeof e==`number`)return cb[16+(e>=0?2*e:-2*e-1)];let t=Error(`No support for non-integer packed references yet`);throw e===void 0&&(t.incomplete=!0),t},ob[28]=e=>{ab||(ab=new Map,ab.id=0);let t=ab.id++,n=G,r=W[G],i;i=r>>5==4?[]:{};let a={target:i};ab.set(t,a);let o=e();return a.used?(Object.getPrototypeOf(i)!==Object.getPrototypeOf(o)&&(G=n,i=o,ab.set(t,{target:i}),o=e()),Object.assign(i,o)):(a.target=o,o)},ob[28].handlesRead=!0,ob[29]=e=>{let t=ab.get(e);return t.used=!0,t.target},ob[258]=e=>new Set(e),(ob[259]=e=>(K.mapsAsObjects&&(K.mapsAsObjects=!1,ub=!0),e())).handlesRead=!0;function Mb(e,t){return typeof e==`string`?e+t:e instanceof Array?e.concat(t):Object.assign({},e,t)}function Nb(){if(!cb)if(K.getShared)Vb();else throw Error(`No packed values available`);return cb}var Pb=1399353956;sb.push((e,t)=>{if(e>=225&&e<=255)return Mb(Nb().prefixes[e-224],t);if(e>=28704&&e<=32767)return Mb(Nb().prefixes[e-28672],t);if(e>=1879052288&&e<=2147483647)return Mb(Nb().prefixes[e-1879048192],t);if(e>=216&&e<=223)return Mb(t,Nb().suffixes[e-216]);if(e>=27647&&e<=28671)return Mb(t,Nb().suffixes[e-27639]);if(e>=1811940352&&e<=1879048191)return Mb(t,Nb().suffixes[e-1811939328]);if(e==Pb)return{packedValues:cb,structures:eb.slice(0),version:t};if(e==55799)return t});var Fb=new Uint8Array(new Uint16Array([1]).buffer)[0]==1,Ib=[Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>`u`?{name:`BigUint64Array`}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>`u`?{name:`BigInt64Array`}:BigInt64Array,Float32Array,Float64Array],Lb=[64,68,69,70,71,72,77,78,79,85,86];for(let e=0;e<Ib.length;e++)Rb(Ib[e],Lb[e]);function Rb(e,t){let n=`get`+e.name.slice(0,-5),r;typeof e==`function`?r=e.BYTES_PER_ELEMENT:e=null;for(let i=0;i<2;i++){if(!i&&r==1)continue;let a=r==2?1:r==4?2:r==8?3:0;ob[i?t:t-4]=r==1||i==Fb?n=>{if(!e)throw Error(`Could not find typed array for code `+t);return!K.copyBuffers&&(r===1||r===2&&!(n.byteOffset&1)||r===4&&!(n.byteOffset&3)||r===8&&!(n.byteOffset&7))?new e(n.buffer,n.byteOffset,n.byteLength>>a):new e(Uint8Array.prototype.slice.call(n,0).buffer)}:r=>{if(!e)throw Error(`Could not find typed array for code `+t);let o=new DataView(r.buffer,r.byteOffset,r.byteLength),s=r.length>>a,c=new e(s),l=o[n];for(let e=0;e<s;e++)c[e]=l.call(o,e<<a,i);return c}}}function zb(){let e=Bb(),t=G+q();for(let t=2;t<e;t++){let e=Bb();G+=e}let n=G;return G=t,ib=[bb(Bb()),bb(Bb())],ib.position0=0,ib.position1=0,ib.postBundlePosition=G,G=n,q()}function Bb(){let e=W[G++]&31;if(e>23)switch(e){case 24:e=W[G++];break;case 25:e=lb.getUint16(G),G+=2;break;case 26:e=lb.getUint32(G),G+=4;break}return e}function Vb(){if(K.getShared){let e=Hb(()=>(W=null,K.getShared()))||{},t=e.structures||[];K.sharedVersion=e.version,cb=K.sharedValues=e.packedValues,eb===!0?K.structures=eb=t:eb.splice.apply(eb,[0,t.length].concat(t))}}function Hb(e){let t=Hy,n=G,r=$y,i=nb,a=rb,o=tb,s=Qy,c=ab,l=ib,u=new Uint8Array(W.slice(0,Hy)),d=eb,f=K,p=fb,m=e();return Hy=t,G=n,$y=r,nb=i,rb=a,tb=o,Qy=s,ab=c,ib=l,W=u,fb=p,eb=d,K=f,lb=new DataView(W.buffer,W.byteOffset,W.byteLength),m}function Ub(){W=null,ab=null,eb=null}var Wb=Array(147);for(let e=0;e<256;e++)Wb[e]=+(`1e`+Math.floor(45.15-e*.30103));var Gb=new mb({useRecords:!1}),Kb=Gb.decode;Gb.decodeMultiple;var qb={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},Jb;try{Jb=new TextEncoder}catch{}var Yb,Xb,Zb=typeof globalThis==`object`&&globalThis.Buffer,Qb=Zb!==void 0,$b=Qb?Zb.allocUnsafeSlow:Uint8Array,ex=Qb?Zb:Uint8Array,tx=256,nx=Qb?4294967296:2144337920,rx,J,ix,Y=0,ax,ox=null,sx=61440,cx=/[\u0080-\uFFFF]/,lx=Symbol(`record-id`),ux=class extends mb{constructor(e){super(e),this.offset=0;let t,n,r,i,a;e||={};let o=ex.prototype.utf8Write?function(e,t){return J.utf8Write(e,t,J.byteLength-t)}:Jb&&Jb.encodeInto?function(e,t){return Jb.encodeInto(e,J.subarray(t)).written}:!1,s=this,c=e.structures||e.saveStructures,l=e.maxSharedStructures;if(l??=c?128:0,l>8190)throw Error(`Maximum maxSharedStructure is 8190`);let u=e.sequential;u&&(l=0),this.structures||=[],this.saveStructures&&(this.saveShared=this.saveStructures);let d,f,p=e.sharedValues,m;if(p){m=Object.create(null);for(let e=0,t=p.length;e<t;e++)m[p[e]]=e}let h=[],g=0,_=0;this.mapEncode=function(e,t){if(this._keyMap&&!this._mapped)switch(e.constructor.name){case`Array`:e=e.map(e=>this.encodeKeys(e));break}return this.encode(e,t)},this.encode=function(o,c){if(J||(J=new $b(8192),ix=new DataView(J.buffer,0,8192),Y=0),ax=J.length-10,ax-Y<2048?(J=new $b(J.length),ix=new DataView(J.buffer,0,J.length),ax=J.length-10,Y=0):c===512&&(Y=Y+7&2147483640),t=Y,s.useSelfDescribedHeader&&(ix.setUint32(Y,3654940416),Y+=3),a=s.structuredClone?new Map:null,s.bundleStrings&&typeof o!=`string`?(ox=[],ox.size=1/0):ox=null,n=s.structures,n){if(n.uninitialized){let e=s.getShared()||{};s.structures=n=e.structures||[],s.sharedVersion=e.version;let t=s.sharedValues=e.packedValues;if(t){m={};for(let e=0,n=t.length;e<n;e++)m[t[e]]=e}}let e=n.length;if(e>l&&!u&&(e=l),!n.transitions){n.transitions=Object.create(null);for(let t=0;t<e;t++){let e=n[t];if(!e)continue;let r,i=n.transitions;for(let n=0,a=e.length;n<a;n++){i[lx]===void 0&&(i[lx]=t);let a=e[n];r=i[a],r||=i[a]=Object.create(null),i=r}i[lx]=t|1048576}}u||(n.nextId=e)}if(r&&=!1,i=n||[],f=m,e.pack){let t=new Map;if(t.values=[],t.encoder=s,t.maxValues=e.maxPrivatePackedValues||(m?16:1/0),t.objectMap=m||!1,t.samplingPackedValues=d,gx(o,t),t.values.length>0){J[Y++]=216,J[Y++]=51,px(4);let e=t.values;v(e),px(0),px(0),f=Object.create(m||null);for(let t=0,n=e.length;t<n;t++)f[e[t]]=t}}rx=c&Ox;try{if(rx)return;if(v(o),ox&&xx(t,v),s.offset=Y,a&&a.idsToInsert){Y+=a.idsToInsert.length*2,Y>ax&&b(Y),s.offset=Y;let e=bx(J.subarray(t,Y),a.idsToInsert);return a=null,e}return c&512?(J.start=t,J.end=Y,J):J.subarray(t,Y)}finally{if(n){if(_<10&&_++,n.length>l&&(n.length=l),g>1e4)n.transitions=null,_=0,g=0,h.length>0&&(h=[]);else if(h.length>0&&!u){for(let e=0,t=h.length;e<t;e++)h[e][lx]=void 0;h=[]}}if(r&&s.saveShared){s.structures.length>l&&(s.structures=s.structures.slice(0,l));let e=J.subarray(t,Y);return s.updateSharedData()===!1?s.encode(o):e}c&1024&&(Y=t)}},this.findCommonStringsToPack=()=>(d=new Map,m||=Object.create(null),e=>{let t=e&&e.threshold||4,n=this.pack?e.maxPrivatePackedValues||16:0;p||=this.sharedValues=[];for(let[e,i]of d)i.count>t&&(m[e]=n++,p.push(e),r=!0);for(;this.saveShared&&this.updateSharedData()===!1;);d=null});let v=n=>{Y>ax&&(J=b(Y));var r=typeof n,i;if(r===`string`){if(f){let t=f[n];if(t>=0){t<16?J[Y++]=t+224:(J[Y++]=198,t&1?v(15-t>>1):v(t-16>>1));return}else if(d&&!e.pack){let e=d.get(n);e?e.count++:d.set(n,{count:1})}}let r=n.length;if(ox&&r>=4&&r<1024){if((ox.size+=r)>sx){let e,n=(ox[0]?ox[0].length*3+ox[1].length:0)+10;Y+n>ax&&(J=b(Y+n)),J[Y++]=217,J[Y++]=223,J[Y++]=249,J[Y++]=ox.position?132:130,J[Y++]=26,e=Y-t,Y+=4,ox.position&&xx(t,v),ox=[``,``],ox.size=0,ox.position=e}let e=cx.test(n);ox[+!e]+=n,J[Y++]=e?206:207,v(r);return}let a;a=r<32?1:r<256?2:r<65536?3:5;let s=r*3;if(Y+s>ax&&(J=b(Y+s)),r<64||!o){let e,t,o,s=Y+a;for(e=0;e<r;e++)t=n.charCodeAt(e),t<128?J[s++]=t:t<2048?(J[s++]=t>>6|192,J[s++]=t&63|128):(t&64512)==55296&&((o=n.charCodeAt(e+1))&64512)==56320?(t=65536+((t&1023)<<10)+(o&1023),e++,J[s++]=t>>18|240,J[s++]=t>>12&63|128,J[s++]=t>>6&63|128,J[s++]=t&63|128):(J[s++]=t>>12|224,J[s++]=t>>6&63|128,J[s++]=t&63|128);i=s-Y-a}else i=o(n,Y+a,s);i<24?J[Y++]=96|i:i<256?(a<2&&J.copyWithin(Y+2,Y+1,Y+1+i),J[Y++]=120,J[Y++]=i):i<65536?(a<3&&J.copyWithin(Y+3,Y+2,Y+2+i),J[Y++]=121,J[Y++]=i>>8,J[Y++]=i&255):(a<5&&J.copyWithin(Y+5,Y+3,Y+3+i),J[Y++]=122,ix.setUint32(Y,i),Y+=4),Y+=i}else if(r===`number`)if(!this.alwaysUseFloat&&n>>>0===n)n<24?J[Y++]=n:n<256?(J[Y++]=24,J[Y++]=n):n<65536?(J[Y++]=25,J[Y++]=n>>8,J[Y++]=n&255):(J[Y++]=26,ix.setUint32(Y,n),Y+=4);else if(!this.alwaysUseFloat&&n>>0===n)n>=-24?J[Y++]=31-n:n>=-256?(J[Y++]=56,J[Y++]=~n):n>=-65536?(J[Y++]=57,ix.setUint16(Y,~n),Y+=2):(J[Y++]=58,ix.setUint32(Y,~n),Y+=4);else if(!this.alwaysUseFloat&&n<0&&n>=-4294967296&&Math.floor(n)===n)J[Y++]=58,ix.setUint32(Y,-1-n),Y+=4;else{let e;if((e=this.useFloat32)>0&&n<4294967296&&n>=-2147483648){J[Y++]=250,ix.setFloat32(Y,n);let t;if(e<4||(t=n*Wb[(J[Y]&127)<<1|J[Y+1]>>7])>>0===t){Y+=4;return}else Y--}J[Y++]=251,ix.setFloat64(Y,n),Y+=8}else if(r===`object`)if(!n)J[Y++]=246;else{if(a){let e=a.get(n);if(e){if(J[Y++]=216,J[Y++]=29,J[Y++]=25,!e.references){let t=a.idsToInsert||=[];e.references=[],t.push(e)}e.references.push(Y-t),Y+=2;return}else a.set(n,{offset:Y-t})}let e=n.constructor;if(e===Object)this.skipFunction===!0&&(n=Object.fromEntries([...Object.keys(n).filter(e=>typeof n[e]!=`function`).map(e=>[e,n[e]])])),y(n);else if(e===Array){i=n.length,i<24?J[Y++]=128|i:px(i);for(let e=0;e<i;e++)v(n[e])}else if(e===Map)if((this.mapsAsObjects?this.useTag259ForMaps!==!1:this.useTag259ForMaps)&&(J[Y++]=217,J[Y++]=1,J[Y++]=3),i=n.size,i<24?J[Y++]=160|i:i<256?(J[Y++]=184,J[Y++]=i):i<65536?(J[Y++]=185,J[Y++]=i>>8,J[Y++]=i&255):(J[Y++]=186,ix.setUint32(Y,i),Y+=4),s.keyMap)for(let[e,t]of n)v(s.encodeKey(e)),v(t);else for(let[e,t]of n)v(e),v(t);else{for(let e=0,t=Yb.length;e<t;e++){let t=Xb[e];if(n instanceof t){let t=Yb[e],r=t.tag;r??=t.getTag&&t.getTag.call(this,n),r<24?J[Y++]=192|r:r<256?(J[Y++]=216,J[Y++]=r):r<65536?(J[Y++]=217,J[Y++]=r>>8,J[Y++]=r&255):r>-1&&(J[Y++]=218,ix.setUint32(Y,r),Y+=4),t.encode.call(this,n,v,b);return}}if(n[Symbol.iterator]){if(rx){let e=Error(`Iterable should be serialized as iterator`);throw e.iteratorNotHandled=!0,e}J[Y++]=159;for(let e of n)v(e);J[Y++]=255;return}if(n[Symbol.asyncIterator]||hx(n)){let e=Error(`Iterable/blob should be serialized as iterator`);throw e.iteratorNotHandled=!0,e}if(this.useToJSON&&n.toJSON){let e=n.toJSON();if(e!==n)return v(e)}y(n)}}else if(r===`boolean`)J[Y++]=n?245:244;else if(r===`bigint`){if(n<BigInt(1)<<BigInt(64)&&n>=0)J[Y++]=27,ix.setBigUint64(Y,n);else if(n>-(BigInt(1)<<BigInt(64))&&n<0)J[Y++]=59,ix.setBigUint64(Y,-n-BigInt(1));else if(this.largeBigIntToFloat)J[Y++]=251,ix.setFloat64(Y,Number(n));else{n>=BigInt(0)?J[Y++]=194:(J[Y++]=195,n=BigInt(-1)-n);let e=[];for(;n;)e.push(Number(n&BigInt(255))),n>>=BigInt(8);yx(new Uint8Array(e.reverse()),b);return}Y+=8}else if(r===`undefined`)J[Y++]=247;else throw Error(`Unknown type: `+r)},y=this.useRecords===!1?this.variableMapSize?e=>{let t=Object.keys(e),n=Object.values(e),r=t.length;if(r<24?J[Y++]=160|r:r<256?(J[Y++]=184,J[Y++]=r):r<65536?(J[Y++]=185,J[Y++]=r>>8,J[Y++]=r&255):(J[Y++]=186,ix.setUint32(Y,r),Y+=4),s.keyMap)for(let e=0;e<r;e++)v(s.encodeKey(t[e])),v(n[e]);else for(let e=0;e<r;e++)v(t[e]),v(n[e])}:e=>{J[Y++]=185;let n=Y-t;Y+=2;let r=0;if(s.keyMap)for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(v(s.encodeKey(t)),v(e[t]),r++);else for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(v(t),v(e[t]),r++);J[n+++t]=r>>8,J[n+t]=r&255}:(e,t)=>{let n,a=i.transitions||=Object.create(null),o=0,s=0,c,u;if(this.keyMap){u=Object.keys(e).map(e=>this.encodeKey(e)),s=u.length;for(let e=0;e<s;e++){let t=u[e];n=a[t],n||(n=a[t]=Object.create(null),o++),a=n}}else for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(n=a[t],n||(a[lx]&1048576&&(c=a[lx]&65535),n=a[t]=Object.create(null),o++),a=n,s++);let d=a[lx];if(d!==void 0)d&=65535,J[Y++]=217,J[Y++]=d>>8|224,J[Y++]=d&255;else if(u||=a.__keys__||=Object.keys(e),c===void 0?(d=i.nextId++,d||(d=0,i.nextId=1),d>=tx&&(i.nextId=(d=l)+1)):d=c,i[d]=u,d<l){J[Y++]=217,J[Y++]=d>>8|224,J[Y++]=d&255,a=i.transitions;for(let e=0;e<s;e++)(a[lx]===void 0||a[lx]&1048576)&&(a[lx]=d),a=a[u[e]];a[lx]=d|1048576,r=!0}else{if(a[lx]=d,ix.setUint32(Y,3655335680),Y+=3,o&&(g+=_*o),h.length>=tx-l&&(h.shift()[lx]=void 0),h.push(a),px(s+2),v(57344+d),v(u),t)return;for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&v(e[t]);return}if(s<24?J[Y++]=128|s:px(s),!t)for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&v(e[t])},b=e=>{let n;if(e>16777216){if(e-t>nx)throw Error(`Encoded buffer would be larger than maximum buffer size`);n=Math.min(nx,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,J.length-1)>>12)+1<<12;let r=new $b(n);return ix=new DataView(r.buffer,0,n),J.copy?J.copy(r,0,t,e):r.set(J.slice(t,e)),Y-=t,t=0,ax=r.length-10,J=r},ee=100,x=1e3;this.encodeAsIterable=function(e,t){return ie(e,t,te)},this.encodeAsAsyncIterable=function(e,t){return ie(e,t,ae)};function*te(e,n,r){let i=e.constructor;if(i===Object){let t=s.useRecords!==!1;t?y(e,!0):dx(Object.keys(e).length,160);for(let r in e){let i=e[r];t||v(r),i&&typeof i==`object`?n[r]?yield*te(i,n[r]):yield*ne(i,n,r):v(i)}}else if(i===Array){let r=e.length;px(r);for(let i=0;i<r;i++){let r=e[i];r&&(typeof r==`object`||Y-t>ee)?n.element?yield*te(r,n.element):yield*ne(r,n,`element`):v(r)}}else if(e[Symbol.iterator]&&!e.buffer){J[Y++]=159;for(let r of e)r&&(typeof r==`object`||Y-t>ee)?n.element?yield*te(r,n.element):yield*ne(r,n,`element`):v(r);J[Y++]=255}else hx(e)?(dx(e.size,64),yield J.subarray(t,Y),yield e,re()):e[Symbol.asyncIterator]?(J[Y++]=159,yield J.subarray(t,Y),yield e,re(),J[Y++]=255):v(e);r&&Y>t?yield J.subarray(t,Y):Y-t>ee&&(yield J.subarray(t,Y),re())}function*ne(e,n,r){let i=Y-t;try{v(e),Y-t>ee&&(yield J.subarray(t,Y),re())}catch(a){if(a.iteratorNotHandled)n[r]={},Y=t+i,yield*te.call(this,e,n[r]);else throw a}}function re(){ee=x,s.encode(null,Ox)}function ie(e,t,n){return ee=t&&t.chunkThreshold?x=t.chunkThreshold:100,e&&typeof e==`object`?(s.encode(null,Ox),n(e,s.iterateProperties||={},!0)):[s.encode(e)]}async function*ae(e,t){for(let n of te(e,t,!0)){let e=n.constructor;if(e===ex||e===Uint8Array)yield n;else if(hx(n)){let e=n.stream().getReader(),t;for(;!(t=await e.read()).done;)yield t.value}else if(n[Symbol.asyncIterator])for await(let e of n)re(),e?yield*ae(e,t.async||={}):yield s.encode(e);else yield n}}}useBuffer(e){J=e,ix=new DataView(J.buffer,J.byteOffset,J.byteLength),Y=0}clearSharedData(){this.structures&&=[],this.sharedValues&&=void 0}updateSharedData(){let e=this.sharedVersion||0;this.sharedVersion=e+1;let t=this.structures.slice(0),n=new fx(t,this.sharedValues,this.sharedVersion),r=this.saveShared(n,t=>(t&&t.version||0)==e);return r===!1?(n=this.getShared()||{},this.structures=n.structures||[],this.sharedValues=n.packedValues,this.sharedVersion=n.version,this.structures.nextId=this.structures.length):t.forEach((e,t)=>this.structures[t]=e),r}};function dx(e,t){e<24?J[Y++]=t|e:e<256?(J[Y++]=t|24,J[Y++]=e):e<65536?(J[Y++]=t|25,J[Y++]=e>>8,J[Y++]=e&255):(J[Y++]=t|26,ix.setUint32(Y,e),Y+=4)}var fx=class{constructor(e,t,n){this.structures=e,this.packedValues=t,this.version=n}};function px(e){e<24?J[Y++]=128|e:e<256?(J[Y++]=152,J[Y++]=e):e<65536?(J[Y++]=153,J[Y++]=e>>8,J[Y++]=e&255):(J[Y++]=154,ix.setUint32(Y,e),Y+=4)}var mx=typeof Blob>`u`?function(){}:Blob;function hx(e){if(e instanceof mx)return!0;let t=e[Symbol.toStringTag];return t===`Blob`||t===`File`}function gx(e,t){switch(typeof e){case`string`:if(e.length>3){if(t.objectMap[e]>-1||t.values.length>=t.maxValues)return;let n=t.get(e);if(n)++n.count==2&&t.values.push(e);else if(t.set(e,{count:1}),t.samplingPackedValues){let n=t.samplingPackedValues.get(e);n?n.count++:t.samplingPackedValues.set(e,{count:1})}}break;case`object`:if(e)if(e instanceof Array)for(let n=0,r=e.length;n<r;n++)gx(e[n],t);else{let r=!t.encoder.useRecords;for(var n in e)e.hasOwnProperty(n)&&(r&&gx(n,t),gx(e[n],t))}break;case`function`:console.log(e)}}var _x=new Uint8Array(new Uint16Array([1]).buffer)[0]==1;Xb=[Date,Set,Error,RegExp,Ob,ArrayBuffer,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>`u`?function(){}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>`u`?function(){}:BigInt64Array,Float32Array,Float64Array,fx],Yb=[{tag:1,encode(e,t){let n=e.getTime()/1e3;(this.useTimestamp32||e.getMilliseconds()===0)&&n>=0&&n<4294967296?(J[Y++]=26,ix.setUint32(Y,n),Y+=4):(J[Y++]=251,ix.setFloat64(Y,n),Y+=8)}},{tag:258,encode(e,t){t(Array.from(e))}},{tag:27,encode(e,t){t([e.name,e.message])}},{tag:27,encode(e,t){t([`RegExp`,e.source,e.flags])}},{getTag(e){return e.tag},encode(e,t){t(e.value)}},{encode(e,t,n){yx(e,n)}},{getTag(e){if(e.constructor===Uint8Array&&(this.tagUint8Array||Qb&&this.tagUint8Array!==!1))return 64},encode(e,t,n){yx(e,n)}},vx(68,1),vx(69,2),vx(70,4),vx(71,8),vx(72,1),vx(77,2),vx(78,4),vx(79,8),vx(85,4),vx(86,8),{encode(e,t){let n=e.packedValues||[],r=e.structures||[];if(n.values.length>0){J[Y++]=216,J[Y++]=51,px(4);let e=n.values;t(e),px(0),px(0),packedObjectMap=Object.create(sharedPackedObjectMap||null);for(let t=0,n=e.length;t<n;t++)packedObjectMap[e[t]]=t}if(r){ix.setUint32(Y,3655335424),Y+=3;let n=r.slice(0);n.unshift(57344),n.push(new Ob(e.version,1399353956)),t(n)}else t(new Ob(e.version,1399353956))}}];function vx(e,t){return!_x&&t>1&&(e-=4),{tag:e,encode:function(e,t){let n=e.byteLength,r=e.byteOffset||0,i=e.buffer||e;t(Qb?Zb.from(i,r,n):new Uint8Array(i,r,n))}}}function yx(e,t){let n=e.byteLength;n<24?J[Y++]=64+n:n<256?(J[Y++]=88,J[Y++]=n):n<65536?(J[Y++]=89,J[Y++]=n>>8,J[Y++]=n&255):(J[Y++]=90,ix.setUint32(Y,n),Y+=4),Y+n>=J.length&&t(Y+n),J.set(e.buffer?e:new Uint8Array(e),Y),Y+=n}function bx(e,t){let n,r=t.length*2,i=e.length-r;t.sort((e,t)=>e.offset>t.offset?1:-1);for(let n=0;n<t.length;n++){let r=t[n];r.id=n;for(let t of r.references)e[t++]=n>>8,e[t]=n&255}for(;n=t.pop();){let t=n.offset;e.copyWithin(t+r,t,i),r-=2;let a=t+r;e[a++]=216,e[a++]=28,i=t}return e}function xx(e,t){ix.setUint32(ox.position+e,Y-ox.position-e+1);let n=ox;ox=null,t(n[0]),t(n[1])}var Sx=new ux({useRecords:!1}),Cx=Sx.encode;Sx.encodeAsIterable,Sx.encodeAsAsyncIterable;var{NEVER:wx,ALWAYS:Tx,DECIMAL_ROUND:Ex,DECIMAL_FIT:Dx}=qb,Ox=2048,kx=class e{static encoder=new ux({tagUint8Array:!1});decode(t){return e.encoder.decode(t)}encode(t){return e.encoder.encode(t)}},Ax=class e{static defaultStringSignatureEncoder(){return new By(Sg.defaultBytesToStringEncoder())}static defaultStringPublicKeyEncryptionEncoder(){return ey.createBase64HCVPkeEncoder()}static cryptoBinaryEncoder=new kx;static getCryptoBinaryEncoder(){return e.cryptoBinaryEncoder}},X=class e{static encoder=Ax.getCryptoBinaryEncoder();static logger=k.getLogger([`utils`]);static computeMicroblockHashFromHeader(t){let n=e.encodeMicroblockHeader(t);return xp.Hashes.sha256AsBinary(n)}static checkHeaderList(t){let n=t.length;if(n===0)return{valid:!0,hashes:[]};if(n===1)return{valid:!0,hashes:[xp.Hashes.sha256AsBinary(t[0])]};let r=[],i=null,a=k.getProviderLogger();for(let n of t.reverse()){let t=xp.Hashes.sha256AsBinary(n);if(i&&!A.binaryIsEqual(t,i))return a.error(`Received headers mismatch: Expected ${A.binaryToHexa(i)}, got ${A.binaryToHexa(t)}: aborting verification`),{valid:!1,hashes:[]};r.push(t),i=e.previousHashFromHeader(n)}return{valid:!0,hashes:r}}static previousHashFromHeader(t){return e.decodeMicroblockHeader(t).previousHash}static encodeChainReference(e){return this.encodeObjectToBinary(R(Qh,e))}static decodeChainReference(e){return R(Qh,this.decodeObjectFromBinary(e))}static encodeVirtualBlockchainInfo(e){return this.encodeObjectToBinary(R(Kh,e))}static decodeVirtualBlockchainInfo(e){return R(Kh,this.decodeObjectFromBinary(e))}static encodeVirtualBlockchainState(e){return this.encodeObjectToBinary(R(Gh,e))}static decodeVirtualBlockchainState(e){return R(Gh,this.decodeObjectFromBinary(e))}static encodeMicroblockBody(e){return this.encodeObjectToBinary(R(Dh,e))}static decodeMicroblockBody(e){return R(Dh,this.decodeObjectFromBinary(e))}static encodeSection(e){return this.encodeObjectToBinary(R(Eh,e))}static decodeSection(e){return R(Eh,this.decodeObjectFromBinary(e))}static encodeMicroblockHeader(e){return this.encodeObjectToBinary(R(Lm,e))}static decodeMicroblockHeader(t){let n=this.decodeObjectFromBinary(t),r=R(Lm,n);if(!A.binaryIsEqual(n.bodyHash,r.bodyHash))throw e.logger.error(`Modified validated object: ${JSON.stringify(n)} vs ${JSON.stringify(r)}`),Error(`Modified body hash detected during deserialization: ${n.bodyHash} vs ${r.bodyHash}`);return r}static encodeEscrowParameters(e){return this.encodeObjectToBinary(R(tg,e))}static decodeEscrowParameters(e){return R(tg,this.decodeObjectFromBinary(e))}static encodeEscrowLock(e){return this.encodeObjectToBinary(R(ng,e))}static decodeEscrowLock(e){return R(ng,this.decodeObjectFromBinary(e))}static encodeVestingParameters(e){return this.encodeObjectToBinary(R(rg,e))}static decodeVestingParameters(e){return R(rg,this.decodeObjectFromBinary(e))}static encodeVestingLock(e){return this.encodeObjectToBinary(R(ig,e))}static decodeVestingLock(e){return R(ig,this.decodeObjectFromBinary(e))}static encodeNodeStakingParameters(e){return this.encodeObjectToBinary(R(ag,e))}static decodeNodeStakingParameters(e){return R(ag,this.decodeObjectFromBinary(e))}static encodeNodeStakingLock(e){return this.encodeObjectToBinary(R(og,e))}static decodeNodeStakingLock(e){return R(og,this.decodeObjectFromBinary(e))}static encodeLock(e){return this.encodeObjectToBinary(R(sg,e))}static decodeLock(e){return R(sg,this.decodeObjectFromBinary(e))}static encodeAccountBreakdown(e){return this.encodeObjectToBinary(R(cg,e))}static decodeAccountBreakdown(e){return R(cg,this.decodeObjectFromBinary(e))}static encodeAccountState(e){return this.encodeObjectToBinary(R(lg,e))}static decodeAccountState(e){return R(lg,this.decodeObjectFromBinary(e))}static encodeAccountInformation(e){return this.encodeObjectToBinary(R(ug,e))}static decodeAccountInformation(e){return R(ug,this.decodeObjectFromBinary(e))}static encodeMicroblockInformation(e){return this.encodeObjectToBinary(R(qh,e))}static decodeMicroblockInformation(e){return R(qh,this.decodeObjectFromBinary(e))}static encodeObjectToBinary(t){return e.encoder.encode(t)}static decodeObjectFromBinary(t){return e.encoder.decode(t)}},jx=86400,Mx=class{constructor(e){this.retentionPolicy=e,this.retentionPolicy.sort((e,t)=>e.maximumNumberOfDays-t.maximumNumberOfDays)}getNumberOfDaysOfStorage(e,t){return t>0?Math.max(1,Math.round((t-e)/jx)):this.retentionPolicy[this.retentionPolicy.length-1].maximumNumberOfDays}getStorageCost(e,t){return this.getBreakdown(e,t).reduce((e,t)=>e+t.costInGasAtoms,0)}getBreakdown(e,t){let n=[];for(let r=0,i=0;i<t;r++){let a=this.retentionPolicy[r],o,s,c;a==null?(o=t-i,s=0,c=1):(o=Math.min(a.maximumNumberOfDays,t)-i,s=a.retentionRatio,c=a.dayDivisor);let l=Math.floor(e*o*s/1e3/c);n.push({numberOfDays:o,retentionRatio:s,costInGasAtoms:l}),i+=o}return n}},Nx=class e{static DEFAULT_GAS_PRICE=hn.createAtomic(1);constructor(e){this.provider=e}async computeFees(t,n,r,i=A.getTimestampInSeconds()){if(r<0)throw Error(`Invalid expiration day`);let a=n.getGasPrice(),o=a.isZero()?e.DEFAULT_GAS_PRICE:a,s=await this.computeGas(t,n,r,i);return hn.createAtomic(s*o.getAmountAsAtomic())}async computeGas(e,t,n,r=A.getTimestampInSeconds()){let i=1*this.computeSizeInBytesOfMicroblock(t)*pr,a=await this.provider.getProtocolState(),o=new Mx(a.getRetentionPolicy()),s=o.getNumberOfDaysOfStorage(r,n),c=o.getStorageCost(i,s),l=this.getAdditionalCosts(a,e);return Math.floor(c/pr)+l}getAdditionalCosts(e,t){let n=0;switch(t){case Ja.SECP256K1:n=e.getSecp256k1SignatureGasCost();break;case Ja.ML_DSA_65:n=e.getMlDsa65SignatureGasCost();break;case Ja.PKMS_SECP256K1:n=e.getPkmsSecp256k1SignatureGasCost();break}return n+e.getFixedGasCost()}computeSizeInBytesOfMicroblock(e){let t=e.getAllSections();if(t.length===0)return 0;let n=t[t.length-1].type===O.SIGNATURE?t.slice(0,t.length-1):t;return this.getSizeOfListOfSections(n)}getSizeOfListOfSections(e){return e.reduce((e,t)=>e+X.encodeSection(t).length,0)}},Px=class{static getGenesisFeesCalculationFormula(e){return new Nx(e)}static async getFeesCalculationFormulaByVersion(e,t){switch(t){case 1:return this.getGenesisFeesCalculationFormula(e)}throw Error(`No fees formula for feesCalculationVersion = ${t}`)}},Fx=class e{constructor(e){this.internalState=e}static createFromObject(t){return new e(t)}static createInitialState(){return new e({signatureSchemeId:0,publicKeyHeight:0})}toObject(){return this.internalState}updateSignatureScheme(e){this.internalState.signatureSchemeId=e}updatePublicKeyHeight(e){this.internalState.publicKeyHeight=e}getPublicKeyHeight(){return this.internalState.publicKeyHeight}getPublicKeySchemeId(){return this.internalState.signatureSchemeId}},Ix=class e{constructor(e){this.hash=e}static from(t){let n=typeof t==`string`,r=t instanceof Uint8Array;if(!n&&!r)throw TypeError(`Expected hash of type string or Uint8Array: got ${typeof t}`);let i=Sg.bytesToHexEncoder();return new e(typeof t==`string`?i.decode(t):t)}static fromHex(t){return new e(Sg.bytesToHexEncoder().decode(t))}encode(e=new wg){return e.encode(this.hash).toUpperCase()}toBytes(){return new Uint8Array(this.hash)}equals(e){return this.hash.every((t,n)=>t===e.hash[n])}},Lx=class e{constructor(e){this.internalState=e}static createFromObject(t){return new e(t)}static createInitialState(){return new e({organizationId:A.getNullHash(),descriptionHeight:0})}clone(){return new e({...this.internalState})}toObject(){return this.internalState}setOrganizationId(e){this.internalState.organizationId=e}setDescriptionHeight(e){this.internalState.descriptionHeight=e}getOrganizationId(){return Ix.from(this.internalState.organizationId)}getDescriptionHeight(){return this.internalState.descriptionHeight}},Rx=class e{static UNDEFINED_APPLICATION_ID=new Uint8Array;constructor(e){this.internalState=e}static createFromObject(t){return new e(t)}static createInitialState(){return new e({allowedAdditionalWriters:[],actors:[],allowedPkeSchemeIds:[],allowedSignatureSchemeIds:[],applicationId:this.UNDEFINED_APPLICATION_ID,channels:[]})}getAdditionalAllowedWriters(){return this.internalState.allowedAdditionalWriters}addAdditionalWriter(e){this.internalState.allowedAdditionalWriters.push(e)}toObject(){return this.internalState}clone(){return new e(structuredClone(this.internalState))}createActor(e){this.internalState.actors.push(e)}createActorWithId(e,t){if(this.isActorDefinedById(e))throw new oe(`Id: ${e}`);this.internalState.actors[e]=t}setAllowedSignatureSchemeIds(e){this.internalState.allowedSignatureSchemeIds=e}setAllowedPkeSchemeIds(e){this.internalState.allowedPkeSchemeIds=e}setApplicationId(e){this.internalState.applicationId=e}isChannelDefinedById(e){return this.internalState.channels[e]!==void 0}isChannelDefinedByName(e){return this.internalState.channels.some(t=>t.name===e)}createChannel(e){if(!this.isActorDefinedById(e.creatorId))throw new oe(`Id: ${e.creatorId}`);if(this.isChannelDefinedByName(e.name))throw new ae(e.name);this.internalState.channels.push(e)}createChannelWithId(e,t){if(this.isChannelDefinedById(e))throw new ae(`Id: ${e}`);if(this.isActorDefinedById(t.creatorId))throw new oe(`Id: ${t.creatorId}`);if(this.isChannelDefinedByName(t.name))throw new ae(t.name);this.internalState.channels[e]=t}isActorDefinedByName(e){return this.internalState.actors.some(t=>t.name===e)}isActorDefinedById(e){return this.internalState.actors[e]!==void 0}getAllowedSignatureSchemes(){return this.internalState.allowedSignatureSchemeIds}getAllowedPkeSchemes(){return this.internalState.allowedPkeSchemeIds}getNumberOfActors(){return this.internalState.actors.length}getActorById(e){let t=this.internalState.actors[e];if(t===void 0)throw new oe(`ID: ${e}`);return t}getNumberOfChannels(){return this.internalState.channels.length}getApplicationId(){return Ix.from(this.internalState.applicationId)}getChannelIdFromChannelName(e){let t=this.internalState.channels.findIndex(t=>t.name===e);if(t===void 0)throw new se(e);return t}getChannelCreatorIdFromChannelId(e){return this.getChannelFromChannelId(e).creatorId}getChannelFromChannelId(e){let t=this.internalState.channels[e];if(t===void 0)throw new se(`ID: ${e}`);return t}getActorByName(e){let t=this.internalState.actors.find(t=>t.name===e);if(t===void 0)throw new oe(e);return t}getActorIdByName(e){let t=this.internalState.actors.findIndex(t=>t.name===e);if(t===-1)throw new oe(e);return t}updateActor(e,t){if(!this.isActorDefinedById(e))throw new oe(`Id: ${e}`);this.internalState.actors[e]=t}updateChannel(e,t){if(!this.isChannelDefinedById(e))throw new se(`Id: ${e}`);this.internalState.channels[e]=t}getAllActors(){return this.internalState.actors}getAllChannels(){return this.internalState.channels}},zx=function(e){return e.INITIAL_PROTOCOL_VERSION_NAME=`Clermont`,e}(zx||{}),Bx=class e{constructor(e){this.internalState=e}static createFromObject(t){let n=om(Oh,t);if(n.success)return new e(n.output);throw Error(`Provided internal state is not valid: ${n.issues}`)}static createInitialState(){return new e({organizationId:A.getNullHash(),currentProtocolVariables:{protocolVersionName:zx.INITIAL_PROTOCOL_VERSION_NAME,protocolVersion:1,feesCalculationVersion:1,fixedGasCost:100,secp256k1SignatureGasCost:100,mlDsa65SignatureGasCost:500,pkmsSecp256k1SignatureGasCost:0,globalStateUpdaterVersion:1,applicationLedgerInternalStateUpdaterVersion:1,applicationInternalStateUpdaterVersion:1,organizationInternalStateUpdaterVersion:1,validatorNodeInternalStateUpdaterVersion:1,accountInternalStateUpdaterVersion:1,protocolInternalStateUpdaterVersion:1,minimumNodeStakingAmountInAtomics:hn.create(1e6).getAmountAsAtomic(),maximumNodeStakingAmountInAtomics:hn.create(1e7).getAmountAsAtomic(),unstakingDelayInDays:30,maxBlockSizeInBytes:4194304,retentionPolicy:[{retentionRatio:100,maximumNumberOfDays:366,dayDivisor:366},{retentionRatio:50,maximumNumberOfDays:366*5,dayDivisor:366},{retentionRatio:20,maximumNumberOfDays:366*10,dayDivisor:366},{retentionRatio:100,maximumNumberOfDays:3661,dayDivisor:1}],abciVersion:1,maxMicroblocksPerBlock:200},protocolUpdates:[]})}getAbciVersion(){return this.internalState.currentProtocolVariables.abciVersion}getMaximumBlockSizeInBytes(){return this.internalState.currentProtocolVariables.maxBlockSizeInBytes}getProtocolVariables(){return this.internalState.currentProtocolVariables}getApplicationLedgerInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.applicationLedgerInternalStateUpdaterVersion}getApplicationInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.applicationInternalStateUpdaterVersion}getOrganizationInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.organizationInternalStateUpdaterVersion}getValidatorNodeInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.validatorNodeInternalStateUpdaterVersion}getAccountInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.accountInternalStateUpdaterVersion}getProtocolInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.protocolInternalStateUpdaterVersion}getMinimumNodeStakingAmountInAtomics(){return this.internalState.currentProtocolVariables.minimumNodeStakingAmountInAtomics}getMaximumNodeStakingAmountInAtomics(){return this.internalState.currentProtocolVariables.maximumNodeStakingAmountInAtomics}getUnstakingDelayInDays(){return this.internalState.currentProtocolVariables.unstakingDelayInDays}getRetentionPolicy(){return this.internalState.currentProtocolVariables.retentionPolicy}toObject(){return this.internalState}getFeesCalculationVersion(){return this.internalState.currentProtocolVariables.feesCalculationVersion}getFixedGasCost(){return this.internalState.currentProtocolVariables.fixedGasCost}getSecp256k1SignatureGasCost(){return this.internalState.currentProtocolVariables.secp256k1SignatureGasCost}getMlDsa65SignatureGasCost(){return this.internalState.currentProtocolVariables.mlDsa65SignatureGasCost}getPkmsSecp256k1SignatureGasCost(){return this.internalState.currentProtocolVariables.pkmsSecp256k1SignatureGasCost}setProtocolVersion(e){this.internalState.currentProtocolVariables.protocolVersion=e}setProtocolVersionName(e){this.internalState.currentProtocolVariables.protocolVersionName=e}setProtocolVariables(e){this.internalState.currentProtocolVariables=e}setOrganizationId(e){this.internalState.organizationId=e}},Vx=class e{constructor(e){this.internalState=e}static createFromObject(t){return new e(t)}static createInitialState(){return new e({accountId:A.getNullHash(),descriptionHeight:0})}toObject(){return this.internalState}getAccountIdAsBytes(){return this.internalState.accountId}getAccountId(){return Ix.from(this.internalState.accountId)}setAccountId(e){return this.internalState.accountId=e}getDescriptionHeight(){return this.internalState.descriptionHeight}updateDescriptionHeight(e){this.internalState.descriptionHeight=e}},Hx=class e{constructor(e){this.internalState=e}static createFromObject(t){return new e(t)}static createInitialState(){return new e({cometbftPublicKeyDeclarationHeight:0,lastKnownApprovalStatus:!1,organizationId:A.getNullHash(),rpcEndpointHeight:0})}toObject(){return this.internalState}getOrganizationId(){return Ix.from(this.internalState.organizationId)}getLastKnownApprovalStatus(){return this.internalState.lastKnownApprovalStatus}getCometbftPublicKeyDeclarationHeight(){return this.internalState.cometbftPublicKeyDeclarationHeight}getRpcEndpointHeight(){return this.internalState.rpcEndpointHeight}clone(){return structuredClone(this)}setApprovalStatus(e){this.internalState.lastKnownApprovalStatus=e}setCometbftPublicKeyDeclarationHeight(e){this.internalState.cometbftPublicKeyDeclarationHeight=e}setOrganizationId(e){this.internalState.organizationId=e}setRpcEndpointDeclarationHeight(e){this.internalState.rpcEndpointHeight=e}},Ux=class{static createInternalStateFromObject(e,t){switch(e){case H.PROTOCOL_VIRTUAL_BLOCKCHAIN:return Bx.createFromObject(t);case H.ACCOUNT_VIRTUAL_BLOCKCHAIN:return Fx.createFromObject(t);case H.APPLICATION_VIRTUAL_BLOCKCHAIN:return Lx.createFromObject(t);case H.APP_LEDGER_VIRTUAL_BLOCKCHAIN:return Rx.createFromObject(t);case H.ORGANIZATION_VIRTUAL_BLOCKCHAIN:return Vx.createFromObject(t);case H.NODE_VIRTUAL_BLOCKCHAIN:return Hx.createFromObject(t);default:throw Error(`Unknown virtual blockchain type: ${e}`)}}},Wx=class{constructor(){}async updateState(e,t,n){let r=Fx.createFromObject({...t.toObject()}),i=n.getAllSections();for(let e of i)switch(e.type){case O.ACCOUNT_PUBLIC_KEY:await this.publicKeyCallback(r,n,e);break;case O.ACCOUNT_TOKEN_ISSUANCE:await this.tokenIssuanceCallback(r,n,e);break;case O.ACCOUNT_CREATION:await this.creationCallback(r,n,e);break;case O.ACCOUNT_TRANSFER:await this.transferCallback(r,n,e);break;case O.ACCOUNT_VESTING_TRANSFER:await this.vestingTransferCallback(r,n,e);break;case O.ACCOUNT_ESCROW_TRANSFER:await this.escrowTransferCallback(r,n,e);break;case O.ACCOUNT_STAKE:await this.stakeCallback(r,n,e);break;case O.SIGNATURE:await this.signatureCallback(r,n,e);break}return r}async publicKeyCallback(e,t,n){e.updatePublicKeyHeight(t.getHeight()),e.updateSignatureScheme(n.schemeId)}async tokenIssuanceCallback(e,t,n){if(n.amount!=0x5af3107a4000)throw Error(`the amount of the initial token issuance is not the expected one`)}async creationCallback(e,t,n){}async transferCallback(e,t,n){}async vestingTransferCallback(e,t,n){if(n.cliffDurationDays<0)throw Error(`The cliff duration must be greater than or equal to 0`);if(n.vestingDurationDays<=0)throw Error(`The vesting duration must be greater than 0`);if(n.amount<=0)throw Error(`The amount must be greater than 0`)}async escrowTransferCallback(e,t,n){}async stakeCallback(e,t,n){}async signatureCallback(e,t,n){}},Gx=class{updateState(e,t,n){let r=t.clone();for(let e of n.getAllSections())e.type===O.APP_CREATION&&r.setOrganizationId(e.organizationId),e.type===O.APP_DESCRIPTION&&r.setDescriptionHeight(n.getHeight());return r}},Kx={[O.AUXILIARY_SIGNATURE]:`AUXILIARY_SIGNATURE`,[O.SIGNATURE]:`SIGNATURE`,[O.ALLOWED_ADDITIONAL_WRITER]:`ALLOWED_ADDITIONAL_WRITER_CREATION`,[O.CUSTOM]:`CUSTOM`,[O.PROTOCOL_CREATION]:`PROTOCOL_CREATION`,[O.PROTOCOL_UPDATE]:`PROTOCOL_UPDATE`,[O.PROTOCOL_VARIABLES]:`PROTOCOL_VARIABLES`,[O.ACCOUNT_PUBLIC_KEY]:`ACCOUNT_PUBLIC_KEY`,[O.ACCOUNT_TOKEN_ISSUANCE]:`ACCOUNT_TOKEN_ISSUANCE`,[O.ACCOUNT_CREATION]:`ACCOUNT_CREATION`,[O.ACCOUNT_TRANSFER]:`ACCOUNT_TRANSFER`,[O.ACCOUNT_VESTING_TRANSFER]:`ACCOUNT_VESTING_TRANSFER`,[O.ACCOUNT_ESCROW_TRANSFER]:`ACCOUNT_ESCROW_TRANSFER`,[O.ACCOUNT_ESCROW_SETTLEMENT]:`ACCOUNT_ESCROW_SETTLEMENT`,[O.ACCOUNT_STAKE]:`ACCOUNT_STAKE`,[O.ACCOUNT_UNSTAKE]:`ACCOUNT_UNSTAKE`,[O.VN_CREATION]:`VN_CREATION`,[O.VN_COMETBFT_PUBLIC_KEY_DECLARATION]:`VN_COMETBFT_PUBLIC_KEY_DECLARATION`,[O.VN_RPC_ENDPOINT]:`VN_RPC_ENDPOINT`,[O.VN_APPROVAL]:`VN_APPROVAL`,[O.VN_SLASHING_CANCELLATION]:`VN_SLASHING_CANCELLATION`,[O.ORG_CREATION]:`ORG_CREATION`,[O.ORG_DESCRIPTION]:`ORG_DESCRIPTION`,[O.APP_CREATION]:`APP_CREATION`,[O.APP_DESCRIPTION]:`APP_DESCRIPTION`,[O.APP_LEDGER_ALLOWED_SIG_SCHEMES]:`APP_LEDGER_ALLOWED_SIG_SCHEMES`,[O.APP_LEDGER_ALLOWED_PKE_SCHEMES]:`APP_LEDGER_ALLOWED_PKE_SCHEMES`,[O.APP_LEDGER_CREATION]:`APP_LEDGER_CREATION`,[O.APP_LEDGER_ACTOR_CREATION]:`APP_LEDGER_ACTOR_CREATION`,[O.APP_LEDGER_CHANNEL_CREATION]:`APP_LEDGER_CHANNEL_CREATION`,[O.APP_LEDGER_SHARED_SECRET]:`APP_LEDGER_SHARED_SECRET`,[O.APP_LEDGER_CHANNEL_INVITATION]:`APP_LEDGER_CHANNEL_INVITATION`,[O.APP_LEDGER_ACTOR_SUBSCRIPTION]:`APP_LEDGER_ACTOR_SUBSCRIPTION`,[O.APP_LEDGER_PUBLIC_CHANNEL_DATA]:`APP_LEDGER_PUBLIC_CHANNEL_DATA`,[O.APP_LEDGER_PRIVATE_CHANNEL_DATA]:`APP_LEDGER_PRIVATE_CHANNEL_DATA`,[O.APP_LEDGER_AUTHOR]:`APP_LEDGER_AUTHOR`,[O.APP_LEDGER_ENDORSEMENT_REQUEST]:`APP_LEDGER_ENDORSEMENT_REQUEST`},qx=class{static getSectionLabelFromSection(e){return this.getSectionLabelFromSectionType(e.type)}static getSectionLabelFromSectionType(e){return Kx[e]}},Jx=class e{logger=k.getInternalStateUpdaterLogger(e.name);async updateState(e,t,n){let r=t.clone(),i=n.getHeight();for(let a of n.getAllSections())r=await this.updateStateFromSection(e,t,a,i);return r}async updateStateFromSection(e,t,n,r){let i=t;switch(n.type){case O.APP_LEDGER_ALLOWED_SIG_SCHEMES:await this.allowedSignatureSchemesCallback(n,i);break;case O.APP_LEDGER_ALLOWED_PKE_SCHEMES:await this.allowedPkeSchemesCallback(n,i);break;case O.APP_LEDGER_CREATION:await this.declarationCallback(n,i);break;case O.APP_LEDGER_ACTOR_CREATION:await this.actorCreationCallback(n,i);break;case O.APP_LEDGER_ACTOR_SUBSCRIPTION:await this.actorSubscriptionCallback(r,n,i);break;case O.APP_LEDGER_CHANNEL_CREATION:await this.channelCreationCallback(n,i);break;case O.APP_LEDGER_SHARED_SECRET:await this.sharedSecretCallback(r,n,i);break;case O.APP_LEDGER_CHANNEL_INVITATION:await this.invitationCallback(r,n,i);break;case O.APP_LEDGER_PUBLIC_CHANNEL_DATA:await this.publicChannelDataCallback(n,i);break;case O.APP_LEDGER_PRIVATE_CHANNEL_DATA:await this.privateChannelDataCallback(n,i);break;case O.ALLOWED_ADDITIONAL_WRITER:i.addAdditionalWriter(n.allowedWriterAccountId);break;case O.SIGNATURE:await this.endorserSignatureCallback();break;default:k.getLogger().warn(`Unhandled section ${qx.getSectionLabelFromSection(n)}`)}return i}async allowedSignatureSchemesCallback(e,t){t.setAllowedSignatureSchemeIds(e.schemeIds)}async allowedPkeSchemesCallback(e,t){t.setAllowedPkeSchemeIds(e.schemeIds)}async declarationCallback(e,t){t.setApplicationId(e.applicationId)}async actorCreationCallback(e,t){let{id:n,name:r}=e,i=t.getNumberOfActors();if(n!=i)throw this.logger.error(`Actor creation failure: Invalid actor identifier found for actor ${r}: expected ${i}, got ${n}`),new ie(n,t.getNumberOfActors());if(t.isActorDefinedByName(r))throw new re(r);this.logger.info(`Creating actor ${r} with id ${n} `),t.createActor({name:r,subscribed:!1,signatureKeyHeight:0,pkeKeyHeight:0,sharedSecrets:[],invitations:[]})}async actorSubscriptionCallback(e,t,n){let r=n.getActorById(t.actorId);if(r===void 0)throw new le(t.actorId);if(r.subscribed)throw new S(t.actorId);let i=t.signatureSchemeId,a=n.getAllowedSignatureSchemes(),o=a.length==0,s=a.includes(i);if(!o&&!s)throw new ue(t.signatureSchemeId);let c=t.pkeSchemeId,l=n.getAllowedPkeSchemes(),u=l.length===0,d=l.includes(c);if(!u&&!d)throw new de(t.pkeSchemeId);r.subscribed=!0,r.signatureKeyHeight=e,r.pkeKeyHeight=e}async channelCreationCallback(e,t){if(e.id!=t.getNumberOfChannels())throw new fe(e.id);let n=e.name;if(t.isChannelDefinedByName(n))throw new ae(n);t.createChannel({name:e.name,isPrivate:e.isPrivate,creatorId:e.creatorId})}async sharedSecretCallback(e,t,n){let{hostId:r,guestId:i}=t;n.getActorById(r).sharedSecrets.push({height:e,peerActorId:i}),n.getActorById(i).sharedSecrets.push({height:e,peerActorId:r})}async invitationCallback(e,t,n){let{guestId:r,channelId:i}=t;n.getActorById(r).invitations.push({channelId:i,height:e}),k.getLogger().debug(`Updated state after channel invitation callback: {state}`,{state:n})}async publicChannelDataCallback(e,t){if(!t.isChannelDefinedById(e.channelId))throw new se(`invalid channel ID ${e.channelId}`)}async privateChannelDataCallback(e,t){if(!t.isChannelDefinedById(e.channelId))throw new se(`invalid channel ID ${e.channelId}`)}async endorserSignatureCallback(){}},Yx=class{updateState(e,t,n){let r=t;for(let e of n.getAllSections())switch(e.type){case O.VN_CREATION:r.setOrganizationId(e.organizationId);break;case O.VN_APPROVAL:this.updateApproval(r,e);break;case O.VN_COMETBFT_PUBLIC_KEY_DECLARATION:r.setCometbftPublicKeyDeclarationHeight(n.getHeight());break;case O.VN_RPC_ENDPOINT:r.setRpcEndpointDeclarationHeight(n.getHeight());break}return r}updateApproval(e,t){e.setApprovalStatus(t.status)}},Xx=class e{logger=k.getInternalStateUpdaterLogger(e.name);updateState(e,t,n){for(let e of n.getAllSections()){if(e.type===O.PROTOCOL_UPDATE){let n=e;this.logger.debug(`Updating protocol variables: ${JSON.stringify(n.protocolVariables)}`),t.setProtocolVariables(n.protocolVariables)}if(e.type===O.PROTOCOL_CREATION){let n=e.organizationId;this.logger.debug(`Updating organization ID: ${A.binaryToHexa(n)}`),t.setOrganizationId(n)}}return t}},Zx=class{updateState(e,t,n){for(let e of n.getAllSections())e.type===O.ORG_CREATION&&t.setAccountId(e.accountId),e.type===O.ORG_DESCRIPTION&&t.updateDescriptionHeight(n.getHeight());return t}},Qx=class{static createApplicationLedgerInternalStateUpdater(e){return new Jx}static createAccountInternalStateUpdater(e){switch(e){case 1:return new Wx;default:throw new i(`Unknown account local state version`)}}static createOrganizationInternalStateUpdater(e){switch(e){case 1:return new Zx;default:throw new i(`Unknown organization local state version`)}}static createProtocolInternalStateUpdater(e){return new Xx}static createValidatorNodeInternalStateUpdater(e){switch(e){case 1:return new Yx;default:throw new i(`Unknown validator node local state version`)}}static createApplicationInternalStateUpdater(e){switch(e){case 1:return new Gx;default:throw new i(`Unknown validator node local state version`)}}static defaultInternalStateUpdaterVersionByVbType(e){return 1}},$x=function(e){return e[e.VALID=0]=`VALID`,e[e.TOO_FAR_IN_THE_PAST=1]=`TOO_FAR_IN_THE_PAST`,e[e.TOO_FAR_IN_THE_FUTURE=2]=`TOO_FAR_IN_THE_FUTURE`,e}({}),eS=I({header:Lm,body:Dh}),tS=class e{static createGenesisMicroblock(t,n=0){let r=new e(t);return r.create(1,null,n),r}static createMicroblock(t,n,r,i){let a=new e(t);return a.create(n,r,i),a}static createGenesisAccountMicroblock(){return new e(H.ACCOUNT_VIRTUAL_BLOCKCHAIN)}static createGenesisValidatorNodeMicroblock(){return new e(H.NODE_VIRTUAL_BLOCKCHAIN)}static createGenesisApplicationMicroblock(){return new e(H.APPLICATION_VIRTUAL_BLOCKCHAIN)}static createGenesisProtocolMicroblock(){return new e(H.PROTOCOL_VIRTUAL_BLOCKCHAIN)}static createGenesisOrganizationMicroblock(){return new e(H.ORGANIZATION_VIRTUAL_BLOCKCHAIN)}static createGenesisApplicationLedgerMicroblock(){return new e(H.APP_LEDGER_VIRTUAL_BLOCKCHAIN)}static loadFromSerializedMicroblock(t,n){let r=R(eS,Kb(t));return e.loadFromHeaderAndBody(r.header,r.body,n)}static loadFromHeaderAndBody(t,n,r){let i=t.microblockType;if(r!==void 0&&r!==i)throw new o(`Microblock type mismatch: expected ${r}, got ${i} from header`);if(t.magicString!=`CMTS`)throw Error(`magic string '${Un}' is missing`);let a=t.bodyHash,s=new e(i);s.header=structuredClone(t),s.addSections(n.sections);let c=s.computeBodyHash();if(!A.binaryIsEqual(a,c)){let e=Sg.bytesToHexEncoder();throw new o(`Body hash in the header is different of the locally computed body hash: header.bodyHash=${e.encode(a)}, computed=${e.encode(c)}`)}return s.setMicroblockHash(s.computeHash()),s}static loadFromSerializedHeaderAndBody(t,n,r){let i=X.decodeMicroblockHeader(t),a=X.decodeMicroblockBody(n);return e.loadFromHeaderAndBody(i,a,r)}static computeInitialBodyHash(){return e.computeBodyHashFromSections([])}static computeMicroblockHash(e){let t=X.encodeMicroblockHeader(e);return xp.Hashes.sha256AsBinary(t)}static computeBodyHashFromSections(e){let t={sections:e},n=X.encodeMicroblockBody(t);return xp.Hashes.sha256AsBinary(n)}static generatePreviousHashForGenesisMicroblock(e,t=0){let n=xp.Random.getBytes(24),r=A.getNullHash();return r[0]=e,r[1]=t>>24,r[2]=t>>16,r[3]=t>>8,r[4]=t,r.set(n,8),r}static logger=k.getMicroblockLogger();hash;header;sections;type;constructor(t){let n=Math.floor(Date.now()/1e3),r=hn.zero().getAmountAsAtomic(),i={magicString:Un,microblockType:t,height:1,previousHash:e.generatePreviousHashForGenesisMicroblock(t,0),timestamp:n,gas:0,gasPrice:r,bodyHash:e.computeInitialBodyHash(),feesPayerAccount:A.getNullHash()};this.type=t,this.sections=[],this.header=i,this.hash=e.computeMicroblockHash(i)}create(t,n,r){if(t==1)n=e.generatePreviousHashForGenesisMicroblock(this.type,r);else if(n===null)throw Error(`previous hash not provided`);this.header={magicString:Un,microblockType:this.type,height:t,previousHash:n,timestamp:A.getTimestampInSeconds(),gas:0,gasPrice:0,bodyHash:A.getNullHash(),feesPayerAccount:A.getNullHash()},this.hash=e.computeMicroblockHash(this.header)}isSigned(){return this.sections.length==0?!1:this.sections[this.sections.length-1].type===O.SIGNATURE}updateTimestamp(){this.header.timestamp=A.getTimestampInSeconds(),this.hash=e.computeMicroblockHash(this.header)}getHeader(){return this.header}getHash(){return Ix.from(this.hash)}getHashAsBytes(){return this.hash}getTimestampAsDate(){return new Date(this.header.timestamp*1e3)}getHeight(){return this.header.height}getPreviousHash(){return Ix.from(this.header.previousHash)}getTimestamp(){return this.header.timestamp}getGas(){return this.header.gas}getFees(){return hn.createAtomic(this.header.gas*this.header.gasPrice)}setGas(t){this.header.gas=t,this.hash=e.computeMicroblockHash(this.header)}setHeight(t){this.header.height=t,this.hash=e.computeMicroblockHash(this.header)}setGasPrice(t){this.header.gasPrice=t.getAmountAsAtomic(),this.hash=e.computeMicroblockHash(this.header)}getGasPrice(){return hn.createAtomic(this.header.gasPrice)}isFeesPayerAccountDefined(){return A.binaryIsEqual(this.getFeesPayerAccount(),A.getNullHash())==0}getFeesPayerAccount(){return this.header.feesPayerAccount}setTimestamp(t){this.header.timestamp=t,this.hash=e.computeMicroblockHash(this.header)}setFeesPayerAccount(t){this.header.feesPayerAccount=t,this.hash=e.computeMicroblockHash(this.header)}computeBodyHash(){return e.computeBodyHashFromSections(this.sections)}serializeHeader(){return X.encodeMicroblockHeader(this.header)}serializedBody(){return X.encodeMicroblockBody({sections:this.sections})}serialize(){let t=this.serializedBody(),n=this.header.bodyHash,r=this.serializeHeader();return{microblockHash:e.computeMicroblockHash(this.header),headerData:r,bodyHash:n,bodyData:t,microblockData:Cx(R(eS,{header:this.header,body:{sections:this.sections}}))}}getSection(e){let t=this.sections.find(t=>e(t));if(t===void 0)throw new Ee;return t}getNumberOfSections(){return this.sections.length}getSections(e){return this.sections.filter(t=>e(t))}getSectionsByType(e){return this.getSections(t=>t.type===e)}getAllSections(){return this.sections}async setGasAndSeal(e,t,n={}){let r=await e.computeMicroblockGas(this,{signatureSchemeId:t.getSignatureSchemeId()});this.setGas(r),await this.seal(t,n)}async seal(e,t={}){let n=t.feesPayerAccount;n&&this.setFeesPayerAccount(n);let r=typeof t.includeGas==`boolean`?t.includeGas:!0,i=await this.sign(e,r),a={type:O.SIGNATURE,signature:i,schemeId:e.getSignatureSchemeId()};this.addSection(a)}async sign(t,n=!0){let r=this.sections,i=e.computeBodyHashFromSections(r),a={...this.header,gas:n?this.header.gas:0,gasPrice:n?this.header.gasPrice:0,bodyHash:i},o=X.encodeMicroblockHeader(a);return await t.sign(o)}async verifySignature(e){let t=this.sections.filter(e=>e.type===O.SIGNATURE);if(t.length===0)throw new a(`The current microblock has no SIGNATURE section`);if(t.length!==1)throw new a(`There are several SIGNATURE sections`);if(this.sections[this.sections.length-1].type!==O.SIGNATURE)throw new a(`The SIGNATURE section is not the last one`);return this.verifySignatureOfSections(e,!0,this.sections.length-1)}async verifyAuxiliarySignature(e,t){let n=this.sections.filter(e=>e.type===O.AUXILIARY_SIGNATURE&&e.tag===t);if(n.length===0)throw new a(`The current microblock has no AUXILIARY_SIGNATURE section with tag '${t}'`);if(n.length!==1)throw new a(`The current microblock has several AUXILIARY_SIGNATURE section with tag '${t}'`);let r=this.sections.findIndex(e=>e.type===O.AUXILIARY_SIGNATURE&&e.tag===t);return this.verifySignatureOfSections(e,!1,r)}async verifySignatureOfSections(t,n,r){let i=this.sections[r];if(i.type!==O.SIGNATURE&&i.type!==O.AUXILIARY_SIGNATURE)throw new a(`Attempt to verify the signature of a non-signature section`);let o=this.sections.slice(0,r),s={...this.header,gas:n?this.header.gas:0,gasPrice:n?this.header.gasPrice:0,bodyHash:e.computeBodyHashFromSections(o)},c=X.encodeMicroblockHeader(s),l=i.signature;return t.verify(c,l)}async verify(t,n={includeGas:!0,verifiedSignatureIndex:`last`}){let r=typeof n.includeGas==`boolean`?n.includeGas:!0,o=this.getNumberOfSignatures();if(o===0)throw new a(`Microblock verification failure: The current microblock is not signed`);let s=n.verifiedSignatureIndex,c=o;if(typeof s==`number`){if(s<=0)throw new i(`verifiedSignatureIndex must be positive`);if(o<s)throw new i(`Invalid provided signature index ${s}: this microblock contains ${o} signatures`);c=s}else if(!(s===`last`||s===void 0))throw new i(`Unknown signature index: ${s} (type ${typeof s})`);let{signatureSection:l,sectionIndexInMicroblock:u}=this.getNthSignatureSectionAndIndexInMicroblock(c),d=this.sections.slice(0,u),f={...this.header,gas:r?this.header.gas:0,gasPrice:r?this.header.gasPrice:0,bodyHash:e.computeBodyHashFromSections(d)},p=X.encodeMicroblockHeader(f),m=l.signature;return await t.verify(p,m)}getNthSignatureSectionAndIndexInMicroblock(e){if(e<=0)throw new i(`Cannot return the ${e}-th signature: should be strictly positive`);let t=this.sections.map((e,t)=>({section:e,index:t})).filter(({section:e,index:t})=>e.type===O.SIGNATURE);if(t.length<e)throw new i(`Cannot return the ${e}-th signature: only ${t.length} signature (index starting at 1)`);let n=t[e-1];if(n.section.type!==O.SIGNATURE)throw Error(`Returned section is not a signature section`);return{signatureSection:n.section,sectionIndexInMicroblock:n.index}}getNumberOfSignatures(){return this.sections.filter(e=>e.type===O.SIGNATURE).length}isLastSectionSignature(){return this.sections.length==0?!1:this.sections[this.sections.length-1].type===O.SIGNATURE}isTemporallyCloseTo(e=A.getTimestampInSeconds()){return this.header.timestamp<e-300?$x.TOO_FAR_IN_THE_PAST:this.header.timestamp>e+120?$x.TOO_FAR_IN_THE_FUTURE:$x.VALID}hasSection(e){try{return this.getSectionByType(e),!0}catch(e){if(e instanceof Ee)return!1;throw e}}containsOnlyTheseSections(e){return this.sections.every(t=>e.includes(t.type))}getIndexOfSection(e){return this.sections.findIndex(t=>t.type===e)}setAsSuccessorOf(t){let n=this.getType(),r=t.getType();if(n!==r)throw new i(`Cannot make this microblock the successor: expected microblock of type ${n}, got ${r}`);let a=t.getHash();this.setPreviousHash(a),this.setHeight(t.getHeight()+1),this.hash=e.computeMicroblockHash(this.header),e.logger.info(`Microblock ${A.binaryToHexa(this.hash)} updated as successor of microblock ${a.encode()}`)}countSectionsByType(e){return this.sections.filter(t=>t.type===e).length}addSections(t){e.logger.debug(`Adding sections to microblock: {names}`,()=>({names:t.map(e=>qx.getSectionLabelFromSection(e)).join(`, `)})),this.sections.push(...t),this.header.bodyHash=this.computeBodyHash(),this.hash=e.computeMicroblockHash(this.header)}addSection(e){this.addSections([e])}popSection(){let t=this.sections.pop();if(this.getNumberOfSections()==0||t===void 0)throw new a(`Cannot pop section from empty microblock`);return this.header.bodyHash=this.computeBodyHash(),this.hash=e.computeMicroblockHash(this.header),t}getSectionByType(e){let t=this.sections.find(t=>t.type===e);if(t===void 0)throw new Ee;return t}toString(){let e=Sg.bytesToHexEncoder(),t=`Microblock:
|
|
6
|
+
`}Ro();var zo={trace:`background-color: gray; color: white;`,debug:`background-color: gray; color: white;`,info:`background-color: white; color: black;`,warning:`background-color: orange; color: black;`,error:`background-color: red; color: white;`,fatal:`background-color: maroon; color: white;`};function Bo(e){let t=``,n=[];for(let r=0;r<e.message.length;r++)r%2==0?t+=e.message[r]:(t+=`%o`,n.push(e.message[r]));let r=new Date(e.timestamp);return[`%c${`${r.getUTCHours().toString().padStart(2,`0`)}:${r.getUTCMinutes().toString().padStart(2,`0`)}:${r.getUTCSeconds().toString().padStart(2,`0`)}.${r.getUTCMilliseconds().toString().padStart(3,`0`)}`} %c${Eo[e.level]}%c %c${e.category.join(`·`)} %c${t}`,`color: gray;`,zo[e.level],`background-color: default;`,`color: gray;`,`color: default;`,...n]}function Vo(e={}){let t=e.formatter??Bo,n={trace:`debug`,debug:`debug`,info:`info`,warning:`warn`,error:`error`,fatal:`error`,...e.levelMap??{}},r=e.console??globalThis.console,i=e=>{let i=t(e),a=n[e.level];if(a===void 0)throw TypeError(`Invalid log level: ${e.level}.`);if(typeof i==`string`){let e=i.replace(/\r?\n$/,``);r[a](e)}else r[a](...i)};if(!e.nonBlocking)return i;let a=e.nonBlocking===!0?{}:e.nonBlocking,o=a.bufferSize??100,s=a.flushInterval??100,c=[],l=null,u=!1,d=!1,f=o*2;function p(){if(c.length===0)return;let e=c.splice(0);for(let t of e)try{i(t)}catch{}}function m(){d||(d=!0,setTimeout(()=>{d=!1,p()},0))}function h(){l!==null||u||(l=setInterval(()=>{p()},s))}let g=e=>{u||(c.length>=f&&c.shift(),c.push(e),c.length>=o?m():l===null&&h())};return g[Symbol.dispose]=()=>{u=!0,l!==null&&(clearInterval(l),l=null),p()},g}var Ho=null,Uo=new Set,Wo=new Set,Go=new Set;function Ko(e){return e.category.length===0||e.category.length===1&&e.category[0]===`logtape`||e.category.length===2&&e.category[0]===`logtape`&&e.category[1]===`meta`}function qo(e){if(Ho!=null&&!e.reset)throw new $o(`Already configured; if you want to reset, turn on the reset flag.`);if(Go.size>0)throw new $o(`Previously configured async disposables are still active. Use configure() instead or explicitly dispose them using dispose().`);Yo();try{Jo(e,!1)}catch(e){throw e instanceof $o&&Yo(),e}}function Jo(e,t){Ho=e;let n=!1,r=new Set;for(let t of e.loggers){Ko(t)&&(n=!0);let i=Array.isArray(t.category)?JSON.stringify(t.category):JSON.stringify([t.category]);if(r.has(i))throw new $o(`Duplicate logger configuration for category: ${i}. Each category can only be configured once.`);r.add(i);let a=uo.getLogger(t.category);for(let n of t.sinks??[]){let t=e.sinks[n];if(!t)throw new $o(`Sink not found: ${n}.`);a.sinks.push(t)}a.parentSinks=t.parentSinks??`inherit`,t.lowestLevel!==void 0&&(a.lowestLevel=t.lowestLevel);for(let n of t.filters??[]){let t=e.filters?.[n];if(t===void 0)throw new $o(`Filter not found: ${n}.`);a.filters.push(io(t))}Uo.add(a)}uo.getLogger().contextLocalStorage=e.contextLocalStorage;for(let n of Object.values(e.sinks)){if(Symbol.asyncDispose in n)if(t)Go.add(n);else throw new $o(`Async disposables cannot be used with configureSync().`);Symbol.dispose in n&&Wo.add(n)}for(let n of Object.values(e.filters??{}))if(!(n==null||typeof n==`string`)){if(Symbol.asyncDispose in n)if(t)Go.add(n);else throw new $o(`Async disposables cannot be used with configureSync().`);Symbol.dispose in n&&Wo.add(n)}if(typeof globalThis.EdgeRuntime!=`string`&&`process`in globalThis&&!(`Deno`in globalThis)){let e=globalThis.process,n=e?.on;typeof n==`function`&&n.call(e,`exit`,t?Zo:Qo)}else addEventListener(`unload`,t?Zo:Qo);let i=uo.getLogger([`logtape`,`meta`]);n||i.sinks.push(Vo()),i.info(`LogTape loggers are configured. Note that LogTape itself uses the meta logger, which has category {metaLoggerCategory}. The meta logger purposes to log internal errors such as sink exceptions. If you are seeing this message, the meta logger is automatically configured. It's recommended to configure the meta logger with a separate sink so that you can easily notice if logging itself fails or is misconfigured. To turn off this message, configure the meta logger with higher log levels than {dismissLevel}. See also <https://logtape.org/manual/categories#meta-logger>.`,{metaLoggerCategory:[`logtape`,`meta`],dismissLevel:`info`})}function Yo(){Qo(),Xo()}function Xo(){let e=uo.getLogger([]);e.resetDescendants(),delete e.contextLocalStorage,Uo.clear(),Ho=null}async function Zo(){Qo();let e=[];for(let t of Go)e.push(t[Symbol.asyncDispose]()),Go.delete(t);await Promise.all(e)}function Qo(){for(let e of Wo)e[Symbol.dispose]();Wo.clear()}var $o=class extends Error{constructor(e){super(e),this.name=`ConfigureError`}},k=class{static getLogger(e=[]){return co([`@cmts-dev/carmentis-sdk-core`,...e])}static getProviderLogger(){return this.getLogger([`provider`])}static getMemoryProviderLogger(){return this.getLogger([`provider`,`memory`])}static async enableLogs(){this.enableLogsSync()}static enableLogsSync(){qo({sinks:{console:Vo()},loggers:[{category:`@cmts-dev/carmentis-sdk-core`,lowestLevel:`debug`,sinks:[`console`]}]})}static getNetworkProviderLogger(){return this.getLogger([`provider`,`network`])}static getMicroblockLogger(){return this.getLogger([`microblock`])}static getVirtualBlockchainLogger(){return this.getLogger([`virtual-blockchain`])}static getInternalStateUpdaterLogger(e){return this.getLogger([`internal-state-updater`,e])}static getAbstractProviderLogger(e){return this.getLogger([`provider`,e])}static getMicroblockStructureCheckerLogger(){return this.getLogger([`microblock`,`structure-checker`])}},A={numberToHexa:ts,truncateString:ns,truncateStringMiddle:rs,getNullHash:is,getTimestampInSeconds:as,encodeDay:ss,decodeDay:cs,dateToDay:ls,dayToDate:us,addDaysToTimestamp:ds,timestampDifferenceInDays:fs,bufferToUint8Array:ps,binaryToHexa:ms,binaryFromHexa:hs,binaryFrom:gs,binaryIsEqual:_s,binaryCompare:vs,intToByteArray:ys,byteArrayToInt:bs,getGenesisEpochInTimestamp:os,jsonPrettify:xs},es=k.getLogger([`utils`]);function ts(e,t){return e.toString(16).toUpperCase().padStart(t||1,`0`)}function ns(e,t){return e.slice(0,t)+(e.length>t?`(...)`:``)}function rs(e,t,n){return e.length<=t+n?e:e.slice(0,t)+`(...)`+e.slice(e.length-n)}function is(){return new Uint8Array(32)}function as(){return Math.floor(Date.now()/1e3)}function os(){return 0}function ss(e,t,n){return e<<9|t<<5|n}function cs(e){let t=e&31,n=e>>5&15;return[e>>>9,n,t]}function ls(e){let t=e.getDate(),n=e.getMonth()+1;return ss(e.getFullYear(),n,t)}function us(e){let[t,n,r]=cs(e);return new Date(Date.UTC(t,n-1,r))}function ds(e,t){let n=new Date(e*1e3);return Math.floor(Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()+t)/1e3)}function fs(e,t){return Math.round((t-e)/86400)}function ps(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT)}function ms(e){return[...e].map(e=>e.toString(16).toUpperCase().padStart(2,`0`)).join(``)}function hs(e){if(typeof e!=`string`)throw new i(`Expecting hex-string value: received ${typeof e}`);if(!e.match(/^([\da-f]{2})*$/gi))throw new i(`Expecting hex-string value: received '${e}'`);let t=(e.match(/../g)||[]).map(e=>parseInt(e,16));return new Uint8Array(t)}function gs(...e){let t=Array(e.length),n=Array(e.length),r=0;e.forEach((i,a)=>{let o=no.getType(i);switch(o){case 4:n[a]=new Uint8Array(ys(i));break;case 3:n[a]=Za.encode(i);break;case 12:n[a]=i;break;default:{let t=e.length,n=e.map(e=>Pn[no.getType(e)]).join(`, `);throw Error(`unsupported type '${Pn[o]}' for Utils.binaryFrom(): got ${t} arguments of type ${n}`)}}t[a]=r,r+=n[a].length});let i=new Uint8Array(r);return t.forEach((e,t)=>{i.set(n[t],e)}),i}function _s(e,t){if(!(e instanceof Uint8Array))throw Error(`Excepted Uint8array, got ${typeof e}`);if(!(t instanceof Uint8Array))throw Error(`Excepted Uint8array, got ${typeof t}`);let n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(n.byteLength!==r.byteLength)return es.debug(`Comparison result is false (distinct length): ${n.byteLength} != ${r.byteLength}`),!1;for(let e=0;e<n.byteLength;e++)if(n[e]!==r[e])return es.debug(`Comparison result is false (distinct value): ${n[e]} != ${r[e]}`),!1;return es.debug(`Comparison result is true`),!0}function vs(e,t){if(!(e instanceof Uint8Array)||!(t instanceof Uint8Array)||e.length!=t.length)throw`cannot compare`;for(let n in e)if(e[n]<t[n])return-1;else if(e[n]>t[n])return 1;return 0}function ys(e,t=1){let n=[],r=e,i=t;for(;r>0||i>0;)n.push(r&255),r=Math.floor(r/256),i--;return n.reverse()}function bs(e){return e.reduce((e,t)=>e*256+t,0)}function xs(e,t=2){return JSON.stringify(e,(e,t)=>{if(t instanceof Uint8Array){let e=t.length>32,n=ms(t.slice(0,e?24:32)),r=e?`(...)`+ms(t.slice(-8)):``;return`Uint8Array[${t.length}]:${n}${r}`}return t},t)}var Ss=typeof globalThis==`object`&&`crypto`in globalThis?globalThis.crypto:void 0;function Cs(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function ws(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got `+e)}function Ts(e,...t){if(!Cs(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function Es(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash should be wrapped by utils.createHasher`);ws(e.outputLen),ws(e.blockLen)}function Ds(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function Os(e,t){Ts(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function ks(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function As(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function js(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ms(e,t){return e<<32-t|e>>>t}function Ns(e,t){return e<<t|e>>>32-t>>>0}var Ps=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Fs(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Is(e){for(let t=0;t<e.length;t++)e[t]=Fs(e[t]);return e}var Ls=Ps?e=>e:Is,Rs=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,zs={_0:48,_9:57,A:65,F:70,a:97,f:102};function Bs(e){if(e>=zs._0&&e<=zs._9)return e-zs._0;if(e>=zs.A&&e<=zs.F)return e-(zs.A-10);if(e>=zs.a&&e<=zs.f)return e-(zs.a-10)}function Vs(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(Rs)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=Bs(e.charCodeAt(i)),a=Bs(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function Hs(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function Us(e){return typeof e==`string`&&(e=Hs(e)),Ts(e),e}function Ws(e){return typeof e==`string`&&(e=Hs(e)),Ts(e),e}function Gs(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];Ts(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}function Ks(e,t){if(t!==void 0&&{}.toString.call(t)!==`[object Object]`)throw Error(`options should be object or undefined`);return Object.assign(e,t)}var qs=class{};function Js(e){let t=t=>e().update(Us(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Ys(e){let t=(t,n)=>e(n).update(Us(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}function Xs(e=32){if(Ss&&typeof Ss.getRandomValues==`function`)return Ss.getRandomValues(new Uint8Array(e));if(Ss&&typeof Ss.randomBytes==`function`)return Uint8Array.from(Ss.randomBytes(e));throw Error(`crypto.getRandomValues must be defined`)}var Zs={getBytes:Qs,getInteger:$s,getKey256:ec};function Qs(e){return Xs(e)}function $s(e){let t=Qs(6),n=0;for(let e=0;e<6;e++)n=n*256+t[e];return Math.floor(n/2**48*e)}function ec(){let e=Qs(32);return A.binaryToHexa(e)}function tc(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}function nc(e,t,n){return e&t^~e&n}function rc(e,t,n){return e&t^e&n^t&n}var ic=class extends qs{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=js(this.buffer)}update(e){Ds(this),e=Us(e),Ts(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=js(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ds(this),Os(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,As(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;tc(n,r-8,BigInt(this.length*8),i),this.process(n,0);let o=js(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},ac=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),oc=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),sc=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),cc=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),lc=BigInt(2**32-1),uc=BigInt(32);function dc(e,t=!1){return t?{h:Number(e&lc),l:Number(e>>uc&lc)}:{h:Number(e>>uc&lc)|0,l:Number(e&lc)|0}}function fc(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=dc(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}var pc=(e,t,n)=>e>>>n,mc=(e,t,n)=>e<<32-n|t>>>n,hc=(e,t,n)=>e>>>n|t<<32-n,gc=(e,t,n)=>e<<32-n|t>>>n,_c=(e,t,n)=>e<<64-n|t>>>n-32,vc=(e,t,n)=>e>>>n-32|t<<64-n,yc=(e,t,n)=>e<<n|t>>>32-n,bc=(e,t,n)=>t<<n|e>>>32-n,xc=(e,t,n)=>t<<n-32|e>>>64-n,Sc=(e,t,n)=>e<<n-32|t>>>64-n;function Cc(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}var wc=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Tc=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Ec=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),Dc=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,Oc=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),kc=(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0,Ac=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),jc=new Uint32Array(64),Mc=class extends ic{constructor(e=32){super(64,e,8,!1),this.A=ac[0]|0,this.B=ac[1]|0,this.C=ac[2]|0,this.D=ac[3]|0,this.E=ac[4]|0,this.F=ac[5]|0,this.G=ac[6]|0,this.H=ac[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)jc[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=jc[e-15],n=jc[e-2],r=Ms(t,7)^Ms(t,18)^t>>>3;jc[e]=(Ms(n,17)^Ms(n,19)^n>>>10)+jc[e-7]+r+jc[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=Ms(o,6)^Ms(o,11)^Ms(o,25),u=l+t+nc(o,s,c)+Ac[e]+jc[e]|0,d=(Ms(n,2)^Ms(n,13)^Ms(n,22))+rc(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){As(jc)}destroy(){this.set(0,0,0,0,0,0,0,0),As(this.buffer)}},Nc=class extends Mc{constructor(){super(28),this.A=oc[0]|0,this.B=oc[1]|0,this.C=oc[2]|0,this.D=oc[3]|0,this.E=oc[4]|0,this.F=oc[5]|0,this.G=oc[6]|0,this.H=oc[7]|0}},Pc=fc(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map(e=>BigInt(e))),Fc=Pc[0],Ic=Pc[1],Lc=new Uint32Array(80),Rc=new Uint32Array(80),zc=class extends ic{constructor(e=64){super(128,e,16,!1),this.Ah=cc[0]|0,this.Al=cc[1]|0,this.Bh=cc[2]|0,this.Bl=cc[3]|0,this.Ch=cc[4]|0,this.Cl=cc[5]|0,this.Dh=cc[6]|0,this.Dl=cc[7]|0,this.Eh=cc[8]|0,this.El=cc[9]|0,this.Fh=cc[10]|0,this.Fl=cc[11]|0,this.Gh=cc[12]|0,this.Gl=cc[13]|0,this.Hh=cc[14]|0,this.Hl=cc[15]|0}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=s|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=m|0,this.Hl=h|0}process(e,t){for(let n=0;n<16;n++,t+=4)Lc[n]=e.getUint32(t),Rc[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=Lc[e-15]|0,n=Rc[e-15]|0,r=hc(t,n,1)^hc(t,n,8)^pc(t,n,7),i=gc(t,n,1)^gc(t,n,8)^mc(t,n,7),a=Lc[e-2]|0,o=Rc[e-2]|0,s=hc(a,o,19)^_c(a,o,61)^pc(a,o,6),c=Ec(i,gc(a,o,19)^vc(a,o,61)^mc(a,o,6),Rc[e-7],Rc[e-16]);Lc[e]=Dc(c,r,s,Lc[e-7],Lc[e-16])|0,Rc[e]=c|0}let{Ah:n,Al:r,Bh:i,Bl:a,Ch:o,Cl:s,Dh:c,Dl:l,Eh:u,El:d,Fh:f,Fl:p,Gh:m,Gl:h,Hh:g,Hl:_}=this;for(let e=0;e<80;e++){let t=hc(u,d,14)^hc(u,d,18)^_c(u,d,41),v=gc(u,d,14)^gc(u,d,18)^vc(u,d,41),y=u&f^~u&m,b=d&p^~d&h,ee=Oc(_,v,b,Ic[e],Rc[e]),x=kc(ee,g,t,y,Fc[e],Lc[e]),te=ee|0,ne=hc(n,r,28)^_c(n,r,34)^_c(n,r,39),re=gc(n,r,28)^vc(n,r,34)^vc(n,r,39),ie=n&i^n&o^i&o,ae=r&a^r&s^a&s;g=m|0,_=h|0,m=f|0,h=p|0,f=u|0,p=d|0,{h:u,l:d}=Cc(c|0,l|0,x|0,te|0),c=o|0,l=s|0,o=i|0,s=a|0,i=n|0,a=r|0;let oe=wc(te,re,ae);n=Tc(oe,x,ne,ie),r=oe|0}({h:n,l:r}=Cc(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:a}=Cc(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:s}=Cc(this.Ch|0,this.Cl|0,o|0,s|0),{h:c,l}=Cc(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=Cc(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=Cc(this.Fh|0,this.Fl|0,f|0,p|0),{h:m,l:h}=Cc(this.Gh|0,this.Gl|0,m|0,h|0),{h:g,l:_}=Cc(this.Hh|0,this.Hl|0,g|0,_|0),this.set(n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)}roundClean(){As(Lc,Rc)}destroy(){As(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Bc=class extends zc{constructor(){super(48),this.Ah=sc[0]|0,this.Al=sc[1]|0,this.Bh=sc[2]|0,this.Bl=sc[3]|0,this.Ch=sc[4]|0,this.Cl=sc[5]|0,this.Dh=sc[6]|0,this.Dl=sc[7]|0,this.Eh=sc[8]|0,this.El=sc[9]|0,this.Fh=sc[10]|0,this.Fl=sc[11]|0,this.Gh=sc[12]|0,this.Gl=sc[13]|0,this.Hh=sc[14]|0,this.Hl=sc[15]|0}},Vc=Uint32Array.from([2352822216,424955298,1944164710,2312950998,502970286,855612546,1738396948,1479516111,258812777,2077511080,2011393907,79989058,1067287976,1780299464,286451373,2446758561]),Hc=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]),Uc=class extends zc{constructor(){super(28),this.Ah=Vc[0]|0,this.Al=Vc[1]|0,this.Bh=Vc[2]|0,this.Bl=Vc[3]|0,this.Ch=Vc[4]|0,this.Cl=Vc[5]|0,this.Dh=Vc[6]|0,this.Dl=Vc[7]|0,this.Eh=Vc[8]|0,this.El=Vc[9]|0,this.Fh=Vc[10]|0,this.Fl=Vc[11]|0,this.Gh=Vc[12]|0,this.Gl=Vc[13]|0,this.Hh=Vc[14]|0,this.Hl=Vc[15]|0}},Wc=class extends zc{constructor(){super(32),this.Ah=Hc[0]|0,this.Al=Hc[1]|0,this.Bh=Hc[2]|0,this.Bl=Hc[3]|0,this.Ch=Hc[4]|0,this.Cl=Hc[5]|0,this.Dh=Hc[6]|0,this.Dl=Hc[7]|0,this.Eh=Hc[8]|0,this.El=Hc[9]|0,this.Fh=Hc[10]|0,this.Fl=Hc[11]|0,this.Gh=Hc[12]|0,this.Gl=Hc[13]|0,this.Hh=Hc[14]|0,this.Hl=Hc[15]|0}},Gc=Js(()=>new Mc),Kc=Js(()=>new Nc),qc=Js(()=>new zc),Jc=Js(()=>new Bc),Yc=Js(()=>new Wc),Xc=Js(()=>new Uc),Zc=qc,Qc={sha256AsBinary:$c,sha256:el,sha512AsBinary:tl,sha512:nl};k.getLogger([`utils`,`crypto`]);function $c(e){if(!(e instanceof Uint8Array))throw new m(`Argument passed to compute sha256 is not an instance of Uint8Array: got ${typeof e}`);return Gc(e)}function el(e){return A.binaryToHexa($c(e))}function tl(e){if(!(e instanceof Uint8Array))throw`Argument passed to compute sha512 is not an instance of Uint8Array`;return Zc(e)}function nl(e){return A.binaryToHexa(tl(e))}function rl(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function il(e){if(typeof e!=`boolean`)throw Error(`boolean expected, not ${e}`)}function al(e,...t){if(!rl(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function ol(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function sl(e,t){al(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function cl(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function ll(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ul(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function dl(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var fl=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,pl=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,ml=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function hl(e){if(al(e),pl)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=ml[e[n]];return t}var gl={_0:48,_9:57,A:65,F:70,a:97,f:102};function _l(e){if(e>=gl._0&&e<=gl._9)return e-gl._0;if(e>=gl.A&&e<=gl.F)return e-(gl.A-10);if(e>=gl.a&&e<=gl.f)return e-(gl.a-10)}function vl(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(pl)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=_l(e.charCodeAt(i)),a=_l(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function yl(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function bl(e){return new TextDecoder().decode(e)}function xl(e){if(typeof e==`string`)e=yl(e);else if(rl(e))e=Ol(e);else throw Error(`Uint8Array expected, got `+typeof e);return e}function Sl(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}var Cl=(e,t)=>{function n(n,...r){if(al(n),!fl)throw Error(`Non little-endian hardware is not yet supported`);if(e.nonceLength!==void 0){let t=r[0];if(!t)throw Error(`nonce / iv required`);e.varSizeNonce?al(t):al(t,e.nonceLength)}let i=e.tagLength;i&&r[1]!==void 0&&al(r[1]);let a=t(n,...r),o=(e,t)=>{if(t!==void 0){if(e!==2)throw Error(`cipher output not supported`);al(t)}},s=!1;return{encrypt(e,t){if(s)throw Error(`cannot encrypt() twice with same key + nonce`);return s=!0,al(e),o(a.encrypt.length,t),a.encrypt(e,t)},decrypt(e,t){if(al(e),i&&e.length<i)throw Error(`invalid ciphertext length: smaller than tagLength=`+i);return o(a.decrypt.length,t),a.decrypt(e,t)}}}return Object.assign(n,e),n};function wl(e,t,n=!0){if(t===void 0)return new Uint8Array(e);if(t.length!==e)throw Error(`invalid output length, expected `+e+`, got: `+t.length);if(n&&!Dl(t))throw Error(`invalid output, must be aligned`);return t}function Tl(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}function El(e,t,n){il(n);let r=new Uint8Array(16),i=dl(r);return Tl(i,0,BigInt(t),n),Tl(i,8,BigInt(e),n),r}function Dl(e){return e.byteOffset%4==0}function Ol(e){return Uint8Array.from(e)}var kl=16,Al=new Uint8Array(16),jl=ll(Al),Ml=225,Nl=(e,t,n,r)=>{let i=r&1;return{s3:n<<31|r>>>1,s2:t<<31|n>>>1,s1:e<<31|t>>>1,s0:e>>>1^Ml<<24&-(i&1)}},Pl=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255|0;function Fl(e){e.reverse();let t=e[15]&1,n=0;for(let t=0;t<e.length;t++){let r=e[t];e[t]=r>>>1|n,n=(r&1)<<7}return e[0]^=-t&225,e}var Il=e=>e>64*1024?8:e>1024?4:2,Ll=class{constructor(e,t){this.blockLen=kl,this.outputLen=kl,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,e=xl(e),al(e,16);let n=dl(e),r=n.getUint32(0,!1),i=n.getUint32(4,!1),a=n.getUint32(8,!1),o=n.getUint32(12,!1),s=[];for(let e=0;e<128;e++)s.push({s0:Pl(r),s1:Pl(i),s2:Pl(a),s3:Pl(o)}),{s0:r,s1:i,s2:a,s3:o}=Nl(r,i,a,o);let c=Il(t||1024);if(![1,2,4,8].includes(c))throw Error(`ghash: invalid window size, expected 2, 4 or 8`);this.W=c;let l=128/c,u=this.windowSize=2**c,d=[];for(let e=0;e<l;e++)for(let t=0;t<u;t++){let n=0,r=0,i=0,a=0;for(let o=0;o<c;o++){if(!(t>>>c-o-1&1))continue;let{s0:l,s1:u,s2:d,s3:f}=s[c*e+o];n^=l,r^=u,i^=d,a^=f}d.push({s0:n,s1:r,s2:i,s3:a})}this.t=d}_updateBlock(e,t,n,r){e^=this.s0,t^=this.s1,n^=this.s2,r^=this.s3;let{W:i,t:a,windowSize:o}=this,s=0,c=0,l=0,u=0,d=(1<<i)-1,f=0;for(let p of[e,t,n,r])for(let e=0;e<4;e++){let t=p>>>8*e&255;for(let e=8/i-1;e>=0;e--){let n=t>>>i*e&d,{s0:r,s1:p,s2:m,s3:h}=a[f*o+n];s^=r,c^=p,l^=m,u^=h,f+=1}}this.s0=s,this.s1=c,this.s2=l,this.s3=u}update(e){ol(this),e=xl(e),al(e);let t=ll(e),n=Math.floor(e.length/kl),r=e.length%kl;for(let e=0;e<n;e++)this._updateBlock(t[e*4+0],t[e*4+1],t[e*4+2],t[e*4+3]);return r&&(Al.set(e.subarray(n*kl)),this._updateBlock(jl[0],jl[1],jl[2],jl[3]),ul(jl)),this}destroy(){let{t:e}=this;for(let t of e)t.s0=0,t.s1=0,t.s2=0,t.s3=0}digestInto(e){ol(this),sl(e,this),this.finished=!0;let{s0:t,s1:n,s2:r,s3:i}=this,a=ll(e);return a[0]=t,a[1]=n,a[2]=r,a[3]=i,e}digest(){let e=new Uint8Array(kl);return this.digestInto(e),this.destroy(),e}},Rl=class extends Ll{constructor(e,t){e=xl(e),al(e);let n=Fl(Ol(e));super(n,t),ul(n)}update(e){e=xl(e),ol(this);let t=ll(e),n=e.length%kl,r=Math.floor(e.length/kl);for(let e=0;e<r;e++)this._updateBlock(Pl(t[e*4+3]),Pl(t[e*4+2]),Pl(t[e*4+1]),Pl(t[e*4+0]));return n&&(Al.set(e.subarray(r*kl)),this._updateBlock(Pl(jl[3]),Pl(jl[2]),Pl(jl[1]),Pl(jl[0])),ul(jl)),this}digestInto(e){ol(this),sl(e,this),this.finished=!0;let{s0:t,s1:n,s2:r,s3:i}=this,a=ll(e);return a[0]=t,a[1]=n,a[2]=r,a[3]=i,e.reverse()}};function zl(e){let t=(t,n)=>e(n,t.length).update(xl(t)).digest(),n=e(new Uint8Array(16),0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=(t,n)=>e(t,n),t}var Bl=zl((e,t)=>new Ll(e,t));zl((e,t)=>new Rl(e,t));var Vl=16,Hl=4,Ul=new Uint8Array(Vl),Wl=283;function Gl(e){return e<<1^Wl&-(e>>7)}function Kl(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(t&1),e=Gl(e);return n}var ql=(()=>{let e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=Gl(n))e[t]=n;let t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=(r^r>>4^r>>5^r>>6^r>>7^99)&255}return ul(e),t})(),Jl=e=>e<<24|e>>>8,Yl=e=>e<<8|e>>>24;function Xl(e,t){if(e.length!==256)throw Error(`Wrong sbox length`);let n=new Uint32Array(256).map((n,r)=>t(e[r])),r=n.map(Yl),i=r.map(Yl),a=i.map(Yl),o=new Uint32Array(256*256),s=new Uint32Array(256*256),c=new Uint16Array(256*256);for(let t=0;t<256;t++)for(let l=0;l<256;l++){let u=t*256+l;o[u]=n[t]^r[l],s[u]=i[t]^a[l],c[u]=e[t]<<8|e[l]}return{sbox:e,sbox2:c,T0:n,T1:r,T2:i,T3:a,T01:o,T23:s}}var Zl=Xl(ql,e=>Kl(e,3)<<24|e<<16|e<<8|Kl(e,2)),Ql=(()=>{let e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=Gl(n))e[t]=n;return e})();function $l(e){al(e);let t=e.length;if(![16,24,32].includes(t))throw Error(`aes: invalid key size, should be 16, 24 or 32, got `+t);let{sbox2:n}=Zl,r=[];Dl(e)||r.push(e=Ol(e));let i=ll(e),a=i.length,o=e=>tu(n,e,e,e,e),s=new Uint32Array(t+28);s.set(i);for(let e=a;e<s.length;e++){let t=s[e-1];e%a===0?t=o(Jl(t))^Ql[e/a-1]:a>6&&e%a===4&&(t=o(t)),s[e]=s[e-a]^t}return ul(...r),s}function eu(e,t,n,r,i,a){return e[n<<8&65280|r>>>8&255]^t[i>>>8&65280|a>>>24&255]}function tu(e,t,n,r,i){return e[t&255|n&65280]|e[r>>>16&255|i>>>16&65280]<<16}function nu(e,t,n,r,i){let{sbox2:a,T01:o,T23:s}=Zl,c=0;t^=e[c++],n^=e[c++],r^=e[c++],i^=e[c++];let l=e.length/4-2;for(let a=0;a<l;a++){let a=e[c++]^eu(o,s,t,n,r,i),l=e[c++]^eu(o,s,n,r,i,t),u=e[c++]^eu(o,s,r,i,t,n),d=e[c++]^eu(o,s,i,t,n,r);t=a,n=l,r=u,i=d}return{s0:e[c++]^tu(a,t,n,r,i),s1:e[c++]^tu(a,n,r,i,t),s2:e[c++]^tu(a,r,i,t,n),s3:e[c++]^tu(a,i,t,n,r)}}function ru(e,t,n,r,i){al(n,Vl),al(r),i=wl(r.length,i);let a=n,o=ll(a),s=dl(a),c=ll(r),l=ll(i),u=t?0:12,d=r.length,f=s.getUint32(u,t),{s0:p,s1:m,s2:h,s3:g}=nu(e,o[0],o[1],o[2],o[3]);for(let n=0;n+4<=c.length;n+=4)l[n+0]=c[n+0]^p,l[n+1]=c[n+1]^m,l[n+2]=c[n+2]^h,l[n+3]=c[n+3]^g,f=f+1>>>0,s.setUint32(u,f,t),{s0:p,s1:m,s2:h,s3:g}=nu(e,o[0],o[1],o[2],o[3]);let _=Vl*Math.floor(c.length/Hl);if(_<d){let e=new Uint32Array([p,m,h,g]),t=cl(e);for(let e=_,n=0;e<d;e++,n++)i[e]=r[e]^t[n];ul(e)}return i}function iu(e,t,n,r,i){let a=i?i.length:0,o=e.create(n,r.length+a);i&&o.update(i);let s=El(8*r.length,8*a,t);o.update(r),o.update(s);let c=o.digest();return ul(s),c}var au=Cl({blockSize:16,nonceLength:12,tagLength:16,varSizeNonce:!0},function(e,t,n){if(t.length<8)throw Error(`aes/gcm: invalid nonce length`);function r(e,t,r){let i=iu(Bl,!1,e,r,n);for(let e=0;e<t.length;e++)i[e]^=t[e];return i}function i(){let n=$l(e),r=Ul.slice(),i=Ul.slice();if(ru(n,!1,i,i,r),t.length===12)i.set(t);else{let e=Ul.slice();Tl(dl(e),8,BigInt(t.length*8),!1);let n=Bl.create(r).update(t).update(e);n.digestInto(i),n.destroy()}return{xk:n,authKey:r,counter:i,tagMask:ru(n,!1,i,Ul)}}return{encrypt(e){let{xk:t,authKey:n,counter:a,tagMask:o}=i(),s=new Uint8Array(e.length+16),c=[t,n,a,o];Dl(e)||c.push(e=Ol(e)),ru(t,!1,a,e,s.subarray(0,e.length));let l=r(n,o,s.subarray(0,s.length-16));return c.push(l),s.set(l,e.length),ul(...c),s},decrypt(e){let{xk:t,authKey:n,counter:a,tagMask:o}=i(),s=[t,n,o,a];Dl(e)||s.push(e=Ol(e));let c=e.subarray(0,-16),l=e.subarray(-16),u=r(n,o,c);if(s.push(u),!Sl(u,l))throw Error(`aes/gcm: invalid ghash tag`);let d=ru(t,!1,a,c);return ul(...s),d}}}),ou=k.getLogger([`crypto`,`aes-gcm`]),su={encryptGcm:cu,decryptGcm:lu};function cu(e,t,n){return au(e,n).encrypt(t)}function lu(e,t,n){try{return au(e,n).decrypt(t)}catch(e){throw ou.warn(`{e}`,{e}),new f}}var uu=BigInt(0),du=BigInt(1),fu=BigInt(2),pu=BigInt(7),mu=BigInt(256),hu=BigInt(113),gu=[],_u=[],vu=[];for(let e=0,t=du,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],gu.push(2*(5*r+n)),_u.push((e+1)*(e+2)/2%64);let i=uu;for(let e=0;e<7;e++)t=(t<<du^(t>>pu)*hu)%mu,t&fu&&(i^=du<<(du<<BigInt(e))-du);vu.push(i)}var yu=fc(vu,!0),bu=yu[0],xu=yu[1],Su=(e,t,n)=>n>32?xc(e,t,n):yc(e,t,n),Cu=(e,t,n)=>n>32?Sc(e,t,n):bc(e,t,n);function wu(e,t=24){let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,i=(t+2)%10,a=n[i],o=n[i+1],s=Su(a,o,1)^n[r],c=Cu(a,o,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=s,e[t+n+1]^=c}let t=e[2],i=e[3];for(let n=0;n<24;n++){let r=_u[n],a=Su(t,i,r),o=Cu(t,i,r),s=gu[n];t=e[s],i=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=bu[r],e[1]^=xu[r]}As(n)}var Tu=class e extends qs{constructor(e,t,n,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=i,ws(n),!(0<e&&e<200))throw Error(`only keccak-f1600 function is supported`);this.state=new Uint8Array(200),this.state32=ks(this.state)}clone(){return this._cloneInto()}keccak(){Ls(this.state32),wu(this.state32,this.rounds),Ls(this.state32),this.posOut=0,this.pos=0}update(e){Ds(this),e=Us(e),Ts(e);let{blockLen:t,state:n}=this,r=e.length;for(let i=0;i<r;){let a=Math.min(t-this.pos,r-i);for(let t=0;t<a;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){Ds(this,!1),Ts(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not possible for this instance`);return this.writeInto(e)}xof(e){return ws(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Os(e,this),this.finished)throw Error(`digest() was already called`);return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,As(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.destroyed=this.destroyed,t}},Eu=(e,t,n)=>Js(()=>new Tu(t,e,n)),Du=Eu(6,144,224/8),Ou=Eu(6,136,256/8),ku=Eu(6,104,384/8),Au=Eu(6,72,512/8);Eu(1,144,224/8),Eu(1,136,256/8),Eu(1,104,384/8),Eu(1,72,512/8);var ju=(e,t,n)=>Ys((r={})=>new Tu(t,e,r.dkLen===void 0?n:r.dkLen,!0)),Mu=ju(31,168,128/8),Nu=ju(31,136,256/8),Pu=Ts,Fu=Xs;function Iu(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function Lu(...e){let t=e=>typeof e==`number`?e:e.bytesLen,n=e.reduce((e,n)=>e+t(n),0);return{bytesLen:n,encode:r=>{let i=new Uint8Array(n);for(let n=0,a=0;n<e.length;n++){let o=e[n],s=t(o),c=typeof o==`number`?r[n]:o.encode(r[n]);Pu(c,s),i.set(c,a),typeof o!=`number`&&c.fill(0),a+=s}return i},decode:r=>{Pu(r,n);let i=[];for(let n of e){let e=t(n),a=r.subarray(0,e);i.push(typeof n==`number`?a:n.decode(a)),r=r.subarray(e)}return i}}}function Ru(e,t){let n=t*e.bytesLen;return{bytesLen:n,encode:r=>{if(r.length!==t)throw Error(`vecCoder.encode: wrong length=${r.length}. Expected: ${t}`);let i=new Uint8Array(n);for(let t=0,n=0;t<r.length;t++){let a=e.encode(r[t]);i.set(a,n),a.fill(0),n+=a.length}return i},decode:t=>{Pu(t,n);let r=[];for(let n=0;n<t.length;n+=e.bytesLen)r.push(e.decode(t.subarray(n,n+e.bytesLen)));return r}}}function zu(...e){for(let t of e)if(Array.isArray(t))for(let e of t)e.fill(0);else t.fill(0)}function Bu(e){return(1<<e)-1}var Vu=new Uint8Array;function Hu(e,t=Vu){if(Pu(e),Pu(t),t.length>255)throw Error(`context should be less than 255 bytes`);return Gs(new Uint8Array([0,t.length]),t,e)}var Uu={"SHA2-256":{oid:Vs(`0609608648016503040201`),hash:Gc},"SHA2-384":{oid:Vs(`0609608648016503040202`),hash:Jc},"SHA2-512":{oid:Vs(`0609608648016503040203`),hash:qc},"SHA2-224":{oid:Vs(`0609608648016503040204`),hash:Kc},"SHA2-512/224":{oid:Vs(`0609608648016503040205`),hash:Xc},"SHA2-512/256":{oid:Vs(`0609608648016503040206`),hash:Yc},"SHA3-224":{oid:Vs(`0609608648016503040207`),hash:Du},"SHA3-256":{oid:Vs(`0609608648016503040208`),hash:Ou},"SHA3-384":{oid:Vs(`0609608648016503040209`),hash:ku},"SHA3-512":{oid:Vs(`060960864801650304020A`),hash:Au},"SHAKE-128":{oid:Vs(`060960864801650304020B`),hash:e=>Mu(e,{dkLen:32})},"SHAKE-256":{oid:Vs(`060960864801650304020C`),hash:e=>Nu(e,{dkLen:64})}};function Wu(e,t,n=Vu){if(Pu(t),Pu(n),n.length>255)throw Error(`context should be less than 255 bytes`);if(!Uu[e])throw Error(`unknown hash: `+e);let{oid:r,hash:i}=Uu[e],a=i(t);return Gs(new Uint8Array([1,n.length]),n,r,a)}function Gu(e,t=8){let n=e.toString(2).padStart(8,`0`).slice(-t).padStart(7,`0`).split(``).reverse().join(``);return Number.parseInt(n,2)}var Ku=e=>{let{newPoly:t,N:n,Q:r,F:i,ROOT_OF_UNITY:a,brvBits:o,isKyber:s}=e,c=(e,t=r)=>{let n=e%t|0;return(n>=0?n|0:t+n|0)|0},l=(e,t=r)=>{let n=c(e,t)|0;return(n>t>>1?n-t|0:n)|0};function u(){let e=t(n);for(let t=0;t<n;t++){let n=Gu(t,o),i=BigInt(a)**BigInt(n)%BigInt(r);e[t]=Number(i)|0}return e}let d=u(),f=s?128:n,p=+!!s;return{mod:c,smod:l,nttZetas:d,NTT:{encode:e=>{for(let t=1,r=128;r>p;r>>=1)for(let i=0;i<n;i+=2*r){let n=d[t++];for(let t=i;t<i+r;t++){let i=c(n*e[t+r]);e[t+r]=c(e[t]-i)|0,e[t]=c(e[t]+i)|0}}return e},decode:e=>{for(let t=f-1,r=1+p;r<f+p;r<<=1)for(let i=0;i<n;i+=2*r){let n=d[t--];for(let t=i;t<i+r;t++){let i=e[t];e[t]=c(i+e[t+r]),e[t+r]=c(n*(e[t+r]-i))}}for(let t=0;t<e.length;t++)e[t]=c(i*e[t]);return e}},bitsCoder:(e,r)=>{let i=Bu(e),a=n/8*e;return{bytesLen:a,encode:t=>{let n=new Uint8Array(a);for(let a=0,o=0,s=0,c=0;a<t.length;a++)for(o|=(r.encode(t[a])&i)<<s,s+=e;s>=8;s-=8,o>>=8)n[c++]=o&Bu(s);return n},decode:a=>{let o=t(n);for(let t=0,n=0,s=0,c=0;t<a.length;t++)for(n|=a[t]<<s,s+=8;s>=e;s-=e,n>>=e)o[c++]=r.decode(n&i);return o}}}}},qu=e=>(t,n)=>{n||=e.blockLen;let r=new Uint8Array(t.length+2);r.set(t);let i=t.length,a=new Uint8Array(n),o=e.create({}),s=0,c=0;return{stats:()=>({calls:s,xofs:c}),get:(t,n)=>(r[i+0]=t,r[i+1]=n,o.destroy(),o=e.create({}).update(r),s++,()=>(c++,o.xofInto(a))),clean:()=>{o.destroy(),a.fill(0),r.fill(0)}}},Ju=qu(Mu),Yu=qu(Nu),Xu=256,Zu=8380417,Qu=1753,$u=8347681,ed=13,td=Math.floor((Zu-1)/88)|0,nd=Math.floor((Zu-1)/32)|0,rd={2:{K:4,L:4,D:ed,GAMMA1:2**17,GAMMA2:td,TAU:39,ETA:2,OMEGA:80},3:{K:6,L:5,D:ed,GAMMA1:2**19,GAMMA2:nd,TAU:49,ETA:4,OMEGA:55},5:{K:8,L:7,D:ed,GAMMA1:2**19,GAMMA2:nd,TAU:60,ETA:2,OMEGA:75}},id=e=>new Int32Array(e),{mod:ad,smod:od,NTT:sd,bitsCoder:cd}=Ku({N:Xu,Q:Zu,F:$u,ROOT_OF_UNITY:Qu,newPoly:id,isKyber:!1,brvBits:8}),ld=e=>e,ud=(e,t=ld,n=ld)=>cd(e,{encode:e=>t(n(e)),decode:e=>n(t(e))}),dd=(e,t)=>{for(let n=0;n<e.length;n++)e[n]=ad(e[n]+t[n]);return e},fd=(e,t)=>{for(let n=0;n<e.length;n++)e[n]=ad(e[n]-t[n]);return e},pd=e=>{for(let t=0;t<Xu;t++)e[t]<<=ed;return e},md=(e,t)=>{for(let n=0;n<Xu;n++)if(Math.abs(od(e[n]))>=t)return!0;return!1},hd=(e,t)=>{let n=id(Xu);for(let r=0;r<e.length;r++)n[r]=ad(e[r]*t[r]);return n};function gd(e){let t=id(Xu);for(let n=0;n<Xu;){let r=e();if(r.length%3)throw Error(`RejNTTPoly: unaligned block`);for(let e=0;n<Xu&&e<=r.length-3;e+=3){let i=(r[e+0]|r[e+1]<<8|r[e+2]<<16)&8388607;i<Zu&&(t[n++]=i)}}return t}function _d(e){let{K:t,L:n,GAMMA1:r,GAMMA2:i,TAU:a,ETA:o,OMEGA:s}=e,{CRH_BYTES:c,TR_BYTES:l,C_TILDE_BYTES:u,XOF128:d,XOF256:f}=e;if(![2,4].includes(o))throw Error(`Wrong ETA`);if(![1<<17,1<<19].includes(r))throw Error(`Wrong GAMMA1`);if(![td,nd].includes(i))throw Error(`Wrong GAMMA2`);let p=a*o,m=e=>{let t=ad(e),n=od(t,2*i)|0;return t-n===Zu-1?{r1:0,r0:n-1|0}:{r1:Math.floor((t-n)/(2*i))|0,r0:n}},h=e=>m(e).r1,g=e=>m(e).r0,_=(e,t)=>e<=i||e>Zu-i||e===Zu-i&&t===0?0:1,v=(e,t)=>{let n=Math.floor((Zu-1)/(2*i)),{r1:r,r0:a}=m(t);return e===1?a>0?ad(r+1,n)|0:ad(r-1,n)|0:r|0},y=e=>{let t=ad(e),n=od(t,2**ed)|0;return{r1:Math.floor((t-n)/2**ed)|0,r0:n}},b={bytesLen:s+t,encode:e=>{if(e===!1)throw Error(`hint.encode: hint is false`);let n=new Uint8Array(s+t);for(let r=0,i=0;r<t;r++){for(let t=0;t<Xu;t++)e[r][t]!==0&&(n[i++]=t);n[s+r]=i}return n},decode:e=>{let n=[],r=0;for(let i=0;i<t;i++){let t=id(Xu);if(e[s+i]<r||e[s+i]>s)return!1;for(let n=r;n<e[s+i];n++){if(n>r&&e[n]<=e[n-1])return!1;t[e[n]]=1}r=e[s+i],n.push(t)}for(let t=r;t<s;t++)if(e[t]!==0)return!1;return n}},ee=ud(o===2?3:4,e=>o-e,e=>{if(!(-o<=e&&e<=o))throw Error(`malformed key s1/s3 ${e} outside of ETA range [${-o}, ${o}]`);return e}),x=ud(13,e=>(1<<ed-1)-e),te=ud(10),ne=ud(r===1<<17?18:20,e=>od(r-e)),re=Ru(ud(i===td?6:4),t),ie=Lu(32,Ru(te,t)),ae=Lu(32,32,l,Ru(ee,n),Ru(ee,t),Ru(x,t)),oe=Lu(u,Ru(ne,n),b),se=o===2?e=>e<15?2-e%5:!1:e=>e<9?4-e:!1;function ce(e){let t=id(Xu);for(let n=0;n<Xu;){let r=e();for(let e=0;n<Xu&&e<r.length;e+=1){let i=se(r[e]&15),a=se(r[e]>>4&15);i!==!1&&(t[n++]=i),n<Xu&&a!==!1&&(t[n++]=a)}}return t}let le=e=>{let t=id(Xu),n=Nu.create({}).update(e),r=new Uint8Array(Nu.blockLen);n.xofInto(r);let i=r.slice(0,8);for(let e=Xu-a,o=8,s=0,c=0;e<Xu;e++){let a=e+1;for(;a>e;)a=r[o++],!(o<Nu.blockLen)&&(n.xofInto(r),o=0);t[e]=t[a],t[a]=1-((i[s]>>c++&1)<<1),c>=8&&(s++,c=0)}return t},S=e=>{let t=id(Xu),n=id(Xu);for(let r=0;r<e.length;r++){let{r0:i,r1:a}=y(e[r]);t[r]=i,n[r]=a}return{r0:t,r1:n}},ue=(e,t)=>{for(let n=0;n<Xu;n++)e[n]=v(t[n],e[n]);return e},de=(e,t)=>{let n=id(Xu),r=0;for(let i=0;i<Xu;i++){let a=_(e[i],t[i]);n[i]=a,r+=a}return{v:n,cnt:r}},fe=Lu(32,64,32),pe={signRandBytes:32,keygen:e=>{let r=new Uint8Array(34),i=e===void 0;i&&(e=Fu(32)),Pu(e,32),r.set(e),i&&e.fill(0),r[32]=t,r[33]=n;let[a,o,s]=fe.decode(Nu(r,{dkLen:fe.bytesLen})),c=f(o),u=[];for(let e=0;e<n;e++)u.push(ce(c.get(e&255,e>>8&255)));let p=[];for(let e=n;e<n+t;e++)p.push(ce(c.get(e&255,e>>8&255)));let m=u.map(e=>sd.encode(e.slice())),h=[],g=[],_=d(a),v=id(Xu);for(let e=0;e<t;e++){v.fill(0);for(let t=0;t<n;t++)dd(v,hd(gd(_.get(t,e)),m[t]));sd.decode(v);let{r0:t,r1:r}=S(dd(v,p[e]));h.push(t),g.push(r)}let y=ie.encode([a,g]),b=Nu(y,{dkLen:l}),ee=ae.encode([a,s,b,u,p,h]);return _.clean(),c.clean(),zu(a,o,s,u,p,m,v,h,g,b,r),{publicKey:y,secretKey:ee}},sign:(e,a,o,l=!1)=>{let[m,_,v,y,b,ee]=ae.decode(e),x=[],te=d(m);for(let e=0;e<t;e++){let t=[];for(let r=0;r<n;r++)t.push(gd(te.get(r,e)));x.push(t)}te.clean();for(let e=0;e<n;e++)sd.encode(y[e]);for(let e=0;e<t;e++)sd.encode(b[e]),sd.encode(ee[e]);let ie=l?a:Nu.create({dkLen:c}).update(v).update(a).digest(),se=o||new Uint8Array(32);Pu(se);let ce=Nu.create({dkLen:c}).update(_).update(se).update(ie).digest();Pu(ce,c);let S=f(ce,ne.bytesLen);main_loop:for(let e=0;;){let a=[];for(let t=0;t<n;t++,e++)a.push(ne.decode(S.get(e&255,e>>8)()));let o=a.map(e=>sd.encode(e.slice())),c=[];for(let e=0;e<t;e++){let t=id(Xu);for(let r=0;r<n;r++)dd(t,hd(x[e][r],o[r]));sd.decode(t),c.push(t)}let l=c.map(e=>e.map(h)),d=Nu.create({dkLen:u}).update(ie).update(re.encode(l)).digest(),f=sd.encode(le(d)),m=y.map(e=>hd(e,f));for(let e=0;e<n;e++)if(dd(sd.decode(m[e]),a[e]),md(m[e],r-p))continue main_loop;let _=0,v=[];for(let e=0;e<t;e++){let t=sd.decode(hd(b[e],f)),n=fd(c[e],t).map(g);if(md(n,i-p))continue main_loop;let r=sd.decode(hd(ee[e],f));if(md(r,i))continue main_loop;dd(n,r);let a=de(n,l[e]);v.push(a.v),_+=a.cnt}if(_>s)continue;S.clean();let te=oe.encode([d,m,v]);return zu(d,m,v,f,l,c,o,a,ce,ie,y,b,ee,...x),te}throw Error(`Unreachable code path reached, report this error`)},verify:(e,i,a,o=!1)=>{let[f,m]=ie.decode(e),h=Nu(e,{dkLen:l});if(a.length!==oe.bytesLen)return!1;let[g,_,v]=oe.decode(a);if(v===!1)return!1;for(let e=0;e<n;e++)if(md(_[e],r-p))return!1;let y=o?i:Nu.create({dkLen:c}).update(h).update(i).digest(),b=sd.encode(le(g)),ee=_.map(e=>e.slice());for(let e=0;e<n;e++)sd.encode(ee[e]);let x=[],te=d(f);for(let e=0;e<t;e++){let t=hd(sd.encode(pd(m[e])),b),r=id(Xu);for(let t=0;t<n;t++)dd(r,hd(gd(te.get(t,e)),ee[t]));let i=sd.decode(fd(r,t));x.push(ue(i,v[e]))}te.clean();let ne=Nu.create({dkLen:u}).update(y).update(re.encode(x)).digest();for(let e of v)if(!(e.reduce((e,t)=>e+t,0)<=s))return!1;for(let e of _)if(md(e,r-p))return!1;return Iu(g,ne)}};return{internal:pe,keygen:pe.keygen,signRandBytes:pe.signRandBytes,sign:(e,t,n=Vu,r)=>{let i=Hu(t,n),a=pe.sign(e,i,r);return i.fill(0),a},verify:(e,t,n,r=Vu)=>pe.verify(e,Hu(t,r),n),prehash:e=>({sign:(t,n,r=Vu,i)=>{let a=Wu(e,n,r),o=pe.sign(t,a,i);return a.fill(0),o},verify:(t,n,r,i=Vu)=>pe.verify(t,Wu(e,n,i),r)})}}var vd=_d({...rd[2],CRH_BYTES:64,TR_BYTES:64,C_TILDE_BYTES:32,XOF128:Ju,XOF256:Yu}),yd=_d({...rd[3],CRH_BYTES:64,TR_BYTES:64,C_TILDE_BYTES:48,XOF128:Ju,XOF256:Yu}),bd=_d({...rd[5],CRH_BYTES:64,TR_BYTES:64,C_TILDE_BYTES:64,XOF128:Ju,XOF256:Yu}),xd={generateKeyPair:Sd,sign:Cd,verify:wd};function Sd(e){e??=Fu(32);let t=yd.keygen(e);return{publicKey:t.publicKey,privateKey:t.secretKey}}function Cd(e,t){return yd.sign(e,t)}function wd(e,t,n){return yd.verify(e,t,n)}var Td=256,Ed=3329,{mod:Dd,nttZetas:Od,NTT:kd,bitsCoder:Ad}=Ku({N:Td,Q:Ed,F:3303,ROOT_OF_UNITY:17,newPoly:e=>new Uint16Array(e),brvBits:7,isKyber:!0}),jd={512:{N:Td,Q:Ed,K:2,ETA1:3,ETA2:2,du:10,dv:4,RBGstrength:128},768:{N:Td,Q:Ed,K:3,ETA1:2,ETA2:2,du:10,dv:4,RBGstrength:192},1024:{N:Td,Q:Ed,K:4,ETA1:2,ETA2:2,du:11,dv:5,RBGstrength:256}},Md=e=>{if(e>=12)return{encode:e=>e,decode:e=>e};let t=2**(e-1);return{encode:t=>((t<<e)+Ed/2)/Ed,decode:n=>n*Ed+t>>>e}},Nd=e=>Ad(e,Md(e));function Pd(e,t){for(let n=0;n<Td;n++)e[n]=Dd(e[n]+t[n])}function Fd(e,t){for(let n=0;n<Td;n++)e[n]=Dd(e[n]-t[n])}function Id(e,t,n,r,i){return{c0:Dd(t*r*i+e*n),c1:Dd(e*r+t*n)}}function Ld(e,t){for(let n=0;n<Td/2;n++){let r=Od[64+(n>>1)];n&1&&(r=-r);let{c0:i,c1:a}=Id(e[2*n+0],e[2*n+1],t[2*n+0],t[2*n+1],r);e[2*n+0]=i,e[2*n+1]=a}return e}function Rd(e){let t=new Uint16Array(Td);for(let n=0;n<Td;){let r=e();if(r.length%3)throw Error(`SampleNTT: unaligned block`);for(let e=0;n<Td&&e+3<=r.length;e+=3){let i=(r[e+0]>>0|r[e+1]<<8)&4095,a=(r[e+1]>>4|r[e+2]<<4)&4095;i<Ed&&(t[n++]=i),n<Td&&a<Ed&&(t[n++]=a)}}return t}function zd(e,t,n,r){let i=e(r*Td/4,t,n),a=new Uint16Array(Td),o=ks(i),s=0;for(let e=0,t=0,n=0,i=0;e<o.length;e++){let c=o[e];for(let e=0;e<32;e++)n+=c&1,c>>=1,s+=1,s===r?(i=n,n=0):s===2*r&&(a[t++]=Dd(i-n),n=0,s=0)}if(s)throw Error(`sampleCBD: leftover bits: ${s}`);return a}var Bd=e=>{let{K:t,PRF:n,XOF:r,HASH512:i,ETA1:a,ETA2:o,du:s,dv:c}=e,l=Nd(1),u=Nd(c),d=Nd(s),f=Lu(Ru(Nd(12),t),32),p=Ru(Nd(12),t),m=Lu(Ru(d,t),u),h=Lu(32,32);return{secretCoder:p,secretKeyLen:p.bytesLen,publicKeyLen:f.bytesLen,cipherTextLen:m.bytesLen,keygen:e=>{Pu(e,32);let o=new Uint8Array(33);o.set(e),o[32]=t;let s=i(o),[c,l]=h.decode(s),u=[],d=[];for(let e=0;e<t;e++)u.push(kd.encode(zd(n,l,e,a)));let m=r(c);for(let e=0;e<t;e++){let r=kd.encode(zd(n,l,t+e,a));for(let n=0;n<t;n++)Pd(r,Ld(Rd(m.get(n,e)),u[n]));d.push(r)}m.clean();let g={publicKey:f.encode([d,c]),secretKey:p.encode(u)};return zu(c,l,u,d,o,s),g},encrypt:(e,i,s)=>{let[c,u]=f.decode(e),d=[];for(let e=0;e<t;e++)d.push(kd.encode(zd(n,s,e,a)));let p=r(u),h=new Uint16Array(Td),g=[];for(let e=0;e<t;e++){let r=zd(n,s,t+e,o),i=new Uint16Array(Td);for(let n=0;n<t;n++)Pd(i,Ld(Rd(p.get(e,n)),d[n]));Pd(r,kd.decode(i)),g.push(r),Pd(h,Ld(c[e],d[e])),i.fill(0)}p.clean();let _=zd(n,s,2*t,o);Pd(_,kd.decode(h));let v=l.decode(i);return Pd(v,_),zu(c,d,h,_),m.encode([g,v])},decrypt:(e,n)=>{let[r,i]=m.decode(e),a=p.decode(n),o=new Uint16Array(Td);for(let e=0;e<t;e++)Pd(o,Ld(a[e],kd.encode(r[e])));return Fd(i,kd.decode(o)),zu(o,a,r),l.encode(i)}}};function Vd(e){let t=Bd(e),{HASH256:n,HASH512:r,KDF:i}=e,{secretCoder:a,cipherTextLen:o}=t,s=t.publicKeyLen,c=Lu(t.secretKeyLen,t.publicKeyLen,32,32),l=c.bytesLen;return{publicKeyLen:s,msgLen:32,keygen:(e=Fu(64))=>{Pu(e,64);let{publicKey:r,secretKey:i}=t.keygen(e.subarray(0,32)),a=n(r),o=c.encode([i,r,a,e.subarray(32)]);return zu(i,a),{publicKey:r,secretKey:o}},encapsulate:(i,o=Fu(32))=>{Pu(i,s),Pu(o,32);let c=i.subarray(0,384*e.K),l=a.encode(a.decode(c.slice()));if(!Iu(l,c))throw zu(l),Error(`ML-KEM.encapsulate: wrong publicKey modulus`);zu(l);let u=r.create().update(o).update(n(i)).digest(),d=t.encrypt(i,o,u.subarray(32,64));return u.subarray(32).fill(0),{cipherText:d,sharedSecret:u.subarray(0,32)}},decapsulate:(e,n)=>{Pu(n,l),Pu(e,o);let[a,s,u,d]=c.decode(n),f=t.decrypt(e,a),p=r.create().update(f).update(u).digest(),m=p.subarray(0,32),h=t.encrypt(s,f,p.subarray(32,64)),g=Iu(e,h),_=i.create({dkLen:32}).update(d).update(e).digest();return zu(f,h,g?_:m),g?m:_}}}function Hd(e,t,n){return Nu.create({dkLen:e}).update(t).update(new Uint8Array([n])).digest()}var Ud={HASH256:Ou,HASH512:Au,KDF:Nu,XOF:Ju,PRF:Hd};({...Ud,...jd[512]});var Wd=Vd({...Ud,...jd[768]});({...Ud,...jd[1024]});var Gd={generateKeyPair:Kd,encapsulate:qd,decapsulate:Jd};function Kd(e){return e??=Fu(64),Wd.keygen(e)}function qd(e){return Wd.encapsulate(e)}function Jd(e,t){return Wd.decapsulate(e,t)}var Yd=Gc,Xd=class extends qs{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Es(e);let n=Us(t);if(this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`Expected instance of class which extends utils.Hash`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),As(i)}update(e){return Ds(this),this.iHash.update(e),this}digestInto(e){Ds(this),Ts(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Zd=(e,t,n)=>new Xd(e,t).update(n).digest();Zd.create=(e,t)=>new Xd(e,t);var{p:Qd,n:$d,Gx:ef,Gy:tf,b:nf}={p:115792089237316195423570985008687907853269984665640564039457584007908834671663n,n:115792089237316195423570985008687907852837564279074904382605163141518161494337n,h:1n,a:0n,b:7n,Gx:55066263022277343669578718895168534326250603453777594175500187360389116729240n,Gy:32670510020758816978083085130507043184471273380659243275938904335757337482424n},rf=32,af=64,of=(e=``)=>{throw Error(e)},sf=e=>typeof e==`bigint`,cf=e=>typeof e==`string`,lf=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`,uf=(e,t)=>!lf(e)||typeof t==`number`&&t>0&&e.length!==t?of(`Uint8Array expected`):e,df=e=>new Uint8Array(e),ff=e=>Uint8Array.from(e),pf=(e,t)=>e.toString(16).padStart(t,`0`),mf=e=>Array.from(uf(e)).map(e=>pf(e,2)).join(``),hf={_0:48,_9:57,A:65,F:70,a:97,f:102},gf=e=>{if(e>=hf._0&&e<=hf._9)return e-hf._0;if(e>=hf.A&&e<=hf.F)return e-(hf.A-10);if(e>=hf.a&&e<=hf.f)return e-(hf.a-10)},_f=e=>{let t=`hex invalid`;if(!cf(e))return of(t);let n=e.length,r=n/2;if(n%2)return of(t);let i=df(r);for(let n=0,a=0;n<r;n++,a+=2){let r=gf(e.charCodeAt(a)),o=gf(e.charCodeAt(a+1));if(r===void 0||o===void 0)return of(t);i[n]=r*16+o}return i},vf=(e,t)=>uf(cf(e)?_f(e):ff(uf(e)),t),yf=()=>globalThis?.crypto,bf=()=>yf()?.subtle??of(`crypto.subtle must be defined`),xf=(...e)=>{let t=df(e.reduce((e,t)=>e+uf(t).length,0)),n=0;return e.forEach(e=>{t.set(e,n),n+=e.length}),t},Sf=(e=rf)=>yf().getRandomValues(df(e)),Cf=BigInt,wf=(e,t,n,r=`bad number: out of range`)=>sf(e)&&t<=e&&e<n?e:of(r),j=(e,t=Qd)=>{let n=e%t;return n>=0n?n:t+n},Tf=e=>j(e,$d),Ef=(e,t)=>{(e===0n||t<=0n)&&of(`no inverse n=`+e+` mod=`+t);let n=j(e,t),r=t,i=0n,a=1n,o=1n,s=0n;for(;n!==0n;){let e=r/n,t=r%n,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}return r===1n?j(i,t):of(`no inverse`)},Df=e=>{let t=cp[e];return typeof t!=`function`&&of(`hashes.`+e+` not set`),t},Of=e=>e instanceof Lf?e:of(`Point expected`),kf=e=>j(j(e*e)*e+nf),Af=e=>wf(e,0n,Qd),jf=e=>wf(e,1n,Qd),Mf=e=>wf(e,1n,$d),Nf=e=>(e&1n)==0n,Pf=e=>Uint8Array.of(e),Ff=e=>Pf(Nf(e)?2:3),If=e=>{let t=kf(jf(e)),n=1n;for(let e=t,r=(Qd+1n)/4n;r>0n;r>>=1n)r&1n&&(n=n*e%Qd),e=e*e%Qd;return j(n*n)===t?n:of(`sqrt invalid`)},Lf=class e{static BASE;static ZERO;px;py;pz;constructor(e,t,n){this.px=Af(e),this.py=jf(t),this.pz=Af(n),Object.freeze(this)}static fromBytes(t){uf(t);let n,r=t[0],i=t.subarray(1),a=Hf(i,0,rf),o=t.length;if(o===rf+1&&[2,3].includes(r)){let t=If(a),i=Nf(t);Nf(Cf(r))!==i&&(t=j(-t)),n=new e(a,t,1n)}return o===af+1&&r===4&&(n=new e(a,Hf(i,rf,af),1n)),n?n.assertValidity():of(`bad point: not on curve`)}equals(e){let{px:t,py:n,pz:r}=this,{px:i,py:a,pz:o}=Of(e),s=j(t*o),c=j(i*r),l=j(n*o),u=j(a*r);return s===c&&l===u}is0(){return this.equals(zf)}negate(){return new e(this.px,j(-this.py),this.pz)}double(){return this.add(this)}add(t){let{px:n,py:r,pz:i}=this,{px:a,py:o,pz:s}=Of(t),c=0n,l=nf,u=0n,d=0n,f=0n,p=j(l*3n),m=j(n*a),h=j(r*o),g=j(i*s),_=j(n+r),v=j(a+o);_=j(_*v),v=j(m+h),_=j(_-v),v=j(n+i);let y=j(a+s);return v=j(v*y),y=j(m+g),v=j(v-y),y=j(r+i),u=j(o+s),y=j(y*u),u=j(h+g),y=j(y-u),f=j(c*v),u=j(p*g),f=j(u+f),u=j(h-f),f=j(h+f),d=j(u*f),h=j(m+m),h=j(h+m),g=j(c*g),v=j(p*v),h=j(h+g),g=j(m-g),g=j(c*g),v=j(v+g),m=j(h*v),d=j(d+m),m=j(y*v),u=j(_*u),u=j(u-m),m=j(_*h),f=j(y*f),f=j(f+m),new e(u,d,f)}multiply(e,t=!0){if(!t&&e===0n)return zf;if(Mf(e),e===1n)return this;if(this.equals(Rf))return gp(e).p;let n=zf,r=Rf;for(let i=this;e>0n;i=i.double(),e>>=1n)e&1n?n=n.add(i):t&&(r=r.add(i));return n}toAffine(){let{px:e,py:t,pz:n}=this;if(this.equals(zf))return{x:0n,y:0n};if(n===1n)return{x:e,y:t};let r=Ef(n,Qd);return j(n*r)!==1n&&of(`inverse invalid`),{x:j(e*r),y:j(t*r)}}assertValidity(){let{x:e,y:t}=this.toAffine();return jf(e),jf(t),j(t*t)===kf(e)?this:of(`bad point: not on curve`)}toBytes(e=!0){let{x:t,y:n}=this.assertValidity().toAffine(),r=Wf(t);return e?xf(Ff(n),r):xf(Pf(4),r,Wf(n))}static fromAffine(t){let{x:n,y:r}=t;return n===0n&&r===0n?zf:new e(n,r,1n)}toHex(e){return mf(this.toBytes(e))}static fromPrivateKey(e){return Rf.multiply(Gf(e))}static fromHex(t){return e.fromBytes(vf(t))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}toRawBytes(e){return this.toBytes(e)}},Rf=new Lf(ef,tf,1n),zf=new Lf(0n,1n,0n);Lf.BASE=Rf,Lf.ZERO=zf;var Bf=(e,t,n)=>Rf.multiply(t,!1).add(e.multiply(n,!1)).assertValidity(),Vf=e=>Cf(`0x`+(mf(e)||`0`)),Hf=(e,t,n)=>Vf(e.subarray(t,n)),Uf=2n**256n,Wf=e=>_f(pf(wf(e,0n,Uf),af)),Gf=e=>wf(sf(e)?e:Vf(vf(e,rf)),1n,$d,`private key invalid 3`),Kf=e=>e>$d>>1n,qf=(e,t=!0)=>Rf.multiply(Gf(e)).toBytes(t),Jf=class e{r;s;recovery;constructor(e,t,n){this.r=Mf(e),this.s=Mf(t),n!=null&&(this.recovery=n),Object.freeze(this)}static fromBytes(t){return uf(t,af),new e(Hf(t,0,rf),Hf(t,rf,af))}toBytes(){let{r:e,s:t}=this;return xf(Wf(e),Wf(t))}addRecoveryBit(t){return new e(this.r,this.s,t)}hasHighS(){return Kf(this.s)}toCompactRawBytes(){return this.toBytes()}toCompactHex(){return mf(this.toBytes())}recoverPublicKey(e){return ip(this,e)}static fromCompact(t){return e.fromBytes(vf(t,af))}assertValidity(){return this}normalizeS(){let{r:t,s:n,recovery:r}=this;return Kf(n)?new e(t,Tf(-n),r):this}},Yf=e=>{let t=e.length*8-256;t>1024&&of(`msg invalid`);let n=Vf(e);return t>0?n>>Cf(t):n},Xf=e=>Tf(Yf(uf(e))),Zf={lowS:!0},Qf={lowS:!0},$f=(e,t,n=Zf)=>{[`der`,`recovered`,`canonical`].some(e=>e in n)&&of(`option not supported`);let{lowS:r,extraEntropy:i}=n;r??=!0;let a=Wf,o=Xf(vf(e)),s=a(o),c=Gf(t),l=[a(c),s];i&&l.push(i===!0?Sf(rf):vf(i));let u=o,d=e=>{let t=Yf(e);if(!(1n<=t&&t<$d))return;let n=Rf.multiply(t).toAffine(),i=Tf(n.x);if(i===0n)return;let a=Tf(Ef(t,$d)*Tf(u+Tf(c*i)));if(a===0n)return;let o=a,s=(n.x===i?0:2)|Number(n.y&1n);return r&&Kf(a)&&(o=Tf(-a),s^=1),new Jf(i,o,s)};return{seed:xf(...l),k2sig:d}},ep=e=>{let t=df(rf),n=df(rf),r=0,i=df(0),a=()=>{t.fill(1),n.fill(0),r=0},o=1e3,s=`drbg: tried 1000 values`;if(e){let e=(...e)=>cp.hmacSha256Async(n,t,...e),c=async(r=i)=>{n=await e(Pf(0),r),t=await e(),r.length!==0&&(n=await e(Pf(1),r),t=await e())},l=async()=>(r++>=o&&of(s),t=await e(),t);return async(e,t)=>{a(),await c(e);let n;for(;!(n=t(await l()));)await c();return a(),n}}else{let e=(...e)=>Df(`hmacSha256Sync`)(n,t,...e),c=(r=i)=>{n=e(Pf(0),r),t=e(),r.length!==0&&(n=e(Pf(1),r),t=e())},l=()=>(r++>=o&&of(s),t=e(),t);return(e,t)=>{a(),c(e);let n;for(;!(n=t(l()));)c();return a(),n}}},tp=async(e,t,n=Zf)=>{let{seed:r,k2sig:i}=$f(e,t,n);return await ep(!0)(r,i)},np=(e,t,n=Zf)=>{let{seed:r,k2sig:i}=$f(e,t,n);return ep(!1)(r,i)},rp=(e,t,n,r=Qf)=>{let{lowS:i}=r;i??=!0,`strict`in r&&of(`option not supported`);let a,o=e&&typeof e==`object`&&`r`in e;!o&&vf(e).length!==af&&of(`signature must be 64 bytes`);try{a=o?new Jf(e.r,e.s):Jf.fromCompact(e);let r=Xf(vf(t)),s=Lf.fromBytes(vf(n)),{r:c,s:l}=a;if(i&&Kf(l))return!1;let u=Ef(l,$d);return Tf(Bf(s,Tf(r*u),Tf(c*u)).toAffine().x)===c}catch{return!1}},ip=(e,t)=>{let{r:n,s:r,recovery:i}=e;[0,1,2,3].includes(i)||of(`recovery id invalid`);let a=Xf(vf(t,rf)),o=i===2||i===3?n+$d:n;jf(o);let s=xf(Ff(Cf(i)),Wf(o)),c=Lf.fromBytes(s),l=Ef(o,$d);return Bf(c,Tf(-a*l),Tf(r*l))},ap=e=>(e=vf(e),(e.length<rf+8||e.length>1024)&&of(`expected 40-1024b`),Wf(j(Vf(e),$d-1n)+1n)),op=()=>ap(Sf(rf+16)),sp=`SHA-256`,cp={hexToBytes:_f,bytesToHex:mf,concatBytes:xf,bytesToNumberBE:Vf,numberToBytesBE:Wf,mod:j,invert:Ef,hmacSha256Async:async(e,...t)=>{let n=bf(),r=`HMAC`,i=await n.importKey(`raw`,e,{name:r,hash:{name:sp}},!1,[`sign`]);return df(await n.sign(r,i,xf(...t)))},hmacSha256Sync:void 0,hashToPrivateKey:ap,randomBytes:Sf},lp={normPrivateKeyToScalar:Gf,isValidPrivateKey:e=>{try{return!!Gf(e)}catch{return!1}},randomPrivateKey:op,precompute:(e=8,t=Rf)=>(t.multiply(3n),t)},up=8,dp=Math.ceil(256/up)+1,fp=2**(up-1),pp=()=>{let e=[],t=Rf,n=t;for(let r=0;r<dp;r++){n=t,e.push(n);for(let r=1;r<fp;r++)n=n.add(t),e.push(n);t=n.double()}return e},mp=void 0,hp=(e,t)=>{let n=t.negate();return e?n:t},gp=e=>{let t=mp||=pp(),n=zf,r=Rf,i=2**up,a=i,o=Cf(i-1),s=Cf(up);for(let i=0;i<dp;i++){let c=Number(e&o);e>>=s,c>fp&&(c-=a,e+=1n);let l=i*fp,u=l,d=l+Math.abs(c)-1,f=i%2!=0,p=c<0;c===0?r=r.add(hp(f,t[u])):n=n.add(hp(p,t[d]))}return{p:n,f:r}};cp.hmacSha256Sync=(e,...t)=>Zd(Yd,e,cp.concatBytes(...t));var _p={publicKeyFromPrivateKey:vp,sign:yp,verify:bp};function vp(e){return qf(e)}function yp(e,t){return np(Yd(t),e).toCompactRawBytes()}function bp(e,t,n){return rp(n,Yd(t),e)}var xp={SECP256K1:0,ML_DSA:1},Sp=[{name:`SECP256K1`,signatureSectionSize:65},{name:`ML_DSA`,signatureSectionSize:3311}],Cp={ML_KEM:0},wp=[{name:`ML-KEM`}],Tp={...xp,SIG_SCHEMES:Sp,...Cp,KEM_SCHEMES:wp,Random:Zs,Hashes:Qc,Aes:su,MLDsa:xd,MLKem:Gd,Secp256k1:_p},Ep;function Dp(e){return{lang:e?.lang??Ep?.lang,message:e?.message,abortEarly:e?.abortEarly??Ep?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Ep?.abortPipeEarly}}var Op;function kp(e){return Op?.get(e)}var Ap;function jp(e){return Ap?.get(e)}var Mp;function Np(e,t){return Mp?.get(e)?.get(t)}function Pp(e){let t=typeof e;return t===`string`?`"${e}"`:t===`number`||t===`bigint`||t===`boolean`?`${e}`:t===`object`||t===`function`?(e&&Object.getPrototypeOf(e)?.constructor?.name)??`null`:t}function Fp(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??Pp(a),c={kind:e.kind,type:e.type,input:a,expected:o,received:s,message:`Invalid ${t}: ${o?`Expected ${o} but r`:`R`}eceived ${s}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=e.kind===`schema`,u=i?.message??e.message??Np(e.reference,c.lang)??(l?jp(c.lang):null)??r.message??kp(c.lang);u!==void 0&&(c.message=typeof u==`function`?u(c):u),l&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}function Ip(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},Dp())}}}function Lp(e,t){return Object.hasOwn(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function Rp(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}var zp=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}};function Bp(e){return{kind:`validation`,type:`integer`,reference:Bp,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&Fp(this,`integer`,e,t),e}}}function Vp(e,t){return{kind:`validation`,type:`max_length`,reference:Vp,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length>this.requirement&&Fp(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function Hp(e,t){return{kind:`validation`,type:`max_value`,reference:Hp,async:!1,expects:`<=${e instanceof Date?e.toJSON():Pp(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value<=this.requirement)&&Fp(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():Pp(e.value)}),e}}}function Up(e){return{kind:`metadata`,type:`metadata`,reference:Up,metadata:e}}function Wp(e,t){return{kind:`validation`,type:`min_value`,reference:Wp,async:!1,expects:`>=${e instanceof Date?e.toJSON():Pp(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value>=this.requirement)&&Fp(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():Pp(e.value)}),e}}}function Gp(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function Kp(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function qp(e,t){return!e[`~run`]({value:t},{abortEarly:!0}).issues}function Jp(){return{kind:`schema`,type:`any`,reference:Jp,expects:`any`,async:!1,get"~standard"(){return Ip(this)},"~run"(e){return e.typed=!0,e}}}function M(e,t){return{kind:`schema`,type:`array`,reference:M,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return Ip(this)},"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){let i=n[r],a=this.item[`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else Fp(this,`type`,e,t);return e}}}function Yp(e){return{kind:`schema`,type:`boolean`,reference:Yp,expects:`boolean`,async:!1,message:e,get"~standard"(){return Ip(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:Fp(this,`type`,e,t),e}}}function Xp(e,t){return{kind:`schema`,type:`custom`,reference:Xp,expects:`unknown`,async:!1,check:e,message:t,get"~standard"(){return Ip(this)},"~run"(e,t){return this.check(e.value)?e.typed=!0:Fp(this,`type`,e,t),e}}}function Zp(e,t){let n=[];for(let t in e)(`${+t}`!==t||typeof e[t]!=`string`||!Object.is(e[e[t]],+t))&&n.push(e[t]);return{kind:`schema`,type:`enum`,reference:Zp,expects:Rp(n.map(Pp),`|`),async:!1,enum:e,options:n,message:t,get"~standard"(){return Ip(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:Fp(this,`type`,e,t),e}}}function Qp(e,t){return{kind:`schema`,type:`instance`,reference:Qp,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return Ip(this)},"~run"(e,t){return e.value instanceof this.class?e.typed=!0:Fp(this,`type`,e,t),e}}}function $p(e,t){if(typeof e==typeof t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{value:e};if(e&&t&&e.constructor===Object&&t.constructor===Object){for(let n in t)if(n in e){let r=$p(e[n],t[n]);if(r.issue)return r;e[n]=r.value}else e[n]=t[n];return{value:e}}if(Array.isArray(e)&&Array.isArray(t)&&e.length===t.length){for(let n=0;n<e.length;n++){let r=$p(e[n],t[n]);if(r.issue)return r;e[n]=r.value}return{value:e}}}return{issue:!0}}function em(e,t){return{kind:`schema`,type:`intersect`,reference:em,expects:Rp(e.map(e=>e.expects),`&`),async:!1,options:e,message:t,get"~standard"(){return Ip(this)},"~run"(e,t){if(this.options.length){let n=e.value,r;e.typed=!0;for(let i of this.options){let a=i[`~run`]({value:n},t);if(a.issues&&(e.issues?e.issues.push(...a.issues):e.issues=a.issues,t.abortEarly)){e.typed=!1;break}a.typed||(e.typed=!1),e.typed&&(r?r.push(a.value):r=[a.value])}if(e.typed){e.value=r[0];for(let n=1;n<r.length;n++){let i=$p(e.value,r[n]);if(i.issue){Fp(this,`type`,e,t,{received:`unknown`});break}e.value=i.value}}}else Fp(this,`type`,e,t);return e}}}function tm(e){return{kind:`schema`,type:`lazy`,reference:tm,expects:`unknown`,async:!1,getter:e,get"~standard"(){return Ip(this)},"~run"(e,t){return this.getter(e.value)[`~run`](e,t)}}}function N(e,t){return{kind:`schema`,type:`literal`,reference:N,expects:Pp(e),async:!1,literal:e,message:t,get"~standard"(){return Ip(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:Fp(this,`type`,e,t),e}}}function nm(e,t){return{kind:`schema`,type:`loose_object`,reference:nm,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return Ip(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:Kp(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=Gp(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(Fp(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}if(!e.issues||!t.abortEarly)for(let t in n)Lp(n,t)&&!(t in this.entries)&&(e.value[t]=n[t])}else Fp(this,`type`,e,t);return e}}}function rm(e){return{kind:`schema`,type:`null`,reference:rm,expects:`null`,async:!1,message:e,get"~standard"(){return Ip(this)},"~run"(e,t){return e.value===null?e.typed=!0:Fp(this,`type`,e,t),e}}}function im(e,t){return{kind:`schema`,type:`nullish`,reference:im,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return Ip(this)},"~run"(e,t){return(e.value===null||e.value===void 0)&&(this.default!==void 0&&(e.value=Kp(this,e,t)),e.value===null||e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function P(e){return{kind:`schema`,type:`number`,reference:P,expects:`number`,async:!1,message:e,get"~standard"(){return Ip(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:Fp(this,`type`,e,t),e}}}function F(e,t){return{kind:`schema`,type:`object`,reference:F,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return Ip(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:Kp(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=Gp(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(Fp(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}}else Fp(this,`type`,e,t);return e}}}function am(e,t,n){return{kind:`schema`,type:`object_with_rest`,reference:am,expects:`Object`,async:!1,entries:e,rest:t,message:n,get"~standard"(){return Ip(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:Kp(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=Gp(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(Fp(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}if(!e.issues||!t.abortEarly){for(let r in n)if(Lp(n,r)&&!(r in this.entries)){let i=this.rest[`~run`]({value:n[r]},t);if(i.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:n[r]};for(let t of i.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=i.issues,t.abortEarly){e.typed=!1;break}}i.typed||(e.typed=!1),e.value[r]=i.value}}}else Fp(this,`type`,e,t);return e}}}function I(e,t){return{kind:`schema`,type:`optional`,reference:I,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return Ip(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=Kp(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function om(e,t){return{kind:`schema`,type:`picklist`,reference:om,expects:Rp(e.map(Pp),`|`),async:!1,options:e,message:t,get"~standard"(){return Ip(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:Fp(this,`type`,e,t),e}}}function sm(e,t,n){return{kind:`schema`,type:`record`,reference:sm,expects:`Object`,async:!1,key:e,value:t,message:n,get"~standard"(){return Ip(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in n)if(Lp(n,r)){let i=n[r],a=this.key[`~run`]({value:r},t);if(a.issues){let o={type:`object`,origin:`key`,input:n,key:r,value:i};for(let t of a.issues)t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}let o=this.value[`~run`]({value:i},t);if(o.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:i};for(let t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}(!a.typed||!o.typed)&&(e.typed=!1),a.typed&&(e.value[a.value]=o.value)}}else Fp(this,`type`,e,t);return e}}}function L(e){return{kind:`schema`,type:`string`,reference:L,expects:`string`,async:!1,message:e,get"~standard"(){return Ip(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:Fp(this,`type`,e,t),e}}}function cm(e){let t;if(e)for(let n of e)t?t.push(...n.issues):t=n.issues;return t}function lm(e,t){return{kind:`schema`,type:`union`,reference:lm,expects:Rp(e.map(e=>e.expects),`|`),async:!1,options:e,message:t,get"~standard"(){return Ip(this)},"~run"(e,t){let n,r,i;for(let a of this.options){let o=a[`~run`]({value:e.value},t);if(o.typed)if(o.issues)r?r.push(o):r=[o];else{n=o;break}else i?i.push(o):i=[o]}if(n)return n;if(r){if(r.length===1)return r[0];Fp(this,`type`,e,t,{issues:cm(r)}),e.typed=!0}else if(i?.length===1)return i[0];else Fp(this,`type`,e,t,{issues:cm(i)});return e}}}function um(){return{kind:`schema`,type:`unknown`,reference:um,expects:`unknown`,async:!1,get"~standard"(){return Ip(this)},"~run"(e){return e.typed=!0,e}}}function dm(e,t,n){return{kind:`schema`,type:`variant`,reference:dm,expects:`Object`,async:!1,key:e,options:t,message:n,get"~standard"(){return Ip(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){let r,i=0,a=this.key,o=[],s=(e,c)=>{for(let l of e.options){if(l.type===`variant`)s(l,new Set(c).add(l.key));else{let e=!0,s=0;for(let t of c){let r=l.entries[t];if(t in n?r[`~run`]({typed:!1,value:n[t]},{abortEarly:!0}).issues:r.type!==`exact_optional`&&r.type!==`optional`&&r.type!==`nullish`){e=!1,a!==t&&(i<s||i===s&&t in n&&!(a in n))&&(i=s,a=t,o=[]),a===t&&o.push(l.entries[t].expects);break}s++}if(e){let e=l[`~run`]({value:n},t);(!r||!r.typed&&e.typed)&&(r=e)}}if(r&&!r.issues)break}};if(s(this,new Set([this.key])),r)return r;Fp(this,`type`,e,t,{input:n[a],expected:Rp(o,`|`),path:[{type:`object`,origin:`value`,input:n,key:a,value:n[a]}]})}else Fp(this,`type`,e,t);return e}}}function R(e,t,n){let r=e[`~run`]({value:t},Dp(n));if(r.issues)throw new zp(r.issues);return r.value}function z(...e){return{...e[0],pipe:e,get"~standard"(){return Ip(this)},"~run"(t,n){for(let r of e)if(r.kind!==`metadata`){if(t.issues&&(r.kind===`schema`||r.kind===`transformation`)){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r[`~run`](t,n))}return t}}}function fm(e,t,n){let r=e[`~run`]({value:t},Dp(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var pm=0,mm=1,hm=2,gm=3,_m=4,vm=5,ym=6,bm=7,xm=8,Sm=9,Cm=10,wm=11,Tm=12,Em=13;function Dm(e){return z(M(e.items),Up({typeId:0,elementSchema:e.items,...e}))}function Om(e={}){let t=e&&e.size||-1;return z(L(),Xp(e=>typeof e==`string`&&(t===-1||e.length===t),`Expected size is ${t} bytes`),Up({typeId:2,size:t,...e}))}function km(e={}){return z(P(),Up({typeId:3,...e}))}function Am(e={}){return z(Yp(),Up({typeId:4,...e}))}function jm(e,t,n){return z(P(),Bp(),Wp(0),Hp(2**t-1),Up({typeId:e,...n}))}function Mm(e={}){return jm(6,8,e)}function Nm(e={}){return jm(7,16,e)}function Pm(e={}){return jm(8,24,e)}function Fm(e={}){return jm(9,32,e)}function Im(e={}){return jm(10,48,e)}function Lm(e={}){let t=e&&e.size||-1;return z(Qp(Uint8Array),Xp(e=>e instanceof Uint8Array&&(t===-1||e.length===t),`Expected size is ${t} bytes`),Up({typeId:11,...e}))}function Rm(e={}){return z(Qp(Uint8Array),Xp(e=>e instanceof Uint8Array&&e.length===32,`Expected Uint8Array of 32 bytes`),Up({typeId:12,...e}))}function B(){return Qp(Uint8Array)}function zm(){return B()}function Bm(){return V()}function V(){return z(P(),Bp(),Wp(0))}function Vm(){return z(P(),Bp(),Wp(1))}function Hm(){return z(P(),Bp(),Wp(0))}var Um=F({magicString:N(Un),microblockType:V(),height:V(),previousHash:B(),timestamp:V(),gas:V(),gasPrice:V(),bodyHash:B(),feesPayerAccount:B()}),Wm=F({retentionRatio:P(),maximumNumberOfDays:P(),dayDivisor:P()}),Gm=M(Wm),Km=F({numberOfDays:P(),retentionRatio:P(),costInGasAtoms:P()}),qm=F({protocolVersionName:L(),protocolVersion:Vm(),feesCalculationVersion:Vm(),fixedGasCost:V(),secp256k1SignatureGasCost:V(),mlDsa65SignatureGasCost:V(),pkmsSecp256k1SignatureGasCost:V(),globalStateUpdaterVersion:Vm(),applicationLedgerInternalStateUpdaterVersion:Vm(),applicationInternalStateUpdaterVersion:Vm(),organizationInternalStateUpdaterVersion:Vm(),validatorNodeInternalStateUpdaterVersion:Vm(),accountInternalStateUpdaterVersion:Vm(),protocolInternalStateUpdaterVersion:Vm(),minimumNodeStakingAmountInAtomics:Vm(),maximumNodeStakingAmountInAtomics:Vm(),unstakingDelayInDays:V(),maxBlockSizeInBytes:Vm(),retentionPolicy:Gm,abciVersion:Vm(),maxMicroblocksPerBlock:Vm()}),Jm=F({protocolVersion:P(),protocolVersionName:L(),changeLog:L(),protocolVariables:qm}),Ym=am({type:N(O.CUSTOM)},um()),Xm=F({type:N(O.SIGNATURE),signature:B(),schemeId:Mm()}),Zm=F({type:N(O.AUXILIARY_SIGNATURE),tag:Om(),signature:B(),schemeId:Mm()}),Qm=F({type:N(O.ALLOWED_ADDITIONAL_WRITER),allowedWriterAccountId:B()}),$m=F({type:N(O.PROTOCOL_CREATION),organizationId:zm()}),eh=F({type:N(O.PROTOCOL_UPDATE),...Jm.entries}),th=F({type:N(O.PROTOCOL_VARIABLES),protocolVariables:Jp()}),nh=F({type:N(O.ACCOUNT_PUBLIC_KEY),publicKey:B(),schemeId:Mm()}),rh=F({type:N(O.ACCOUNT_TOKEN_ISSUANCE),amount:V()}),ih=F({type:N(O.ACCOUNT_CREATION),sellerAccount:zm(),amount:V()}),ah=F({type:N(O.ACCOUNT_TRANSFER),account:zm(),amount:V(),publicReference:Om(),privateReference:Om()}),oh=F({type:N(O.ACCOUNT_VESTING_TRANSFER),account:zm(),amount:V(),publicReference:Om(),privateReference:Om(),cliffDurationDays:V(),vestingDurationDays:V()}),sh=F({type:N(O.ACCOUNT_ESCROW_TRANSFER),account:zm(),amount:V(),publicReference:Om(),privateReference:Om(),escrowIdentifier:zm(),agentAccount:zm(),durationDays:V()}),ch=F({type:N(O.ACCOUNT_ESCROW_SETTLEMENT),escrowIdentifier:zm(),confirmed:Am()}),lh=F({type:N(O.ACCOUNT_STAKE),amount:V(),objectType:V(),objectIdentifier:zm()}),uh=F({type:N(O.ACCOUNT_UNSTAKE),amount:V(),objectType:V(),objectIdentifier:zm()}),dh=F({type:N(O.VN_CREATION),organizationId:zm()}),fh=F({type:N(O.VN_COMETBFT_PUBLIC_KEY_DECLARATION),cometPublicKeyType:Om(),cometPublicKey:Om()}),ph=F({type:N(O.VN_RPC_ENDPOINT),rpcEndpoint:Om()}),mh=F({type:N(O.VN_APPROVAL),status:Am()}),hh=F({type:N(O.VN_SLASHING_CANCELLATION),reason:Om()}),gh=F({type:N(O.ORG_CREATION),accountId:zm()}),_h=F({type:N(O.ORG_DESCRIPTION),name:Om(),city:Om(),countryCode:Om(),website:Om(),misc:I(sm(L(),L()))}),vh=F({type:N(O.APP_CREATION),organizationId:zm()}),yh=F({type:N(O.APP_DESCRIPTION),name:Om(),logoUrl:Om(),homepageUrl:Om(),description:Om(),misc:I(sm(L(),L()))}),bh=F({type:N(O.APP_LEDGER_ALLOWED_SIG_SCHEMES),schemeIds:M(Mm())}),xh=F({type:N(O.APP_LEDGER_ALLOWED_PKE_SCHEMES),schemeIds:M(Mm())}),Sh=F({type:N(O.APP_LEDGER_CREATION),applicationId:zm()}),Ch=F({type:N(O.APP_LEDGER_ACTOR_CREATION),id:V(),actorType:V(),name:Om()}),wh=F({type:N(O.APP_LEDGER_CHANNEL_CREATION),id:V(),isPrivate:Am(),creatorId:V(),name:Om()}),Th=F({type:N(O.APP_LEDGER_SHARED_SECRET),hostId:V(),guestId:V(),encryptedSharedKey:B()}),Eh=F({type:N(O.APP_LEDGER_CHANNEL_INVITATION),channelId:V(),hostId:V(),guestId:V(),encryptedChannelKey:B()}),Dh=F({type:N(O.APP_LEDGER_ACTOR_SUBSCRIPTION),actorId:V(),actorType:V(),organizationId:zm(),signatureSchemeId:Mm(),signaturePublicKey:B(),pkeSchemeId:Mm(),pkePublicKey:B()}),Oh=F({type:N(O.APP_LEDGER_PUBLIC_CHANNEL_DATA),channelId:V(),data:B()}),kh=F({type:N(O.APP_LEDGER_PRIVATE_CHANNEL_DATA),channelId:V(),merkleRootHash:zm(),encryptedData:B()}),Ah=F({type:N(O.APP_LEDGER_AUTHOR),authorId:V()}),jh=F({type:N(O.APP_LEDGER_ENDORSEMENT_REQUEST),endorserId:V(),message:Om()}),Mh=dm(`type`,[Zm,Xm,Qm,Ym,$m,eh,th,nh,rh,ih,ah,oh,sh,ch,lh,uh,dh,fh,ph,mh,hh,gh,_h,vh,yh,bh,xh,Sh,Ch,wh,Th,Eh,Dh,Oh,kh,Ah,jh]),Nh=F({sections:M(Mh)}),H=function(e){return e[e.ACCOUNT_VIRTUAL_BLOCKCHAIN=1]=`ACCOUNT_VIRTUAL_BLOCKCHAIN`,e[e.NODE_VIRTUAL_BLOCKCHAIN=2]=`NODE_VIRTUAL_BLOCKCHAIN`,e[e.APPLICATION_VIRTUAL_BLOCKCHAIN=4]=`APPLICATION_VIRTUAL_BLOCKCHAIN`,e[e.ORGANIZATION_VIRTUAL_BLOCKCHAIN=3]=`ORGANIZATION_VIRTUAL_BLOCKCHAIN`,e[e.APP_LEDGER_VIRTUAL_BLOCKCHAIN=5]=`APP_LEDGER_VIRTUAL_BLOCKCHAIN`,e[e.PROTOCOL_VIRTUAL_BLOCKCHAIN=0]=`PROTOCOL_VIRTUAL_BLOCKCHAIN`,e}({}),Ph=F({organizationId:zm(),currentProtocolVariables:qm,protocolUpdates:M(Jm)}),Fh=F({signatureSchemeId:km(),publicKeyHeight:Bm()}),Ih=F({accountId:zm(),descriptionHeight:Bm()}),Lh=F({organizationId:zm(),cometbftPublicKeyDeclarationHeight:Bm(),rpcEndpointHeight:Bm(),lastKnownApprovalStatus:Am()}),Rh=F({organizationId:zm(),descriptionHeight:Bm()}),zh=F({name:Om(),isPrivate:Am(),creatorId:km()}),Bh=F({channelId:km(),height:Bm()}),Vh=F({peerActorId:km(),height:Bm()}),Hh=F({name:Om(),subscribed:Am(),signatureKeyHeight:km(),pkeKeyHeight:km(),sharedSecrets:M(Vh),invitations:M(Bh)}),Uh=F({allowedAdditionalWriters:M(zm()),allowedSignatureSchemeIds:M(km()),allowedPkeSchemeIds:M(km()),applicationId:zm(),channels:M(zh),actors:M(Hh)}),Wh=F({height:km(),expirationDay:km(),lastMicroblockHash:B(),merkleRootHash:B()}),Gh=F({type:N(H.ACCOUNT_VIRTUAL_BLOCKCHAIN),...Wh.entries,internalState:Fh}),Kh=F({type:N(H.ORGANIZATION_VIRTUAL_BLOCKCHAIN),...Wh.entries,internalState:Ih}),qh=F({type:N(H.NODE_VIRTUAL_BLOCKCHAIN),...Wh.entries,internalState:Lh}),Jh=F({type:N(H.APPLICATION_VIRTUAL_BLOCKCHAIN),...Wh.entries,internalState:Rh}),Yh=F({type:N(H.APP_LEDGER_VIRTUAL_BLOCKCHAIN),...Wh.entries,internalState:Uh}),Xh=F({type:N(H.PROTOCOL_VIRTUAL_BLOCKCHAIN),...Wh.entries,internalState:Ph}),Zh=dm(`type`,[Gh,Kh,qh,Jh,Yh,Xh]),Qh=F({virtualBlockchainType:P(),virtualBlockchainId:zm()}),$h=F({virtualBlockchainId:B(),virtualBlockchainType:P(),header:Um}),eg=function(e){return e[e.BLOCK=0]=`BLOCK`,e[e.MICROBLOCK=1]=`MICROBLOCK`,e[e.SECTION=2]=`SECTION`,e}({}),tg=F({type:N(eg.BLOCK),height:P()}),ng=F({type:N(eg.MICROBLOCK),microblockHash:Rm()}),rg=F({type:N(eg.SECTION),microblockHash:Rm(),sectionIndex:P()}),ig=dm(`type`,[tg,ng,rg]),ag=3,og=function(e){return e[e.Escrow=0]=`Escrow`,e[e.Vesting=1]=`Vesting`,e[e.NodeStaking=2]=`NodeStaking`,e}({}),sg=F({escrowIdentifier:B(),fundEmitterAccountId:B(),transferAuthorizerAccountId:B(),startTimestamp:P(),durationDays:P()}),cg=F({type:N(og.Escrow),lockedAmountInAtomics:P(),parameters:sg}),lg=F({initialVestedAmountInAtomics:P(),cliffStartTimestamp:P(),cliffDurationDays:P(),vestingDurationDays:P()}),ug=F({type:N(og.Vesting),lockedAmountInAtomics:P(),parameters:lg}),dg=F({validatorNodeId:B(),plannedUnlockAmountInAtomics:P(),plannedUnlockTimestamp:P(),slashed:Yp(),plannedSlashingAmountInAtomics:P(),plannedSlashingTimestamp:P()}),fg=F({type:N(og.NodeStaking),lockedAmountInAtomics:P(),parameters:dg}),pg=dm(`type`,[cg,ug,fg]),mg=F({balance:P(),escrowed:P(),vested:P(),releasable:P(),staked:P(),stakeable:P(),locked:P(),spendable:P()}),hg=F({height:P(),balance:P(),lastHistoryHash:B(),locks:M(pg)}),gg=F({type:P(),exists:Yp(),state:hg}),_g=F({height:z(P(),Bp(),Wp(0)),previousHistoryHash:Rm(),type:z(P(),Bp(),Wp(0),Hp(255)),publicReference:L(),privateReference:L(),timestamp:z(P(),Bp(),Wp(0)),linkedAccount:Rm(),amount:z(P(),Bp(),Wp(0)),chainReference:ig}),vg=M(_g),yg=F({accountHash:B(),lastKnownHistoryHash:B(),firstHistoryHash:I(B())}),bg=F({accountHash:B(),currentState:hg,historyUpdate:vg}),xg=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`,Sg=xg+`+/=`,Cg={BASE64:Sg,URL:xg+`-_=`,encodeString:wg,decodeString:Tg,encodeBinary:Eg,decodeBinary:Dg};function wg(e,t=Sg,n=!1){return Eg(Za.encode(e),t,n)}function Tg(e,t=Sg){return Za.decode(Dg(e,t))}function Eg(e,t=Sg,n=!1){let r=e.length%3,i=0,a=``;for(let n=0;n<e.length||n%3;)if(i=i<<8|e[n++],!(n%3)){for(let e=4;e--;)a+=t[i>>e*6&63];i=0}return r?a.slice(0,r-3)+t[64].repeat(n?3-r:0):a}function Dg(e,t=Sg){let n=0,r=0,i=[];e+=t[64].repeat(-e.length&3);for(let a=0;a<e.length;){let o=t.indexOf(e[a++]);o==64&&n++,r=r<<6|o,a&3||i.push(r>>16&255,r>>8&255,r&255)}return new Uint8Array(n?i.slice(0,-n):i)}var Og=class{static defaultBytesToStringEncoder(){return new Ag}static bytesToBase64Encoder(){return new kg}static bytesToHexEncoder(){return new Ag}},kg=class{static decode(e){return Cg.decodeBinary(e,Cg.BASE64)}static encode(e){return Cg.encodeBinary(e,Cg.BASE64,!0)}decode(e){return Cg.decodeBinary(e,Cg.BASE64)}encode(e){return Cg.encodeBinary(e,Cg.BASE64,!0)}},Ag=class{decode(e){return vl(e)}encode(e){if(!(e instanceof Uint8Array))throw TypeError(`Encoding data must be a Uint8Array, got ${typeof e}`);return hl(e)}},jg=class{keys;value;constructor(e,t){this.keys=e,this.value=t}matchesKeys(...e){return e.length===this.keys.length?e.every((e,t)=>e===this.keys[t]):!1}getKeys(){return[...this.keys]}getValue(){return this.value}},Mg=class{static encode(...e){if(e.length<2)throw Error(`At least one key and one value must be provided`);let t=e.slice(0,-1),n=e[e.length-1];return`${t.join(`:`)}${n?`{${n}}`:`{}`}`}static decode(e){let t=e.match(/^(.*?)(?:\{(.*)\})?$/);if(!t)throw Error(`Invalid encoded string format`);let n=t[1],r=t[2]||``;return new jg(n?n.split(`:`):[],r)}},Ng={},Pg={};Pg.byteLength=Hg,Pg.toByteArray=Wg,Pg.fromByteArray=qg;for(var Fg=[],Ig=[],Lg=typeof Uint8Array<`u`?Uint8Array:Array,Rg=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,zg=0,Bg=Rg.length;zg<Bg;++zg)Fg[zg]=Rg[zg],Ig[Rg.charCodeAt(zg)]=zg;Ig[45]=62,Ig[95]=63;function Vg(e){var t=e.length;if(t%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var n=e.indexOf(`=`);n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function Hg(e){var t=Vg(e),n=t[0],r=t[1];return(n+r)*3/4-r}function Ug(e,t,n){return(t+n)*3/4-n}function Wg(e){var t,n=Vg(e),r=n[0],i=n[1],a=new Lg(Ug(e,r,i)),o=0,s=i>0?r-4:r,c;for(c=0;c<s;c+=4)t=Ig[e.charCodeAt(c)]<<18|Ig[e.charCodeAt(c+1)]<<12|Ig[e.charCodeAt(c+2)]<<6|Ig[e.charCodeAt(c+3)],a[o++]=t>>16&255,a[o++]=t>>8&255,a[o++]=t&255;return i===2&&(t=Ig[e.charCodeAt(c)]<<2|Ig[e.charCodeAt(c+1)]>>4,a[o++]=t&255),i===1&&(t=Ig[e.charCodeAt(c)]<<10|Ig[e.charCodeAt(c+1)]<<4|Ig[e.charCodeAt(c+2)]>>2,a[o++]=t>>8&255,a[o++]=t&255),a}function Gg(e){return Fg[e>>18&63]+Fg[e>>12&63]+Fg[e>>6&63]+Fg[e&63]}function Kg(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(Gg(r));return i.join(``)}function qg(e){for(var t,n=e.length,r=n%3,i=[],a=16383,o=0,s=n-r;o<s;o+=a)i.push(Kg(e,o,o+a>s?s:o+a));return r===1?(t=e[n-1],i.push(Fg[t>>2]+Fg[t<<4&63]+`==`)):r===2&&(t=(e[n-2]<<8)+e[n-1],i.push(Fg[t>>10]+Fg[t>>4&63]+Fg[t<<2&63]+`=`)),i.join(``)}var Jg={};Jg.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else if(a===c)return o?NaN:(p?-1:1)*(1/0);else o+=2**r,a-=l;return(p?-1:1)*o*2**(a-r)},Jg.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=+(t<0||t===0&&1/t<0);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128},(function(e){let t=Pg,n=Jg,r=typeof Symbol==`function`&&typeof Symbol.for==`function`?Symbol.for(`nodejs.util.inspect.custom`):null;e.Buffer=u,e.SlowBuffer=ee,e.INSPECT_MAX_BYTES=50;let i=2147483647;e.kMaxLength=i;let{Uint8Array:a,ArrayBuffer:o,SharedArrayBuffer:s}=globalThis;u.TYPED_ARRAY_SUPPORT=c(),!u.TYPED_ARRAY_SUPPORT&&typeof console<`u`&&typeof console.error==`function`&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function c(){try{let e=new a(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,a.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,`parent`,{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,`offset`,{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function l(e){if(e>i)throw RangeError(`The value "`+e+`" is invalid for option "size"`);let t=new a(e);return Object.setPrototypeOf(t,u.prototype),t}function u(e,t,n){if(typeof e==`number`){if(typeof t==`string`)throw TypeError(`The "string" argument must be of type string. Received type number`);return m(e)}return d(e,t,n)}u.poolSize=8192;function d(e,t,n){if(typeof e==`string`)return h(e,t);if(o.isView(e))return _(e);if(e==null)throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e);if(Le(e,o)||e&&Le(e.buffer,o)||s!==void 0&&(Le(e,s)||e&&Le(e.buffer,s)))return v(e,t,n);if(typeof e==`number`)throw TypeError(`The "value" argument must not be of type number. Received type number`);let r=e.valueOf&&e.valueOf();if(r!=null&&r!==e)return u.from(r,t,n);let i=y(e);if(i)return i;if(typeof Symbol<`u`&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]==`function`)return u.from(e[Symbol.toPrimitive](`string`),t,n);throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e)}u.from=function(e,t,n){return d(e,t,n)},Object.setPrototypeOf(u.prototype,a.prototype),Object.setPrototypeOf(u,a);function f(e){if(typeof e!=`number`)throw TypeError(`"size" argument must be of type number`);if(e<0)throw RangeError(`The value "`+e+`" is invalid for option "size"`)}function p(e,t,n){return f(e),e<=0||t===void 0?l(e):typeof n==`string`?l(e).fill(t,n):l(e).fill(t)}u.alloc=function(e,t,n){return p(e,t,n)};function m(e){return f(e),l(e<0?0:b(e)|0)}u.allocUnsafe=function(e){return m(e)},u.allocUnsafeSlow=function(e){return m(e)};function h(e,t){if((typeof t!=`string`||t===``)&&(t=`utf8`),!u.isEncoding(t))throw TypeError(`Unknown encoding: `+t);let n=x(e,t)|0,r=l(n),i=r.write(e,t);return i!==n&&(r=r.slice(0,i)),r}function g(e){let t=e.length<0?0:b(e.length)|0,n=l(t);for(let r=0;r<t;r+=1)n[r]=e[r]&255;return n}function _(e){if(Le(e,a)){let t=new a(e);return v(t.buffer,t.byteOffset,t.byteLength)}return g(e)}function v(e,t,n){if(t<0||e.byteLength<t)throw RangeError(`"offset" is outside of buffer bounds`);if(e.byteLength<t+(n||0))throw RangeError(`"length" is outside of buffer bounds`);let r;return r=t===void 0&&n===void 0?new a(e):n===void 0?new a(e,t):new a(e,t,n),Object.setPrototypeOf(r,u.prototype),r}function y(e){if(u.isBuffer(e)){let t=b(e.length)|0,n=l(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!=`number`||Re(e.length)?l(0):g(e);if(e.type===`Buffer`&&Array.isArray(e.data))return g(e.data)}function b(e){if(e>=i)throw RangeError(`Attempt to allocate Buffer larger than maximum size: 0x`+i.toString(16)+` bytes`);return e|0}function ee(e){return+e!=e&&(e=0),u.alloc(+e)}u.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==u.prototype},u.compare=function(e,t){if(Le(e,a)&&(e=u.from(e,e.offset,e.byteLength)),Le(t,a)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(e)||!u.isBuffer(t))throw TypeError(`The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array`);if(e===t)return 0;let n=e.length,r=t.length;for(let i=0,a=Math.min(n,r);i<a;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:+(r<n)},u.isEncoding=function(e){switch(String(e).toLowerCase()){case`hex`:case`utf8`:case`utf-8`:case`ascii`:case`latin1`:case`binary`:case`base64`:case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return!0;default:return!1}},u.concat=function(e,t){if(!Array.isArray(e))throw TypeError(`"list" argument must be an Array of Buffers`);if(e.length===0)return u.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let r=u.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){let t=e[n];if(Le(t,a))i+t.length>r.length?(u.isBuffer(t)||(t=u.from(t)),t.copy(r,i)):a.prototype.set.call(r,t,i);else if(u.isBuffer(t))t.copy(r,i);else throw TypeError(`"list" argument must be an Array of Buffers`);i+=t.length}return r};function x(e,t){if(u.isBuffer(e))return e.length;if(o.isView(e)||Le(e,o))return e.byteLength;if(typeof e!=`string`)throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type `+typeof e);let n=e.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let i=!1;for(;;)switch(t){case`ascii`:case`latin1`:case`binary`:return n;case`utf8`:case`utf-8`:return Ne(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return Ie(e).length;default:if(i)return r?-1:Ne(e).length;t=(``+t).toLowerCase(),i=!0}}u.byteLength=x;function te(e,t,n){let r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return``;for(e||=`utf8`;;)switch(e){case`hex`:return he(this,t,n);case`utf8`:case`utf-8`:return ue(this,t,n);case`ascii`:return pe(this,t,n);case`latin1`:case`binary`:return me(this,t,n);case`base64`:return S(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return ge(this,t,n);default:if(r)throw TypeError(`Unknown encoding: `+e);e=(e+``).toLowerCase(),r=!0}}u.prototype._isBuffer=!0;function ne(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}u.prototype.swap16=function(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let t=0;t<e;t+=2)ne(this,t,t+1);return this},u.prototype.swap32=function(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let t=0;t<e;t+=4)ne(this,t,t+3),ne(this,t+1,t+2);return this},u.prototype.swap64=function(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let t=0;t<e;t+=8)ne(this,t,t+7),ne(this,t+1,t+6),ne(this,t+2,t+5),ne(this,t+3,t+4);return this},u.prototype.toString=function(){let e=this.length;return e===0?``:arguments.length===0?ue(this,0,e):te.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(e){if(!u.isBuffer(e))throw TypeError(`Argument must be a Buffer`);return this===e?!0:u.compare(this,e)===0},u.prototype.inspect=function(){let t=``,n=e.INSPECT_MAX_BYTES;return t=this.toString(`hex`,0,n).replace(/(.{2})/g,`$1 `).trim(),this.length>n&&(t+=` ... `),`<Buffer `+t+`>`},r&&(u.prototype[r]=u.prototype.inspect),u.prototype.compare=function(e,t,n,r,i){if(Le(e,a)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(e))throw TypeError(`The "target" argument must be one of type Buffer or Uint8Array. Received type `+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw RangeError(`out of range index`);if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;let o=i-r,s=n-t,c=Math.min(o,s),l=this.slice(r,i),d=e.slice(t,n);for(let e=0;e<c;++e)if(l[e]!==d[e]){o=l[e],s=d[e];break}return o<s?-1:+(s<o)};function re(e,t,n,r,i){if(e.length===0)return-1;if(typeof n==`string`?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Re(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0)if(i)n=0;else return-1;if(typeof t==`string`&&(t=u.from(t,r)),u.isBuffer(t))return t.length===0?-1:ie(e,t,n,r,i);if(typeof t==`number`)return t&=255,typeof a.prototype.indexOf==`function`?i?a.prototype.indexOf.call(e,t,n):a.prototype.lastIndexOf.call(e,t,n):ie(e,[t],n,r,i);throw TypeError(`val must be string, number or Buffer`)}function ie(e,t,n,r,i){let a=1,o=e.length,s=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r===`ucs2`||r===`ucs-2`||r===`utf16le`||r===`utf-16le`)){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,n/=2}function c(e,t){return a===1?e[t]:e.readUInt16BE(t*a)}let l;if(i){let r=-1;for(l=n;l<o;l++)if(c(e,l)===c(t,r===-1?0:l-r)){if(r===-1&&(r=l),l-r+1===s)return r*a}else r!==-1&&(l-=l-r),r=-1}else for(n+s>o&&(n=o-s),l=n;l>=0;l--){let n=!0;for(let r=0;r<s;r++)if(c(e,l+r)!==c(t,r)){n=!1;break}if(n)return l}return-1}u.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},u.prototype.indexOf=function(e,t,n){return re(this,e,t,n,!0)},u.prototype.lastIndexOf=function(e,t,n){return re(this,e,t,n,!1)};function ae(e,t,n,r){n=Number(n)||0;let i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;let a=t.length;r>a/2&&(r=a/2);let o;for(o=0;o<r;++o){let r=parseInt(t.substr(o*2,2),16);if(Re(r))return o;e[n+o]=r}return o}function oe(e,t,n,r){return C(Ne(t,e.length-n),e,n,r)}function se(e,t,n,r){return C(Pe(t),e,n,r)}function ce(e,t,n,r){return C(Ie(t),e,n,r)}function le(e,t,n,r){return C(Fe(t,e.length-n),e,n,r)}u.prototype.write=function(e,t,n,r){if(t===void 0)r=`utf8`,n=this.length,t=0;else if(n===void 0&&typeof t==`string`)r=t,n=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(n)?(n>>>=0,r===void 0&&(r=`utf8`)):(r=n,n=void 0);else throw Error(`Buffer.write(string, encoding, offset[, length]) is no longer supported`);let i=this.length-t;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw RangeError(`Attempt to write outside buffer bounds`);r||=`utf8`;let a=!1;for(;;)switch(r){case`hex`:return ae(this,e,t,n);case`utf8`:case`utf-8`:return oe(this,e,t,n);case`ascii`:case`latin1`:case`binary`:return se(this,e,t,n);case`base64`:return ce(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return le(this,e,t,n);default:if(a)throw TypeError(`Unknown encoding: `+r);r=(``+r).toLowerCase(),a=!0}},u.prototype.toJSON=function(){return{type:`Buffer`,data:Array.prototype.slice.call(this._arr||this,0)}};function S(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function ue(e,t,n){n=Math.min(e.length,n);let r=[],i=t;for(;i<n;){let t=e[i],a=null,o=t>239?4:t>223?3:t>191?2:1;if(i+o<=n){let n,r,s,c;switch(o){case 1:t<128&&(a=t);break;case 2:n=e[i+1],(n&192)==128&&(c=(t&31)<<6|n&63,c>127&&(a=c));break;case 3:n=e[i+1],r=e[i+2],(n&192)==128&&(r&192)==128&&(c=(t&15)<<12|(n&63)<<6|r&63,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:n=e[i+1],r=e[i+2],s=e[i+3],(n&192)==128&&(r&192)==128&&(s&192)==128&&(c=(t&15)<<18|(n&63)<<12|(r&63)<<6|s&63,c>65535&&c<1114112&&(a=c))}}a===null?(a=65533,o=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),i+=o}return fe(r)}let de=4096;function fe(e){let t=e.length;if(t<=de)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=de));return n}function pe(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]&127);return r}function me(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function he(e,t,n){let r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);let i=``;for(let r=t;r<n;++r)i+=ze[e[r]];return i}function ge(e,t,n){let r=e.slice(t,n),i=``;for(let e=0;e<r.length-1;e+=2)i+=String.fromCharCode(r[e]+r[e+1]*256);return i}u.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let r=this.subarray(e,t);return Object.setPrototypeOf(r,u.prototype),r};function _e(e,t,n){if(e%1!=0||e<0)throw RangeError(`offset is not uint`);if(e+t>n)throw RangeError(`Trying to access beyond buffer length`)}u.prototype.readUintLE=u.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||_e(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return r},u.prototype.readUintBE=u.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||_e(e,t,this.length);let r=this[e+--t],i=1;for(;t>0&&(i*=256);)r+=this[e+--t]*i;return r},u.prototype.readUint8=u.prototype.readUInt8=function(e,t){return e>>>=0,t||_e(e,1,this.length),this[e]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,t){return e>>>=0,t||_e(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,t){return e>>>=0,t||_e(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,t){return e>>>=0,t||_e(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(e,t){return e>>>=0,t||_e(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readBigUInt64LE=Be(function(e){e>>>=0,ke(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ae(e,this.length-8);let r=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),u.prototype.readBigUInt64BE=Be(function(e){e>>>=0,ke(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ae(e,this.length-8);let r=t*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),u.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||_e(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return i*=128,r>=i&&(r-=2**(8*t)),r},u.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||_e(e,t,this.length);let r=t,i=1,a=this[e+--r];for(;r>0&&(i*=256);)a+=this[e+--r]*i;return i*=128,a>=i&&(a-=2**(8*t)),a},u.prototype.readInt8=function(e,t){return e>>>=0,t||_e(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},u.prototype.readInt16LE=function(e,t){e>>>=0,t||_e(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},u.prototype.readInt16BE=function(e,t){e>>>=0,t||_e(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},u.prototype.readInt32LE=function(e,t){return e>>>=0,t||_e(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return e>>>=0,t||_e(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readBigInt64LE=Be(function(e){e>>>=0,ke(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ae(e,this.length-8);let r=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)}),u.prototype.readBigInt64BE=Be(function(e){e>>>=0,ke(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Ae(e,this.length-8);let r=(t<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)}),u.prototype.readFloatLE=function(e,t){return e>>>=0,t||_e(e,4,this.length),n.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return e>>>=0,t||_e(e,4,this.length),n.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return e>>>=0,t||_e(e,8,this.length),n.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return e>>>=0,t||_e(e,8,this.length),n.read(this,e,!1,52,8)};function ve(e,t,n,r,i,a){if(!u.isBuffer(e))throw TypeError(`"buffer" argument must be a Buffer instance`);if(t>i||t<a)throw RangeError(`"value" argument is out of bounds`);if(n+r>e.length)throw RangeError(`Index out of range`)}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;ve(this,e,t,n,r,0)}let i=1,a=0;for(this[t]=e&255;++a<n&&(i*=256);)this[t+a]=e/i&255;return t+n},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;ve(this,e,t,n,r,0)}let i=n-1,a=1;for(this[t+i]=e&255;--i>=0&&(a*=256);)this[t+i]=e/a&255;return t+n},u.prototype.writeUint8=u.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||ve(this,e,t,1,255,0),this[t]=e&255,t+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||ve(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||ve(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||ve(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||ve(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function ye(e,t,n,r,i){Oe(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,n}function be(e,t,n,r,i){Oe(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n+7]=a,a>>=8,e[n+6]=a,a>>=8,e[n+5]=a,a>>=8,e[n+4]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=o,o>>=8,e[n+2]=o,o>>=8,e[n+1]=o,o>>=8,e[n]=o,n+8}u.prototype.writeBigUInt64LE=Be(function(e,t=0){return ye(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),u.prototype.writeBigUInt64BE=Be(function(e,t=0){return be(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),u.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);ve(this,e,t,n,r-1,-r)}let i=0,a=1,o=0;for(this[t]=e&255;++i<n&&(a*=256);)e<0&&o===0&&this[t+i-1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},u.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);ve(this,e,t,n,r-1,-r)}let i=n-1,a=1,o=0;for(this[t+i]=e&255;--i>=0&&(a*=256);)e<0&&o===0&&this[t+i+1]!==0&&(o=1),this[t+i]=(e/a>>0)-o&255;return t+n},u.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||ve(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},u.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||ve(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},u.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||ve(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},u.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||ve(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},u.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||ve(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},u.prototype.writeBigInt64LE=Be(function(e,t=0){return ye(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),u.prototype.writeBigInt64BE=Be(function(e,t=0){return be(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function xe(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function Se(e,t,r,i,a){return t=+t,r>>>=0,a||xe(e,t,r,4),n.write(e,t,r,i,23,4),r+4}u.prototype.writeFloatLE=function(e,t,n){return Se(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return Se(this,e,t,!1,n)};function Ce(e,t,r,i,a){return t=+t,r>>>=0,a||xe(e,t,r,8),n.write(e,t,r,i,52,8),r+8}u.prototype.writeDoubleLE=function(e,t,n){return Ce(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return Ce(this,e,t,!1,n)},u.prototype.copy=function(e,t,n,r){if(!u.isBuffer(e))throw TypeError(`argument should be a Buffer`);if(n||=0,!r&&r!==0&&(r=this.length),t>=e.length&&(t=e.length),t||=0,r>0&&r<n&&(r=n),r===n||e.length===0||this.length===0)return 0;if(t<0)throw RangeError(`targetStart out of bounds`);if(n<0||n>=this.length)throw RangeError(`Index out of range`);if(r<0)throw RangeError(`sourceEnd out of bounds`);r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);let i=r-n;return this===e&&typeof a.prototype.copyWithin==`function`?this.copyWithin(t,n,r):a.prototype.set.call(e,this.subarray(n,r),t),i},u.prototype.fill=function(e,t,n,r){if(typeof e==`string`){if(typeof t==`string`?(r=t,t=0,n=this.length):typeof n==`string`&&(r=n,n=this.length),r!==void 0&&typeof r!=`string`)throw TypeError(`encoding must be a string`);if(typeof r==`string`&&!u.isEncoding(r))throw TypeError(`Unknown encoding: `+r);if(e.length===1){let t=e.charCodeAt(0);(r===`utf8`&&t<128||r===`latin1`)&&(e=t)}}else typeof e==`number`?e&=255:typeof e==`boolean`&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw RangeError(`Out of range index`);if(n<=t)return this;t>>>=0,n=n===void 0?this.length:n>>>0,e||=0;let i;if(typeof e==`number`)for(i=t;i<n;++i)this[i]=e;else{let a=u.isBuffer(e)?e:u.from(e,r),o=a.length;if(o===0)throw TypeError(`The value "`+e+`" is invalid for argument "value"`);for(i=0;i<n-t;++i)this[i+t]=a[i%o]}return this};let we={};function Te(e,t,n){we[e]=class extends n{constructor(){super(),Object.defineProperty(this,`message`,{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,`code`,{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}Te(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),Te(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),Te(`ERR_OUT_OF_RANGE`,function(e,t,n){let r=`The value of "${e}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=Ee(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=Ee(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function Ee(e){let t=``,n=e.length,r=+(e[0]===`-`);for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function De(e,t,n){ke(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&Ae(t,e.length-(n+1))}function Oe(e,t,n,r,i,a){if(e>n||e<t){let r=typeof t==`bigint`?`n`:``,i;throw i=a>3?t===0||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${(a+1)*8}${r}`:`>= -(2${r} ** ${(a+1)*8-1}${r}) and < 2 ** ${(a+1)*8-1}${r}`:`>= ${t}${r} and <= ${n}${r}`,new we.ERR_OUT_OF_RANGE(`value`,i,e)}De(r,i,a)}function ke(e,t){if(typeof e!=`number`)throw new we.ERR_INVALID_ARG_TYPE(t,`number`,e)}function Ae(e,t,n){throw Math.floor(e)===e?t<0?new we.ERR_BUFFER_OUT_OF_BOUNDS:new we.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(ke(e,n),new we.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}let je=/[^+/0-9A-Za-z-_]/g;function Me(e){if(e=e.split(`=`)[0],e=e.trim().replace(je,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function Ne(e,t){t||=1/0;let n,r=e.length,i=null,a=[];for(let o=0;o<r;++o){if(n=e.charCodeAt(o),n>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(o+1===r){(t-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if(--t<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw Error(`Invalid code point`)}return a}function Pe(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function Fe(e,t){let n,r,i,a=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),r=n>>8,i=n%256,a.push(i),a.push(r);return a}function Ie(e){return t.toByteArray(Me(e))}function C(e,t,n,r){let i;for(i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function Le(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Re(e){return e!==e}let ze=(function(){let e=`0123456789abcdef`,t=Array(256);for(let n=0;n<16;++n){let r=n*16;for(let i=0;i<16;++i)t[r+i]=e[n]+e[i]}return t})();function Be(e){return typeof BigInt>`u`?Ve:e}function Ve(){throw Error(`BigInt not supported`)}})(Ng);var Yg=Ng.Buffer;Ng.Blob,Ng.BlobOptions,Ng.Buffer,Ng.File,Ng.FileOptions,Ng.INSPECT_MAX_BYTES,Ng.SlowBuffer,Ng.TranscodeEncoding,Ng.atob,Ng.btoa,Ng.constants,Ng.isAscii,Ng.isUtf8,Ng.kMaxLength,Ng.kStringMaxLength,Ng.resolveObjectURL,Ng.transcode;var Xg=function(e){return e[e.AES_256_GCM=0]=`AES_256_GCM`,e}({}),Zg=class e{static KEY_LENGTH_IN_BYTES=32;getSymmetricEncryptionSchemeId(){return Xg.AES_256_GCM}getSupportedKeyLengths(){return[e.KEY_LENGTH_IN_BYTES]}getDefaultKeyLength(){return e.KEY_LENGTH_IN_BYTES}},Qg=class e{constructor(e){this.key=e}static async generate(){let t=new Uint8Array(32);return crypto.getRandomValues(t),new e(t)}static createFromBytes(t){return new e(t)}getRawSecretKey(){return this.key}getSymmetricEncryptionSchemeId(){return Xg.AES_256_GCM}async encrypt(e){let t=new Uint8Array(12);crypto.getRandomValues(t);let n=au(this.key,t).encrypt(e),r=new Uint8Array(t.length+n.length);return r.set(t),r.set(n,t.length),r}async decrypt(e){try{let t=e.slice(0,12),n=e.slice(12);return au(this.key,t).decrypt(n)}catch(e){throw o.isCarmentisError(e)?new f:e}}},$g=class{constructor(e){this.wrappedKey=e}async encryptString(e){let t=new TextEncoder().encode(e),n=await this.encrypt(t);return Yg.from(n).toString(`base64`)}async decryptString(e){let t=Yg.from(e,`base64`),n=await this.decrypt(t);return new TextDecoder().decode(n)}getSymmetricEncryptionSchemeId(){return this.wrappedKey.getSymmetricEncryptionSchemeId()}async encrypt(e){return this.wrappedKey.encrypt(e)}async decrypt(e){return this.wrappedKey.decrypt(e)}getRawSecretKey(){return this.wrappedKey.getRawSecretKey()}},e_=function(e){return e[e.ML_KEM=0]=`ML_KEM`,e}({}),t_=class{getPrivateKeyAsString(e=Og.defaultBytesToStringEncoder()){return e.encode(this.getPrivateKeyAsBytes())}getSignatureSchemeId(){return this.getScheme().getSignatureSchemeId()}getSignatureSize(){return this.getScheme().getSignatureSize()}getSignatureAlgorithmId(){return this.getSignatureSchemeId()}},n_=class{async getPublicKeyAsString(e=Og.defaultBytesToStringEncoder()){return e.encode(await this.getPublicKeyAsBytes())}getSignatureSize(){return this.getScheme().getSignatureSize()}getSignatureSchemeId(){return this.getScheme().getSignatureSchemeId()}getSignatureAlgorithmId(){return this.getSignatureSchemeId()}},r_=class e{static SIGNATURE_SIZE=3311;getSignatureSchemeId(){return Ja.ML_DSA_65}getSignatureSize(){return e.SIGNATURE_SIZE}getSignatureAlgorithmId(){return this.getSignatureSchemeId()}expectedSeedSize(){return 32}},i_=class extends n_{constructor(e){super(),this.publicKey=e}async getPublicKeyAsString(e=Og.defaultBytesToStringEncoder()){return e.encode(await this.getPublicKeyAsBytes())}async verify(e,t){return yd.verify(this.publicKey,e,t)}async getPublicKeyAsBytes(){return this.publicKey}getScheme(){return new r_}},a_=class e extends t_{static async gen(){return new e(Fu(32))}verificationKey;signatureKey;getPrivateKeyAsString(e){return e.encode(this.getPrivateKeyAsBytes())}constructor(e){super(),this.seed=e;let t=yd.keygen(e);this.signatureKey=t.secretKey,this.verificationKey=t.publicKey}async getPublicKey(){return new i_(this.verificationKey)}getPrivateKeyAsBytes(){return this.seed}async sign(e){return yd.sign(this.signatureKey,e)}getScheme(){return new r_}},o_={p:57896044618658097711785492504343953926634992332820282019728792003956564819949n,n:7237005577332262213973186563042994240857116359379907606001950938285454250989n,h:8n,a:57896044618658097711785492504343953926634992332820282019728792003956564819948n,d:37095705934669439343138083508754565189542113879843219016388785533085940283555n,Gx:15112221349535400772501151409588531511454012693041857206046113283949847762202n,Gy:46316835694926478169428394003475163141307993866256225615783033603165251855960n},{p:s_,n:c_,Gx:l_,Gy:u_,a:d_,d:f_,h:p_}=o_,m_=32,h_=(...e)=>{`captureStackTrace`in Error&&typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(...e)},g_=(e=``)=>{let t=Error(e);throw h_(t,g_),t},__=e=>typeof e==`bigint`,v_=e=>typeof e==`string`,y_=e=>e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`,b_=(e,t,n=``)=>{let r=y_(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`;g_(o+`expected Uint8Array`+s+`, got `+c)}return e},x_=e=>new Uint8Array(e),S_=e=>Uint8Array.from(e),C_=(e,t)=>e.toString(16).padStart(t,`0`),w_=e=>Array.from(b_(e)).map(e=>C_(e,2)).join(``),T_={_0:48,_9:57,A:65,F:70,a:97,f:102},E_=e=>{if(e>=T_._0&&e<=T_._9)return e-T_._0;if(e>=T_.A&&e<=T_.F)return e-(T_.A-10);if(e>=T_.a&&e<=T_.f)return e-(T_.a-10)},D_=e=>{let t=`hex invalid`;if(!v_(e))return g_(t);let n=e.length,r=n/2;if(n%2)return g_(t);let i=x_(r);for(let n=0,a=0;n<r;n++,a+=2){let r=E_(e.charCodeAt(a)),o=E_(e.charCodeAt(a+1));if(r===void 0||o===void 0)return g_(t);i[n]=r*16+o}return i},O_=()=>globalThis?.crypto,k_=()=>O_()?.subtle??g_(`crypto.subtle must be defined, consider polyfill`),A_=(...e)=>{let t=x_(e.reduce((e,t)=>e+b_(t).length,0)),n=0;return e.forEach(e=>{t.set(e,n),n+=e.length}),t},j_=(e=m_)=>O_().getRandomValues(x_(e)),M_=BigInt,N_=(e,t,n,r=`bad number: out of range`)=>__(e)&&t<=e&&e<n?e:g_(r),P_=(e,t=s_)=>{let n=e%t;return n>=0n?n:t+n},F_=(1n<<255n)-1n,U=e=>{e<0n&&g_(`negative coordinate`);let t=(e>>255n)*19n+(e&F_);return t=(t>>255n)*19n+(t&F_),t%s_},I_=e=>P_(e,c_),L_=(e,t)=>{(e===0n||t<=0n)&&g_(`no inverse n=`+e+` mod=`+t);let n=P_(e,t),r=t,i=0n,a=1n,o=1n,s=0n;for(;n!==0n;){let e=r/n,t=r%n,c=i-o*e,l=a-s*e;r=n,n=t,i=o,a=s,o=c,s=l}return r===1n?P_(i,t):g_(`no inverse`)},R_=e=>{let t=lv[e];return typeof t!=`function`&&g_(`hashes.`+e+` not set`),t},z_=e=>e instanceof V_?e:g_(`Point expected`),B_=2n**256n,V_=class e{static BASE;static ZERO;X;Y;Z;T;constructor(e,t,n,r){let i=B_;this.X=N_(e,0n,i),this.Y=N_(t,0n,i),this.Z=N_(n,1n,i),this.T=N_(r,0n,i),Object.freeze(this)}static CURVE(){return o_}static fromAffine(t){return new e(t.x,t.y,1n,U(t.x*t.y))}static fromBytes(t,n=!1){let r=f_,i=S_(b_(t,m_)),a=t[31];i[31]=a&-129;let o=G_(i);N_(o,0n,n?B_:s_);let s=U(o*o),{isValid:c,value:l}=Y_(P_(s-1n),U(r*s+1n));c||g_(`bad point: y not sqrt`);let u=(l&1n)==1n,d=(a&128)!=0;return!n&&l===0n&&d&&g_(`bad point: x==0, isLastByteOdd`),d!==u&&(l=P_(-l)),new e(l,o,1n,U(l*o))}static fromHex(t,n){return e.fromBytes(D_(t),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}assertValidity(){let e=d_,t=f_,n=this;if(n.is0())return g_(`bad point: ZERO`);let{X:r,Y:i,Z:a,T:o}=n,s=U(r*r),c=U(i*i),l=U(a*a),u=U(l*l);return U(l*(U(s*e)+c))===P_(u+U(t*U(s*c)))?U(r*i)===U(a*o)?this:g_(`bad point: equation left != right (2)`):g_(`bad point: equation left != right (1)`)}equals(e){let{X:t,Y:n,Z:r}=this,{X:i,Y:a,Z:o}=z_(e),s=U(t*o),c=U(i*r),l=U(n*o),u=U(a*r);return s===c&&l===u}is0(){return this.equals(U_)}negate(){return new e(P_(-this.X),this.Y,this.Z,P_(-this.T))}double(){let{X:t,Y:n,Z:r}=this,i=d_,a=U(t*t),o=U(n*n),s=U(2n*r*r),c=U(i*a),l=P_(t+n),u=P_(U(l*l)-a-o),d=P_(c+o),f=P_(d-s),p=P_(c-o),m=U(u*f),h=U(d*p),g=U(u*p);return new e(m,h,U(f*d),g)}add(t){let{X:n,Y:r,Z:i,T:a}=this,{X:o,Y:s,Z:c,T:l}=z_(t),u=d_,d=f_,f=U(n*o),p=U(r*s),m=U(U(a*d)*l),h=U(i*c),g=P_(U(P_(n+r)*P_(o+s))-f-p),_=P_(h-m),v=P_(h+m),y=P_(p-U(u*f)),b=U(g*_),ee=U(v*y),x=U(g*y);return new e(b,ee,U(_*v),x)}subtract(e){return this.add(z_(e).negate())}multiply(e,t=!0){if(!t&&(e===0n||this.is0()))return U_;if(N_(e,1n,c_),e===1n)return this;if(this.equals(H_))return _v(e).p;let n=U_,r=H_;for(let i=this;e>0n;i=i.double(),e>>=1n)e&1n?n=n.add(i):t&&(r=r.add(i));return n}multiplyUnsafe(e){return this.multiply(e,!1)}toAffine(){let{X:e,Y:t,Z:n}=this;if(this.equals(U_))return{x:0n,y:1n};let r=L_(n,s_);return U(n*r)!==1n&&g_(`invalid inverse`),{x:U(e*r),y:U(t*r)}}toBytes(){let{x:e,y:t}=this.toAffine(),n=W_(t);return n[31]|=e&1n?128:0,n}toHex(){return w_(this.toBytes())}clearCofactor(){return this.multiply(M_(p_),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.multiply(c_/2n,!1).double();return c_%2n&&(e=e.add(this)),e.is0()}},H_=new V_(l_,u_,1n,P_(l_*u_)),U_=new V_(0n,1n,1n,0n);V_.BASE=H_,V_.ZERO=U_;var W_=e=>D_(C_(N_(e,0n,B_),64)).reverse(),G_=e=>M_(`0x`+w_(S_(b_(e)).reverse())),K_=(e,t)=>{let n=e;for(;t-- >0n;)n=U(n*n);return n},q_=e=>{let t=U(U(e*e)*e),n=U(K_(U(K_(t,2n)*t),1n)*e),r=U(K_(n,5n)*n),i=U(K_(r,10n)*r),a=U(K_(i,20n)*i),o=U(K_(a,40n)*a);return{pow_p_5_8:U(K_(U(K_(U(K_(U(K_(o,80n)*o),80n)*o),10n)*r),2n)*e),b2:t}},J_=19681161376707505956807079304988542015446066515923890162744021073123829784752n,Y_=(e,t)=>{let n=U(t*U(t*t)),r=q_(U(e*U(U(n*n)*t))).pow_p_5_8,i=U(e*U(n*r)),a=U(t*U(i*i)),o=i,s=U(i*J_),c=a===e,l=a===P_(-e),u=a===P_(-e*J_);return c&&(i=o),(l||u)&&(i=s),(P_(i)&1n)==1n&&(i=P_(-i)),{isValid:c||l,value:i}},X_=e=>I_(G_(e)),Z_=(...e)=>lv.sha512Async(A_(...e)),Q_=(...e)=>R_(`sha512`)(A_(...e)),$_=e=>{let t=e.slice(0,32);t[0]&=248,t[31]&=127,t[31]|=64;let n=e.slice(32,64),r=X_(t),i=H_.multiply(r);return{head:t,prefix:n,scalar:r,point:i,pointBytes:i.toBytes()}},ev=e=>Z_(b_(e,m_)).then($_),tv=e=>$_(Q_(b_(e,m_))),nv=e=>tv(e).pointBytes,rv=e=>e.finish(Q_(e.hashable)),iv=(e,t,n)=>{let{pointBytes:r,scalar:i}=e,a=X_(t),o=H_.multiply(a).toBytes();return{hashable:A_(o,r,n),finish:e=>b_(A_(o,W_(I_(a+X_(e)*i))),64)}},av=(e,t)=>{let n=b_(e),r=tv(t);return rv(iv(r,Q_(r.prefix,n),n))},ov={zip215:!0},sv=(e,t,n,r=ov)=>{e=b_(e,64),t=b_(t),n=b_(n,m_);let{zip215:i}=r,a=e.subarray(0,m_),o=G_(e.subarray(m_,m_*2)),s,c,l,u=Uint8Array.of(),d=!1;try{s=V_.fromBytes(n,i),c=V_.fromBytes(a,i),l=H_.multiply(o,!1),u=A_(c.toBytes(),s.toBytes(),t),d=!0}catch{}return{hashable:u,finish:e=>{if(!d||!i&&s.isSmallOrder())return!1;let t=X_(e);return c.add(s.multiply(t,!1)).subtract(l).clearCofactor().is0()}}},cv=(e,t,n,r=ov)=>rv(sv(e,t,n,r)),lv={sha512Async:async e=>{let t=k_(),n=A_(e);return x_(await t.digest(`SHA-512`,n.buffer))},sha512:void 0},uv={getExtendedPublicKeyAsync:ev,getExtendedPublicKey:tv,randomSecretKey:(e=j_(m_))=>e},dv=8,fv=Math.ceil(256/dv)+1,pv=2**(dv-1),mv=()=>{let e=[],t=H_,n=t;for(let r=0;r<fv;r++){n=t,e.push(n);for(let r=1;r<pv;r++)n=n.add(t),e.push(n);t=n.double()}return e},hv=void 0,gv=(e,t)=>{let n=t.negate();return e?n:t},_v=e=>{let t=hv||=mv(),n=U_,r=H_,i=2**dv,a=i,o=M_(i-1),s=M_(dv);for(let i=0;i<fv;i++){let c=Number(e&o);e>>=s,c>pv&&(c-=a,e+=1n);let l=i*pv,u=l,d=l+Math.abs(c)-1,f=i%2!=0,p=c<0;c===0?r=r.add(gv(f,t[u])):n=n.add(gv(p,t[d]))}return e!==0n&&g_(`invalid wnaf`),{p:n,f:r}};lv.sha512=qc;var vv=function(e){return e[e.SHA256=0]=`SHA256`,e}({}),yv=class{getHashSchemeId(){return vv.SHA256}hash(e){return Gc(e)}};function bv(e,t,n,r){Es(e);let{c:i,dkLen:a,asyncTick:o}=Ks({dkLen:32,asyncTick:10},r);if(ws(i),ws(a),ws(o),i<1)throw Error(`iterations (c) should be >= 1`);let s=Ws(t),c=Ws(n),l=new Uint8Array(a),u=Zd.create(e,s);return{c:i,dkLen:a,asyncTick:o,DK:l,PRF:u,PRFSalt:u._cloneInto().update(c)}}function xv(e,t,n,r,i){return e.destroy(),t.destroy(),r&&r.destroy(),As(i),n}function Sv(e,t,n,r){let{c:i,dkLen:a,DK:o,PRF:s,PRFSalt:c}=bv(e,t,n,r),l,u=new Uint8Array(4),d=js(u),f=new Uint8Array(s.outputLen);for(let e=1,t=0;t<a;e++,t+=s.outputLen){let n=o.subarray(t,t+s.outputLen);d.setInt32(0,e,!1),(l=c._cloneInto(l)).update(u).digestInto(f),n.set(f.subarray(0,n.length));for(let e=1;e<i;e++){s._cloneInto(l).update(f).digestInto(f);for(let e=0;e<n.length;e++)n[e]^=f[e]}}return xv(s,c,o,l,f)}var Cv=function(e){return e[e.PBKDF2=0]=`PBKDF2`,e[e.SCRYPT=1]=`SCRYPT`,e}({}),wv=class{deriveKeyNoSalt(e,t){return this.deriveKey(e,``,t)}},Tv=class extends wv{getKeyDerivationFunctionSchemeId(){return Cv.PBKDF2}deriveKey(e,t,n){return Sv(Gc,e,t,{c:1e5,dkLen:n})}};function Ev(e,t,n){return Es(e),n===void 0&&(n=new Uint8Array(e.outputLen)),Zd(e,Us(n),Us(t))}var Dv=Uint8Array.from([0]),Ov=Uint8Array.of();function kv(e,t,n,r=32){Es(e),ws(r);let i=e.outputLen;if(r>255*i)throw Error(`Length should be <= 255*HashLen`);let a=Math.ceil(r/i);n===void 0&&(n=Ov);let o=new Uint8Array(a*i),s=Zd.create(e,t),c=s._cloneInto(),l=new Uint8Array(s.outputLen);for(let e=0;e<a;e++)Dv[0]=e+1,c.update(e===0?Ov:l).update(n).update(Dv).digestInto(l),o.set(l,i*e),s._cloneInto(c);return s.destroy(),c.destroy(),As(l,Dv),o.slice(0,r)}var Av=(e,t,n,r,i)=>kv(e,Ev(e,t,n),r,i),jv=class{deriveKeyNoSalt(e,t,n){let r=new Uint8Array;return this.deriveKey(e,r,t,n)}},Mv=function(e){return e[e.HKDF=0]=`HKDF`,e}({}),Nv=class extends jv{getKeyDerivationFunctionSchemeId(){return Mv.HKDF}deriveKey(e,t,n,r){return Av(Gc,e,t,n,r)}},Pv=function(e){return e[e.ML_KEM_768_AES_256_GCM=0]=`ML_KEM_768_AES_256_GCM`,e}({}),Fv=function(e){return e[e.ML_KEM_768_AES_256_GCM=0]=`ML_KEM_768_AES_256_GCM`,e}({}),Iv=class{},Lv=class{async encode(e=Og.defaultBytesToStringEncoder()){return e.encode(await this.getRawPublicKey())}getSchemeId(){return this.getScheme().getSchemeId()}},Rv=class{encode(e=Og.defaultBytesToStringEncoder()){return e.encode(this.getRawPrivateKey())}},zv=class extends Iv{getSchemeId(){return Pv.ML_KEM_768_AES_256_GCM}getSupportedSeedLength(){return[32]}},Bv=128,Vv=96,Hv=32,Uv=64,Wv=7,Gv=8,Kv=class{byteStream;constructor(){this.clear()}clear(){this.byteStream=[]}getByteStream(){return new Uint8Array(this.byteStream)}writeJsonValue(e,t){switch(e){case 3:this.writeString(t);break;case 4:this.writeNumber(t);break;case 5:this.writeBoolean(t);break;case 6:break;default:throw`Type ${e} is not a JSON type`}}writeSchemaValue(e,t,n){switch(e){case 3:this.writeString(t,n);break;case 4:this.writeNumber(t);break;case 5:this.writeBoolean(t);break;case 6:break;case 7:this.writeUint8(t);break;case 8:this.writeUint16(t);break;case 9:this.writeUint24(t);break;case 10:this.writeUint32(t);break;case 11:this.writeUint48(t);break;case 12:this.writeBinary(t,n);break;case 13:this.writeByteArray(t);break;case 14:this.writeHashString(t);break;default:throw`Unexpected type ${e}`}}writeByte(e){this.byteStream.push(e&255)}writeUnsigned(e,t){for(;t--;)this.writeByte(e/2**(t*8))}writeUint8(e){this.writeUnsigned(e,1)}writeUint16(e){this.writeUnsigned(e,2)}writeUint24(e){this.writeUnsigned(e,3)}writeUint32(e){this.writeUnsigned(e,4)}writeUint48(e){this.writeUnsigned(e,6)}writeBinary(e,t=-1){t==-1&&this.writeVarUint(e.length),this.writeByteArray(e)}writeHashString(e){this.writeByteArray(A.binaryFromHexa(e))}writeByteArray(e){for(let t of e)this.writeByte(t)}writeString(e,t=-1){let n=Za.encode(e);t==-1&&this.writeVarUint(n.length),this.writeByteArray(n)}writeVarUint(e){if(e==0)this.writeByte(0);else{if(e<0||e%1||e>2**53-1)throw`Invalid varUint ${e}`;for(;e;)this.writeByte(e%128|(e>127)<<7),e=Math.floor(e/128)}}writeBoolean(e){this.writeByte(e?255:0)}writeNumber(e){let t=!(e%1);if(t&&e>=-64&&e<64){this.writeByte(Bv|e&127);return}for(let n=1,r=256;n<=6;n++,r*=256){if(t&&e>=-r&&e<r){let t=e<0;this.writeByte(t<<3|n),this.writeUnsigned(t?-e-1:e,n);return}if(n==4){let t=new Float32Array([e]);if(+t[0].toPrecision(7)===e){this.writeByte(Hv),this.writeByteArray(new Uint8Array(t.buffer));return}}}this.writeByte(Uv),this.writeByteArray(new Uint8Array(new Float64Array([e]).buffer))}},qv=class{byteStream;lastPointer;pointer;constructor(e){this.byteStream=e,this.pointer=0}readJsonValue(e){switch(this.lastPointer=this.pointer,e){case 3:return this.readString();case 4:return this.readNumber();case 5:return this.readBoolean();case 6:return null;default:throw`Type ${e} is not a JSON type`}}readSchemaValue(e,t){switch(this.lastPointer=this.pointer,e){case 3:return this.readString(t);case 4:return this.readNumber();case 5:return this.readBoolean();case 6:return null;case 7:return this.readUint8();case 8:return this.readUint16();case 9:return this.readUint24();case 10:return this.readUint32();case 11:return this.readUint48();case 12:return this.readBinary(t);case 13:return this.readByteArray(32);case 14:return this.readHashString()}}getPointer(){return this.pointer}extractFrom(e){return this.byteStream.slice(e,this.pointer)}getLastField(){return this.byteStream.slice(this.lastPointer,this.pointer)}readByte(){return this.byteStream[this.pointer++]}readUnsigned(e){let t=0;for(;e--;)t=t*256+this.readByte();return t}readUint8(){return this.readUnsigned(1)}readUint16(){return this.readUnsigned(2)}readUint24(){return this.readUnsigned(3)}readUint32(){return this.readUnsigned(4)}readUint48(){return this.readUnsigned(6)}readBinary(e=-1){return this.readByteArray(e==-1?this.readVarUint():e)}readHashString(){return A.binaryToHexa(this.readByteArray(32))}readByteArray(e){return this.byteStream.slice(this.pointer,this.pointer+=e)}readString(e=-1){let t=this.readByteArray(e==-1?this.readVarUint():e);return Za.decode(t)}readVarUint(){let e=[],t;do t=this.readByte(),e.push(t&127);while(t&128);return e.reduceRight((e,t)=>e*128+t,0)}readBoolean(){return!!this.readByte()}readNumber(){let e=this.readByte();if(e&Bv)return(e&127^64)-64;switch(e&Vv){case Hv:return+new Float32Array(this.readByteArray(4).buffer)[0].toPrecision(7);case Uv:return new Float64Array(this.readByteArray(8).buffer)[0];default:{let t=this.readUnsigned(e&Wv);return e&Gv?-t-1:t}}}},Jv=class{schema;stream;constructor(e){this.schema=e}serialize(e){if(this.schema===void 0)throw new Oe(`Provided schema is undefined: this should not happen`);return this.stream=new Kv,this.serializeObject(this.schema.definition,e),this.stream.getByteStream()}serializeObject(e,t,n=``){for(let r of e){let e=n+(n&&`.`)+r.name,i=t[r.name];if(i===void 0)throw new Oe(`field '${e}' is missing`);if(r.type&32){if(no.getType(i)!=1)throw new Oe(`'${e}' is not an array`);if(r.size!==void 0){if(i.length!=r.size)throw new Oe(`invalid size for '${e}' (expecting ${r.size} entries, got ${i.length})`)}else this.stream.writeVarUint(i.length);for(let t in i)this.serializeItem(r,i[t],e+`[${t}]`)}else this.serializeItem(r,i,e)}}serializeItem(e,t,n){let r=e.type&31;if(r==2){if(no.getType(t)!=2)throw new Oe(`'${n}' is not an object`);if(e.definition)this.serializeObject(e.definition,t,n);else if(e.schema)this.serializeObject(e.schema.definition,t,n);else throw new Oe(`missing definition in schema`)}else{let i=new ro(e,t);try{i.check()}catch(e){throw new Oe(`Error on field '${n}': ${e}`)}this.stream.writeSchemaValue(r,t,e.size)}}},Yv=class{schema;stream;constructor(e){this.schema=e}unserialize(e){this.stream=new qv(e);let t=this.unserializeObject(this.schema.definition),n=this.stream.getPointer(),r=e.length;if(n!=r)throw console.error(A.binaryToHexa(e)),new o(`Invalid stream length (decoded ${n} bytes, actual length is ${r} bytes)`);return t}unserializeObject(e){let t={};for(let n of e){let e;if(n.type&32){let t=n.size===void 0?this.stream.readVarUint():n.size;for(e=[];t--;)e.push(this.unserializeItem(n))}else e=this.unserializeItem(n);t[n.name]=e}return t}unserializeItem(e){let t=e.type&31;if(t==2){if(e.definition)return this.unserializeObject(e.definition);if(e.schema)return this.unserializeObject(e.schema.definition);throw`missing definition in schema`}return this.stream.readSchemaValue(t,e.size)}},Xv=class e{static schema={label:`PKE_ML_KEM_CIPHERTEXT`,definition:[{name:`encryptedSharedSecret`,type:12},{name:`encryptedMessage`,type:12}]};serializer=new Jv(e.schema);deserializer=new Yv(e.schema);encode(e,t){return this.serializer.serialize({encryptedSharedSecret:e,encryptedMessage:t})}decode(e){return this.deserializer.unserialize(e)}},Zv=class extends Lv{static encoder=Og.bytesToBase64Encoder();constructor(e){super(),this.publicKey=e}async encrypt(e){let{cipherText:t,sharedSecret:n}=Wd.encapsulate(this.publicKey),r=await Qg.createFromBytes(n).encrypt(e);return new Xv().encode(t,r)}async getRawPublicKey(){return this.publicKey}getScheme(){return new zv}},Qv=class e extends Rv{static async genFromSeed(t){if(t.length!==64)throw Error(`Seed must be 64 bytes long: got length: ${t?.length} bytes`);return new e(t)}static async gen(){return new e(Fu(64))}privateKey;publicKey;constructor(e){super();let{secretKey:t,publicKey:n}=Wd.keygen(e);this.privateKey=t,this.publicKey=n}getSupportedSeedLength(){return[64]}getScheme(){return new zv}async getPublicKey(){return new Zv(this.publicKey)}getRawPrivateKey(){return this.privateKey}async decrypt(e){try{let{encryptedMessage:t,encryptedSharedSecret:n}=new Xv().decode(e),r=Wd.decapsulate(n,this.privateKey);return Qg.createFromBytes(r).decrypt(t)}catch(e){throw o.isCarmentisError(e)?new f:e}}},$v=class e{static SIGNATURE_SIZE=65;getSignatureSchemeId(){return Ja.SECP256K1}getSignatureSize(){return e.SIGNATURE_SIZE}expectedSeedSize(){return 32}},ey=class extends n_{constructor(e){super(),this.publicKey=e}async getPublicKeyAsBytes(){return this.publicKey}async verify(e,t){return rp(t,Gc(e),this.publicKey)}getScheme(){return new $v}},ty=class e extends t_{constructor(e){super(),this.privateKey=e}getPrivateKeyAsString(e){return e.encode(this.getPrivateKeyAsBytes())}static gen(){return new e(lp.randomPrivateKey())}static genFromSeed(t){return new e(cp.bytesToHex(t))}async getPublicKey(){if(this.privateKey instanceof Uint8Array)return new ey(qf(this.privateKey));throw Error(`Invalid private key format: expected Uint8Array, got `+typeof this.privateKey+` instead.`)}getPrivateKeyAsBytes(){if(this.privateKey instanceof Uint8Array)return this.privateKey;throw Error(`Invalid private key format: expected Uint8Array, got `+typeof this.privateKey+` instead.`)}async sign(e){return(await tp(Gc(e),this.privateKey)).toCompactRawBytes()}getScheme(){return new $v}},ny=class e{static SIGNATURE_SIZE=65;getSignatureSchemeId(){return Ja.ED25519}getSignatureSize(){return e.SIGNATURE_SIZE}expectedSeedSize(){return 32}},ry=class extends n_{constructor(e){super(),this.publicKey=e}async getPublicKeyAsBytes(){return this.publicKey}async verify(e,t){return cv(t,Gc(e),this.publicKey)}getScheme(){return new ny}};lv.sha512=qc;var iy=class e extends t_{constructor(e){super(),this.privateKey=e}getPrivateKeyAsString(e){return e.encode(this.getPrivateKeyAsBytes())}static gen(){return new e(uv.randomSecretKey())}static genFromSeed(t){return new e(t)}async getPublicKey(){if(this.privateKey instanceof Uint8Array)return new ry(nv(this.privateKey));throw Error(`Invalid private key format: expected Uint8Array, got `+typeof this.privateKey+` instead.`)}getPrivateKeyAsBytes(){if(this.privateKey instanceof Uint8Array)return this.privateKey;throw Error(`Invalid private key format: expected Uint8Array, got `+typeof this.privateKey+` instead.`)}async sign(e){return av(Gc(e),this.privateKey)}getScheme(){return new ny}},ay={"P-256":{alg:`ES256`,fieldSize:32,hash:`SHA-256`},"P-384":{alg:`ES384`,fieldSize:48,hash:`SHA-384`},"P-521":{alg:`ES512`,fieldSize:66,hash:`SHA-512`},secp256k1:{alg:`ES256K`,fieldSize:32,hash:`SHA-256`}},oy={Ed25519:{alg:`Ed25519`,seedSize:32,signatureSize:64},Ed448:{alg:`Ed448`,seedSize:57,signatureSize:114}},sy={"ML-DSA-44":2420,"ML-DSA-65":3309,"ML-DSA-87":4627},cy={EC:[`crv`,`x`,`y`],OKP:[`crv`,`x`],RSA:[`n`,`e`],AKP:[`pub`]},ly={EC:[`d`],OKP:[`d`],RSA:[`d`,`p`,`q`,`dp`,`dq`,`qi`,`oth`],AKP:[`priv`]},uy={EC:[`d`],OKP:[`d`],RSA:[`d`],AKP:[`priv`]},dy=new Set([`RSA`,`AKP`]);function fy(e){if(!e||typeof e!=`object`)throw Error(`Cannot import JWK: not an object`);if(!e.kty)throw Error(`Cannot import JWK: missing 'kty' member`);switch(e.kty){case`EC`:return py(e);case`OKP`:return my(e);case`RSA`:return hy(e);case`AKP`:return gy(e);case`oct`:throw Error(`Cannot import JWK: 'oct' keys are symmetric (HMAC) and have no public counterpart, which the private/public signature key pair requires`);default:throw Error(`Cannot import JWK: unsupported key type '${e.kty}'`)}}function py(e){if(!e.crv)throw Error(`Cannot import EC JWK: missing 'crv' member`);let t=ay[e.crv];if(!t)throw Error(`Cannot import EC JWK: unsupported curve '${e.crv}', expected one of ${Object.keys(ay).join(`, `)}`);return yy(e,[t.alg]),e.crv===`secp256k1`?{alg:t.alg,kty:`EC`,crv:e.crv,backend:`secp256k1`,seedSize:t.fieldSize,signatureSize:2*t.fieldSize}:{alg:t.alg,kty:`EC`,crv:e.crv,backend:`webcrypto`,keyAlgorithm:{name:`ECDSA`,namedCurve:e.crv},signAlgorithm:{name:`ECDSA`,hash:t.hash},seedSize:t.fieldSize,signatureSize:2*t.fieldSize}}function my(e){if(!e.crv)throw Error(`Cannot import OKP JWK: missing 'crv' member`);let t=oy[e.crv];if(!t)throw Error(`Cannot import OKP JWK: curve '${e.crv}' cannot sign, expected one of ${Object.keys(oy).join(`, `)}`);return yy(e,[t.alg,`EdDSA`]),e.crv===`Ed25519`?{alg:t.alg,kty:`OKP`,crv:e.crv,backend:`ed25519`,seedSize:t.seedSize,signatureSize:t.signatureSize}:{alg:t.alg,kty:`OKP`,crv:e.crv,backend:`webcrypto`,keyAlgorithm:{name:e.crv},signAlgorithm:{name:e.crv},seedSize:t.seedSize,signatureSize:t.signatureSize}}function hy(e){let t=e.alg??`RS256`,n=/^(RS|PS)(256|384|512)$/.exec(t);if(!n)throw Error(`Cannot import RSA JWK: unsupported algorithm '${t}', expected RS256, RS384, RS512, PS256, PS384 or PS512`);let[,r,i]=n,a=`SHA-${i}`,o=r===`PS`?`RSA-PSS`:`RSASSA-PKCS1-v1_5`;return{alg:t,kty:`RSA`,backend:`webcrypto`,keyAlgorithm:{name:o,hash:a},signAlgorithm:o===`RSA-PSS`?{name:o,saltLength:Number(i)/8}:{name:o},seedSize:void 0,signatureSize:void 0}}function gy(e){if(!e.alg)throw Error(`Cannot import AKP JWK: missing 'alg' member`);let t=sy[e.alg];if(t===void 0)throw Error(`Cannot import AKP JWK: unsupported algorithm '${e.alg}', expected one of ${Object.keys(sy).join(`, `)}`);return{alg:e.alg,kty:`AKP`,backend:`ml-dsa`,seedSize:32,signatureSize:t}}var _y={ES256:{kty:`EC`,crv:`P-256`},ES384:{kty:`EC`,crv:`P-384`},ES512:{kty:`EC`,crv:`P-521`},ES256K:{kty:`EC`,crv:`secp256k1`},Ed25519:{kty:`OKP`,crv:`Ed25519`},Ed448:{kty:`OKP`,crv:`Ed448`},RS256:{kty:`RSA`,alg:`RS256`},RS384:{kty:`RSA`,alg:`RS384`},RS512:{kty:`RSA`,alg:`RS512`},PS256:{kty:`RSA`,alg:`PS256`},PS384:{kty:`RSA`,alg:`PS384`},PS512:{kty:`RSA`,alg:`PS512`},"ML-DSA-44":{kty:`AKP`,alg:`ML-DSA-44`},"ML-DSA-65":{kty:`AKP`,alg:`ML-DSA-65`},"ML-DSA-87":{kty:`AKP`,alg:`ML-DSA-87`}};function vy(e){let t=_y[e];if(!t)throw Error(`Unsupported JOSE signature algorithm '${e}', expected one of ${Object.keys(_y).join(`, `)}`);return fy(t)}function yy(e,t){if(e.alg!==void 0&&!t.includes(e.alg))throw Error(`Cannot import JWK: declared algorithm '${e.alg}' is incompatible with curve '${e.crv}', expected ${t.join(` or `)}`)}function by(e,t){let n={kty:t.kty};dy.has(t.kty)&&(n.alg=t.alg);for(let r of cy[t.kty]){let i=e[r];if(i===void 0)throw Error(`Cannot import ${t.kty} JWK: missing public member '${r}'`);n[r]=i}return Sy(n)}function xy(e,t){for(let n of uy[t.kty])if(e[n]===void 0)throw Error(`Cannot import ${t.kty} JWK as a private key: missing member '${n}'`);let n={...by(e,t)};for(let r of ly[t.kty]){let t=e[r];t!==void 0&&(n[r]=t)}return Sy(n)}function Sy(e){let t={};for(let n of Object.keys(e).sort())t[n]=e[n];return t}function Cy(e,t){let n=e[t];if(typeof n!=`string`)throw Error(`Malformed JWK: missing or invalid member '${t}'`);return n}var wy=new TextEncoder,Ty=new TextDecoder;function Ey(e){if(Uint8Array.prototype.toBase64)return e.toBase64();let t=32768,n=[];for(let r=0;r<e.length;r+=t)n.push(String.fromCharCode.apply(null,e.subarray(r,r+t)));return btoa(n.join(``))}function Dy(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Oy(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof e==`string`?e:Ty.decode(e),{alphabet:`base64url`});let t=e;t instanceof Uint8Array&&(t=Ty.decode(t)),t=t.replace(/-/g,`+`).replace(/_/g,`/`);try{return Dy(t)}catch{throw TypeError(`The input to be decoded is not correctly encoded.`)}}function ky(e){let t=e;return typeof t==`string`&&(t=wy.encode(t)),Uint8Array.prototype.toBase64?t.toBase64({alphabet:`base64url`,omitPadding:!0}):Ey(t).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}var Ay=class extends Error{static code=`ERR_JOSE_GENERIC`;code=`ERR_JOSE_GENERIC`;constructor(e,t){super(e,t),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}},jy=class extends Ay{static code=`ERR_JOSE_NOT_SUPPORTED`;code=`ERR_JOSE_NOT_SUPPORTED`},My=e=>typeof e==`object`&&!!e;function Ny(e){if(!My(e)||Object.prototype.toString.call(e)!==`[object Object]`)return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}var Py=`Invalid or unsupported JWK "alg" (Algorithm) Parameter value`;function Fy(e){let t,n;switch(e.kty){case`AKP`:switch(e.alg){case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:t={name:e.alg},n=e.priv?[`sign`]:[`verify`];break;default:throw new jy(Py)}break;case`RSA`:switch(e.alg){case`PS256`:case`PS384`:case`PS512`:t={name:`RSA-PSS`,hash:`SHA-${e.alg.slice(-3)}`},n=e.d?[`sign`]:[`verify`];break;case`RS256`:case`RS384`:case`RS512`:t={name:`RSASSA-PKCS1-v1_5`,hash:`SHA-${e.alg.slice(-3)}`},n=e.d?[`sign`]:[`verify`];break;case`RSA-OAEP`:case`RSA-OAEP-256`:case`RSA-OAEP-384`:case`RSA-OAEP-512`:t={name:`RSA-OAEP`,hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},n=e.d?[`decrypt`,`unwrapKey`]:[`encrypt`,`wrapKey`];break;default:throw new jy(Py)}break;case`EC`:switch(e.alg){case`ES256`:case`ES384`:case`ES512`:t={name:`ECDSA`,namedCurve:{ES256:`P-256`,ES384:`P-384`,ES512:`P-521`}[e.alg]},n=e.d?[`sign`]:[`verify`];break;case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:t={name:`ECDH`,namedCurve:e.crv},n=e.d?[`deriveBits`]:[];break;default:throw new jy(Py)}break;case`OKP`:switch(e.alg){case`Ed25519`:case`EdDSA`:t={name:`Ed25519`},n=e.d?[`sign`]:[`verify`];break;case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:t={name:e.crv},n=e.d?[`deriveBits`]:[];break;default:throw new jy(Py)}break;default:throw new jy(`Invalid or unsupported JWK "kty" (Key Type) Parameter value`)}return{algorithm:t,keyUsages:n}}async function Iy(e){if(!e.alg)throw TypeError(`"alg" argument is required when "jwk.alg" is not present`);let{algorithm:t,keyUsages:n}=Fy(e),r={...e};return r.kty!==`AKP`&&delete r.alg,delete r.use,crypto.subtle.importKey(`jwk`,r,t,e.ext??!(e.d||e.priv),e.key_ops??n)}async function Ly(e,t,n){if(!Ny(e))throw TypeError(`JWK must be an object`);let r;switch(t??=e.alg,r??=n?.extractable??e.ext,e.kty){case`oct`:if(typeof e.k!=`string`||!e.k)throw TypeError(`missing "k" (Key Value) Parameter value`);return Oy(e.k);case`RSA`:if(`oth`in e&&e.oth!==void 0)throw new jy(`RSA JWK "oth" (Other Primes Info) Parameter value is not supported`);return Iy({...e,alg:t,ext:r});case`AKP`:if(typeof e.alg!=`string`||!e.alg)throw TypeError(`missing "alg" (Algorithm) Parameter value`);if(t!==void 0&&t!==e.alg)throw TypeError(`JWK alg and alg option value mismatch`);return Iy({...e,ext:r});case`EC`:case`OKP`:return Iy({...e,alg:t,ext:r});default:throw new jy(`Unsupported "kty" (Key Type) Parameter value`)}}Ja.ML_DSA_65;var Ry=class e{static forJwk(t,n){return new e(t,t.signatureSize??Oy(Cy(n,`n`)).length)}constructor(e,t){this.algorithm=e,this.signatureSize=t}getAlgorithm(){return this.algorithm}getAlgorithmName(){return this.algorithm.alg}getSignatureSchemeId(){return Ja.JWK}getSignatureSize(){return this.signatureSize}expectedSeedSize(){if(this.algorithm.seedSize===void 0)throw Error(`${this.algorithm.alg} keys are not derived from a seed`);return this.algorithm.seedSize}};function zy(){let e=globalThis.crypto;if(!e||!e.subtle)throw Error("The Web Crypto API is not available: 'globalThis.crypto.subtle' is undefined. In Node.js, use version 19 or later (or assign `globalThis.crypto = require('node:crypto').webcrypto`); in a browser, make sure the page runs in a secure context (HTTPS or localhost).");return e.subtle}lv.sha512=qc,cp.hmacSha256Sync=(e,...t)=>Zd(Gc,e,cp.concatBytes(...t));var By={"ML-DSA-44":{module:vd,secretKeySize:2560},"ML-DSA-65":{module:yd,secretKeySize:4032},"ML-DSA-87":{module:bd,secretKeySize:4896}},Vy=2048;async function Hy(e,t){switch(e.backend){case`webcrypto`:return qy(e,t);case`ed25519`:return Yy(t);case`secp256k1`:return Zy(t);case`ml-dsa`:return $y(e,t);default:throw Error(`Unsupported signature backend '${e.backend}'`)}}async function Uy(e,t){switch(e.backend){case`webcrypto`:return Jy(e,t);case`ed25519`:return Xy(t);case`secp256k1`:return Qy(t);case`ml-dsa`:return eb(e,t);default:throw Error(`Unsupported signature backend '${e.backend}'`)}}async function Wy(e,t={}){let n=vy(e);switch(n.backend){case`webcrypto`:{let e=zy(),r=await e.generateKey(Ky(n,t),!0,[`sign`,`verify`]);return await e.exportKey(`jwk`,r.privateKey)}case`ed25519`:{let e=uv.randomSecretKey();return{kty:`OKP`,crv:`Ed25519`,d:ky(e),x:ky(nv(e))}}case`secp256k1`:{let e=lp.randomPrivateKey(),t=qf(e,!1);return{kty:`EC`,crv:`secp256k1`,alg:`ES256K`,d:ky(e),x:ky(t.slice(1,33)),y:ky(t.slice(33,65))}}case`ml-dsa`:{let e=Fu(32);return{kty:`AKP`,alg:n.alg,pub:ky(tb(n).module.keygen(e).publicKey),priv:ky(e)}}default:throw Error(`Unsupported signature backend '${n.backend}'`)}}function Gy(e){let{keyAlgorithm:t,signAlgorithm:n}=e;if(!t||!n)throw Error(`Algorithm '${e.alg}' does not carry Web Crypto parameters`);return{keyAlgorithm:t,signAlgorithm:n}}function Ky(e,t){let{keyAlgorithm:n}=Gy(e);return e.kty===`RSA`?{...n,modulusLength:t.modulusLength??Vy,publicExponent:new Uint8Array([1,0,1])}:n}async function qy(e,t){let n=zy(),{keyAlgorithm:r,signAlgorithm:i}=Gy(e),a=await n.importKey(`jwk`,t,r,!0,[`sign`]);return{privateKeyBytes:e.kty===`RSA`?new Uint8Array(await n.exportKey(`pkcs8`,a)):Oy(Cy(t,`d`)),sign:async e=>new Uint8Array(await n.sign(i,a,e))}}async function Jy(e,t){let n=zy(),{keyAlgorithm:r,signAlgorithm:i}=Gy(e),a=await n.importKey(`jwk`,t,r,!0,[`verify`]),o=e.kty===`RSA`?`spki`:`raw`;return{publicKeyBytes:new Uint8Array(await n.exportKey(o,a)),verify:(e,t)=>n.verify(i,a,t,e)}}function Yy(e){let t=Oy(Cy(e,`d`));return{privateKeyBytes:t,sign:async e=>av(e,t)}}function Xy(e){let t=Oy(Cy(e,`x`));return{publicKeyBytes:t,verify:async(e,n)=>cv(n,e,t)}}function Zy(e){let t=Oy(Cy(e,`d`));return{privateKeyBytes:t,sign:async e=>np(Gc(e),t).toCompactRawBytes()}}function Qy(e){let t=Oy(Cy(e,`x`)),n=Oy(Cy(e,`y`)),r=new Uint8Array(1+t.length+n.length);return r[0]=4,r.set(t,1),r.set(n,1+t.length),{publicKeyBytes:r,verify:async(e,t)=>rp(t,Gc(e),r)}}function $y(e,t){let{module:n,secretKeySize:r}=tb(e),i=Oy(Cy(t,`priv`)),a;if(i.length===32)a=n.keygen(i).secretKey;else if(i.length===r)a=i;else throw Error(`Cannot import AKP JWK: 'priv' is ${i.length} bytes, expected a 32-byte seed or a ${r}-byte ${e.alg} secret key`);return{privateKeyBytes:i,sign:async e=>n.sign(a,e)}}function eb(e,t){let{module:n}=tb(e),r=Oy(Cy(t,`pub`));return{publicKeyBytes:r,verify:async(e,t)=>n.verify(r,e,t)}}function tb(e){let t=By[e.alg];if(!t)throw Error(`Unsupported ML-DSA parameter set '${e.alg}'`);return t}var nb;try{nb=new TextDecoder}catch{}var W,rb,G=0,ib=[],ab=105,ob=57342,sb=57343,cb=57337,lb=6,ub={},db=11281e4,fb=1681e4,pb=ib,mb=0,K={},hb,gb,_b=0,vb=0,yb,bb,xb=[],Sb=[],Cb,wb,Tb,Eb={useRecords:!1,mapsAsObjects:!0},Db=!1,Ob=2;try{Function(``)}catch{Ob=1/0}var kb=class e{constructor(e){if(e&&((e.keyMap||e._keyMap)&&!e.useRecords&&(e.useRecords=!1,e.mapsAsObjects=!0),e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.getStructures&&(e.getShared=e.getStructures),e.getShared&&!e.structures&&((e.structures=[]).uninitialized=!0),e.keyMap)){this.mapKey=new Map;for(let[t,n]of Object.entries(e.keyMap))this.mapKey.set(n,t)}Object.assign(this,e)}decodeKey(e){return this.keyMap&&this.mapKey.get(e)||e}encodeKey(e){return this.keyMap&&this.keyMap.hasOwnProperty(e)?this.keyMap[e]:e}encodeKeys(e){if(!this._keyMap)return e;let t=new Map;for(let[n,r]of Object.entries(e))t.set(this._keyMap.hasOwnProperty(n)?this._keyMap[n]:n,r);return t}decodeKeys(e){if(!this._keyMap||e.constructor.name!=`Map`)return e;if(!this._mapKey){this._mapKey=new Map;for(let[e,t]of Object.entries(this._keyMap))this._mapKey.set(t,e)}let t={};return e.forEach((e,n)=>t[Nb(this._mapKey.has(n)?this._mapKey.get(n):n)]=e),t}mapDecode(e,t){let n=this.decode(e);if(this._keyMap)switch(n.constructor.name){case`Array`:return n.map(e=>this.decodeKeys(e))}return n}decode(t,n){if(W)return rx(()=>(ix(),this?this.decode(t,n):e.prototype.decode.call(Eb,t,n)));rb=n>-1?n:t.length,G=0,mb=0,vb=0,gb=null,pb=ib,yb=null,W=t;try{wb=t.dataView||=new DataView(t.buffer,t.byteOffset,t.byteLength)}catch(e){throw W=null,t instanceof Uint8Array?e:Error(`Source must be a Uint8Array or Buffer but was a `+(t&&typeof t==`object`?t.constructor.name:typeof t))}if(this instanceof e){if(K=this,Cb=this.sharedValues&&(this.pack?Array(this.maxPrivatePackedValues||16).concat(this.sharedValues):this.sharedValues),this.structures)return hb=this.structures,Ab();(!hb||hb.length>0)&&(hb=[])}else K=Eb,(!hb||hb.length>0)&&(hb=[]),Cb=null;return Ab()}decodeMultiple(e,t){let n,r=0;try{let i=e.length;Db=!0;let a=this?this.decode(e,i):ox.decode(e,i);if(t){if(t(a)===!1)return;for(;G<i;)if(r=G,t(Ab())===!1)return}else{for(n=[a];G<i;)r=G,n.push(Ab());return n}}catch(e){throw e.lastPosition=r,e.values=n,e}finally{Db=!1,ix()}}};function Ab(){try{let e=q();if(yb){if(G>=yb.postBundlePosition){let e=Error(`Unexpected bundle position`);throw e.incomplete=!0,e}G=yb.postBundlePosition,yb=null}if(G==rb)hb=null,W=null,bb&&=null;else if(G>rb){let e=Error(`Unexpected end of CBOR data`);throw e.incomplete=!0,e}else if(!Db)throw Error(`Data read, but end of buffer not reached`);return e}catch(e){throw ix(),(e instanceof RangeError||e.message.startsWith(`Unexpected end of buffer`))&&(e.incomplete=!0),e}}function q(){let e=W[G++],t=e>>5;if(e&=31,e>23)switch(e){case 24:e=W[G++];break;case 25:if(t==7)return Hb();e=wb.getUint16(G),G+=2;break;case 26:if(t==7){let e=wb.getFloat32(G);if(K.useFloat32>2){let t=ax[(W[G]&127)<<1|W[G+1]>>7];return G+=4,(t*e+(e>0?.5:-.5)>>0)/t}return G+=4,e}if(e=wb.getUint32(G),G+=4,t===1)return-1-e;break;case 27:if(t==7){let e=wb.getFloat64(G);return G+=8,e}if(t>1){if(wb.getUint32(G)>0)throw Error(`JavaScript does not support arrays, maps, or strings with length over 4294967295`);e=wb.getUint32(G+4)}else K.int64AsNumber?(e=wb.getUint32(G)*4294967296,e+=wb.getUint32(G+4)):e=wb.getBigUint64(G);G+=8;break;case 31:switch(t){case 2:case 3:throw Error(`Indefinite length not supported for byte or text strings`);case 4:let e=[],n,r=0;for(;(n=q())!=ub;){if(r>=db)throw Error(`Array length exceeds ${db}`);e[r++]=n}return t==4?e:t==3?e.join(``):Yg.concat(e);case 5:let i;if(K.mapsAsObjects){let e={},t=0;if(K.keyMap)for(;(i=q())!=ub;){if(t++>=fb)throw Error(`Property count exceeds ${fb}`);e[Nb(K.decodeKey(i))]=q()}else for(;(i=q())!=ub;){if(t++>=fb)throw Error(`Property count exceeds ${fb}`);e[Nb(i)]=q()}return e}else{Tb&&=(K.mapsAsObjects=!0,!1);let e=new Map;if(K.keyMap){let t=0;for(;(i=q())!=ub;){if(t++>=fb)throw Error(`Map size exceeds ${fb}`);e.set(K.decodeKey(i),q())}}else{let t=0;for(;(i=q())!=ub;){if(t++>=fb)throw Error(`Map size exceeds ${fb}`);e.set(i,q())}}return e}case 7:return ub;default:throw Error(`Invalid major type for indefinite length `+t)}default:throw Error(`Unknown token `+e)}switch(t){case 0:return e;case 1:return~e;case 2:return zb(e);case 3:if(vb>=G)return gb.slice(G-_b,(G+=e)-_b);if(vb==0&&rb<140&&e<32){let t=e<16?Rb(e):Lb(e);if(t!=null)return t}return Pb(e);case 4:if(e>=db)throw Error(`Array length exceeds ${db}`);let t=Array(e);for(let n=0;n<e;n++)t[n]=q();return t;case 5:if(e>=fb)throw Error(`Map size exceeds ${db}`);if(K.mapsAsObjects){let t={};if(K.keyMap)for(let n=0;n<e;n++)t[Nb(K.decodeKey(q()))]=q();else for(let n=0;n<e;n++)t[Nb(q())]=q();return t}else{Tb&&=(K.mapsAsObjects=!0,!1);let t=new Map;if(K.keyMap)for(let n=0;n<e;n++)t.set(K.decodeKey(q()),q());else for(let n=0;n<e;n++)t.set(q(),q());return t}case 6:if(e>=cb){let t=hb[e&8191];if(t)return t.read||=Mb(t),t.read();if(e<65536){if(e==sb){let e=tx(),t=q(),n=q();Wb(t,n);let r={};if(K.keyMap)for(let t=2;t<e;t++){let e=K.decodeKey(n[t-2]);r[Nb(e)]=q()}else for(let t=2;t<e;t++){let e=n[t-2];r[Nb(e)]=q()}return r}else if(e==ob){let e=tx(),t=q();for(let n=2;n<e;n++)Wb(t++,q());return q()}else if(e==cb)return ex();if(K.getShared&&(nx(),t=hb[e&8191],t))return t.read||=Mb(t),t.read()}}let n=xb[e];if(n)return n.handlesRead?n(q):n(q());{let t=q();for(let n=0;n<Sb.length;n++){let r=Sb[n](e,t);if(r!==void 0)return r}return new Ub(t,e)}case 7:switch(e){case 20:return!1;case 21:return!0;case 22:return null;case 23:return;default:let t=(Cb||Jb())[e];if(t!==void 0)return t;throw Error(`Unknown token `+e)}default:if(isNaN(e)){let e=Error(`Unexpected end of CBOR data`);throw e.incomplete=!0,e}throw Error(`Unknown CBOR token `+e)}}var jb=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Mb(e){if(!e)throw Error(`Structure is required in record definition`);function t(){let e=W[G++];if(e&=31,e>23)switch(e){case 24:e=W[G++];break;case 25:e=wb.getUint16(G),G+=2;break;case 26:e=wb.getUint32(G),G+=4;break;default:throw Error(`Expected array header, but got `+W[G-1])}let t=this.compiledReader;for(;t;){if(t.propertyCount===e)return t(q);t=t.next}if(this.slowReads++>=Ob){let n=this.length==e?this:this.slice(0,e);return t=K.keyMap?Function(`r`,`return {`+n.map(e=>K.decodeKey(e)).map(e=>jb.test(e)?Nb(e)+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`}`):Function(`r`,`return {`+n.map(e=>jb.test(e)?Nb(e)+`:r()`:`[`+JSON.stringify(e)+`]:r()`).join(`,`)+`}`),this.compiledReader&&(t.next=this.compiledReader),t.propertyCount=e,this.compiledReader=t,t(q)}let n={};if(K.keyMap)for(let t=0;t<e;t++)n[Nb(K.decodeKey(this[t]))]=q();else for(let t=0;t<e;t++)n[Nb(this[t])]=q();return n}return e.slowReads=0,t}function Nb(e){if(typeof e==`string`)return e===`__proto__`?`__proto_`:e;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return e.toString();if(e==null)return e+``;throw Error(`Invalid property name type `+typeof e)}var Pb=Fb;function Fb(e){let t;if(e<16&&(t=Rb(e)))return t;if(e>64&&nb)return nb.decode(W.subarray(G,G+=e));let n=G+e,r=[];for(t=``;G<n;){let e=W[G++];if(!(e&128))r.push(e);else if((e&224)==192){let t=W[G++]&63,n=(e&31)<<6|t;n<128?r.push(65533):r.push(n)}else if((e&240)==224){let t=W[G++]&63,n=W[G++]&63,i=(e&31)<<12|t<<6|n;i<2048||i>=55296&&i<=57343?r.push(65533):r.push(i)}else if((e&248)==240){let t=W[G++]&63,n=W[G++]&63,i=W[G++]&63,a=(e&7)<<18|t<<12|n<<6|i;a<65536||a>1114111?r.push(65533):a>65535?(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023,r.push(a)):r.push(a)}else r.push(65533);r.length>=4096&&(t+=Ib.apply(String,r),r.length=0)}return r.length>0&&(t+=Ib.apply(String,r)),t}var Ib=String.fromCharCode;function Lb(e){let t=G,n=Array(e);for(let r=0;r<e;r++){let e=W[G++];if((e&128)>0){G=t;return}n[r]=e}return Ib.apply(String,n)}function Rb(e){if(e<4)if(e<2){if(e===0)return``;{let e=W[G++];if((e&128)>1){--G;return}return Ib(e)}}else{let t=W[G++],n=W[G++];if((t&128)>0||(n&128)>0){G-=2;return}if(e<3)return Ib(t,n);let r=W[G++];if((r&128)>0){G-=3;return}return Ib(t,n,r)}else{let t=W[G++],n=W[G++],r=W[G++],i=W[G++];if((t&128)>0||(n&128)>0||(r&128)>0||(i&128)>0){G-=4;return}if(e<6){if(e===4)return Ib(t,n,r,i);{let e=W[G++];if((e&128)>0){G-=5;return}return Ib(t,n,r,i,e)}}else if(e<8){let a=W[G++],o=W[G++];if((a&128)>0||(o&128)>0){G-=6;return}if(e<7)return Ib(t,n,r,i,a,o);let s=W[G++];if((s&128)>0){G-=7;return}return Ib(t,n,r,i,a,o,s)}else{let a=W[G++],o=W[G++],s=W[G++],c=W[G++];if((a&128)>0||(o&128)>0||(s&128)>0||(c&128)>0){G-=8;return}if(e<10){if(e===8)return Ib(t,n,r,i,a,o,s,c);{let e=W[G++];if((e&128)>0){G-=9;return}return Ib(t,n,r,i,a,o,s,c,e)}}else if(e<12){let l=W[G++],u=W[G++];if((l&128)>0||(u&128)>0){G-=10;return}if(e<11)return Ib(t,n,r,i,a,o,s,c,l,u);let d=W[G++];if((d&128)>0){G-=11;return}return Ib(t,n,r,i,a,o,s,c,l,u,d)}else{let l=W[G++],u=W[G++],d=W[G++],f=W[G++];if((l&128)>0||(u&128)>0||(d&128)>0||(f&128)>0){G-=12;return}if(e<14){if(e===12)return Ib(t,n,r,i,a,o,s,c,l,u,d,f);{let e=W[G++];if((e&128)>0){G-=13;return}return Ib(t,n,r,i,a,o,s,c,l,u,d,f,e)}}else{let p=W[G++],m=W[G++];if((p&128)>0||(m&128)>0){G-=14;return}if(e<15)return Ib(t,n,r,i,a,o,s,c,l,u,d,f,p,m);let h=W[G++];if((h&128)>0){G-=15;return}return Ib(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}}}}}function zb(e){return K.copyBuffers?Uint8Array.prototype.slice.call(W,G,G+=e):W.subarray(G,G+=e)}var Bb=new Float32Array(1),Vb=new Uint8Array(Bb.buffer,0,4);function Hb(){let e=W[G++],t=W[G++],n=(e&127)>>2;if(n===31)return t||e&3?NaN:e&128?-1/0:1/0;if(n===0){let n=((e&3)<<8|t)/(1<<24);return e&128?-n:n}return Vb[3]=e&128|(n>>1)+56,Vb[2]=(e&7)<<5|t>>3,Vb[1]=t<<5,Vb[0]=0,Bb[0]}Array(4096);var Ub=class{constructor(e,t){this.value=e,this.tag=t}};xb[0]=e=>new Date(e),xb[1]=e=>new Date(Math.round(e*1e3)),xb[2]=e=>{let t=BigInt(0);for(let n=0,r=e.byteLength;n<r;n++)t=BigInt(e[n])+(t<<BigInt(8));return t},xb[3]=e=>BigInt(-1)-xb[2](e),xb[4]=e=>+(e[1]+`e`+e[0]),xb[5]=e=>e[1]*Math.exp(e[0]*Math.log(2));var Wb=(e,t)=>{e-=57344;let n=hb[e];n&&n.isShared&&((hb.restoreStructures||=[])[e]=n),hb[e]=t,t.read=Mb(t)};xb[ab]=e=>{let t=e.length,n=e[1];Wb(e[0],n);let r={};for(let i=2;i<t;i++){let t=n[i-2];r[Nb(t)]=e[i]}return r},xb[14]=e=>yb?yb[0].slice(yb.position0,yb.position0+=e):new Ub(e,14),xb[15]=e=>yb?yb[1].slice(yb.position1,yb.position1+=e):new Ub(e,15);var Gb={Error,RegExp};xb[27]=e=>(Gb[e[0]]||Error)(e[1],e[2]);var Kb=e=>{if(W[G++]!=132){let e=Error(`Packed values structure must be followed by a 4 element array`);throw W.length<G&&(e.incomplete=!0),e}let t=e();if(!t||!t.length){let e=Error(`Packed values structure must be followed by a 4 element array`);throw e.incomplete=!0,e}return Cb=Cb?t.concat(Cb.slice(t.length)):t,Cb.prefixes=e(),Cb.suffixes=e(),e()};Kb.handlesRead=!0,xb[51]=Kb,xb[lb]=e=>{if(!Cb)if(K.getShared)nx();else return new Ub(e,lb);if(typeof e==`number`)return Cb[16+(e>=0?2*e:-2*e-1)];let t=Error(`No support for non-integer packed references yet`);throw e===void 0&&(t.incomplete=!0),t},xb[28]=e=>{bb||(bb=new Map,bb.id=0);let t=bb.id++,n=G,r=W[G],i;i=r>>5==4?[]:{};let a={target:i};bb.set(t,a);let o=e();return a.used?(Object.getPrototypeOf(i)!==Object.getPrototypeOf(o)&&(G=n,i=o,bb.set(t,{target:i}),o=e()),Object.assign(i,o)):(a.target=o,o)},xb[28].handlesRead=!0,xb[29]=e=>{let t=bb.get(e);return t.used=!0,t.target},xb[258]=e=>new Set(e),(xb[259]=e=>(K.mapsAsObjects&&(K.mapsAsObjects=!1,Tb=!0),e())).handlesRead=!0;function qb(e,t){return typeof e==`string`?e+t:e instanceof Array?e.concat(t):Object.assign({},e,t)}function Jb(){if(!Cb)if(K.getShared)nx();else throw Error(`No packed values available`);return Cb}var Yb=1399353956;Sb.push((e,t)=>{if(e>=225&&e<=255)return qb(Jb().prefixes[e-224],t);if(e>=28704&&e<=32767)return qb(Jb().prefixes[e-28672],t);if(e>=1879052288&&e<=2147483647)return qb(Jb().prefixes[e-1879048192],t);if(e>=216&&e<=223)return qb(t,Jb().suffixes[e-216]);if(e>=27647&&e<=28671)return qb(t,Jb().suffixes[e-27639]);if(e>=1811940352&&e<=1879048191)return qb(t,Jb().suffixes[e-1811939328]);if(e==Yb)return{packedValues:Cb,structures:hb.slice(0),version:t};if(e==55799)return t});var Xb=new Uint8Array(new Uint16Array([1]).buffer)[0]==1,Zb=[Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>`u`?{name:`BigUint64Array`}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>`u`?{name:`BigInt64Array`}:BigInt64Array,Float32Array,Float64Array],Qb=[64,68,69,70,71,72,77,78,79,85,86];for(let e=0;e<Zb.length;e++)$b(Zb[e],Qb[e]);function $b(e,t){let n=`get`+e.name.slice(0,-5),r;typeof e==`function`?r=e.BYTES_PER_ELEMENT:e=null;for(let i=0;i<2;i++){if(!i&&r==1)continue;let a=r==2?1:r==4?2:r==8?3:0;xb[i?t:t-4]=r==1||i==Xb?n=>{if(!e)throw Error(`Could not find typed array for code `+t);return!K.copyBuffers&&(r===1||r===2&&!(n.byteOffset&1)||r===4&&!(n.byteOffset&3)||r===8&&!(n.byteOffset&7))?new e(n.buffer,n.byteOffset,n.byteLength>>a):new e(Uint8Array.prototype.slice.call(n,0).buffer)}:r=>{if(!e)throw Error(`Could not find typed array for code `+t);let o=new DataView(r.buffer,r.byteOffset,r.byteLength),s=r.length>>a,c=new e(s),l=o[n];for(let e=0;e<s;e++)c[e]=l.call(o,e<<a,i);return c}}}function ex(){let e=tx(),t=G+q();for(let t=2;t<e;t++){let e=tx();G+=e}let n=G;return G=t,yb=[Fb(tx()),Fb(tx())],yb.position0=0,yb.position1=0,yb.postBundlePosition=G,G=n,q()}function tx(){let e=W[G++]&31;if(e>23)switch(e){case 24:e=W[G++];break;case 25:e=wb.getUint16(G),G+=2;break;case 26:e=wb.getUint32(G),G+=4;break}return e}function nx(){if(K.getShared){let e=rx(()=>(W=null,K.getShared()))||{},t=e.structures||[];K.sharedVersion=e.version,Cb=K.sharedValues=e.packedValues,hb===!0?K.structures=hb=t:hb.splice.apply(hb,[0,t.length].concat(t))}}function rx(e){let t=rb,n=G,r=mb,i=_b,a=vb,o=gb,s=pb,c=bb,l=yb,u=new Uint8Array(W.slice(0,rb)),d=hb,f=K,p=Db,m=e();return rb=t,G=n,mb=r,_b=i,vb=a,gb=o,pb=s,bb=c,yb=l,W=u,Db=p,hb=d,K=f,wb=new DataView(W.buffer,W.byteOffset,W.byteLength),m}function ix(){W=null,bb=null,hb=null}var ax=Array(147);for(let e=0;e<256;e++)ax[e]=+(`1e`+Math.floor(45.15-e*.30103));var ox=new kb({useRecords:!1}),sx=ox.decode;ox.decodeMultiple;var cx={NEVER:0,ALWAYS:1,DECIMAL_ROUND:3,DECIMAL_FIT:4},lx;try{lx=new TextEncoder}catch{}var ux,dx,fx=typeof globalThis==`object`&&globalThis.Buffer,px=fx!==void 0,mx=px?fx.allocUnsafeSlow:Uint8Array,hx=px?fx:Uint8Array,gx=256,_x=px?4294967296:2144337920,vx,J,yx,Y=0,bx,xx=null,Sx=61440,Cx=/[\u0080-\uFFFF]/,wx=Symbol(`record-id`),Tx=class extends kb{constructor(e){super(e),this.offset=0;let t,n,r,i,a;e||={};let o=hx.prototype.utf8Write?function(e,t){return J.utf8Write(e,t,J.byteLength-t)}:lx&&lx.encodeInto?function(e,t){return lx.encodeInto(e,J.subarray(t)).written}:!1,s=this,c=e.structures||e.saveStructures,l=e.maxSharedStructures;if(l??=c?128:0,l>8190)throw Error(`Maximum maxSharedStructure is 8190`);let u=e.sequential;u&&(l=0),this.structures||=[],this.saveStructures&&(this.saveShared=this.saveStructures);let d,f,p=e.sharedValues,m;if(p){m=Object.create(null);for(let e=0,t=p.length;e<t;e++)m[p[e]]=e}let h=[],g=0,_=0;this.mapEncode=function(e,t){if(this._keyMap&&!this._mapped)switch(e.constructor.name){case`Array`:e=e.map(e=>this.encodeKeys(e));break}return this.encode(e,t)},this.encode=function(o,c){if(J||(J=new mx(8192),yx=new DataView(J.buffer,0,8192),Y=0),bx=J.length-10,bx-Y<2048?(J=new mx(J.length),yx=new DataView(J.buffer,0,J.length),bx=J.length-10,Y=0):c===512&&(Y=Y+7&2147483640),t=Y,s.useSelfDescribedHeader&&(yx.setUint32(Y,3654940416),Y+=3),a=s.structuredClone?new Map:null,s.bundleStrings&&typeof o!=`string`?(xx=[],xx.size=1/0):xx=null,n=s.structures,n){if(n.uninitialized){let e=s.getShared()||{};s.structures=n=e.structures||[],s.sharedVersion=e.version;let t=s.sharedValues=e.packedValues;if(t){m={};for(let e=0,n=t.length;e<n;e++)m[t[e]]=e}}let e=n.length;if(e>l&&!u&&(e=l),!n.transitions){n.transitions=Object.create(null);for(let t=0;t<e;t++){let e=n[t];if(!e)continue;let r,i=n.transitions;for(let n=0,a=e.length;n<a;n++){i[wx]===void 0&&(i[wx]=t);let a=e[n];r=i[a],r||=i[a]=Object.create(null),i=r}i[wx]=t|1048576}}u||(n.nextId=e)}if(r&&=!1,i=n||[],f=m,e.pack){let t=new Map;if(t.values=[],t.encoder=s,t.maxValues=e.maxPrivatePackedValues||(m?16:1/0),t.objectMap=m||!1,t.samplingPackedValues=d,jx(o,t),t.values.length>0){J[Y++]=216,J[Y++]=51,Ox(4);let e=t.values;v(e),Ox(0),Ox(0),f=Object.create(m||null);for(let t=0,n=e.length;t<n;t++)f[e[t]]=t}}vx=c&Ux;try{if(vx)return;if(v(o),xx&&Ix(t,v),s.offset=Y,a&&a.idsToInsert){Y+=a.idsToInsert.length*2,Y>bx&&b(Y),s.offset=Y;let e=Fx(J.subarray(t,Y),a.idsToInsert);return a=null,e}return c&512?(J.start=t,J.end=Y,J):J.subarray(t,Y)}finally{if(n){if(_<10&&_++,n.length>l&&(n.length=l),g>1e4)n.transitions=null,_=0,g=0,h.length>0&&(h=[]);else if(h.length>0&&!u){for(let e=0,t=h.length;e<t;e++)h[e][wx]=void 0;h=[]}}if(r&&s.saveShared){s.structures.length>l&&(s.structures=s.structures.slice(0,l));let e=J.subarray(t,Y);return s.updateSharedData()===!1?s.encode(o):e}c&1024&&(Y=t)}},this.findCommonStringsToPack=()=>(d=new Map,m||=Object.create(null),e=>{let t=e&&e.threshold||4,n=this.pack?e.maxPrivatePackedValues||16:0;p||=this.sharedValues=[];for(let[e,i]of d)i.count>t&&(m[e]=n++,p.push(e),r=!0);for(;this.saveShared&&this.updateSharedData()===!1;);d=null});let v=n=>{Y>bx&&(J=b(Y));var r=typeof n,i;if(r===`string`){if(f){let t=f[n];if(t>=0){t<16?J[Y++]=t+224:(J[Y++]=198,t&1?v(15-t>>1):v(t-16>>1));return}else if(d&&!e.pack){let e=d.get(n);e?e.count++:d.set(n,{count:1})}}let r=n.length;if(xx&&r>=4&&r<1024){if((xx.size+=r)>Sx){let e,n=(xx[0]?xx[0].length*3+xx[1].length:0)+10;Y+n>bx&&(J=b(Y+n)),J[Y++]=217,J[Y++]=223,J[Y++]=249,J[Y++]=xx.position?132:130,J[Y++]=26,e=Y-t,Y+=4,xx.position&&Ix(t,v),xx=[``,``],xx.size=0,xx.position=e}let e=Cx.test(n);xx[+!e]+=n,J[Y++]=e?206:207,v(r);return}let a;a=r<32?1:r<256?2:r<65536?3:5;let s=r*3;if(Y+s>bx&&(J=b(Y+s)),r<64||!o){let e,t,o,s=Y+a;for(e=0;e<r;e++)t=n.charCodeAt(e),t<128?J[s++]=t:t<2048?(J[s++]=t>>6|192,J[s++]=t&63|128):(t&64512)==55296&&((o=n.charCodeAt(e+1))&64512)==56320?(t=65536+((t&1023)<<10)+(o&1023),e++,J[s++]=t>>18|240,J[s++]=t>>12&63|128,J[s++]=t>>6&63|128,J[s++]=t&63|128):(J[s++]=t>>12|224,J[s++]=t>>6&63|128,J[s++]=t&63|128);i=s-Y-a}else i=o(n,Y+a,s);i<24?J[Y++]=96|i:i<256?(a<2&&J.copyWithin(Y+2,Y+1,Y+1+i),J[Y++]=120,J[Y++]=i):i<65536?(a<3&&J.copyWithin(Y+3,Y+2,Y+2+i),J[Y++]=121,J[Y++]=i>>8,J[Y++]=i&255):(a<5&&J.copyWithin(Y+5,Y+3,Y+3+i),J[Y++]=122,yx.setUint32(Y,i),Y+=4),Y+=i}else if(r===`number`)if(!this.alwaysUseFloat&&n>>>0===n)n<24?J[Y++]=n:n<256?(J[Y++]=24,J[Y++]=n):n<65536?(J[Y++]=25,J[Y++]=n>>8,J[Y++]=n&255):(J[Y++]=26,yx.setUint32(Y,n),Y+=4);else if(!this.alwaysUseFloat&&n>>0===n)n>=-24?J[Y++]=31-n:n>=-256?(J[Y++]=56,J[Y++]=~n):n>=-65536?(J[Y++]=57,yx.setUint16(Y,~n),Y+=2):(J[Y++]=58,yx.setUint32(Y,~n),Y+=4);else if(!this.alwaysUseFloat&&n<0&&n>=-4294967296&&Math.floor(n)===n)J[Y++]=58,yx.setUint32(Y,-1-n),Y+=4;else{let e;if((e=this.useFloat32)>0&&n<4294967296&&n>=-2147483648){J[Y++]=250,yx.setFloat32(Y,n);let t;if(e<4||(t=n*ax[(J[Y]&127)<<1|J[Y+1]>>7])>>0===t){Y+=4;return}else Y--}J[Y++]=251,yx.setFloat64(Y,n),Y+=8}else if(r===`object`)if(!n)J[Y++]=246;else{if(a){let e=a.get(n);if(e){if(J[Y++]=216,J[Y++]=29,J[Y++]=25,!e.references){let t=a.idsToInsert||=[];e.references=[],t.push(e)}e.references.push(Y-t),Y+=2;return}else a.set(n,{offset:Y-t})}let e=n.constructor;if(e===Object)this.skipFunction===!0&&(n=Object.fromEntries([...Object.keys(n).filter(e=>typeof n[e]!=`function`).map(e=>[e,n[e]])])),y(n);else if(e===Array){i=n.length,i<24?J[Y++]=128|i:Ox(i);for(let e=0;e<i;e++)v(n[e])}else if(e===Map)if((this.mapsAsObjects?this.useTag259ForMaps!==!1:this.useTag259ForMaps)&&(J[Y++]=217,J[Y++]=1,J[Y++]=3),i=n.size,i<24?J[Y++]=160|i:i<256?(J[Y++]=184,J[Y++]=i):i<65536?(J[Y++]=185,J[Y++]=i>>8,J[Y++]=i&255):(J[Y++]=186,yx.setUint32(Y,i),Y+=4),s.keyMap)for(let[e,t]of n)v(s.encodeKey(e)),v(t);else for(let[e,t]of n)v(e),v(t);else{for(let e=0,t=ux.length;e<t;e++){let t=dx[e];if(n instanceof t){let t=ux[e],r=t.tag;r??=t.getTag&&t.getTag.call(this,n),r<24?J[Y++]=192|r:r<256?(J[Y++]=216,J[Y++]=r):r<65536?(J[Y++]=217,J[Y++]=r>>8,J[Y++]=r&255):r>-1&&(J[Y++]=218,yx.setUint32(Y,r),Y+=4),t.encode.call(this,n,v,b);return}}if(n[Symbol.iterator]){if(vx){let e=Error(`Iterable should be serialized as iterator`);throw e.iteratorNotHandled=!0,e}J[Y++]=159;for(let e of n)v(e);J[Y++]=255;return}if(n[Symbol.asyncIterator]||Ax(n)){let e=Error(`Iterable/blob should be serialized as iterator`);throw e.iteratorNotHandled=!0,e}if(this.useToJSON&&n.toJSON){let e=n.toJSON();if(e!==n)return v(e)}y(n)}}else if(r===`boolean`)J[Y++]=n?245:244;else if(r===`bigint`){if(n<BigInt(1)<<BigInt(64)&&n>=0)J[Y++]=27,yx.setBigUint64(Y,n);else if(n>-(BigInt(1)<<BigInt(64))&&n<0)J[Y++]=59,yx.setBigUint64(Y,-n-BigInt(1));else if(this.largeBigIntToFloat)J[Y++]=251,yx.setFloat64(Y,Number(n));else{n>=BigInt(0)?J[Y++]=194:(J[Y++]=195,n=BigInt(-1)-n);let e=[];for(;n;)e.push(Number(n&BigInt(255))),n>>=BigInt(8);Px(new Uint8Array(e.reverse()),b);return}Y+=8}else if(r===`undefined`)J[Y++]=247;else throw Error(`Unknown type: `+r)},y=this.useRecords===!1?this.variableMapSize?e=>{let t=Object.keys(e),n=Object.values(e),r=t.length;if(r<24?J[Y++]=160|r:r<256?(J[Y++]=184,J[Y++]=r):r<65536?(J[Y++]=185,J[Y++]=r>>8,J[Y++]=r&255):(J[Y++]=186,yx.setUint32(Y,r),Y+=4),s.keyMap)for(let e=0;e<r;e++)v(s.encodeKey(t[e])),v(n[e]);else for(let e=0;e<r;e++)v(t[e]),v(n[e])}:e=>{J[Y++]=185;let n=Y-t;Y+=2;let r=0;if(s.keyMap)for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(v(s.encodeKey(t)),v(e[t]),r++);else for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(v(t),v(e[t]),r++);J[n+++t]=r>>8,J[n+t]=r&255}:(e,t)=>{let n,a=i.transitions||=Object.create(null),o=0,s=0,c,u;if(this.keyMap){u=Object.keys(e).map(e=>this.encodeKey(e)),s=u.length;for(let e=0;e<s;e++){let t=u[e];n=a[t],n||(n=a[t]=Object.create(null),o++),a=n}}else for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&(n=a[t],n||(a[wx]&1048576&&(c=a[wx]&65535),n=a[t]=Object.create(null),o++),a=n,s++);let d=a[wx];if(d!==void 0)d&=65535,J[Y++]=217,J[Y++]=d>>8|224,J[Y++]=d&255;else if(u||=a.__keys__||=Object.keys(e),c===void 0?(d=i.nextId++,d||(d=0,i.nextId=1),d>=gx&&(i.nextId=(d=l)+1)):d=c,i[d]=u,d<l){J[Y++]=217,J[Y++]=d>>8|224,J[Y++]=d&255,a=i.transitions;for(let e=0;e<s;e++)(a[wx]===void 0||a[wx]&1048576)&&(a[wx]=d),a=a[u[e]];a[wx]=d|1048576,r=!0}else{if(a[wx]=d,yx.setUint32(Y,3655335680),Y+=3,o&&(g+=_*o),h.length>=gx-l&&(h.shift()[wx]=void 0),h.push(a),Ox(s+2),v(57344+d),v(u),t)return;for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&v(e[t]);return}if(s<24?J[Y++]=128|s:Ox(s),!t)for(let t in e)(typeof e.hasOwnProperty!=`function`||e.hasOwnProperty(t))&&v(e[t])},b=e=>{let n;if(e>16777216){if(e-t>_x)throw Error(`Encoded buffer would be larger than maximum buffer size`);n=Math.min(_x,Math.round(Math.max((e-t)*(e>67108864?1.25:2),4194304)/4096)*4096)}else n=(Math.max(e-t<<2,J.length-1)>>12)+1<<12;let r=new mx(n);return yx=new DataView(r.buffer,0,n),J.copy?J.copy(r,0,t,e):r.set(J.slice(t,e)),Y-=t,t=0,bx=r.length-10,J=r},ee=100,x=1e3;this.encodeAsIterable=function(e,t){return ie(e,t,te)},this.encodeAsAsyncIterable=function(e,t){return ie(e,t,ae)};function*te(e,n,r){let i=e.constructor;if(i===Object){let t=s.useRecords!==!1;t?y(e,!0):Ex(Object.keys(e).length,160);for(let r in e){let i=e[r];t||v(r),i&&typeof i==`object`?n[r]?yield*te(i,n[r]):yield*ne(i,n,r):v(i)}}else if(i===Array){let r=e.length;Ox(r);for(let i=0;i<r;i++){let r=e[i];r&&(typeof r==`object`||Y-t>ee)?n.element?yield*te(r,n.element):yield*ne(r,n,`element`):v(r)}}else if(e[Symbol.iterator]&&!e.buffer){J[Y++]=159;for(let r of e)r&&(typeof r==`object`||Y-t>ee)?n.element?yield*te(r,n.element):yield*ne(r,n,`element`):v(r);J[Y++]=255}else Ax(e)?(Ex(e.size,64),yield J.subarray(t,Y),yield e,re()):e[Symbol.asyncIterator]?(J[Y++]=159,yield J.subarray(t,Y),yield e,re(),J[Y++]=255):v(e);r&&Y>t?yield J.subarray(t,Y):Y-t>ee&&(yield J.subarray(t,Y),re())}function*ne(e,n,r){let i=Y-t;try{v(e),Y-t>ee&&(yield J.subarray(t,Y),re())}catch(a){if(a.iteratorNotHandled)n[r]={},Y=t+i,yield*te.call(this,e,n[r]);else throw a}}function re(){ee=x,s.encode(null,Ux)}function ie(e,t,n){return ee=t&&t.chunkThreshold?x=t.chunkThreshold:100,e&&typeof e==`object`?(s.encode(null,Ux),n(e,s.iterateProperties||={},!0)):[s.encode(e)]}async function*ae(e,t){for(let n of te(e,t,!0)){let e=n.constructor;if(e===hx||e===Uint8Array)yield n;else if(Ax(n)){let e=n.stream().getReader(),t;for(;!(t=await e.read()).done;)yield t.value}else if(n[Symbol.asyncIterator])for await(let e of n)re(),e?yield*ae(e,t.async||={}):yield s.encode(e);else yield n}}}useBuffer(e){J=e,yx=new DataView(J.buffer,J.byteOffset,J.byteLength),Y=0}clearSharedData(){this.structures&&=[],this.sharedValues&&=void 0}updateSharedData(){let e=this.sharedVersion||0;this.sharedVersion=e+1;let t=this.structures.slice(0),n=new Dx(t,this.sharedValues,this.sharedVersion),r=this.saveShared(n,t=>(t&&t.version||0)==e);return r===!1?(n=this.getShared()||{},this.structures=n.structures||[],this.sharedValues=n.packedValues,this.sharedVersion=n.version,this.structures.nextId=this.structures.length):t.forEach((e,t)=>this.structures[t]=e),r}};function Ex(e,t){e<24?J[Y++]=t|e:e<256?(J[Y++]=t|24,J[Y++]=e):e<65536?(J[Y++]=t|25,J[Y++]=e>>8,J[Y++]=e&255):(J[Y++]=t|26,yx.setUint32(Y,e),Y+=4)}var Dx=class{constructor(e,t,n){this.structures=e,this.packedValues=t,this.version=n}};function Ox(e){e<24?J[Y++]=128|e:e<256?(J[Y++]=152,J[Y++]=e):e<65536?(J[Y++]=153,J[Y++]=e>>8,J[Y++]=e&255):(J[Y++]=154,yx.setUint32(Y,e),Y+=4)}var kx=typeof Blob>`u`?function(){}:Blob;function Ax(e){if(e instanceof kx)return!0;let t=e[Symbol.toStringTag];return t===`Blob`||t===`File`}function jx(e,t){switch(typeof e){case`string`:if(e.length>3){if(t.objectMap[e]>-1||t.values.length>=t.maxValues)return;let n=t.get(e);if(n)++n.count==2&&t.values.push(e);else if(t.set(e,{count:1}),t.samplingPackedValues){let n=t.samplingPackedValues.get(e);n?n.count++:t.samplingPackedValues.set(e,{count:1})}}break;case`object`:if(e)if(e instanceof Array)for(let n=0,r=e.length;n<r;n++)jx(e[n],t);else{let r=!t.encoder.useRecords;for(var n in e)e.hasOwnProperty(n)&&(r&&jx(n,t),jx(e[n],t))}break;case`function`:console.log(e)}}var Mx=new Uint8Array(new Uint16Array([1]).buffer)[0]==1;dx=[Date,Set,Error,RegExp,Ub,ArrayBuffer,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array,typeof BigUint64Array>`u`?function(){}:BigUint64Array,Int8Array,Int16Array,Int32Array,typeof BigInt64Array>`u`?function(){}:BigInt64Array,Float32Array,Float64Array,Dx],ux=[{tag:1,encode(e,t){let n=e.getTime()/1e3;(this.useTimestamp32||e.getMilliseconds()===0)&&n>=0&&n<4294967296?(J[Y++]=26,yx.setUint32(Y,n),Y+=4):(J[Y++]=251,yx.setFloat64(Y,n),Y+=8)}},{tag:258,encode(e,t){t(Array.from(e))}},{tag:27,encode(e,t){t([e.name,e.message])}},{tag:27,encode(e,t){t([`RegExp`,e.source,e.flags])}},{getTag(e){return e.tag},encode(e,t){t(e.value)}},{encode(e,t,n){Px(e,n)}},{getTag(e){if(e.constructor===Uint8Array&&(this.tagUint8Array||px&&this.tagUint8Array!==!1))return 64},encode(e,t,n){Px(e,n)}},Nx(68,1),Nx(69,2),Nx(70,4),Nx(71,8),Nx(72,1),Nx(77,2),Nx(78,4),Nx(79,8),Nx(85,4),Nx(86,8),{encode(e,t){let n=e.packedValues||[],r=e.structures||[];if(n.values.length>0){J[Y++]=216,J[Y++]=51,Ox(4);let e=n.values;t(e),Ox(0),Ox(0),packedObjectMap=Object.create(sharedPackedObjectMap||null);for(let t=0,n=e.length;t<n;t++)packedObjectMap[e[t]]=t}if(r){yx.setUint32(Y,3655335424),Y+=3;let n=r.slice(0);n.unshift(57344),n.push(new Ub(e.version,1399353956)),t(n)}else t(new Ub(e.version,1399353956))}}];function Nx(e,t){return!Mx&&t>1&&(e-=4),{tag:e,encode:function(e,t){let n=e.byteLength,r=e.byteOffset||0,i=e.buffer||e;t(px?fx.from(i,r,n):new Uint8Array(i,r,n))}}}function Px(e,t){let n=e.byteLength;n<24?J[Y++]=64+n:n<256?(J[Y++]=88,J[Y++]=n):n<65536?(J[Y++]=89,J[Y++]=n>>8,J[Y++]=n&255):(J[Y++]=90,yx.setUint32(Y,n),Y+=4),Y+n>=J.length&&t(Y+n),J.set(e.buffer?e:new Uint8Array(e),Y),Y+=n}function Fx(e,t){let n,r=t.length*2,i=e.length-r;t.sort((e,t)=>e.offset>t.offset?1:-1);for(let n=0;n<t.length;n++){let r=t[n];r.id=n;for(let t of r.references)e[t++]=n>>8,e[t]=n&255}for(;n=t.pop();){let t=n.offset;e.copyWithin(t+r,t,i),r-=2;let a=t+r;e[a++]=216,e[a++]=28,i=t}return e}function Ix(e,t){yx.setUint32(xx.position+e,Y-xx.position-e+1);let n=xx;xx=null,t(n[0]),t(n[1])}var Lx=new Tx({useRecords:!1}),Rx=Lx.encode;Lx.encodeAsIterable,Lx.encodeAsAsyncIterable;var{NEVER:zx,ALWAYS:Bx,DECIMAL_ROUND:Vx,DECIMAL_FIT:Hx}=cx,Ux=2048,Wx=new Tx({useRecords:!1,variableMapSize:!0,mapsAsObjects:!0});function Gx(e){return Uint8Array.from(Wx.encode(Sy(e)))}function Kx(e){let t;try{t=Wx.decode(e)}catch(e){throw Error(`Cannot decode JWK: the payload is not valid CBOR: ${e.message}`)}if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`Cannot decode JWK: the CBOR payload does not hold a map`);return t}var qx=class e extends n_{constructor(e,t,n,r){super(),this.algorithm=e,this.publicJwk=t,this.verifier=n,this.scheme=r}static async fromJwk(t){let n=fy(t),r=by(t,n);return new e(n,r,await Uy(n,r),Ry.forJwk(n,r))}static async fromBytes(t){return e.fromJwk(Kx(t))}getAlgorithm(){return this.algorithm.alg}getPublicJwk(){return{...this.publicJwk}}async getPublicKeyAsBytes(){return Gx(this.publicJwk)}getRawPublicKeyBytes(){return this.verifier.publicKeyBytes}getScheme(){return this.scheme}async verify(e,t){try{return await this.verifier.verify(e,t)}catch{return!1}}},Jx=class e{static createPrivateSignatureKey(e,t){switch(e){case Ja.SECP256K1:return new ty(t);case Ja.ML_DSA_65:return new a_(t);case Ja.ED25519:return new iy(t.slice(0,32));default:throw`Not supported signature scheme ID: ${e}`}}static createVirtualBlockchainPrivateSignature(e,t,n,r){let i=new Uint8Array([...n,...r]),a=new TextEncoder,o=e.deriveKeyNoSalt(i,a.encode(`VB_ACTOR_KEY`),32);switch(t){case Ja.ML_DSA_65:return new a_(o);case Ja.SECP256K1:return ty.genFromSeed(o);case Ja.ED25519:return new iy(o.slice(0,32));default:throw`Not supported signature scheme ID: ${t}`}}static deriveKeyFromPassword(t,n=Cv.PBKDF2,r=Xg.AES_256_GCM){let i=e.createSymmetricEncryptionKeyScheme(r).getDefaultKeyLength(),a=e.createDefaultPBKDF().deriveKeyNoSalt(t,i);return e.createSymmetricEncryptionKey(r,a)}createDecapsulationKey(e,t){switch(e){default:throw`Not supported encryption scheme ID: ${e}`}}createVirtualBlockchainDecapsulationKey(e,t,n){switch(e){default:throw`Not supported encryption scheme ID: ${e}`}}async createPublicSignatureKey(t,n){return e.createPublicSignatureKey(t,n)}static async createPublicSignatureKey(e,t){switch(e){case Ja.SECP256K1:return new ey(t);case Ja.ML_DSA_65:return new i_(t);case Ja.ED25519:return new ry(t);case Ja.JWK:return qx.fromBytes(t);default:throw Error(`Not supported signature scheme ID: ${e}`)}}static async createPublicEncryptionKey(e,t){switch(e){case Pv.ML_KEM_768_AES_256_GCM:return new Zv(t);default:throw Error(`Not supported scheme ID: ${e}`)}}static async createPrivateDecryptionKey(e,t){switch(e){case Pv.ML_KEM_768_AES_256_GCM:return await Qv.genFromSeed(t);default:throw Error(`Not supported scheme ID: ${e}`)}}createSymmetricEncryptionKey(t,n){return e.createSymmetricEncryptionKey(t,n)}static createSymmetricEncryptionKey(e,t){switch(e){case Xg.AES_256_GCM:return Qg.createFromBytes(t);default:throw`Not supported encryption scheme ID: ${e}`}}static createSymmetricEncryptionKeyScheme(e){switch(e){case Xg.AES_256_GCM:return new Zg;default:throw`Not supported encryption scheme ID: ${e}`}}static createCryptographicHash(e){switch(e){case vv.SHA256:return new yv;default:throw`Not supported hash scheme ID: ${e}`}}static createDefaultCryptographicHash(){return new yv}static createDefaultPBKDF(){return new Tv}static createDefaultKDF(){return new Nv}static createSignatureScheme(e){switch(e){case Ja.SECP256K1:return new $v;case Ja.ML_DSA_65:return new r_;case Ja.ED25519:return new ny;default:throw Error(`Not supported signature scheme ID: ${e}`)}}},Yx=class e{static PKE_KEY=`PKE`;static SK_PKE_KEY=`SK`;static PK_PKE_KEY=`PK`;static PKE_SCHEMES=[{algoId:Pv.ML_KEM_768_AES_256_GCM,label:`MLKEM768AES256GCM`}];static createHexHCVPkeEncoder(){return new e(Og.bytesToHexEncoder())}static createBase64HCVPkeEncoder(){return new e(Og.bytesToBase64Encoder())}constructor(e){this.stringEncoder=e}async decodePrivateDecryptionKey(t){let n=Mg.decode(t);for(let{algoId:t,label:r}of e.PKE_SCHEMES)if(n.matchesKeys(e.PKE_KEY,r,e.SK_PKE_KEY))return await Jx.createPrivateDecryptionKey(t,this.stringEncoder.decode(n.getValue()));throw Error(`Invalid private key format: no scheme key found`)}async decodePublicEncryptionKey(t){let n=Mg.decode(t);for(let{algoId:t,label:r}of e.PKE_SCHEMES)if(n.matchesKeys(e.PKE_KEY,r,e.PK_PKE_KEY))return Jx.createPublicEncryptionKey(t,this.stringEncoder.decode(n.getValue()));throw Error(`Invalid private key format: no scheme key found`)}async encodePrivateDecryptionKey(t){return Mg.encode(e.PKE_KEY,`MLKEM768AES256GCM`,e.SK_PKE_KEY,this.stringEncoder.encode(t.getRawPrivateKey()))}async encodePublicEncryptionKey(t){return Mg.encode(e.PKE_KEY,`MLKEM768AES256GCM`,e.PK_PKE_KEY,this.stringEncoder.encode(await t.getRawPublicKey()))}};function Xx(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var Zx={exports:{}},Qx=Zx.exports={},$x,eS;function tS(){throw Error(`setTimeout has not been defined`)}function nS(){throw Error(`clearTimeout has not been defined`)}(function(){try{$x=typeof setTimeout==`function`?setTimeout:tS}catch{$x=tS}try{eS=typeof clearTimeout==`function`?clearTimeout:nS}catch{eS=nS}})();function rS(e){if($x===setTimeout)return setTimeout(e,0);if(($x===tS||!$x)&&setTimeout)return $x=setTimeout,setTimeout(e,0);try{return $x(e,0)}catch{try{return $x.call(null,e,0)}catch{return $x.call(this,e,0)}}}function iS(e){if(eS===clearTimeout)return clearTimeout(e);if((eS===nS||!eS)&&clearTimeout)return eS=clearTimeout,clearTimeout(e);try{return eS(e)}catch{try{return eS.call(null,e)}catch{return eS.call(this,e)}}}var aS=[],oS=!1,sS,cS=-1;function lS(){!oS||!sS||(oS=!1,sS.length?aS=sS.concat(aS):cS=-1,aS.length&&uS())}function uS(){if(!oS){var e=rS(lS);oS=!0;for(var t=aS.length;t;){for(sS=aS,aS=[];++cS<t;)sS&&sS[cS].run();cS=-1,t=aS.length}sS=null,oS=!1,iS(e)}}Qx.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];aS.push(new dS(e,t)),aS.length===1&&!oS&&rS(uS)};function dS(e,t){this.fun=e,this.array=t}dS.prototype.run=function(){this.fun.apply(null,this.array)},Qx.title=`browser`,Qx.browser=!0,Qx.env={},Qx.argv=[],Qx.version=``,Qx.versions={};function fS(){}Qx.on=fS,Qx.addListener=fS,Qx.once=fS,Qx.off=fS,Qx.removeListener=fS,Qx.removeAllListeners=fS,Qx.emit=fS,Qx.prependListener=fS,Qx.prependOnceListener=fS,Qx.listeners=function(e){return[]},Qx.binding=function(e){throw Error(`process.binding is not supported`)},Qx.cwd=function(){return`/`},Qx.chdir=function(e){throw Error(`process.chdir is not supported`)},Qx.umask=function(){return 0};var pS=Zx.exports,mS=Xx(pS),hS=class{async getPkmsCredential(){let e=mS.env.PKMS_API_KEY;if(e===void 0)throw Error(`PKMS_API_KEY environment variable is not set.`);return e}},gS=`https://pkms.admin.carmentis.io`,_S=class e{static createFromKeyId(t){return new e(t)}credentialProvider=new hS;constructor(e,t={host:gS}){this.keyId=e,this.options=t}getKeyId(){return this.keyId}getPrivateKeyAsBytes(){throw Error(`Private key material cannot be exported.`)}async getPublicKey(){let e=await fetch(`${this.options.host}/api/keys/${this.keyId}/pk`,{method:`GET`,headers:{"Content-Type":`application/json`}});if(!e.ok)throw Error(`Failed to fetch public key with id ${this.keyId} at ${this.options.host}: ${e.statusText}.`);let t=(await e.json()).publicKey;if(t===void 0)throw Error(`Failed to fetch public key: no "publicKey" field found in response body.`);return new ey(new Uint8Array(Yg.from(t,`base64`)))}getScheme(){return new $v}getSignatureSchemeId(){return Ja.PKMS_SECP256K1}getSignatureSize(){return this.getScheme().getSignatureSize()}setCredentialProvider(e){this.credentialProvider=e}async sign(e){let t=await this.credentialProvider.getPkmsCredential();try{let n=await fetch(`${this.options.host}/api/sign`,{method:`POST`,headers:{authorization:`Bearer ${t}`,"Content-Type":`application/json`},body:JSON.stringify({keyId:this.keyId,base64EncodedData:Yg.from(e).toString(`base64`)})});if(n.ok){let e=await n.json();return Yg.from(e.signature,`base64`)}else throw Error(`Failed to sign data.`)}catch(e){throw e}}},vS=class extends ey{getSignatureSchemeId(){return Ja.PKMS_SECP256K1}},yS=`sig`,bS=`secp256k1`,xS=`mldsa65`,SS=`pkms`,CS=`pk`,wS=`sk`,TS=`did`,ES=`jwk`,DS=class e extends t_{constructor(e,t,n,r,i){super(),this.algorithm=e,this.privateJwk=t,this.publicJwk=n,this.signer=r,this.scheme=i}static async gen(t=`Ed25519`,n={}){return e.fromJwk(await Wy(t,n))}static async fromJwk(t){let n=fy(t),r=xy(t,n),i=by(t,n);return new e(n,r,i,await Hy(n,r),Ry.forJwk(n,i))}static async fromBytes(t){return e.fromJwk(Kx(t))}getAlgorithm(){return this.algorithm.alg}getPrivateJwk(){return{...this.privateJwk}}getPublicJwk(){return{...this.publicJwk}}getPrivateKeyAsBytes(){return Gx(this.privateJwk)}getRawPrivateKeyBytes(){return this.signer.privateKeyBytes}async getPublicKey(){return qx.fromJwk(this.publicJwk)}getScheme(){return this.scheme}async sign(e){return this.signer.sign(e)}},OS=class{bytesEncoder=Og.bytesToHexEncoder();async isAcceptingPublicKeyEncodingRequest(e){return this.getPublicKeySchemeTags(e).length>0}async isAcceptingPrivateKeyEncodingRequest(e){return this.getPrivateKeySchemeTags(e).length>0}async encodePublicKey(e){if(!this.isAcceptingPublicKeyEncodingRequest(e))throw Error(`unexpected public key type`);if(e instanceof qx)return`did:jwk:${ky(JSON.stringify(e.getPublicJwk()))}`;let t=this.getPublicKeySchemeTags(e),n=await this.getPublicKeyPayload(e);return[`sig`,...t,`pk`,n].join(`:`)}async encodePrivateKey(e){if(!this.isAcceptingPrivateKeyEncodingRequest(e))throw Error(`unexpected private key type`);let t=this.getPrivateKeySchemeTags(e),n=await this.getPrivateKeyPayload(e);return[`sig`,...t,`sk`,n].join(`:`)}async getPublicKeyPayload(e){return this.bytesEncoder.encode(await e.getPublicKeyAsBytes())}async getPrivateKeyPayload(e){return e instanceof _S?e.getKeyId():this.bytesEncoder.encode(e.getPrivateKeyAsBytes())}getPublicKeySchemeTags(e){return e instanceof ey?[bS]:e instanceof i_?[xS]:e instanceof vS?[SS,bS]:e instanceof qx?[`jwk`]:[]}getPrivateKeySchemeTags(e){return e instanceof ty?[bS]:e instanceof a_?[xS]:e instanceof _S?[SS,bS]:e instanceof DS?[`jwk`]:[]}},kS=`SIG`,AS=`SK`,jS=`PK`,MS=class e{static logger=k.getLogger([`HCVSignatureDecoder`]);bytesEncoder=Og.bytesToHexEncoder();constructor(e){this.labels=e}async isAcceptingPrivateKeyDecodingRequest(t){try{let n=Mg.decode(t);return e.logger.debug(`Attempt to decode private key for ${this.labels}: found ${n.getKeys()}`),n.matchesKeys(kS,...this.labels,AS)}catch(t){return e.logger.debug(`Fail to decode private key for ${this.labels}: ${t}`),!1}}async isAcceptingPublicKeyDecodingRequest(e){try{return Mg.decode(e).matchesKeys(kS,...this.labels,jS)}catch{return!1}}static getSignatureKey(){return kS}static getSkSignatureKey(){return AS}static getPkSignatureKey(){return jS}},NS=class extends MS{async decodePrivateKey(e){let t=Mg.decode(e),n=this.bytesEncoder.decode(t.getValue());return this.bootstrapPrivateKey(n)}async decodePublicKey(e){let t=Mg.decode(e),n=this.bytesEncoder.decode(t.getValue());return this.bootstrapPublicKey(n)}},PS=class e extends NS{static label=`SECP256K1`;constructor(){super([e.label])}bootstrapPrivateKey(e){return new ty(e)}bootstrapPublicKey(e){return new ey(e)}},FS=class e extends NS{static ML_DSA65_SIGNATURE_KEY=`MLDSA65`;constructor(){super([e.ML_DSA65_SIGNATURE_KEY])}bootstrapPrivateKey(e){return new a_(e)}bootstrapPublicKey(e){return new i_(e)}},IS=class e extends MS{static label=[`PKMS`,`SECP256K1`];constructor(){super(e.label)}async decodePrivateKey(e){return new _S(Mg.decode(e).getValue())}async decodePublicKey(e){let t=Mg.decode(e);return new vS(this.bytesEncoder.decode(t.getValue()))}},LS=class e{bytesEncoder=Og.bytesToHexEncoder();static getAcceptedSchemeTags(){return[[bS],[xS],[SS,bS],[`jwk`]]}async isAcceptingPublicKeyDecodingRequest(e){if(e.startsWith(`did:jwk`))return!0;let t=this.getKeyParts(e);return t!==null&&t.typeTag===`pk`}async isAcceptingPrivateKeyDecodingRequest(e){let t=this.getKeyParts(e);return t!==null&&t.typeTag===`sk`}didJwkToJwk(e){if(!e.startsWith(`did:jwk:`))throw Error(`Invalid did:jwk identifier: ${e}`);let t=e.slice(8).split(/[#?]/)[0],n=Oy(t),r=new TextDecoder().decode(n);return JSON.parse(r)}async decodePublicKey(e){if(e.startsWith(`did:jwk`)){let t=this.didJwkToJwk(e);return qx.fromJwk(t)}let t=this.getKeyParts(e);if(t===null)throw Error(`invalid key format`);if(t.typeTag!==`pk`)throw Error(`not a public key format`);switch(t.schemeTags[0]){case bS:return new ey(this.bytesEncoder.decode(t.payload));case xS:return new i_(this.bytesEncoder.decode(t.payload));case SS:if(t.schemeTags[1]===`secp256k1`)return new vS(this.bytesEncoder.decode(t.payload));break;case`jwk`:{let e=this.bytesEncoder.decode(t.payload);return qx.fromBytes(e)}}throw Error(`unsupported key format`)}async decodePrivateKey(e){let t=this.getKeyParts(e);if(t===null)throw Error(`invalid key format`);if(t.typeTag!==`sk`)throw Error(`not a private key format`);switch(t.schemeTags[0]){case bS:return new ty(this.bytesEncoder.decode(t.payload));case xS:return new a_(this.bytesEncoder.decode(t.payload));case SS:if(t.schemeTags[1]===`secp256k1`){let e=t.payload;return new _S(e)}break;case`jwk`:{let e=this.bytesEncoder.decode(t.payload);return DS.fromBytes(e)}}throw Error(`unsupported key format`)}getKeyParts(t){let n=t.split(`:`),r=0;if(n[r++]!==`sig`)return null;let i=[],a=n[r++];if(i.push(a),a===`pkms`&&i.push(n[r++]),!e.getAcceptedSchemeTags().some(e=>i.length===e.length&&i.every((t,n)=>e[n]===t)))return null;let o=n[r++];if(o!==`pk`&&o!==`sk`)return null;let s=n[r++];return s===void 0||n[r]!==void 0?null:{schemeTags:i,typeTag:o,payload:s}}},RS=class e{static createEmpty(){let t=new e;return t.clear(),t}encoders=[new OS];decoders=[new LS,new PS,new FS,new IS];constructor(e=Og.bytesToHexEncoder()){this.bytesEncoder=e}registerEncoder(e){this.encoders.push(e)}registerDecoder(e){this.decoders.push(e)}decodeMessage(e){return this.bytesEncoder.decode(e)}async decodePrivateKey(e){for(let t of this.decoders)if(await t.isAcceptingPrivateKeyDecodingRequest(e))return await t.decodePrivateKey(e);throw Error(`Invalid private key format: no decoder found`)}async decodePublicKey(e){for(let t of this.decoders)if(await t.isAcceptingPublicKeyDecodingRequest(e))return await t.decodePublicKey(e);throw Error(`Invalid private key format: no decoder found`)}decodeSignature(e){return this.bytesEncoder.decode(e)}encodeMessage(e){return this.bytesEncoder.encode(e)}async encodePrivateKey(e){for(let t of this.encoders)if(await t.isAcceptingPrivateKeyEncodingRequest(e))return await t.encodePrivateKey(e);throw Error(`No encoder found`)}async encodePublicKey(e){for(let t of this.encoders)if(await t.isAcceptingPublicKeyEncodingRequest(e))return await t.encodePublicKey(e);throw Error(`No encoder found`)}encodeSignature(e){return this.bytesEncoder.encode(e)}clear(){this.clearEncoders(),this.clearDecoders()}clearEncoders(){this.encoders=[]}clearDecoders(){this.decoders=[]}},zS=class e{static encoder=new Tx({tagUint8Array:!1});decode(t){return e.encoder.decode(t)}encode(t){return e.encoder.encode(t)}},BS=class e{static defaultStringSignatureEncoder(){return new RS(Og.defaultBytesToStringEncoder())}static defaultStringPublicKeyEncryptionEncoder(){return Yx.createBase64HCVPkeEncoder()}static cryptoBinaryEncoder=new zS;static getCryptoBinaryEncoder(){return e.cryptoBinaryEncoder}},X=class e{static encoder=BS.getCryptoBinaryEncoder();static logger=k.getLogger([`utils`]);static computeMicroblockHashFromHeader(t){let n=e.encodeMicroblockHeader(t);return Tp.Hashes.sha256AsBinary(n)}static checkHeaderList(t){let n=t.length;if(n===0)return{valid:!0,hashes:[]};if(n===1)return{valid:!0,hashes:[Tp.Hashes.sha256AsBinary(t[0])]};let r=[],i=null,a=k.getProviderLogger();for(let n of t.reverse()){let t=Tp.Hashes.sha256AsBinary(n);if(i&&!A.binaryIsEqual(t,i))return a.error(`Received headers mismatch: Expected ${A.binaryToHexa(i)}, got ${A.binaryToHexa(t)}: aborting verification`),{valid:!1,hashes:[]};r.push(t),i=e.previousHashFromHeader(n)}return{valid:!0,hashes:r}}static previousHashFromHeader(t){return e.decodeMicroblockHeader(t).previousHash}static encodeChainReference(e){return this.encodeObjectToBinary(R(ig,e))}static decodeChainReference(e){return R(ig,this.decodeObjectFromBinary(e))}static encodeVirtualBlockchainInfo(e){return this.encodeObjectToBinary(R(Qh,e))}static decodeVirtualBlockchainInfo(e){return R(Qh,this.decodeObjectFromBinary(e))}static encodeVirtualBlockchainState(e){return this.encodeObjectToBinary(R(Zh,e))}static decodeVirtualBlockchainState(e){return R(Zh,this.decodeObjectFromBinary(e))}static encodeMicroblockBody(e){return this.encodeObjectToBinary(R(Nh,e))}static decodeMicroblockBody(e){return R(Nh,this.decodeObjectFromBinary(e))}static encodeSection(e){return this.encodeObjectToBinary(R(Mh,e))}static decodeSection(e){return R(Mh,this.decodeObjectFromBinary(e))}static encodeMicroblockHeader(e){return this.encodeObjectToBinary(R(Um,e))}static decodeMicroblockHeader(t){let n=this.decodeObjectFromBinary(t),r=R(Um,n);if(!A.binaryIsEqual(n.bodyHash,r.bodyHash))throw e.logger.error(`Modified validated object: ${JSON.stringify(n)} vs ${JSON.stringify(r)}`),Error(`Modified body hash detected during deserialization: ${n.bodyHash} vs ${r.bodyHash}`);return r}static encodeEscrowParameters(e){return this.encodeObjectToBinary(R(sg,e))}static decodeEscrowParameters(e){return R(sg,this.decodeObjectFromBinary(e))}static encodeEscrowLock(e){return this.encodeObjectToBinary(R(cg,e))}static decodeEscrowLock(e){return R(cg,this.decodeObjectFromBinary(e))}static encodeVestingParameters(e){return this.encodeObjectToBinary(R(lg,e))}static decodeVestingParameters(e){return R(lg,this.decodeObjectFromBinary(e))}static encodeVestingLock(e){return this.encodeObjectToBinary(R(ug,e))}static decodeVestingLock(e){return R(ug,this.decodeObjectFromBinary(e))}static encodeNodeStakingParameters(e){return this.encodeObjectToBinary(R(dg,e))}static decodeNodeStakingParameters(e){return R(dg,this.decodeObjectFromBinary(e))}static encodeNodeStakingLock(e){return this.encodeObjectToBinary(R(fg,e))}static decodeNodeStakingLock(e){return R(fg,this.decodeObjectFromBinary(e))}static encodeLock(e){return this.encodeObjectToBinary(R(pg,e))}static decodeLock(e){return R(pg,this.decodeObjectFromBinary(e))}static encodeAccountBreakdown(e){return this.encodeObjectToBinary(R(mg,e))}static decodeAccountBreakdown(e){return R(mg,this.decodeObjectFromBinary(e))}static encodeAccountState(e){return this.encodeObjectToBinary(R(hg,e))}static decodeAccountState(e){return R(hg,this.decodeObjectFromBinary(e))}static encodeAccountInformation(e){return this.encodeObjectToBinary(R(gg,e))}static decodeAccountInformation(e){return R(gg,this.decodeObjectFromBinary(e))}static encodeMicroblockInformation(e){return this.encodeObjectToBinary(R($h,e))}static decodeMicroblockInformation(e){return R($h,this.decodeObjectFromBinary(e))}static encodeObjectToBinary(t){return e.encoder.encode(t)}static decodeObjectFromBinary(t){return e.encoder.decode(t)}},VS=86400,HS=class{constructor(e){this.retentionPolicy=e,this.retentionPolicy.sort((e,t)=>e.maximumNumberOfDays-t.maximumNumberOfDays)}getNumberOfDaysOfStorage(e,t){return t>0?Math.max(1,Math.round((t-e)/VS)):this.retentionPolicy[this.retentionPolicy.length-1].maximumNumberOfDays}getStorageCost(e,t){return this.getBreakdown(e,t).reduce((e,t)=>e+t.costInGasAtoms,0)}getBreakdown(e,t){let n=[];for(let r=0,i=0;i<t;r++){let a=this.retentionPolicy[r],o,s,c;a==null?(o=t-i,s=0,c=1):(o=Math.min(a.maximumNumberOfDays,t)-i,s=a.retentionRatio,c=a.dayDivisor);let l=Math.floor(e*o*s/1e3/c);n.push({numberOfDays:o,retentionRatio:s,costInGasAtoms:l}),i+=o}return n}},US=class e{static DEFAULT_GAS_PRICE=hn.createAtomic(1);constructor(e){this.provider=e}async computeFees(t,n,r,i=A.getTimestampInSeconds()){if(r<0)throw Error(`Invalid expiration day`);let a=n.getGasPrice(),o=a.isZero()?e.DEFAULT_GAS_PRICE:a,s=await this.computeGas(t,n,r,i);return hn.createAtomic(s*o.getAmountAsAtomic())}async computeGas(e,t,n,r=A.getTimestampInSeconds()){let i=1*this.computeSizeInBytesOfMicroblock(t)*pr,a=await this.provider.getProtocolState(),o=new HS(a.getRetentionPolicy()),s=o.getNumberOfDaysOfStorage(r,n),c=o.getStorageCost(i,s),l=this.getAdditionalCosts(a,e);return Math.floor(c/pr)+l}getAdditionalCosts(e,t){let n=0;switch(t){case Ja.SECP256K1:n=e.getSecp256k1SignatureGasCost();break;case Ja.ML_DSA_65:n=e.getMlDsa65SignatureGasCost();break;case Ja.PKMS_SECP256K1:n=e.getPkmsSecp256k1SignatureGasCost();break}return n+e.getFixedGasCost()}computeSizeInBytesOfMicroblock(e){let t=e.getAllSections();if(t.length===0)return 0;let n=t[t.length-1].type===O.SIGNATURE?t.slice(0,t.length-1):t;return this.getSizeOfListOfSections(n)}getSizeOfListOfSections(e){return e.reduce((e,t)=>e+X.encodeSection(t).length,0)}},WS=class{static getGenesisFeesCalculationFormula(e){return new US(e)}static async getFeesCalculationFormulaByVersion(e,t){switch(t){case 1:return this.getGenesisFeesCalculationFormula(e)}throw Error(`No fees formula for feesCalculationVersion = ${t}`)}},GS=class e{constructor(e){this.internalState=e}static createFromObject(t){return new e(t)}static createInitialState(){return new e({signatureSchemeId:0,publicKeyHeight:0})}toObject(){return this.internalState}updateSignatureScheme(e){this.internalState.signatureSchemeId=e}updatePublicKeyHeight(e){this.internalState.publicKeyHeight=e}getPublicKeyHeight(){return this.internalState.publicKeyHeight}getPublicKeySchemeId(){return this.internalState.signatureSchemeId}},KS=class e{constructor(e){this.hash=e}static from(t){let n=typeof t==`string`,r=t instanceof Uint8Array;if(!n&&!r)throw TypeError(`Expected hash of type string or Uint8Array: got ${typeof t}`);let i=Og.bytesToHexEncoder();return new e(typeof t==`string`?i.decode(t):t)}static fromHex(t){return new e(Og.bytesToHexEncoder().decode(t))}encode(e=new Ag){return e.encode(this.hash).toUpperCase()}toBytes(){return new Uint8Array(this.hash)}equals(e){return this.hash.every((t,n)=>t===e.hash[n])}},qS=class e{constructor(e){this.internalState=e}static createFromObject(t){return new e(t)}static createInitialState(){return new e({organizationId:A.getNullHash(),descriptionHeight:0})}clone(){return new e({...this.internalState})}toObject(){return this.internalState}setOrganizationId(e){this.internalState.organizationId=e}setDescriptionHeight(e){this.internalState.descriptionHeight=e}getOrganizationId(){return KS.from(this.internalState.organizationId)}getDescriptionHeight(){return this.internalState.descriptionHeight}},JS=class e{static UNDEFINED_APPLICATION_ID=new Uint8Array;constructor(e){this.internalState=e}static createFromObject(t){return new e(t)}static createInitialState(){return new e({allowedAdditionalWriters:[],actors:[],allowedPkeSchemeIds:[],allowedSignatureSchemeIds:[],applicationId:this.UNDEFINED_APPLICATION_ID,channels:[]})}getAdditionalAllowedWriters(){return this.internalState.allowedAdditionalWriters}addAdditionalWriter(e){this.internalState.allowedAdditionalWriters.push(e)}toObject(){return this.internalState}clone(){return new e(structuredClone(this.internalState))}createActor(e){this.internalState.actors.push(e)}createActorWithId(e,t){if(this.isActorDefinedById(e))throw new oe(`Id: ${e}`);this.internalState.actors[e]=t}setAllowedSignatureSchemeIds(e){this.internalState.allowedSignatureSchemeIds=e}setAllowedPkeSchemeIds(e){this.internalState.allowedPkeSchemeIds=e}setApplicationId(e){this.internalState.applicationId=e}isChannelDefinedById(e){return this.internalState.channels[e]!==void 0}isChannelDefinedByName(e){return this.internalState.channels.some(t=>t.name===e)}createChannel(e){if(!this.isActorDefinedById(e.creatorId))throw new oe(`Id: ${e.creatorId}`);if(this.isChannelDefinedByName(e.name))throw new ae(e.name);this.internalState.channels.push(e)}createChannelWithId(e,t){if(this.isChannelDefinedById(e))throw new ae(`Id: ${e}`);if(this.isActorDefinedById(t.creatorId))throw new oe(`Id: ${t.creatorId}`);if(this.isChannelDefinedByName(t.name))throw new ae(t.name);this.internalState.channels[e]=t}isActorDefinedByName(e){return this.internalState.actors.some(t=>t.name===e)}isActorDefinedById(e){return this.internalState.actors[e]!==void 0}getAllowedSignatureSchemes(){return this.internalState.allowedSignatureSchemeIds}getAllowedPkeSchemes(){return this.internalState.allowedPkeSchemeIds}getNumberOfActors(){return this.internalState.actors.length}getActorById(e){let t=this.internalState.actors[e];if(t===void 0)throw new oe(`ID: ${e}`);return t}getNumberOfChannels(){return this.internalState.channels.length}getApplicationId(){return KS.from(this.internalState.applicationId)}getChannelIdFromChannelName(e){let t=this.internalState.channels.findIndex(t=>t.name===e);if(t===void 0)throw new se(e);return t}getChannelCreatorIdFromChannelId(e){return this.getChannelFromChannelId(e).creatorId}getChannelFromChannelId(e){let t=this.internalState.channels[e];if(t===void 0)throw new se(`ID: ${e}`);return t}getActorByName(e){let t=this.internalState.actors.find(t=>t.name===e);if(t===void 0)throw new oe(e);return t}getActorIdByName(e){let t=this.internalState.actors.findIndex(t=>t.name===e);if(t===-1)throw new oe(e);return t}updateActor(e,t){if(!this.isActorDefinedById(e))throw new oe(`Id: ${e}`);this.internalState.actors[e]=t}updateChannel(e,t){if(!this.isChannelDefinedById(e))throw new se(`Id: ${e}`);this.internalState.channels[e]=t}getAllActors(){return this.internalState.actors}getAllChannels(){return this.internalState.channels}},YS=function(e){return e.INITIAL_PROTOCOL_VERSION_NAME=`Clermont`,e}(YS||{}),XS=class e{constructor(e){this.internalState=e}static createFromObject(t){let n=fm(Ph,t);if(n.success)return new e(n.output);throw Error(`Provided internal state is not valid: ${n.issues}`)}static createInitialState(){return new e({organizationId:A.getNullHash(),currentProtocolVariables:{protocolVersionName:YS.INITIAL_PROTOCOL_VERSION_NAME,protocolVersion:1,feesCalculationVersion:1,fixedGasCost:100,secp256k1SignatureGasCost:100,mlDsa65SignatureGasCost:500,pkmsSecp256k1SignatureGasCost:0,globalStateUpdaterVersion:1,applicationLedgerInternalStateUpdaterVersion:1,applicationInternalStateUpdaterVersion:1,organizationInternalStateUpdaterVersion:1,validatorNodeInternalStateUpdaterVersion:1,accountInternalStateUpdaterVersion:1,protocolInternalStateUpdaterVersion:1,minimumNodeStakingAmountInAtomics:hn.create(1e6).getAmountAsAtomic(),maximumNodeStakingAmountInAtomics:hn.create(1e7).getAmountAsAtomic(),unstakingDelayInDays:30,maxBlockSizeInBytes:4194304,retentionPolicy:[{retentionRatio:100,maximumNumberOfDays:366,dayDivisor:366},{retentionRatio:50,maximumNumberOfDays:366*5,dayDivisor:366},{retentionRatio:20,maximumNumberOfDays:366*10,dayDivisor:366},{retentionRatio:100,maximumNumberOfDays:3661,dayDivisor:1}],abciVersion:1,maxMicroblocksPerBlock:200},protocolUpdates:[]})}getAbciVersion(){return this.internalState.currentProtocolVariables.abciVersion}getMaximumBlockSizeInBytes(){return this.internalState.currentProtocolVariables.maxBlockSizeInBytes}getProtocolVariables(){return this.internalState.currentProtocolVariables}getApplicationLedgerInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.applicationLedgerInternalStateUpdaterVersion}getApplicationInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.applicationInternalStateUpdaterVersion}getOrganizationInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.organizationInternalStateUpdaterVersion}getValidatorNodeInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.validatorNodeInternalStateUpdaterVersion}getAccountInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.accountInternalStateUpdaterVersion}getProtocolInternalStateUpdaterVersion(){return this.internalState.currentProtocolVariables.protocolInternalStateUpdaterVersion}getMinimumNodeStakingAmountInAtomics(){return this.internalState.currentProtocolVariables.minimumNodeStakingAmountInAtomics}getMaximumNodeStakingAmountInAtomics(){return this.internalState.currentProtocolVariables.maximumNodeStakingAmountInAtomics}getUnstakingDelayInDays(){return this.internalState.currentProtocolVariables.unstakingDelayInDays}getRetentionPolicy(){return this.internalState.currentProtocolVariables.retentionPolicy}toObject(){return this.internalState}getFeesCalculationVersion(){return this.internalState.currentProtocolVariables.feesCalculationVersion}getFixedGasCost(){return this.internalState.currentProtocolVariables.fixedGasCost}getSecp256k1SignatureGasCost(){return this.internalState.currentProtocolVariables.secp256k1SignatureGasCost}getMlDsa65SignatureGasCost(){return this.internalState.currentProtocolVariables.mlDsa65SignatureGasCost}getPkmsSecp256k1SignatureGasCost(){return this.internalState.currentProtocolVariables.pkmsSecp256k1SignatureGasCost}setProtocolVersion(e){this.internalState.currentProtocolVariables.protocolVersion=e}setProtocolVersionName(e){this.internalState.currentProtocolVariables.protocolVersionName=e}setProtocolVariables(e){this.internalState.currentProtocolVariables=e}setOrganizationId(e){this.internalState.organizationId=e}},ZS=class e{constructor(e){this.internalState=e}static createFromObject(t){return new e(t)}static createInitialState(){return new e({accountId:A.getNullHash(),descriptionHeight:0})}toObject(){return this.internalState}getAccountIdAsBytes(){return this.internalState.accountId}getAccountId(){return KS.from(this.internalState.accountId)}setAccountId(e){return this.internalState.accountId=e}getDescriptionHeight(){return this.internalState.descriptionHeight}updateDescriptionHeight(e){this.internalState.descriptionHeight=e}},QS=class e{constructor(e){this.internalState=e}static createFromObject(t){return new e(t)}static createInitialState(){return new e({cometbftPublicKeyDeclarationHeight:0,lastKnownApprovalStatus:!1,organizationId:A.getNullHash(),rpcEndpointHeight:0})}toObject(){return this.internalState}getOrganizationId(){return KS.from(this.internalState.organizationId)}getLastKnownApprovalStatus(){return this.internalState.lastKnownApprovalStatus}getCometbftPublicKeyDeclarationHeight(){return this.internalState.cometbftPublicKeyDeclarationHeight}getRpcEndpointHeight(){return this.internalState.rpcEndpointHeight}clone(){return structuredClone(this)}setApprovalStatus(e){this.internalState.lastKnownApprovalStatus=e}setCometbftPublicKeyDeclarationHeight(e){this.internalState.cometbftPublicKeyDeclarationHeight=e}setOrganizationId(e){this.internalState.organizationId=e}setRpcEndpointDeclarationHeight(e){this.internalState.rpcEndpointHeight=e}},$S=class{static createInternalStateFromObject(e,t){switch(e){case H.PROTOCOL_VIRTUAL_BLOCKCHAIN:return XS.createFromObject(t);case H.ACCOUNT_VIRTUAL_BLOCKCHAIN:return GS.createFromObject(t);case H.APPLICATION_VIRTUAL_BLOCKCHAIN:return qS.createFromObject(t);case H.APP_LEDGER_VIRTUAL_BLOCKCHAIN:return JS.createFromObject(t);case H.ORGANIZATION_VIRTUAL_BLOCKCHAIN:return ZS.createFromObject(t);case H.NODE_VIRTUAL_BLOCKCHAIN:return QS.createFromObject(t);default:throw Error(`Unknown virtual blockchain type: ${e}`)}}},eC=class{constructor(){}async updateState(e,t,n){let r=GS.createFromObject({...t.toObject()}),i=n.getAllSections();for(let e of i)switch(e.type){case O.ACCOUNT_PUBLIC_KEY:await this.publicKeyCallback(r,n,e);break;case O.ACCOUNT_TOKEN_ISSUANCE:await this.tokenIssuanceCallback(r,n,e);break;case O.ACCOUNT_CREATION:await this.creationCallback(r,n,e);break;case O.ACCOUNT_TRANSFER:await this.transferCallback(r,n,e);break;case O.ACCOUNT_VESTING_TRANSFER:await this.vestingTransferCallback(r,n,e);break;case O.ACCOUNT_ESCROW_TRANSFER:await this.escrowTransferCallback(r,n,e);break;case O.ACCOUNT_STAKE:await this.stakeCallback(r,n,e);break;case O.SIGNATURE:await this.signatureCallback(r,n,e);break}return r}async publicKeyCallback(e,t,n){e.updatePublicKeyHeight(t.getHeight()),e.updateSignatureScheme(n.schemeId)}async tokenIssuanceCallback(e,t,n){if(n.amount!=0x5af3107a4000)throw Error(`the amount of the initial token issuance is not the expected one`)}async creationCallback(e,t,n){}async transferCallback(e,t,n){}async vestingTransferCallback(e,t,n){if(n.cliffDurationDays<0)throw Error(`The cliff duration must be greater than or equal to 0`);if(n.vestingDurationDays<=0)throw Error(`The vesting duration must be greater than 0`);if(n.amount<=0)throw Error(`The amount must be greater than 0`)}async escrowTransferCallback(e,t,n){}async stakeCallback(e,t,n){}async signatureCallback(e,t,n){}},tC=class{updateState(e,t,n){let r=t.clone();for(let e of n.getAllSections())e.type===O.APP_CREATION&&r.setOrganizationId(e.organizationId),e.type===O.APP_DESCRIPTION&&r.setDescriptionHeight(n.getHeight());return r}},nC={[O.AUXILIARY_SIGNATURE]:`AUXILIARY_SIGNATURE`,[O.SIGNATURE]:`SIGNATURE`,[O.ALLOWED_ADDITIONAL_WRITER]:`ALLOWED_ADDITIONAL_WRITER_CREATION`,[O.CUSTOM]:`CUSTOM`,[O.PROTOCOL_CREATION]:`PROTOCOL_CREATION`,[O.PROTOCOL_UPDATE]:`PROTOCOL_UPDATE`,[O.PROTOCOL_VARIABLES]:`PROTOCOL_VARIABLES`,[O.ACCOUNT_PUBLIC_KEY]:`ACCOUNT_PUBLIC_KEY`,[O.ACCOUNT_TOKEN_ISSUANCE]:`ACCOUNT_TOKEN_ISSUANCE`,[O.ACCOUNT_CREATION]:`ACCOUNT_CREATION`,[O.ACCOUNT_TRANSFER]:`ACCOUNT_TRANSFER`,[O.ACCOUNT_VESTING_TRANSFER]:`ACCOUNT_VESTING_TRANSFER`,[O.ACCOUNT_ESCROW_TRANSFER]:`ACCOUNT_ESCROW_TRANSFER`,[O.ACCOUNT_ESCROW_SETTLEMENT]:`ACCOUNT_ESCROW_SETTLEMENT`,[O.ACCOUNT_STAKE]:`ACCOUNT_STAKE`,[O.ACCOUNT_UNSTAKE]:`ACCOUNT_UNSTAKE`,[O.VN_CREATION]:`VN_CREATION`,[O.VN_COMETBFT_PUBLIC_KEY_DECLARATION]:`VN_COMETBFT_PUBLIC_KEY_DECLARATION`,[O.VN_RPC_ENDPOINT]:`VN_RPC_ENDPOINT`,[O.VN_APPROVAL]:`VN_APPROVAL`,[O.VN_SLASHING_CANCELLATION]:`VN_SLASHING_CANCELLATION`,[O.ORG_CREATION]:`ORG_CREATION`,[O.ORG_DESCRIPTION]:`ORG_DESCRIPTION`,[O.APP_CREATION]:`APP_CREATION`,[O.APP_DESCRIPTION]:`APP_DESCRIPTION`,[O.APP_LEDGER_ALLOWED_SIG_SCHEMES]:`APP_LEDGER_ALLOWED_SIG_SCHEMES`,[O.APP_LEDGER_ALLOWED_PKE_SCHEMES]:`APP_LEDGER_ALLOWED_PKE_SCHEMES`,[O.APP_LEDGER_CREATION]:`APP_LEDGER_CREATION`,[O.APP_LEDGER_ACTOR_CREATION]:`APP_LEDGER_ACTOR_CREATION`,[O.APP_LEDGER_CHANNEL_CREATION]:`APP_LEDGER_CHANNEL_CREATION`,[O.APP_LEDGER_SHARED_SECRET]:`APP_LEDGER_SHARED_SECRET`,[O.APP_LEDGER_CHANNEL_INVITATION]:`APP_LEDGER_CHANNEL_INVITATION`,[O.APP_LEDGER_ACTOR_SUBSCRIPTION]:`APP_LEDGER_ACTOR_SUBSCRIPTION`,[O.APP_LEDGER_PUBLIC_CHANNEL_DATA]:`APP_LEDGER_PUBLIC_CHANNEL_DATA`,[O.APP_LEDGER_PRIVATE_CHANNEL_DATA]:`APP_LEDGER_PRIVATE_CHANNEL_DATA`,[O.APP_LEDGER_AUTHOR]:`APP_LEDGER_AUTHOR`,[O.APP_LEDGER_ENDORSEMENT_REQUEST]:`APP_LEDGER_ENDORSEMENT_REQUEST`},rC=class{static getSectionLabelFromSection(e){return this.getSectionLabelFromSectionType(e.type)}static getSectionLabelFromSectionType(e){return nC[e]}},iC=class e{logger=k.getInternalStateUpdaterLogger(e.name);async updateState(e,t,n){let r=t.clone(),i=n.getHeight();for(let a of n.getAllSections())r=await this.updateStateFromSection(e,t,a,i);return r}async updateStateFromSection(e,t,n,r){let i=t;switch(n.type){case O.APP_LEDGER_ALLOWED_SIG_SCHEMES:await this.allowedSignatureSchemesCallback(n,i);break;case O.APP_LEDGER_ALLOWED_PKE_SCHEMES:await this.allowedPkeSchemesCallback(n,i);break;case O.APP_LEDGER_CREATION:await this.declarationCallback(n,i);break;case O.APP_LEDGER_ACTOR_CREATION:await this.actorCreationCallback(n,i);break;case O.APP_LEDGER_ACTOR_SUBSCRIPTION:await this.actorSubscriptionCallback(r,n,i);break;case O.APP_LEDGER_CHANNEL_CREATION:await this.channelCreationCallback(n,i);break;case O.APP_LEDGER_SHARED_SECRET:await this.sharedSecretCallback(r,n,i);break;case O.APP_LEDGER_CHANNEL_INVITATION:await this.invitationCallback(r,n,i);break;case O.APP_LEDGER_PUBLIC_CHANNEL_DATA:await this.publicChannelDataCallback(n,i);break;case O.APP_LEDGER_PRIVATE_CHANNEL_DATA:await this.privateChannelDataCallback(n,i);break;case O.ALLOWED_ADDITIONAL_WRITER:i.addAdditionalWriter(n.allowedWriterAccountId);break;case O.SIGNATURE:await this.endorserSignatureCallback();break;default:k.getLogger().warn(`Unhandled section ${rC.getSectionLabelFromSection(n)}`)}return i}async allowedSignatureSchemesCallback(e,t){t.setAllowedSignatureSchemeIds(e.schemeIds)}async allowedPkeSchemesCallback(e,t){t.setAllowedPkeSchemeIds(e.schemeIds)}async declarationCallback(e,t){t.setApplicationId(e.applicationId)}async actorCreationCallback(e,t){let{id:n,name:r}=e,i=t.getNumberOfActors();if(n!=i)throw this.logger.error(`Actor creation failure: Invalid actor identifier found for actor ${r}: expected ${i}, got ${n}`),new ie(n,t.getNumberOfActors());if(t.isActorDefinedByName(r))throw new re(r);this.logger.info(`Creating actor ${r} with id ${n} `),t.createActor({name:r,subscribed:!1,signatureKeyHeight:0,pkeKeyHeight:0,sharedSecrets:[],invitations:[]})}async actorSubscriptionCallback(e,t,n){let r=n.getActorById(t.actorId);if(r===void 0)throw new le(t.actorId);if(r.subscribed)throw new S(t.actorId);let i=t.signatureSchemeId,a=n.getAllowedSignatureSchemes(),o=a.length==0,s=a.includes(i);if(!o&&!s)throw new ue(t.signatureSchemeId);let c=t.pkeSchemeId,l=n.getAllowedPkeSchemes(),u=l.length===0,d=l.includes(c);if(!u&&!d)throw new de(t.pkeSchemeId);r.subscribed=!0,r.signatureKeyHeight=e,r.pkeKeyHeight=e}async channelCreationCallback(e,t){if(e.id!=t.getNumberOfChannels())throw new fe(e.id);let n=e.name;if(t.isChannelDefinedByName(n))throw new ae(n);t.createChannel({name:e.name,isPrivate:e.isPrivate,creatorId:e.creatorId})}async sharedSecretCallback(e,t,n){let{hostId:r,guestId:i}=t;n.getActorById(r).sharedSecrets.push({height:e,peerActorId:i}),n.getActorById(i).sharedSecrets.push({height:e,peerActorId:r})}async invitationCallback(e,t,n){let{guestId:r,channelId:i}=t;n.getActorById(r).invitations.push({channelId:i,height:e}),k.getLogger().debug(`Updated state after channel invitation callback: {state}`,{state:n})}async publicChannelDataCallback(e,t){if(!t.isChannelDefinedById(e.channelId))throw new se(`invalid channel ID ${e.channelId}`)}async privateChannelDataCallback(e,t){if(!t.isChannelDefinedById(e.channelId))throw new se(`invalid channel ID ${e.channelId}`)}async endorserSignatureCallback(){}},aC=class{updateState(e,t,n){let r=t;for(let e of n.getAllSections())switch(e.type){case O.VN_CREATION:r.setOrganizationId(e.organizationId);break;case O.VN_APPROVAL:this.updateApproval(r,e);break;case O.VN_COMETBFT_PUBLIC_KEY_DECLARATION:r.setCometbftPublicKeyDeclarationHeight(n.getHeight());break;case O.VN_RPC_ENDPOINT:r.setRpcEndpointDeclarationHeight(n.getHeight());break}return r}updateApproval(e,t){e.setApprovalStatus(t.status)}},oC=class e{logger=k.getInternalStateUpdaterLogger(e.name);updateState(e,t,n){for(let e of n.getAllSections()){if(e.type===O.PROTOCOL_UPDATE){let n=e;this.logger.debug(`Updating protocol variables: ${JSON.stringify(n.protocolVariables)}`),t.setProtocolVariables(n.protocolVariables)}if(e.type===O.PROTOCOL_CREATION){let n=e.organizationId;this.logger.debug(`Updating organization ID: ${A.binaryToHexa(n)}`),t.setOrganizationId(n)}}return t}},sC=class{updateState(e,t,n){for(let e of n.getAllSections())e.type===O.ORG_CREATION&&t.setAccountId(e.accountId),e.type===O.ORG_DESCRIPTION&&t.updateDescriptionHeight(n.getHeight());return t}},cC=class{static createApplicationLedgerInternalStateUpdater(e){return new iC}static createAccountInternalStateUpdater(e){switch(e){case 1:return new eC;default:throw new i(`Unknown account local state version`)}}static createOrganizationInternalStateUpdater(e){switch(e){case 1:return new sC;default:throw new i(`Unknown organization local state version`)}}static createProtocolInternalStateUpdater(e){return new oC}static createValidatorNodeInternalStateUpdater(e){switch(e){case 1:return new aC;default:throw new i(`Unknown validator node local state version`)}}static createApplicationInternalStateUpdater(e){switch(e){case 1:return new tC;default:throw new i(`Unknown validator node local state version`)}}static defaultInternalStateUpdaterVersionByVbType(e){return 1}},lC=function(e){return e[e.VALID=0]=`VALID`,e[e.TOO_FAR_IN_THE_PAST=1]=`TOO_FAR_IN_THE_PAST`,e[e.TOO_FAR_IN_THE_FUTURE=2]=`TOO_FAR_IN_THE_FUTURE`,e}({}),uC=F({header:Um,body:Nh}),dC=class e{static createGenesisMicroblock(t,n=0){let r=new e(t);return r.create(1,null,n),r}static createMicroblock(t,n,r,i){let a=new e(t);return a.create(n,r,i),a}static createGenesisAccountMicroblock(){return new e(H.ACCOUNT_VIRTUAL_BLOCKCHAIN)}static createGenesisValidatorNodeMicroblock(){return new e(H.NODE_VIRTUAL_BLOCKCHAIN)}static createGenesisApplicationMicroblock(){return new e(H.APPLICATION_VIRTUAL_BLOCKCHAIN)}static createGenesisProtocolMicroblock(){return new e(H.PROTOCOL_VIRTUAL_BLOCKCHAIN)}static createGenesisOrganizationMicroblock(){return new e(H.ORGANIZATION_VIRTUAL_BLOCKCHAIN)}static createGenesisApplicationLedgerMicroblock(){return new e(H.APP_LEDGER_VIRTUAL_BLOCKCHAIN)}static loadFromSerializedMicroblock(t,n){let r=R(uC,sx(t));return e.loadFromHeaderAndBody(r.header,r.body,n)}static loadFromHeaderAndBody(t,n,r){let i=t.microblockType;if(r!==void 0&&r!==i)throw new o(`Microblock type mismatch: expected ${r}, got ${i} from header`);if(t.magicString!=`CMTS`)throw Error(`magic string '${Un}' is missing`);let a=t.bodyHash,s=new e(i);s.header=structuredClone(t),s.addSections(n.sections);let c=s.computeBodyHash();if(!A.binaryIsEqual(a,c)){let e=Og.bytesToHexEncoder();throw new o(`Body hash in the header is different of the locally computed body hash: header.bodyHash=${e.encode(a)}, computed=${e.encode(c)}`)}return s.setMicroblockHash(s.computeHash()),s}static loadFromSerializedHeaderAndBody(t,n,r){let i=X.decodeMicroblockHeader(t),a=X.decodeMicroblockBody(n);return e.loadFromHeaderAndBody(i,a,r)}static computeInitialBodyHash(){return e.computeBodyHashFromSections([])}static computeMicroblockHash(e){let t=X.encodeMicroblockHeader(e);return Tp.Hashes.sha256AsBinary(t)}static computeBodyHashFromSections(e){let t={sections:e},n=X.encodeMicroblockBody(t);return Tp.Hashes.sha256AsBinary(n)}static generatePreviousHashForGenesisMicroblock(e,t=0){let n=Tp.Random.getBytes(24),r=A.getNullHash();return r[0]=e,r[1]=t>>24,r[2]=t>>16,r[3]=t>>8,r[4]=t,r.set(n,8),r}static logger=k.getMicroblockLogger();hash;header;sections;type;constructor(t){let n=Math.floor(Date.now()/1e3),r=hn.zero().getAmountAsAtomic(),i={magicString:Un,microblockType:t,height:1,previousHash:e.generatePreviousHashForGenesisMicroblock(t,0),timestamp:n,gas:0,gasPrice:r,bodyHash:e.computeInitialBodyHash(),feesPayerAccount:A.getNullHash()};this.type=t,this.sections=[],this.header=i,this.hash=e.computeMicroblockHash(i)}create(t,n,r){if(t==1)n=e.generatePreviousHashForGenesisMicroblock(this.type,r);else if(n===null)throw Error(`previous hash not provided`);this.header={magicString:Un,microblockType:this.type,height:t,previousHash:n,timestamp:A.getTimestampInSeconds(),gas:0,gasPrice:0,bodyHash:A.getNullHash(),feesPayerAccount:A.getNullHash()},this.hash=e.computeMicroblockHash(this.header)}isSigned(){return this.sections.length==0?!1:this.sections[this.sections.length-1].type===O.SIGNATURE}updateTimestamp(){this.header.timestamp=A.getTimestampInSeconds(),this.hash=e.computeMicroblockHash(this.header)}getHeader(){return this.header}getHash(){return KS.from(this.hash)}getHashAsBytes(){return this.hash}getTimestampAsDate(){return new Date(this.header.timestamp*1e3)}getHeight(){return this.header.height}getPreviousHash(){return KS.from(this.header.previousHash)}getTimestamp(){return this.header.timestamp}getGas(){return this.header.gas}getFees(){return hn.createAtomic(this.header.gas*this.header.gasPrice)}setGas(t){this.header.gas=t,this.hash=e.computeMicroblockHash(this.header)}setHeight(t){this.header.height=t,this.hash=e.computeMicroblockHash(this.header)}setGasPrice(t){this.header.gasPrice=t.getAmountAsAtomic(),this.hash=e.computeMicroblockHash(this.header)}getGasPrice(){return hn.createAtomic(this.header.gasPrice)}isFeesPayerAccountDefined(){return A.binaryIsEqual(this.getFeesPayerAccount(),A.getNullHash())==0}getFeesPayerAccount(){return this.header.feesPayerAccount}setTimestamp(t){this.header.timestamp=t,this.hash=e.computeMicroblockHash(this.header)}setFeesPayerAccount(t){this.header.feesPayerAccount=t,this.hash=e.computeMicroblockHash(this.header)}computeBodyHash(){return e.computeBodyHashFromSections(this.sections)}serializeHeader(){return X.encodeMicroblockHeader(this.header)}serializedBody(){return X.encodeMicroblockBody({sections:this.sections})}serialize(){let t=this.serializedBody(),n=this.header.bodyHash,r=this.serializeHeader();return{microblockHash:e.computeMicroblockHash(this.header),headerData:r,bodyHash:n,bodyData:t,microblockData:Rx(R(uC,{header:this.header,body:{sections:this.sections}}))}}getSection(e){let t=this.sections.find(t=>e(t));if(t===void 0)throw new Ee;return t}getNumberOfSections(){return this.sections.length}getSections(e){return this.sections.filter(t=>e(t))}getSectionsByType(e){return this.getSections(t=>t.type===e)}getAllSections(){return this.sections}async setGasAndSeal(e,t,n={}){let r=await e.computeMicroblockGas(this,{signatureSchemeId:t.getSignatureSchemeId()});this.setGas(r),await this.seal(t,n)}async seal(e,t={}){let n=t.feesPayerAccount;n&&this.setFeesPayerAccount(n);let r=typeof t.includeGas==`boolean`?t.includeGas:!0,i=await this.sign(e,r),a={type:O.SIGNATURE,signature:i,schemeId:e.getSignatureSchemeId()};this.addSection(a)}async sign(t,n=!0){let r=this.sections,i=e.computeBodyHashFromSections(r),a={...this.header,gas:n?this.header.gas:0,gasPrice:n?this.header.gasPrice:0,bodyHash:i},o=X.encodeMicroblockHeader(a);return await t.sign(o)}async verifySignature(e){let t=this.sections.filter(e=>e.type===O.SIGNATURE);if(t.length===0)throw new a(`The current microblock has no SIGNATURE section`);if(t.length!==1)throw new a(`There are several SIGNATURE sections`);if(this.sections[this.sections.length-1].type!==O.SIGNATURE)throw new a(`The SIGNATURE section is not the last one`);return this.verifySignatureOfSections(e,!0,this.sections.length-1)}async verifyAuxiliarySignature(e,t){let n=this.sections.filter(e=>e.type===O.AUXILIARY_SIGNATURE&&e.tag===t);if(n.length===0)throw new a(`The current microblock has no AUXILIARY_SIGNATURE section with tag '${t}'`);if(n.length!==1)throw new a(`The current microblock has several AUXILIARY_SIGNATURE section with tag '${t}'`);let r=this.sections.findIndex(e=>e.type===O.AUXILIARY_SIGNATURE&&e.tag===t);return this.verifySignatureOfSections(e,!1,r)}async verifySignatureOfSections(t,n,r){let i=this.sections[r];if(i.type!==O.SIGNATURE&&i.type!==O.AUXILIARY_SIGNATURE)throw new a(`Attempt to verify the signature of a non-signature section`);let o=this.sections.slice(0,r),s={...this.header,gas:n?this.header.gas:0,gasPrice:n?this.header.gasPrice:0,bodyHash:e.computeBodyHashFromSections(o)},c=X.encodeMicroblockHeader(s),l=i.signature;return t.verify(c,l)}async verify(t,n={includeGas:!0,verifiedSignatureIndex:`last`}){let r=typeof n.includeGas==`boolean`?n.includeGas:!0,o=this.getNumberOfSignatures();if(o===0)throw new a(`Microblock verification failure: The current microblock is not signed`);let s=n.verifiedSignatureIndex,c=o;if(typeof s==`number`){if(s<=0)throw new i(`verifiedSignatureIndex must be positive`);if(o<s)throw new i(`Invalid provided signature index ${s}: this microblock contains ${o} signatures`);c=s}else if(!(s===`last`||s===void 0))throw new i(`Unknown signature index: ${s} (type ${typeof s})`);let{signatureSection:l,sectionIndexInMicroblock:u}=this.getNthSignatureSectionAndIndexInMicroblock(c),d=this.sections.slice(0,u),f={...this.header,gas:r?this.header.gas:0,gasPrice:r?this.header.gasPrice:0,bodyHash:e.computeBodyHashFromSections(d)},p=X.encodeMicroblockHeader(f),m=l.signature;return await t.verify(p,m)}getNthSignatureSectionAndIndexInMicroblock(e){if(e<=0)throw new i(`Cannot return the ${e}-th signature: should be strictly positive`);let t=this.sections.map((e,t)=>({section:e,index:t})).filter(({section:e,index:t})=>e.type===O.SIGNATURE);if(t.length<e)throw new i(`Cannot return the ${e}-th signature: only ${t.length} signature (index starting at 1)`);let n=t[e-1];if(n.section.type!==O.SIGNATURE)throw Error(`Returned section is not a signature section`);return{signatureSection:n.section,sectionIndexInMicroblock:n.index}}getNumberOfSignatures(){return this.sections.filter(e=>e.type===O.SIGNATURE).length}isLastSectionSignature(){return this.sections.length==0?!1:this.sections[this.sections.length-1].type===O.SIGNATURE}isTemporallyCloseTo(e=A.getTimestampInSeconds()){return this.header.timestamp<e-300?lC.TOO_FAR_IN_THE_PAST:this.header.timestamp>e+120?lC.TOO_FAR_IN_THE_FUTURE:lC.VALID}hasSection(e){try{return this.getSectionByType(e),!0}catch(e){if(e instanceof Ee)return!1;throw e}}containsOnlyTheseSections(e){return this.sections.every(t=>e.includes(t.type))}getIndexOfSection(e){return this.sections.findIndex(t=>t.type===e)}setAsSuccessorOf(t){let n=this.getType(),r=t.getType();if(n!==r)throw new i(`Cannot make this microblock the successor: expected microblock of type ${n}, got ${r}`);let a=t.getHash();this.setPreviousHash(a),this.setHeight(t.getHeight()+1),this.hash=e.computeMicroblockHash(this.header),e.logger.info(`Microblock ${A.binaryToHexa(this.hash)} updated as successor of microblock ${a.encode()}`)}countSectionsByType(e){return this.sections.filter(t=>t.type===e).length}addSections(t){e.logger.debug(`Adding sections to microblock: {names}`,()=>({names:t.map(e=>rC.getSectionLabelFromSection(e)).join(`, `)})),this.sections.push(...t),this.header.bodyHash=this.computeBodyHash(),this.hash=e.computeMicroblockHash(this.header)}addSection(e){this.addSections([e])}popSection(){let t=this.sections.pop();if(this.getNumberOfSections()==0||t===void 0)throw new a(`Cannot pop section from empty microblock`);return this.header.bodyHash=this.computeBodyHash(),this.hash=e.computeMicroblockHash(this.header),t}getSectionByType(e){let t=this.sections.find(t=>t.type===e);if(t===void 0)throw new Ee;return t}toString(){let e=Og.bytesToHexEncoder(),t=`Microblock:
|
|
7
7
|
`;return t+=` Hash: ${e.encode(this.hash)}\n`,t+=` Recomputed hash: ${e.encode(this.computeHash())}\n`,t+=` Header:
|
|
8
|
-
`,t+=` Microblock type: ${this.header.microblockType} or ${this.type}\n`,t+=` Magic String: ${this.header.magicString}\n`,t+=` Fees payer account: ${e.encode(this.header.feesPayerAccount)}\n`,t+=` Height: ${this.header.height}\n`,t+=` Previous Hash: ${e.encode(this.header.previousHash)}\n`,t+=` Timestamp: ${this.header.timestamp}\n`,t+=` Gas: ${this.header.gas}\n`,t+=` Gas Price: ${this.header.gasPrice}\n`,t+=` Body Hash: ${e.encode(this.header.bodyHash)}\n`,t+=` Computed body Hash: ${e.encode(this.computeBodyHash())}\n`,t+=` Sections (${this.sections.length}):\n`,this.sections.forEach((e,n)=>{t+=` Section ${n}:\n`,t+=` Section Type: ${qx.getSectionLabelFromSection(e)} (type ${e.type})\n`,t+=` Section Data: ${A.binaryToHexa(X.encodeSection(e))}\n`}),t}getType(){return this.type}setPreviousHash(e){this.header.previousHash=e.toBytes()}static extractTypeFromGenesisPreviousHash(e){return e[0]}static extractExpirationDayFromGenesisPreviousHash(e){return e[1]<<24|e[2]<<16|e[3]<<8|e[4]}getBodyHashInHeader(){return this.header.bodyHash}isDeclaringConsistentBodyHash(){let e=this.computeBodyHash();return A.binaryIsEqual(e,this.header.bodyHash)}isGenesisMicroblock(){return this.getHeight()===1}setBodyHash(e){this.header.bodyHash=e}computeHash(){let{microblockHash:e}=this.serialize();return e}setMicroblockHash(e){this.hash=e}getLastSignatureSection(){let e=this.sections[this.sections.length-1];if(e.type!==O.SIGNATURE)throw Error(`Last section is not a signature section`);return e}},nS=class{onMicroblockSearchFailureForExceedingHeight(e,t){throw e.isEmpty()?new x(Ix.from(A.getNullHash()),t):new x(e.getIdentifier(),t)}},rS=class e{static INITIAL_HEIGHT=1;static staticLogger=k.getVirtualBlockchainLogger();logger=e.staticLogger;internalState;height;identifier;microblockHashByHeight;microblockByHeight;provider;type;merkleRootHash;expirationDay;microblockSearchFailureFallback;onMicroblockInsertionEventListeners=[];constructor(e,t,n){this.internalState=n,this.provider=e,this.microblockHashByHeight=new Map,this.microblockByHeight=new Map,this.type=t,this.merkleRootHash=A.getNullHash(),this.expirationDay=0,this.height=0,this.microblockSearchFailureFallback=new nS}async isAccountIdAllowedToWrite(e){if(this.height===0)return!0;let t=await this.getVirtualBlockchainOwnerId();return A.binaryIsEqual(t.toBytes(),e.toBytes())}getProvider(){return this.provider}addOnMicroblockInsertionEventListener(e){this.onMicroblockInsertionEventListeners.push(e)}getInternalState(){return this.internalState}setInternalState(e){this.internalState=e}setMerkleRootHash(e){this.merkleRootHash=e}getMerkleRootHash(){return this.merkleRootHash}async createMicroblock(){if(this.isEmpty())return new tS(this.type);let e=await this.getLastMicroblock(),t=new tS(this.type);return t.setPreviousHash(e.getHash()),t.setHeight(this.getHeight()+1),t}getLastMicroblock(){return this.getMicroblock(this.getHeight())}setHeight(e){this.height=e}setIdentifier(e){this.logger.debug(`Updating virtual blockchain identifier to ${A.binaryToHexa(e)}`),this.identifier=e}setMicroblockHashes(e){let t=1;for(let n of e)this.microblockHashByHeight.set(t,n),t++}setExpirationDay(e){this.expirationDay=e}async getSerializedVirtualBlockchainState(){return X.encodeVirtualBlockchainState(await this.getVirtualBlockchainState())}async getGenesisSeed(){return(await this.getFirstMicroBlock()).getPreviousHash()}getHeight(){return this.height}getId(){return this.identifier}isVirtualBlockchainIdDefined(){return this.identifier instanceof Uint8Array}async getFirstMicroBlock(){return this.getMicroblock(1)}getAllMicroblockHashes(){let e=[];for(let t of this.microblockHashByHeight.entries())e.push(Ix.from(t[1]));return e}async getMicroblock(e){if(this.logger.debug(`Accessing microblock at height ${e} of vb`),e<1)throw new i(`Cannot retrieve microblock at height strictly lower than 1: got ${e}`);if(this.getHeight()<e)return await this.microblockSearchFailureFallback.onMicroblockSearchFailureForExceedingHeight(this,e);let t=this.microblockByHeight.get(e);if(t!==void 0)return t;let n=await this.provider.getSerializedMicroblockByHeight(this.getId(),e);if(n===null)throw Sg.bytesToHexEncoder(),Error(`Unable to load microblock at height ${e}`);let r=tS.loadFromSerializedMicroblock(n,this.type);if(r.getHeight()!==e)throw Error(`Received microblock contains an unexpected height: expected ${e}, got ${r.getHeight()} `);this.microblockByHeight.set(e,r);for(let e of this.onMicroblockInsertionEventListeners)e.onMicroblockInserted(this,r);return r}getIdentifier(){if(this.identifier===void 0)throw new a(`You cannot access identifier of an empty virtual blockchain (current height is ${this.height})`);return Ix.from(this.identifier)}isEmpty(){return this.getHeight()===0}async appendMicroBlock(e){if(!e||!(e instanceof tS))throw Error(`Microblock cannot be null or undefined`);if(e.getType()!==this.type)throw Error(`Invalid microblock type for append operation`);if(this.isEmpty()&&this.identifier instanceof Uint8Array)throw Error(`Virtual blockchain is empty but is initialized: should not happen`);if(!this.isEmpty()&&!(this.identifier instanceof Uint8Array))throw Error(`Virtual blockchain is empty but has an identifier: should not happen`);let t=this.height+1,n=e.getHeight();if(t!==n)throw Error(`Microblock height mismatch: expected ${t} but got ${n}`);if(!this.isEmpty()){let t=(await this.getLastMicroblock()).getHash().toBytes(),n=e.getPreviousHash().toBytes();if(!A.binaryIsEqual(n,t))throw Error(`Previous hash mismatch: microblock's previous hash ${A.binaryToHexa(n)} does not match the last microblock's hash ${A.binaryToHexa(t)}`)}if(!this.checkMicroblockStructure(e))throw new i(`Provided microblock has an invalid structure`);let r=await this.provider.getProtocolState();this.internalState=await this.updateInternalState(r,this.internalState,e),this.identifier===void 0&&(this.identifier=e.getHash().toBytes()),this.height+=1;let a=e.getHash().toBytes();this.microblockHashByHeight.set(this.height,a),this.microblockByHeight.set(this.height,e),this.logger.debug(`Microblock ${A.binaryToHexa(a)} added to vb (now at height ${this.height} `)}setMicroblockSearchFailureFallback(e){this.microblockSearchFailureFallback=e}getType(){return this.type}getExpirationDay(){return this.expirationDay}},Z=function(e){return e[e.ANY=0]=`ANY`,e[e.ZERO=1]=`ZERO`,e[e.ONE=2]=`ONE`,e[e.AT_MOST_ONE=3]=`AT_MOST_ONE`,e[e.AT_LEAST_ONE=4]=`AT_LEAST_ONE`,e}({}),iS={[Z.ANY]:`Any`,[Z.ONE]:`Exactly one`,[Z.ZERO]:`Exactly zero`,[Z.AT_LEAST_ONE]:`At least one`,[Z.AT_MOST_ONE]:`At most one`},aS=class{microblock;pointer;constructor(e){this.microblock=e,this.pointer=0}isFirstBlock(){return this.microblock.getHeight()==1}expects(e,t){let n=0;for(;!this.endOfList()&&this.currentSection().type==t;)n++,this.pointer++;if(!this.checkConstraint(e,n))throw new s(`expected ${iS[e]} of type ${this.getSectionLabelBySectionType(t)} in section, got ${n}`);return n}group(e,t){let n=new Map,r=0;for(let[e,r]of t)n.set(r,0);for(;!this.endOfList();){let e=this.currentSection().type;if(!t.some(([t,n])=>n==e))break;n.set(e,n.get(e)+1),r++,this.pointer++}if(!this.checkConstraint(e,r))throw new s(`expected ${iS[e]} section(s) in group, got ${r}`);for(let[e,r]of t){let t=n.get(r);if(!this.checkConstraint(e,t))throw new s(`expected ${iS[e]} of type ${this.getSectionLabelBySectionType(r)} in group section, got ${t}`)}}endsHere(){if(!this.endOfList()){let e=this.currentSection().type;throw new s(`Unexpected section ${this.getSectionLabelBySectionType(e)}`)}}currentSection(){return this.microblock.getAllSections()[this.pointer]}endOfList(){return!this.currentSection()}checkConstraint(e,t){switch(e){case Z.ANY:return!0;case Z.ZERO:return t==0;case Z.ONE:return t==1;case Z.AT_LEAST_ONE:return t>=1;case Z.AT_MOST_ONE:return t<=1}return!1}getSectionLabelBySectionType(e){return qx.getSectionLabelFromSectionType(e)}},oS=class{logger=k.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new aS(e);return t.expects(t.isFirstBlock()?Z.ONE:Z.ZERO,O.ORG_CREATION),t.group(Z.AT_LEAST_ONE,[[Z.AT_MOST_ONE,O.ORG_DESCRIPTION],[Z.ANY,O.CUSTOM]]),t.expects(Z.ANY,O.AUXILIARY_SIGNATURE),t.expects(Z.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return typeof e==`string`&&this.logger.error(`Microblock structure error details: ${e}`),e instanceof Error&&(e instanceof s?this.logger.error(`Microblock structure error: ${e.message}`):this.logger.error(`An unexpected error occurred during structure checking: ${e.message} at ${e.stack}`)),!1}}},sS=class e extends rS{static createOrganizationVirtualBlockchain(t){return new e(t)}constructor(e,t=Vx.createInitialState()){super(e,H.ORGANIZATION_VIRTUAL_BLOCKCHAIN,t)}async updateInternalState(e,t,n){let r=e.getOrganizationInternalStateUpdaterVersion();return Qx.createOrganizationInternalStateUpdater(r).updateState(this.provider,t,n)}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?A.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType(),merkleRootHash:this.getMerkleRootHash()}}async getVirtualBlockchainOwnerId(){return this.internalState.getAccountId()}checkMicroblockStructure(e){return new oS().checkMicroblockStructure(e)}getAccountId(){return this.internalState.getAccountId()}async getDescription(){let e=this.internalState.getDescriptionHeight(),t=await this.getMicroblock(e);for(let e of t.getAllSections())if(e.type===O.ORG_DESCRIPTION)return e;throw new a(`No description found for the organization`)}},cS=class{logger=k.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new aS(e);return!t.isFirstBlock()&&t.expects(Z.AT_MOST_ONE,O.ACCOUNT_ESCROW_SETTLEMENT)===1||(t.expects(t.isFirstBlock()?Z.ONE:Z.AT_MOST_ONE,O.ACCOUNT_PUBLIC_KEY),t.isFirstBlock()?t.group(Z.ONE,[[Z.AT_MOST_ONE,O.ACCOUNT_TOKEN_ISSUANCE],[Z.AT_MOST_ONE,O.ACCOUNT_CREATION],[Z.ANY,O.CUSTOM]]):t.group(Z.AT_LEAST_ONE,[[Z.ANY,O.ACCOUNT_TRANSFER],[Z.ANY,O.ACCOUNT_VESTING_TRANSFER],[Z.ANY,O.ACCOUNT_STAKE],[Z.ANY,O.ACCOUNT_UNSTAKE],[Z.ANY,O.ACCOUNT_ESCROW_TRANSFER],[Z.ANY,O.CUSTOM]])),t.expects(Z.ANY,O.AUXILIARY_SIGNATURE),t.expects(Z.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return e instanceof Error&&(e instanceof s?this.logger.error(`Invalid microblock structure: ${e.message}`):this.logger.error(`Unexpected error occurred during microblock structure checking: ${e.message} at ${e.stack}`)),!1}}},lS=class extends rS{constructor(e,t=Fx.createInitialState()){super(e,H.ACCOUNT_VIRTUAL_BLOCKCHAIN,t)}async updateInternalState(e,t,n){let r=e.getAccountInternalStateUpdaterVersion();return Qx.createAccountInternalStateUpdater(r).updateState(this.provider,t,n)}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?A.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType(),merkleRootHash:this.getMerkleRootHash()}}async getVirtualBlockchainOwnerId(){return Ix.from(this.getId())}checkMicroblockStructure(e){return new cS().checkMicroblockStructure(e)}async getPublicKey(){let e=this.internalState.getPublicKeyHeight(),t=this.internalState.getPublicKeySchemeId(),n=await this.getMicroblock(e);for(let e of n.getAllSections())if(e.type===O.ACCOUNT_PUBLIC_KEY)return new $v().createPublicSignatureKey(t,e.publicKey);throw new a(`Account public key not found`)}async isIssuer(){let e=await this.getFirstMicroBlock();for(let t of e.getAllSections())if(t.type===O.ACCOUNT_TOKEN_ISSUANCE)return!0;return!1}static async createAccountCreationMicroblock(e,t,n,r=``){let i=tS.createGenesisAccountMicroblock();return i.addSection({type:O.ACCOUNT_PUBLIC_KEY,publicKey:await e.getPublicKeyAsBytes(),schemeId:e.getSignatureSchemeId()}),i.addSection({type:O.ACCOUNT_CREATION,amount:t.getAmountAsAtomic(),sellerAccount:n}),i}static async createIssuerAccountCreationMicroblock(e){let t=e,n=tS.createGenesisAccountMicroblock();return n.addSection({type:O.ACCOUNT_PUBLIC_KEY,publicKey:await t.getPublicKeyAsBytes(),schemeId:t.getSignatureSchemeId()}),n.addSection({type:O.ACCOUNT_TOKEN_ISSUANCE,amount:lr}),n}},uS=class{logger=k.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new aS(e);return t.expects(t.isFirstBlock()?Z.ONE:Z.ZERO,O.APP_CREATION),t.group(Z.AT_LEAST_ONE,[[Z.AT_MOST_ONE,O.APP_DESCRIPTION],[Z.ANY,O.CUSTOM]]),t.expects(Z.ANY,O.AUXILIARY_SIGNATURE),t.expects(Z.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return e instanceof Error&&(e instanceof s?this.logger.error(`Invalid microblock structure: ${e.message}`):this.logger.error(`Unexpected error occurred during microblock structure checking: ${e.message} at ${e.stack}`)),!1}}},dS=class extends rS{constructor(e,t=Lx.createInitialState()){super(e,H.APPLICATION_VIRTUAL_BLOCKCHAIN,t)}async updateInternalState(e,t,n){let r=e.getApplicationInternalStateUpdaterVersion();return Qx.createApplicationInternalStateUpdater(r).updateState(this.provider,t,n)}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?A.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType(),merkleRootHash:this.getMerkleRootHash()}}async getVirtualBlockchainOwnerId(){let e=this.internalState.getOrganizationId();return(await this.provider.loadOrganizationVirtualBlockchain(e)).getVirtualBlockchainOwnerId()}checkMicroblockStructure(e){return new uS().checkMicroblockStructure(e)}getOrganizationId(){return this.internalState.getOrganizationId()}async getApplicationDescription(){let e=this.internalState.getDescriptionHeight(),t=await this.getMicroblock(e);for(let e of t.getAllSections())if(e.type==O.APP_DESCRIPTION)return e;throw Error(`Application description not found`)}},fS=class{logger=k.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new aS(e),n=!t.isFirstBlock()&&t.expects(Z.AT_MOST_ONE,O.VN_APPROVAL)===1,r=!n&&!t.isFirstBlock()&&t.expects(Z.AT_MOST_ONE,O.VN_SLASHING_CANCELLATION)===1;return!n&&!r&&(t.expects(t.isFirstBlock()?Z.ONE:Z.ZERO,O.VN_CREATION),t.group(Z.AT_LEAST_ONE,[[Z.AT_MOST_ONE,O.VN_COMETBFT_PUBLIC_KEY_DECLARATION],[Z.AT_MOST_ONE,O.VN_RPC_ENDPOINT],[Z.ANY,O.CUSTOM]])),t.expects(Z.ANY,O.AUXILIARY_SIGNATURE),t.expects(Z.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return e instanceof Error&&(e instanceof s?this.logger.error(`Invalid microblock structure: ${e.message}`):this.logger.error(`Unexpected error occurred during microblock structure checking: ${e.message} at ${e.stack}`)),!1}}},pS=class extends rS{constructor(e,t=Hx.createInitialState()){super(e,H.NODE_VIRTUAL_BLOCKCHAIN,t)}async updateInternalState(e,t,n){let r=e.getValidatorNodeInternalStateUpdaterVersion();return Qx.createValidatorNodeInternalStateUpdater(r).updateState(this.provider,t,n)}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?A.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType(),merkleRootHash:this.getMerkleRootHash()}}async getVirtualBlockchainOwnerId(){let e=await this.getOrganizationId();return(await this.provider.loadOrganizationVirtualBlockchain(e)).getVirtualBlockchainOwnerId()}async getOrganizationId(){return this.internalState.getOrganizationId()}checkMicroblockStructure(e){return new fS().checkMicroblockStructure(e)}async getCometbftPublicKeyDeclaration(){let e=this.internalState.getCometbftPublicKeyDeclarationHeight();if(e===0)throw new a(`Node has not declared its CometBFT public key yet`);let t=await this.getMicroblock(e);for(let e of t.getAllSections()){if(e.type!==O.VN_COMETBFT_PUBLIC_KEY_DECLARATION)continue;let t=e.cometPublicKey;return{cometbftPublicKeyType:e.cometPublicKeyType,cometbftPublicKey:t}}throw new a(`Node has not declared its CometBFT public key yet`)}async getRpcEndpointDeclaration(){let e=this.internalState.getRpcEndpointHeight();if(e===0)throw new a(`Node has not declared its RPC endpoint yet`);let t=await this.getMicroblock(e);for(let e of t.getAllSections())if(e.type===O.VN_RPC_ENDPOINT)return e.rpcEndpoint;throw new a(`Node has not declared its RPC endpoint yet`)}getNodeDeclarationHeight(){return this.getInternalState().getCometbftPublicKeyDeclarationHeight()}async getOrganizationVirtualBlockchain(){let e=this.internalState.getOrganizationId();return await this.provider.loadOrganizationVirtualBlockchain(e)}},mS=class{logger=k.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new aS(e);return t.expects(t.isFirstBlock()?Z.ONE:Z.ZERO,O.PROTOCOL_CREATION),t.isFirstBlock()||t.group(Z.AT_MOST_ONE,[[Z.ONE,O.PROTOCOL_UPDATE],[Z.ANY,O.CUSTOM]]),t.expects(Z.ANY,O.AUXILIARY_SIGNATURE),t.expects(Z.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return typeof e==`string`&&this.logger.error(`Microblock structure error details: ${e}`),e instanceof Error&&(e instanceof s?this.logger.error(`Microblock structure error: ${e.message}`):this.logger.error(`An unexpected error occurred during structure checking: ${e.message} at ${e.stack}`)),!1}}},hS=class extends rS{constructor(e,t=Bx.createInitialState()){super(e,H.PROTOCOL_VIRTUAL_BLOCKCHAIN,t)}checkMicroblockStructure(e){return new mS().checkMicroblockStructure(e)}async updateInternalState(e,t,n){let r=e.getProtocolInternalStateUpdaterVersion();return Qx.createProtocolInternalStateUpdater(r).updateState(this.provider,t,n)}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?A.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType(),merkleRootHash:this.getMerkleRootHash()}}async getVirtualBlockchainOwnerId(){let e=await this.getOrganizationId();return(await this.provider.loadOrganizationVirtualBlockchain(e)).getVirtualBlockchainOwnerId()}async getOrganizationId(){let e=(await this.getFirstMicroBlock()).getAllSections();for(let t of e)if(t.type===O.PROTOCOL_CREATION)return Ix.from(t.organizationId);throw Error(`Organization ID not found in protocol vb`)}},gS=class{static assert(e,t=`Unspecified verification`){if(!e)throw new m(`Assertion failed: ${t}`)}},_S=class{logger=k.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new aS(e);return t.expects(t.isFirstBlock()?Z.ONE:Z.ZERO,O.APP_LEDGER_CREATION),t.group(Z.ANY,[[Z.ANY,O.APP_LEDGER_ACTOR_CREATION],[Z.ANY,O.APP_LEDGER_ACTOR_SUBSCRIPTION],[Z.ANY,O.APP_LEDGER_ENDORSEMENT_REQUEST],[Z.ANY,O.APP_LEDGER_AUTHOR],[Z.ANY,O.APP_LEDGER_PUBLIC_CHANNEL_DATA],[Z.ANY,O.APP_LEDGER_PRIVATE_CHANNEL_DATA],[Z.ANY,O.APP_LEDGER_SHARED_SECRET],[Z.ANY,O.APP_LEDGER_CHANNEL_CREATION],[Z.ANY,O.APP_LEDGER_CHANNEL_INVITATION],[Z.ANY,O.ALLOWED_ADDITIONAL_WRITER],[Z.ANY,O.CUSTOM]]),t.expects(Z.ANY,O.AUXILIARY_SIGNATURE),t.expects(Z.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return typeof e==`string`&&this.logger.error(`Microblock structure error details: ${e}`),e instanceof Error&&(e instanceof s?this.logger.error(`Microblock structure error: ${e.message}`):this.logger.error(`An unexpected error occurred during structure checking: ${e.message} at ${e.stack}`)),!1}}},vS=class e{identifier;microblocks;constructor(){this.identifier=``,this.microblocks=[]}static fromObject(t){let n=new e;n.setIdentifier(t.id);for(let e of t.microblocks)n.addMicroblock(e.height,e.channels);return n}toObject(){return{id:this.identifier,microblocks:this.microblocks}}setIdentifier(e){this.identifier=e}getIdentifier(){return this.identifier}addMicroblock(e,t){let n={height:e,channels:t};this.microblocks.push(n)}getMicroblock(e){let t=this.microblocks.find(t=>t.height===e);if(!t)throw Error(`no microblock found for height ${e}`);return t}getMicroblocks(){return this.microblocks}},yS=N(rm([L(),F()])),bS=function(e){return e[e.None=0]=`None`,e[e.Hashable=1]=`Hashable`,e[e.Maskable=2]=`Maskable`,e}({}),xS=am(`type`,[I({type:P(bS.None)}),I({type:P(bS.Hashable)}),I({type:P(bS.Maskable),visibleParts:N(L()),hiddenParts:N(L())})]),SS=function(e){return e[e.String=0]=`String`,e[e.Number=1]=`Number`,e[e.Boolean=2]=`Boolean`,e[e.Null=3]=`Null`,e[e.Array=4]=`Array`,e[e.Object=5]=`Object`,e}({}),CS,wS={channelId:F()};CS=am(`type`,[I({...wS,type:P(SS.String),value:L(),transformation:xS}),I({...wS,type:P(SS.Number),value:F()}),I({...wS,type:P(SS.Boolean),value:Gp()}),I({...wS,type:P(SS.Null),value:Zp()}),I({type:P(SS.Array),value:N(Xp(()=>CS))}),I({type:P(SS.Object),value:N(I({key:L(),value:Xp(()=>CS)}))})]);var TS=rm([L(),F(),Gp(),Zp()]),ES=I({pepper:B(),data:B()}),DS=I({path:yS,value:TS,transformation:$p(xS)}),OS=N(DS),Q=function(e){return e[e.Public=0]=`Public`,e[e.Plain=1]=`Plain`,e[e.HashableFromValue=2]=`HashableFromValue`,e[e.Hashable=3]=`Hashable`,e[e.MaskableFromAllParts=4]=`MaskableFromAllParts`,e[e.MaskableFromVisibleParts=5]=`MaskableFromVisibleParts`,e[e.Maskable=6]=`Maskable`,e}({});Q.Public,Q.Plain,Q.HashableFromValue,Q.Hashable,Q.MaskableFromAllParts,Q.MaskableFromVisibleParts,Q.Maskable;var kS=function(e){return e[e.Public=0]=`Public`,e[e.Plain=1]=`Plain`,e[e.HashableAsPlain=2]=`HashableAsPlain`,e[e.HashableAsHash=3]=`HashableAsHash`,e[e.MaskableAsAllParts=4]=`MaskableAsAllParts`,e[e.MaskableAsVisibleParts=5]=`MaskableAsVisibleParts`,e}({}),AS=I({path:yS,type:P(kS.Public),value:TS}),jS={path:yS,index:F()},MS=am(`type`,[AS,I({...jS,type:P(kS.Plain),salt:L(),value:TS}),I({...jS,type:P(kS.HashableAsPlain),salt:L(),value:TS}),I({...jS,type:P(kS.HashableAsHash),salt:L(),hash:L()}),I({...jS,type:P(kS.MaskableAsAllParts),vSalt:L(),vParts:N(L()),hSalt:L(),hParts:N(L())}),I({...jS,type:P(kS.MaskableAsVisibleParts),vSalt:L(),vParts:N(L()),hHash:L()})]),NS=I({virtualBlockchains:N(I({id:L(),microblocks:N(I({height:F(),channels:N(I({id:F(),isPublic:Gp(),nLeaves:F(),fields:N(MS),witnesses:N(L())}))}))}))}),PS=I({height:F(),vbRadixHash:B(),tokenRadixHash:B(),storageHash:B(),appHash:B()}),FS=I({height:F(),vbRadixHash:L(),tokenRadixHash:L(),storageHash:L(),appHash:L()}),IS=I({block:PS,account:I({virtualBlockchainId:B(),state:lg,radixProof:N(B())})}),LS=I({block:FS,account:I({virtualBlockchainId:L(),serializedState:L(),radixProof:N(L())})}),RS=I({accounts:N(LS)}),zS=I({block:PS,microblock:I({virtualBlockchainId:B(),height:F(),hash:B()}),virtualBlockchain:I({state:Gh,merkleWitnesses:N(B()),radixProof:N(B())})}),BS=I({block:FS,microblock:I({virtualBlockchainId:L(),height:F(),hash:L()}),virtualBlockchain:I({serializedState:L(),merkleWitnesses:N(L()),radixProof:N(L())})}),VS=I({microblocks:N(BS)}),HS=I({version:F(),chainId:L(),description:L(),date:L(),author:L()}),US=I({commitment:I({issuedAt:$p(L()),digestAlg:$p(em([`sha256`])),digestTarget:$p(em([`cborProof`])),digest:$p(L())}),signer:L(),pubkey:L(),alg:em([`ecdsaSecp256k1`,`mlDsa65`]),sig:L()}),WS=I({type:P(`appLedgerProof`),proof:NS}),GS=I({type:P(`accountProof`),proof:RS}),KS=I({type:P(`microblockProof`),proof:VS}),qS=am(`type`,[WS,GS,KS]),JS=I({info:HS}),YS=I({signature:$p(US)}),XS=Yp([qS,JS]),ZS=Yp([XS,YS]),QS=Yp([WS,JS]),$S=Yp([QS,YS]),eC=Yp([GS,JS]),tC=Yp([eC,YS]),nC=Yp([KS,JS]),rC=Yp([nC,YS]),iC=class{wrapper;encoder=new kx;constructor(e){this.wrapper=e}static getDefaultInfo(e,t){return{version:e,chainId:t,description:`This is a Carmentis proof file. Visit www.carmentis.io for more information.`,author:``,date:new Date().toISOString()}}getObject(){return this.wrapper}setVersion(e){this.wrapper.info.version=e}getVersion(){return this.wrapper.info.version}setChainId(e){this.wrapper.info.chainId=e}getChainId(){return this.wrapper.info.chainId}setDescription(e){this.wrapper.info.description=e}getDescription(){return this.wrapper.info.description}setAuthor(e){this.wrapper.info.author=e}getAuthor(){return this.wrapper.info.author}setDate(e){this.wrapper.info.date=e.toISOString()}getDate(){return new Date(this.wrapper.info.date)}sign(e=new Date){let t=this.computeDigest(),n={issuedAt:e.toISOString(),digestAlg:`sha256`,digestTarget:`cborProof`,digest:A.binaryToHexa(t)},r=this.encoder.encode(n);xp.Hashes.sha256AsBinary(r),this.wrapper.signature={commitment:n,signer:``,pubkey:``,alg:`ecdsaSecp256k1`,sig:``}}verifySignature(){this.computeDigest()}computeDigest(){let{signature:e,...t}=this.wrapper,n=R(XS,t),r=this.encoder.encode(n);return xp.Hashes.sha256AsBinary(r)}},aC=1,oC=class e extends iC{constructor(e){super(e)}static createEmptyProof(t){return new e({type:`appLedgerProof`,info:iC.getDefaultInfo(aC,t),proof:{virtualBlockchains:[]}})}static fromObject(t){return new e(R($S,t))}addVirtualBlockchain(e){this.wrapper.proof.virtualBlockchains.push(e.toObject())}getSingleVirtualBlockchainOrFail(){let e=this.getVirtualBlockchains();if(e.length==0)throw Error(`no virtual blockchain is defined in this proof`);if(e.length>1)throw Error(`proofs with multiple virtual blockchains are not supported at this time`);return e[0]}getVirtualBlockchain(e){let t=this.wrapper.proof.virtualBlockchains.find(t=>t.id===e);if(!t)throw Error(`no virtual blockchain found with ID ${e}`);return t}getVirtualBlockchains(){return this.wrapper.proof.virtualBlockchains.map(e=>vS.fromObject(e))}},sC=class{leaves;nLeaves;tree;constructor(){this.leaves=[],this.nLeaves=0,this.tree=[]}addLeaf(e){this.checkHash(e),this.leaves.push(e)}setLeaf(e,t){this.checkHash(t),this.leaves[e]=t}checkHash(e){if(e.length!=32)throw Error(`invalid hash: expected size is 32 bytes, got ${e.length}`)}finalize(e=void 0){this.nLeaves=e===void 0?this.leaves.length:e,this.buildTreeStructure()}getNumberOfLeaves(){return this.nLeaves}getRootHash(){let e=this.tree.length-1;for(let t=0;t<e;t++){let e=this.tree[t];for(let n=0;n<e.length;n+=2)e[n]&&e[n+1]&&(this.tree[t+1][n>>1]=this.mergeHashes(t+1,e[n],e[n+1]))}return this.tree[e][0]}getWitnesses(e){let t=new Set(e),n=this.getWitnessPositions(t),r=[];for(let e=0;e<this.tree[0].length;e++)if(!t.has(e)&&!this.tree[0][e])throw Error(`cannot find leaf at index ${e}`);for(let[e,t]of n){let n=this.tree[e][t];if(!n)throw Error(`cannot find witness hash at depth ${e}, index ${t}`);r.push(n)}return r}setWitnesses(e){let t=new Set;for(let e=0;e<this.nLeaves;e++)this.leaves[e]||t.add(e);let n=this.getWitnessPositions(t);if(e.length!=n.length)throw Error(`invalid witness list: expected ${n.length} witness(es), got ${e.length}`);let r=0;for(let[t,i]of n)this.checkHash(e[r]),this.tree[t][i]=e[r++]}buildTreeStructure(){let e=this.nLeaves;for(this.tree=[];e;){let t=Array(e).fill(null);e>1&&e&1&&(t.push(A.getNullHash()),e++),this.tree.push(t),e>>=1}for(let e=0;e<this.nLeaves;e++)this.leaves[e]&&(this.tree[0][e]=this.leaves[e])}getWitnessPositions(e){let t=this.nLeaves,n=[];for(let r=0;t;r++){let i=new Set;for(let a=0;a<t;a+=2){let o=e.has(a),s=a+1<t&&e.has(a+1);o&&s?i.add(a>>1):(o||s)&&n.push([r,s?a+1:a])}e=i,t=t+ +(t>1)>>1}return n}mergeHashes(e,t,n){let r=new Uint8Array(65);return r[0]=+(e==this.tree.length-1),r.set(t,1),r.set(n,33),xp.Hashes.sha256AsBinary(r)}},cC=class e{internalData=void 0;encoder=new kx;static fromProofFormat(t){let n=new e;return n.fromProofField(t),n}static fromItemWithPublicData(t){let n=new e;return n.setPublicDataFromValue(t.value),n}static fromItemWithPlainData(t,n){let r=new e,i=t.getSalt();return r.setPlainDataFromValue(i,n.value),r}static fromItemWithHashedData(t,n){let r=new e,i=t.getSalt();return r.setHashedDataFromValue(i,n.value),r}static fromItemWithMaskedData(t,n){let r=new e,i=t.getSalt(),a=t.getSalt();return r.setMaskedDataFromAllParts(i,n.transformation.visibleParts,a,n.transformation.hiddenParts),r}setPublicDataFromValue(e){this.internalData={type:Q.Public,value:e}}setPlainDataFromValue(e,t){this.internalData={type:Q.Plain,salt:e,value:t}}setHashedDataFromValue(e,t){this.internalData={type:Q.HashableFromValue,salt:e,value:t}}setHashedDataFromHash(e,t){this.internalData={type:Q.Hashable,salt:e,hash:t}}setMaskedDataFromAllParts(e,t,n,r){let i={salt:e,parts:t},a={salt:n,parts:r};this.internalData={type:Q.MaskableFromAllParts,visible:i,hidden:a}}setMaskedDataFromVisibleParts(e,t,n){let r={salt:e,parts:t};this.internalData={type:Q.MaskableFromVisibleParts,visible:r,hiddenHash:n}}setToHashed(){let e=this.getInternalData();if(e.type==Q.Hashable)return;if(e.type!=Q.HashableFromValue)throw Error(`this field is not hashable`);let t=this.encoder.encode(e.value),n=xp.Hashes.sha256AsBinary(t);this.setHashedDataFromHash(e.salt,n)}setToMasked(){let e=this.getInternalData();if(e.type==Q.MaskableFromVisibleParts)return;if(e.type!=Q.MaskableFromAllParts)throw Error(`this field is not maskable`);let t=this.encoder.encode(e.hidden),n=xp.Hashes.sha256AsBinary(t);this.setMaskedDataFromVisibleParts(e.visible.salt,e.visible.parts,n)}getInternalData(){if(this.internalData===void 0)throw Error(`internal leaf data has not been set`);return this.internalData}fromProofField(e){switch(e.type){case kS.Public:this.setPublicDataFromValue(e.value);break;case kS.Plain:this.setPlainDataFromValue(A.binaryFromHexa(e.salt),e.value);break;case kS.HashableAsPlain:this.setHashedDataFromValue(A.binaryFromHexa(e.salt),e.value);break;case kS.HashableAsHash:this.setHashedDataFromHash(A.binaryFromHexa(e.salt),A.binaryFromHexa(e.hash));break;case kS.MaskableAsAllParts:this.setMaskedDataFromAllParts(A.binaryFromHexa(e.vSalt),e.vParts,A.binaryFromHexa(e.hSalt),e.hParts);break;case kS.MaskableAsVisibleParts:this.setMaskedDataFromVisibleParts(A.binaryFromHexa(e.vSalt),e.vParts,A.binaryFromHexa(e.hHash));break}}toProofFormat(e,t){let n=this.getInternalData();switch(n.type){case Q.Public:return{path:e,type:kS.Public,value:n.value};case Q.Plain:return{path:e,index:t,type:kS.Plain,salt:A.binaryToHexa(n.salt),value:n.value};case Q.HashableFromValue:return{path:e,index:t,type:kS.HashableAsPlain,salt:A.binaryToHexa(n.salt),value:n.value};case Q.Hashable:return{path:e,index:t,type:kS.HashableAsHash,salt:A.binaryToHexa(n.salt),hash:A.binaryToHexa(n.hash)};case Q.MaskableFromAllParts:return{path:e,index:t,type:kS.MaskableAsAllParts,vSalt:A.binaryToHexa(n.visible.salt),vParts:n.visible.parts,hSalt:A.binaryToHexa(n.hidden.salt),hParts:n.hidden.parts};case Q.MaskableFromVisibleParts:return{path:e,index:t,type:kS.MaskableAsVisibleParts,vSalt:A.binaryToHexa(n.visible.salt),vParts:n.visible.parts,hHash:A.binaryToHexa(n.hiddenHash)};default:throw Error(`invalid internal data type ${n.type}`)}}getCommitmentData(){let e=this.getInternalData();switch(e.type){case Q.Public:case Q.Plain:case Q.Hashable:return e;case Q.HashableFromValue:{let t=this.encoder.encode(e.value),n=xp.Hashes.sha256AsBinary(t);return{type:Q.Hashable,salt:e.salt,hash:n}}case Q.MaskableFromAllParts:{let t=this.encoder.encode(e.visible),n=xp.Hashes.sha256AsBinary(t),r=this.encoder.encode(e.hidden),i=xp.Hashes.sha256AsBinary(r);return{type:Q.Maskable,visibleHash:n,hiddenHash:i}}case Q.MaskableFromVisibleParts:{let t=this.encoder.encode(e.visible),n=xp.Hashes.sha256AsBinary(t);return{type:Q.Maskable,visibleHash:n,hiddenHash:e.hiddenHash}}default:throw Error(`invalid internal data type ${e.type}`)}}getHash(){let e=this.getCommitmentData(),t=this.encoder.encode(e);return xp.Hashes.sha256AsBinary(t)}getRawValue(){let e=this.getInternalData();switch(e.type){case Q.Public:case Q.Plain:case Q.HashableFromValue:return e.value;case Q.Hashable:return A.binaryToHexa(e.hash);case Q.MaskableFromAllParts:return e.visible.parts.map((t,n)=>n&1?e.hidden.parts[n>>1]:t).join(``);case Q.MaskableFromVisibleParts:return e.visible.parts.join(``);default:throw Error(`invalid internal data type ${e.type}`)}}getTypedValue(){let e=this.getInternalData(),t=this.getRawValue();switch(e.type){case Q.Public:case Q.Plain:case Q.HashableFromValue:case Q.MaskableFromAllParts:return{disclosure:`plain`,value:t};case Q.Hashable:return{disclosure:`hashed`,value:t};case Q.MaskableFromVisibleParts:return{disclosure:`masked`,value:t};default:throw Error(`invalid internal data type ${e.type}`)}}},lC=class e{channelMap;fieldMap;publicChannels;constructor(){this.channelMap=new Map,this.fieldMap=new Map,this.publicChannels=new Set}static fromMerkleRecord(t){let n=new e;return n.setChannelsFromMerkleRecord(t),n}static fromProofChannels(t){let n=new e;return n.setChannelsFromProofChannels(t),n}setChannelsFromMerkleRecord(e){this.publicChannels=e.getPublicChannels();let t=e.getLeavesByChannelMap();for(let[e,n]of t)this.channelMap.set(e,{nLeaves:n.length,leaves:n,tree:new sC,witnesses:[]});this.buildTrees(),this.buildFieldMap()}setChannelsFromProofChannels(e){for(let t of e){let e=[];for(let n of t.fields){let t=cC.fromProofFormat(n),r=n.type==kS.Public?0:n.index;e.push({leaf:t,path:n.path,index:r})}let n=t.witnesses.map(e=>A.binaryFromHexa(e));t.isPublic&&this.publicChannels.add(t.id),this.channelMap.set(t.id,{nLeaves:t.nLeaves,leaves:e,tree:new sC,witnesses:n})}this.buildTrees(),this.buildFieldMap()}toJson(e=!1){let t={},n=[];for(let{leaves:e}of this.channelMap.values())for(let t of e)t!==null&&n.push(t);for(let{path:r,leaf:i}of n){let n=[`root`,...r],a=t;for(let t=0;t<n.length;t++){let r=n[t];if(t==n.length-1)a[r]=e?i.getTypedValue():i.getRawValue();else{let e=typeof n[t+1]==`number`;if(a[r]===void 0)a[r]=e?[]:{};else if(Array.isArray(a[r])!==e){let e=n.slice(0,t+1).join(`.`);throw Error(`${e} is defined as both an array and an object`)}a=a[r]}}}return t.root}buildTrees(){for(let[e,t]of this.channelMap)if(!this.publicChannels.has(e)){for(let e of t.leaves)e!==null&&t.tree.setLeaf(e.index,e.leaf.getHash());t.tree.finalize(t.nLeaves),t.tree.setWitnesses(t.witnesses)}}buildWitnesses(){for(let[e,t]of this.channelMap){if(this.publicChannels.has(e))continue;let n=new Set;for(let e of t.leaves)e!==null&&n.add(e.index);let r=[];for(let e=0;e<t.nLeaves;e++)n.has(e)||r.push(e);t.witnesses=t.tree.getWitnesses(r)}}buildFieldMap(){this.fieldMap.clear();for(let[e,t]of this.channelMap)for(let n=0;n<t.leaves.length;n++){let r=t.leaves[n];if(r===null)continue;let i=r.path,a=JSON.stringify(i);this.fieldMap.set(a,{channelId:e,index:n})}}getLeafByPath(e){let{channelId:t,index:n}=this.getFieldByPath(e),r=this.getChannel(t).leaves[n];if(r===null)throw Error(`this field has been removed`);return r.leaf}getFieldByPath(e){let t=JSON.stringify(e),n=this.fieldMap.get(t);if(n===void 0)throw Error(`unknown path ${t}`);return n}getChannel(e){let t=this.channelMap.get(e);if(t===void 0)throw Error(`unknown channel ID ${e}`);return t}removeField(e){let{channelId:t,index:n}=this.getFieldByPath(e),r=this.getChannel(t);r.leaves[n]=null}setFieldToHashed(e){this.getLeafByPath(e).setToHashed()}setFieldToMasked(e){this.getLeafByPath(e).setToMasked()}getRootHashAsBinary(e){let t=this.getChannel(e);return this.publicChannels.has(e)?A.getNullHash():t.tree.getRootHash()}getRootHashAsHexString(e){let t=this.getRootHashAsBinary(e);return A.binaryToHexa(t)}toProofChannels(){this.buildWitnesses();let e=[];for(let[t,n]of this.channelMap){let r=this.publicChannels.has(t),i=[];for(let e of n.leaves){if(e===null)continue;let t=e.leaf.toProofFormat(e.path,e.index);i.push(t)}let a=n.witnesses.map(e=>A.binaryToHexa(e));e.push({id:t,isPublic:r,nLeaves:n.nLeaves,fields:i,witnesses:a})}return e}},uC=class e{channelMap;publicChannels;constructor(){this.channelMap=new Map,this.publicChannels=new Set}static fromRecord(t){let n=new e;n.setPublicChannels(t.getPublicChannels());let r=t.getItemList();for(let e of r){let t=e.item.channelId,r=n.channelMap.get(t);r===void 0&&(r=[],n.channelMap.set(t,r)),r.push(e)}return n}setChannel(e,t,n){t?this.publicChannels.add(e):this.publicChannels.delete(e),this.channelMap.set(e,n)}setPublicChannels(e){this.publicChannels=e}getPublicChannels(){return this.publicChannels}getChannelIds(){return[...this.channelMap.keys()].sort((e,t)=>e-t)}getFlatItems(e){let t=this.channelMap.get(e);if(t==null)throw Error(`Channel ${e} not found`);return t}},dC=class{pepper;hasNullPepper;sha512;counter;constructor(e){this.pepper=e,this.sha512=new Uint8Array(64),this.counter=0,this.hasNullPepper=this.pepper.every(e=>e==0)}static generatePepper(){return xp.Random.getBytes(32)}getPepper(){return this.pepper}getSalt(){let e=this.counter&3,t=this.counter++>>2;return!e&&!this.hasNullPepper&&(this.sha512=xp.Hashes.sha512AsBinary(A.binaryFrom(this.pepper,t))),this.sha512.slice(e<<4,e+1<<4)}},fC=class e{channelMap;recordByChannels;publicChannels;constructor(){this.channelMap=new Map,this.publicChannels=new Set}static fromRecordByChannels(t,n=void 0){let r=new e;return r.setChannelsFromRecordByChannels(t,n),r}setChannelsFromRecordByChannels(e,t=void 0){this.publicChannels=e.getPublicChannels(),this.recordByChannels=e;let n=this.recordByChannels.getChannelIds();for(let e of n){let n=this.publicChannels.has(e),r=n?A.getNullHash():t===void 0?dC.generatePepper():t.get(e);if(r===void 0)throw Error(`no pepper specified for channel ${e}`);let i=this.recordByChannels.getFlatItems(e);this.storeChannel(e,n,i,r)}}storeChannel(e,t,n,r){let i=this.flatItemsToPositionedLeaves(n,t,r);this.channelMap.set(e,{pepper:r,positionedLeaves:i})}getPublicChannels(){return this.publicChannels}getLeavesByChannelMap(){let e=new Map;for(let[t,n]of this.channelMap)e.set(t,n.positionedLeaves);return e}getRecordByChannels(){let e=this.recordByChannels;if(e===void 0)throw Error(`recordByChannels is not set`);return e}getChannelIds(){return[...this.channelMap.keys()].sort((e,t)=>e-t)}getChannelPepper(e){return this.getChannel(e).pepper}getChannelRootHash(e){let t=this.getChannel(e);if(this.publicChannels.has(e))return A.getNullHash();let n=new sC;for(let e of t.positionedLeaves){let t=e.leaf.getHash();n.addLeaf(t)}return n.finalize(),n.getRootHash()}getChannel(e){let t=this.channelMap.get(e);if(t===void 0)throw Error(`channel ${e} not found`);return t}flatItemsToPositionedLeaves(e,t,n){let r=new dC(n);return e.map((e,n)=>({leaf:this.flatItemToLeaf(r,t,e.item),index:n,path:e.path}))}flatItemToLeaf(e,t,n){let r=n.type==SS.String?n.transformation.type:bS.None;if(t&&r!=bS.None)throw Error(`no transformation may be applied to a public field`);switch(r){case bS.None:return t?cC.fromItemWithPublicData(n):cC.fromItemWithPlainData(e,n);case bS.Hashable:return cC.fromItemWithHashedData(e,n);case bS.Maskable:return cC.fromItemWithMaskedData(e,n);default:throw Error(`unsupported transformation type ${r}`)}}},pC=Xp(()=>rm([L(),F(),Gp(),Zp(),N(pC),tm(L(),pC)])),mC=class e{itemList;publicChannels;constructor(){this.itemList=[],this.publicChannels=new Set}static fromObject(t){let n=new e,r=R(pC,t);return n.buildItemListByDfs(r),n}setChannelAsPublic(e){this.publicChannels.add(e)}setChannelAsPrivate(e){this.publicChannels.delete(e)}getPublicChannels(){return this.publicChannels}setChannel(e,t){let n=this.getFieldsByPathString(e);for(let e of n)this.setFieldChannel(e.item,t)}setFieldChannel(e,t){e.channelId=t}setAsHashable(e){let t=this.getFieldsByPathString(e);for(let e of t)this.setFieldAsHashable(e.item)}setFieldAsHashable(e){if(e.type!==SS.String)throw Error(`only a string may be set as hashable`);e.transformation={type:bS.Hashable}}setMaskOnField(e,t){if(e.type!==SS.String)throw Error(`a mask may only be applied to a string`);let n=[],r=[];t.sort((e,t)=>e.start-t.start),t.forEach((i,a)=>{let o=a>0?t[a-1].start:0,s=a>0?t[a-1].end:0;if(i.start<0||i.start>=e.value.length||i.end<=i.start)throw`invalid interval [${[i.start,i.end]}]`;if(i.start<s)throw`overlapping intervals [${[o,s]}] and [${[i.start,i.end]}]`;let c=e.value.slice(i.start,i.end);a&&i.start==s?(n[n.length-1]+=i.replacement,r[r.length-1]+=c):(n.push(e.value.slice(s,i.start),i.replacement),r.push(c)),a==t.length-1&&i.end<e.value.length&&n.push(e.value.slice(i.end))}),e.transformation={type:bS.Maskable,visibleParts:n,hiddenParts:r}}setMaskByPositions(e,t){let n=this.getFieldsByPathString(e);for(let e of n)this.setMaskOnField(e.item,t)}setMaskByRegex(e,t,n){let r=this.getFieldsByPathString(e);for(let e of r)this.setMaskByRegexOnField(e.item,t,n)}setMaskByRegexOnField(e,t,n){if(e.type!==SS.String)throw Error(`a mask may only be applied to a string`);let r=(t.exec(e.value)||[]).slice(1);if(r.join(``)!=e.value)throw`the regular expression ${t} does not capture all string parts`;let i=n.split(/(\$\d+)/).map((e,t)=>({shown:!!(t&1),string:e})).filter(e=>e.string!=``);if(i.length!=r.length||i.some((e,t)=>e.shown&&e.string!=`$`+(t+1)))throw`invalid substitution string "${n}"`;let a=[],o=0;i.forEach((e,t)=>{let n=o+r[t].length;e.shown||a.push({start:o,end:n,replacement:e.string}),o=n}),this.setMaskOnField(e,a)}getItemList(){return this.itemList}getFieldsByPathString(e){let t=e.match(/\[\d+\]|[^.[]+/g)||[];if(t[0]!==`this`)throw Error(`the path should begin with 'this'`);let n=t.slice(1).map(e=>e[0]==`[`?Number(e.slice(1,-1)):e);if(n.some((e,t)=>e==`*`&&t!=n.length-1))throw Error(`a wildcard may only appear at the end of the path`);let r=n[n.length-1]==`*`;return this.itemList.filter(e=>{let t;if(r){if(e.path.length<n.length)return!1;t=n.slice(0,-1)}else{if(e.path.length!=n.length)return!1;t=n}return t.every((t,n)=>t===e.path[n])})}static getValueType(e){if(typeof e==`string`)return SS.String;if(typeof e==`number`)return SS.Number;if(typeof e==`boolean`)return SS.Boolean;if(e===null)return SS.Null;if(Array.isArray(e))return SS.Array;if(typeof e==`object`&&Object.getPrototypeOf(e).isPrototypeOf(Object))return SS.Object;throw Error(`unsupported field type`)}static getPrimitiveValueType(t){let n=e.getValueType(t);if(n==SS.Array||n==SS.Object)throw Error(`expected a primitive value, got an array or an object`);return n}buildItemListByDfs(t,n=[]){switch(e.getValueType(t)){case SS.String:this.addFlatItem(n,this.buildStringItem(t));break;case SS.Number:this.addFlatItem(n,this.buildNumberItem(t));break;case SS.Boolean:this.addFlatItem(n,this.buildBooleanItem(t));break;case SS.Null:this.addFlatItem(n,this.buildNullItem());break;case SS.Array:this.buildArrayItem(t,n);break;case SS.Object:this.buildObjectItem(t,n);break;default:throw Error(`unsupported field type`)}}addFlatItem(e,t){let n={path:e,item:t};this.itemList.push(n)}buildStringItem(e){return{type:SS.String,value:e,transformation:{type:bS.None},channelId:-1}}buildNumberItem(e){return{type:SS.Number,value:e,channelId:-1}}buildBooleanItem(e){return{type:SS.Boolean,value:e,channelId:-1}}buildNullItem(){return{type:SS.Null,value:null,channelId:-1}}buildArrayItem(e,t){e.forEach((e,n)=>{this.buildItemListByDfs(e,[...t,n])})}buildObjectItem(e,t){Object.keys(e).forEach(n=>{let r=e[n];this.buildItemListByDfs(r,[...t,n])})}},hC=class e{encoder=new kx;channelMap;publicChannels;constructor(){this.channelMap=new Map,this.publicChannels=new Set}static fromMerkleRecord(t){let n=new e;return n.setChannelsFromMerkleRecord(t),n}logger=k.getLogger([e.name]);setChannelsFromMerkleRecord(e){this.publicChannels=e.getPublicChannels();let t=e.getRecordByChannels(),n=e.getChannelIds();for(let r of n){let n=e.getChannelPepper(r),i=e.getChannelRootHash(r),a=t.getFlatItems(r).map(e=>({path:e.path,value:e.item.value,...e.item.transformation?{transformation:e.item.transformation}:{}}));this.channelMap.set(r,{rootHash:i,pepper:n,onChainItems:a})}}getChannelIds(){return[...this.channelMap.keys()].sort((e,t)=>e-t)}getOnChainData(e,t=!1){let n=this.getChannel(e),r=new kx().encode(n.onChainItems),i={pepper:n.pepper,data:r},a=this.encoder.encode(i);return{isPublic:this.publicChannels.has(e),merkleRootHash:n.rootHash,data:a}}addOnChainData(e,t,n,r){if(this.channelMap.has(e))throw Error(`channel ${e} has already been set`);t?this.publicChannels.add(e):this.publicChannels.delete(e);let i=this.encoder.decode(r);R(ES,i);let a=i.pepper,o=this.encoder.decode(i.data);R(OS,o),this.channelMap.set(e,{rootHash:n,pepper:a,onChainItems:o})}toMerkleRecord(e=!0){let t=new uC,n=new Map;for(let[e,r]of this.channelMap){let i=r.onChainItems.map(t=>{let n={channelId:e,type:mC.getPrimitiveValueType(t.value),value:t.value,...t.transformation?{transformation:t.transformation}:{}};return{path:t.path,item:n}}),a=this.publicChannels.has(e);t.setChannel(e,a,i),n.set(e,r.pepper)}let r=fC.fromRecordByChannels(t,n);if(e){for(let[e,t]of this.channelMap)if(!this.publicChannels.has(e)){let n=r.getChannelRootHash(e);if(!A.binaryIsEqual(n,t.rootHash))throw Error(`inconsistent Merkle root hash for private channel ${e} (computed ${A.binaryToHexa(n)}, on-chain value is ${A.binaryToHexa(t.rootHash)})`)}}return r}getChannel(e){let t=this.channelMap.get(e);if(t===void 0)throw Error(`channel ${e} not found`);return t}},gC=class e extends rS{static createApplicationLedgerVirtualBlockchain(t){return new e(t)}draftModeEnabled=!1;constructor(e,t=Rx.createInitialState()){super(e,H.APP_LEDGER_VIRTUAL_BLOCKCHAIN,t)}async isAccountIdAllowedToWrite(e){if(this.getHeight()===0)return!0;let t=await this.getVirtualBlockchainOwnerId(),n=this.internalState.getAdditionalAllowedWriters();return[t.toBytes(),...n].some(t=>A.binaryIsEqual(t,e.toBytes()))}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?A.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType(),merkleRootHash:this.getMerkleRootHash()}}async getVirtualBlockchainOwnerId(){let e=this.internalState.getApplicationId();return(await this.provider.loadApplicationVirtualBlockchain(e)).getVirtualBlockchainOwnerId()}async updateInternalState(e,t,n){let r=e.getApplicationLedgerInternalStateUpdaterVersion();return Qx.createApplicationLedgerInternalStateUpdater(r).updateState(this.provider,this.internalState,n)}checkMicroblockStructure(e){return this.draftModeEnabled?!0:new _S().checkMicroblockStructure(e)}enableDraftMode(){this.draftModeEnabled=!0}disableDraftMode(){this.draftModeEnabled=!1}setInternalState(e){this.internalState=e}isActorDefined(e){return this.internalState.isActorDefinedByName(e)}actorIsSubscribed(e){return this.getActor(e).subscribed}getInternalState(){return this.internalState}async getActorIdByPublicSignatureKey(t){let n=k.getLogger([e.name]),r=this.internalState,i=t.getPublicKeyAsBytes();for(let e=0;e<r.getNumberOfActors();e++){let t=r.getActorById(e);if(n.debug(`Search current actor id: loop index ${e}`),t.subscribed)try{let r=await this.getMicroblock(t.signatureKeyHeight);for(let a of r.getAllSections()){if(a.type!==O.APP_LEDGER_ACTOR_SUBSCRIPTION)continue;let{actorId:r}=a;if(r!==e)continue;let{signaturePublicKey:o}=a;if(!A.binaryIsEqual(o,await i)){n.debug(`Public signature key mismatch for actor ${t.name} (id ${e})`,{actor:t});continue}return n.debug(`Matching public signature key: {actor.name} (id ${e})`,{actor:t}),e}}catch(e){if(e instanceof x)n.debug(`{e}`,{e});else if(e instanceof Ee)n.debug(`{e}`,{e});else throw e}}throw n.debug(`Current actor not found`),new pe}async getPublicEncryptionKeyByActorId(e){let t=this.internalState.getActorById(e).pkeKeyHeight;if(typeof t==`number`&&t!==0){let n=await this.getMicroblock(t);for(let t of n.getAllSections()){if(t.type!==O.APP_LEDGER_ACTOR_SUBSCRIPTION||t.actorId!=e)continue;let n=t.pkePublicKey,r=t.pkeSchemeId;return $v.createPublicEncryptionKey(r,n)}}throw new Te(e,this.getActorNameById(e))}async getPublicSignatureKeyByActorId(e){let t=this.internalState.getActorById(e).signatureKeyHeight;if(typeof t==`number`&&t!==0){let n=await this.getMicroblock(t);for(let t of n.getAllSections()){if(t.type!==O.APP_LEDGER_ACTOR_SUBSCRIPTION||t.actorId!=e)continue;let n=t.signaturePublicKey,r=t.signatureSchemeId;return $v.createPublicSignatureKey(r,n)}}throw new we(`Actor ${e} has not subscribed to a public signature key.`)}async getExistingSharedKey(e,t){let n=this.internalState.getActorById(t).sharedSecrets.find(t=>t.peerActorId==e);if(n===void 0)return;let r=await this.getMicroblock(n.height);for(let n of r.getAllSections())if(n.type===O.APP_LEDGER_SHARED_SECRET&&!(n.hostId!==e||n.guestId!==t))return n.encryptedSharedKey;throw new De(t,e)}getChannelIdByChannelName(e){return this.internalState.getChannelIdFromChannelName(e)}getActorNameById(e){return this.internalState.getActorById(e).name}getChannelNameById(e){return this.internalState.getChannelFromChannelId(e).name}getActorIdFromActorName(e){return this.internalState.getActorIdByName(e)}getActor(e){return this.internalState.getActorByName(e)}getAllActors(){return this.internalState.getAllActors()}getAllChannels(){return this.internalState.getAllChannels()}async getOrganizationId(){let e=this.getApplicationId();return(await this.provider.loadApplicationVirtualBlockchain(e)).getOrganizationId()}getApplicationId(){return this.internalState.getApplicationId()}getNumberOfChannels(){return this.internalState.getNumberOfChannels()}getChannelById(e){return this.internalState.getChannelFromChannelId(e)}getNumberOfActors(){return this.internalState.getNumberOfActors()}async getMicroblockMerkleRecord(t,n){let r=await this.getMicroblock(t),i=[];for(let e of r.getAllSections()){if(e.type!==O.APP_LEDGER_PUBLIC_CHANNEL_DATA)continue;let{channelId:t,data:n}=e;i.push({channelId:t,isPublic:!0,merkleRootHash:A.getNullHash(),data:n})}let a=k.getLogger([e.name]);if(n!==void 0){let o=await(await n.getPrivateSignatureKey()).getPublicKey(),s;try{s=await this.getActorIdByPublicSignatureKey(o)}catch(t){if(t instanceof pe)k.getLogger([e.name]).debug(`Unabled to recover private channels: {e}`,{e:t});else throw t}if(typeof s==`number`)for(let e of r.getAllSections()){if(e.type!==O.APP_LEDGER_PRIVATE_CHANNEL_DATA)continue;let{channelId:r,encryptedData:o,merkleRootHash:c}=e;try{let e=await this.getChannelKey(s,r,n),l=this.deriveChannelSectionKey(e,t,r),u=this.deriveChannelSectionIv(e,t,r);a.debug(`Channel key for channel id ${r} and Channel section key at height ${t} derived `);let d=xp.Aes.decryptGcm(l,o,u);a.debug(`Allowed to access private channel {channelName} (channel id={channelId})`,()=>({channelName:this.getChannelNameById(r),channelId:r})),i.push({channelId:r,isPublic:!1,merkleRootHash:c,data:d})}catch(e){if(e instanceof f||e instanceof he)a.debug(`Access to private channel {channelName} forbidden (channel id={channelId}): {e}`,()=>({e,channelName:this.getChannelNameById(r),channelId:r}));else throw e}}}else console.warn(`No private channel loaded: no private decryption key provided.`);let o=new hC;for(let e of i)o.addOnChainData(e.channelId,e.isPublic,e.merkleRootHash,e.data);return o.toMerkleRecord(!1)}deriveChannelSectionKey(e,t,n){return this.deriveChannelSectionMaterial(e,`CHANNEL_SECTION_KEY`,t,n,32)}deriveChannelSectionIv(e,t,n){return this.deriveChannelSectionMaterial(e,`CHANNEL_SECTION_IV`,t,n,12)}deriveChannelSectionMaterial(e,t,n,r,i){let a=new Uint8Array,o=new TextEncoder,s=A.binaryFrom(o.encode(t),r,new Uint8Array(A.intToByteArray(n,6)));return new Dv().deriveKey(e,a,s,i)}async getChannelKey(e,t,n){if(gS.assert(Number.isInteger(e),`Expected actor id with type number`),gS.assert(Number.isInteger(t),`Expected channel id of type number: got ${typeof t}`),this.internalState.getChannelCreatorIdFromChannelId(t)===e){let e=n.getSeedAsBytes();return await this.deriveChannelKey(e,t)}let r=await n.getPrivateDecryptionKey();return await this.getChannelKeyFromInvitation(e,t,r)}async deriveChannelKey(e,t){let n=await this.getGenesisSeed(),r=new TextEncoder,i=A.binaryFrom(r.encode(`CHANNEL_KEY`)),a=A.binaryFrom(e,r.encode(`GENESIS_SEED`),n.toBytes(),r.encode(`CHANNEL_ID`),A.binaryFrom(t));return new Dv().deriveKeyNoSalt(a,i,32)}async getChannelKeyFromInvitation(e,t,n){gS.assert(Number.isInteger(e),`Expected actor id with type number`),gS.assert(Number.isInteger(t),`Expected channel id of type number: got ${typeof t}`);let r=this.internalState.getActorById(e).invitations.find(e=>e.channelId==t);if(!r){let n=this.internalState.getActorById(e).name,r=this.internalState.getChannelFromChannelId(t).name;throw new he(n,r)}let i=await this.getMicroblock(r.height),a;for(let n of i.getAllSections())n.type===O.APP_LEDGER_CHANNEL_INVITATION&&(n.guestId!==e||n.channelId!==t||(a=n));if(a===void 0)throw new he(e,t);let o=a.encryptedChannelKey;return await n.decrypt(o)}async exportProof(e,t){let n=new vS;n.setIdentifier(A.binaryToHexa(this.getIdentifier().toBytes()));for(let e=1;e<=this.getHeight();e++){let r=await this.getMicroblockMerkleRecord(e,t),i=lC.fromMerkleRecord(r).toProofChannels();n.addMicroblock(e,i)}let r=await this.provider.getChainId(),i=oC.createEmptyProof(r);return i.setAuthor(e.author),i.addVirtualBlockchain(n),i.getObject()}async importProof(e){let t=[],n=oC.fromObject(e).getSingleVirtualBlockchainOrFail().getMicroblocks();for(let e of n){let n=e.height,r=await this.getMicroblock(n),i=[];for(let e of r.getAllSections())if(e.type===O.APP_LEDGER_PUBLIC_CHANNEL_DATA){let{channelId:t}=e;i.push({channelId:t,merkleRootHash:A.getNullHash()})}else if(e.type===O.APP_LEDGER_PRIVATE_CHANNEL_DATA){let{channelId:t,merkleRootHash:n}=e;i.push({channelId:t,merkleRootHash:n})}let a=lC.fromProofChannels(e.channels);for(let e of i){let t=a.getRootHashAsBinary(e.channelId);if(!A.binaryIsEqual(e.merkleRootHash,t)){let n=A.binaryToHexa(t),r=A.binaryToHexa(e.merkleRootHash);throw new ce(e.channelId,n,r)}}t.push({height:n,data:a.toJson()})}return t}async getRecord(e,t){let n=await this.getMicroblockMerkleRecord(e,t);return lC.fromMerkleRecord(n).toJson()}async isActorInChannel(e,t){return this.internalState.getActorById(t).invitations.some(t=>t.channelId==e)}},_C=class e{constructor(e){this.value=e}static of(t){return new e(t)}static some(t){return new e(t)}static none(){return new e(null)}map(t){return this.value===null?e.none():e.some(t(this.value))}unwrap(){if(this.value===null)throw Error(`Called unwrap on a None value`);return this.value}unwrapOrThrow(e){if(this.value===null)throw e;return this.value}unwrapOr(e){return this.value===null?e:this.value}isSome(){return this.value!==null}isNone(){return this.value===null}},vC=class{_error=_C.none();hash;header;verificationState={isMicroblockParsingCompleted:!1};constructor(e,t){this.provider=e,this.checkedMicroblock=t}async checkVirtualBlockchainConsistencyOrFail(){if(this.verificationState.isMicroblockParsingCompleted)throw new a(`You have already called parseMicroblock() method. You can only call it once.`);if(!this.checkedMicroblock.isDeclaringConsistentBodyHash())throw Error(`inconsistent body hash detected for microblock hash ${A.binaryToHexa(this.checkedMicroblock.getHashAsBytes())}`);let e=this.checkedMicroblock.getType(),t=0,n,r=this.checkedMicroblock.getPreviousHash().toBytes();if(this.checkedMicroblock.isGenesisMicroblock()){let t=r;e=tS.extractTypeFromGenesisPreviousHash(t),n=this.checkedMicroblock.getHash()}else{let e=await this.provider.getMicroblockHeader(Ix.from(r));if(!e)throw Error(`previous microblock ${A.binaryToHexa(r)} not found`);if(this.checkedMicroblock.getHeight()!=e.height+1)throw Error(`inconsistent microblock height (expected ${e.height+1}, got ${this.checkedMicroblock.getHeight()})`);let t=X.computeMicroblockHashFromHeader(e);n=await this.provider.getVirtualBlockchainIdContainingMicroblock(Ix.from(t))}let i;if(this.checkedMicroblock.isGenesisMicroblock()){switch(e){case H.ORGANIZATION_VIRTUAL_BLOCKCHAIN:i=new sS(this.provider);break;case H.ACCOUNT_VIRTUAL_BLOCKCHAIN:i=new lS(this.provider);break;case H.APPLICATION_VIRTUAL_BLOCKCHAIN:i=new dS(this.provider);break;case H.NODE_VIRTUAL_BLOCKCHAIN:i=new pS(this.provider);break;case H.PROTOCOL_VIRTUAL_BLOCKCHAIN:i=new hS(this.provider);break;case H.APP_LEDGER_VIRTUAL_BLOCKCHAIN:i=new gC(this.provider);break;default:throw Error(`Unknown virtual blockchain type: ${e}`)}let n=this.checkedMicroblock.getPreviousHash().toBytes();t=tS.extractExpirationDayFromGenesisPreviousHash(n),i.setExpirationDay(t)}else switch(e){case H.ORGANIZATION_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadOrganizationVirtualBlockchain(n);break;case H.ACCOUNT_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadAccountVirtualBlockchain(n);break;case H.APPLICATION_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadApplicationVirtualBlockchain(n);break;case H.NODE_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadValidatorNodeVirtualBlockchain(n);break;case H.PROTOCOL_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadProtocolVirtualBlockchain(n);break;case H.APP_LEDGER_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadApplicationLedgerVirtualBlockchain(n);break;default:throw Error(`Unknown virtual blockchain type: ${e}`)}await i.appendMicroBlock(this.checkedMicroblock),this.verificationState={isMicroblockParsingCompleted:!0,virtualBlockchain:i}}checkTimestampOrFail(e){if(this.verificationState.isMicroblockParsingCompleted===!1)throw new a(`You have already called reconstructMicroblockAndVirtualBlockchain() method. You can only call it once.`);let t=this.checkedMicroblock;e||=A.getTimestampInSeconds();let n=t.isTemporallyCloseTo(e);if(n===$x.TOO_FAR_IN_THE_PAST)throw Error(`timestamp is too far in the past (header:${t.getTimestamp()} / current:${e})`);if(n===$x.TOO_FAR_IN_THE_FUTURE)throw Error(`timestamp is too far in the future (header:${t.getTimestamp()} / current:${e})`)}async checkGasOrFail(e=A.getTimestampInSeconds()){if(this.verificationState.isMicroblockParsingCompleted===!1)throw new a(`You have already called reconstructMicroblockAndVirtualBlockchain() method. You can only call it once.`);let t=this.checkedMicroblock,n=await this.provider.computeMicroblockGas(t,{referenceTimestampInSeconds:e}),r=t.getGas();if(r!=n)throw Error(`Computed gas ${n} is not equal to declared gas ${r} `)}get virtualBlockchain(){if(this.verificationState.isMicroblockParsingCompleted)return this.verificationState.virtualBlockchain;throw new a(`Virtual blockchain not initialized.`)}getVirtualBlockchain(){return this.virtualBlockchain}getMicroblock(){return this.checkedMicroblock}getHash(){return this.hash}getError(){return this._error}containsError(){return this._error.isSome()}get error(){return this.containsError()?this._error.unwrap().toString():``}},yC=2,bC=32,xC={CACHE_HORIZON:yC,HASH_SIZE:bC,ROOT_ANCHORING_HASH:new Uint8Array(bC)},SC={keyDifference:CC,getHashList:wC};function CC(e,t,n){for(let r=e;r<xC.HASH_SIZE*2;r++)if((t[r>>1]^n[2+(r>>1)-(e>>1)])>>4*(r&1)&15)return!0;return!1}function wC(e,t){let n=[],r=2;for(let i=0;i<16;i++)n.push(e&1<<i?t.slice(r,r+=xC.HASH_SIZE):null);return n}function TC(e,t,n){return EC(e,t,n,null,0)?xp.Hashes.sha256AsBinary(n[0]):null}function EC(e,t,n,r,i){if(i===xC.HASH_SIZE*2)return r===null||t===null?r===null&&t===null:A.binaryIsEqual(r,t);let a=n[i];if(i&&(r===null||!A.binaryIsEqual(xp.Hashes.sha256AsBinary(a),r)))return!1;let o=a[0]<<8|a[1];if(o){let r=SC.getHashList(o,a),s=e[i>>1]>>4*(i&1)&15;return o&1<<s?EC(e,t,n,r[s],i+1):t===null}if(SC.keyDifference(i,e,a))return t===null;let s=xC.HASH_SIZE*2+1-i>>1;return t!==null&&A.binaryIsEqual(a.slice(2+s),t)}var DC=class e{static verifyAccountProofFromObject(t){let n=t.account.state,r=X.encodeAccountState(n),i=xp.Hashes.sha256AsBinary(r);return e.verifyRadixProof(t.account.virtualBlockchainId,i,t.account.radixProof,t.block.tokenRadixHash),e.verifyAppHash(t.block)}static verifyAccountProofFromJson(t){let{block:n,account:r}=t,i=r.radixProof.map(e=>A.binaryFromHexa(e)),a=_g.decodeBinary(r.serializedState,_g.BASE64),o=X.decodeAccountState(a),s={block:e.decodeJsonBlock(n),account:{virtualBlockchainId:A.binaryFromHexa(r.virtualBlockchainId),state:o,radixProof:i}};return e.verifyAccountProofFromObject(s)}static verifyMicroblockProofFromObject(t){let n=33-Math.clz32(t.virtualBlockchain.state.height-1),r=t.virtualBlockchain.merkleWitnesses,i=t.microblock.height-1,a=t.microblock.hash;if(r.length!==n-1)throw Error(`State proof failure: inconsistent list of Merkle witnesses`);for(let t=0;t<n-1;t++){let n=r[t];a=i>>>t&1?e.mergeHashes(n,a):e.mergeHashes(a,n)}let o=t.virtualBlockchain.state;if(!A.binaryIsEqual(o.merkleRootHash,a))throw Error(`State proof failure: invalid Merkle root hash`);let s=X.encodeVirtualBlockchainState(o),c=xp.Hashes.sha256AsBinary(s);return e.verifyRadixProof(t.microblock.virtualBlockchainId,c,t.virtualBlockchain.radixProof,t.block.vbRadixHash),e.verifyAppHash(t.block)}static verifyMicroblockProofFromJson(t){let{block:n,microblock:r,virtualBlockchain:i}=t,a=i.merkleWitnesses.map(e=>A.binaryFromHexa(e)),o=i.radixProof.map(e=>A.binaryFromHexa(e)),s=_g.decodeBinary(i.serializedState,_g.BASE64),c=X.decodeVirtualBlockchainState(s),l={block:e.decodeJsonBlock(n),microblock:{virtualBlockchainId:A.binaryFromHexa(r.virtualBlockchainId),height:r.height,hash:A.binaryFromHexa(r.hash)},virtualBlockchain:{state:c,merkleWitnesses:a,radixProof:o}};return e.verifyMicroblockProofFromObject(l)}static decodeJsonBlock(e){return{height:e.height,vbRadixHash:A.binaryFromHexa(e.vbRadixHash),tokenRadixHash:A.binaryFromHexa(e.tokenRadixHash),storageHash:A.binaryFromHexa(e.storageHash),appHash:A.binaryFromHexa(e.appHash)}}static mergeHashes(e,t){let n=new Uint8Array(64);return n.set(e,0),n.set(t,32),xp.Hashes.sha256AsBinary(n)}static verifyRadixProof(e,t,n,r){let i=TC(e,t,n);if(i===null)throw Error(`State proof failure: inconsistent Radix proof`);if(!A.binaryIsEqual(i,r))throw Error(`State proof failure: invalid Radix root hash`)}static verifyAppHash(e){let t=xp.Hashes.sha256AsBinary(A.binaryFrom(e.vbRadixHash,e.tokenRadixHash)),n=xp.Hashes.sha256AsBinary(A.binaryFrom(t,e.storageHash));if(!A.binaryIsEqual(n,e.appHash))throw Error(`State proof failure: computed app hash does not match the one declared in the block`);return n}},OC=class{stateUpdater;constructor(e,t,n){this.mbUnderConstruction=e,this.vb=t,this.provider=n}onMicroblockSearchFailureForExceedingHeight(e,t){if(e.getHeight()+1===t)return Promise.resolve(this.mbUnderConstruction);throw new x(e.getIdentifier(),t)}getBuiltMicroblock(){return this.mbUnderConstruction}async updateStateWithSection(e){if(!this.stateUpdater){let e=await this.provider.getProtocolState();this.stateUpdater=Qx.createApplicationLedgerInternalStateUpdater(e.getApplicationLedgerInternalStateUpdaterVersion())}this.vb.setInternalState(await this.stateUpdater.updateStateFromSection(this.provider,this.vb.getInternalState(),e,this.mbUnderConstruction.getHeight()))}getInternalState(){return this.vb.getInternalState()}},kC=function(e){return e[e.UNKNOWN=0]=`UNKNOWN`,e[e.WALLET=1]=`WALLET`,e[e.OPERATOR=2]=`OPERATOR`,e}({}),AC=I({name:L()}),jC=I({name:L(),public:Gp()}),MC=I({fieldPath:L(),channelName:L()}),NC=I({actorName:L(),channelName:L()}),PC=I({position:F(),length:F(),replacementString:L()}),FC=I({fieldPath:L(),maskedParts:N(PC)}),IC=I({fieldPath:L()}),LC=I({virtualBlockchainId:$p(L()),data:Wp(),actors:$p(N(AC)),channels:$p(N(jC)),channelAssignations:$p(N(MC)),actorAssignations:$p(N(NC)),hashableFields:$p(N(IC)),maskableFields:$p(N(FC)),author:L(),endorser:$p(L()),approvalMessage:$p(L())}),RC=class{static validate(e){return R(LC,e)}static safeParse(e){return om(LC,e)}static is(e){return Up(LC,e)}},zC=class e extends OC{logger=k.getLogger([e.name]);static async createFromVirtualBlockchain(t,n){let r=await n.createMicroblock(),i=new e(r,n);if(n.setMicroblockSearchFailureFallback(i),n.isEmpty()){let e={type:O.APP_LEDGER_CREATION,applicationId:t.toBytes()};r.addSection(e),await i.updateStateWithSection(e)}return i}usedSignatureSchemeId=Ja.SECP256K1;usedPkeSchemeId=Ov.ML_KEM_768_AES_256_GCM;constructor(e,t){super(e,t,t.getProvider())}get state(){return this.getInternalState()}getActorPrivateSignatureKey(e){return e.getPrivateSignatureKey(this.usedSignatureSchemeId)}getActorPrivateDecryptionKey(e){return e.getPrivateDecryptionKey(this.usedPkeSchemeId)}async createMicroblockFromStateUpdateRequest(e,t){let n=RC.validate(t),r=await this.getActorPrivateDecryptionKey(e),a=await this.getActorPrivateSignatureKey(e),o=this.state.getNumberOfActors();for(let e of n.actors||[]){console.log(this.state.getAllActors());let t=e.name;this.vb.isActorDefined(t)?console.log(`Skipping actor creation: ${t} already created`):(await this.createActor(o,e.name),o+=1)}let s=n.author,c=this.getActorIdFromActorName(s);if(this.vb.isEmpty()){let e=await r.getPublicKey();await this.subscribeActor(s,await a.getPublicKey(),e)}let l=this.state.getNumberOfChannels();for(let e of n.channels||[]){let t={type:O.APP_LEDGER_CHANNEL_CREATION,id:l,isPrivate:!e.public,creatorId:c,name:e.name};this.mbUnderConstruction.addSection(t),await this.updateStateWithSection(t),l+=1}let u=mC.fromObject(n.data);for(let e of n.channelAssignations||[]){let t=this.state.getChannelIdFromChannelName(e.channelName);u.setChannel(e.fieldPath,t)}for(let t of n.actorAssignations||[]){let n=t.channelName,r=t.actorName;await this.inviteActorOnChannel(r,n,e)}for(let e of n.hashableFields||[])u.setAsHashable(e.fieldPath);for(let e of n.maskableFields||[]){let t=e.maskedParts.map(e=>({start:e.position,end:e.position+e.length,replacement:e.replacementString}));u.setMaskByPositions(e.fieldPath,t)}let d=this.state.getAllChannels();for(let e in d){let t=Number(e);d[t].isPrivate||u.setChannelAsPublic(Number(t))}let f=uC.fromRecord(u),p=fC.fromRecordByChannels(f),m=hC.fromMerkleRecord(p),h=m.getChannelIds();for(let t of h){let n=m.getOnChainData(t),{isPublic:r,merkleRootHash:i}=n;if(r){let e={type:O.APP_LEDGER_PUBLIC_CHANNEL_DATA,channelId:t,data:n.data};this.mbUnderConstruction.addSection(e),await this.updateStateWithSection(e)}else{let r=k.getLogger([`critical`]),a=this.vb.getHeight()+1,o=await this.vb.getChannelKey(c,t,e),s=this.vb.deriveChannelSectionKey(o,a,t),l=this.vb.deriveChannelSectionIv(o,a,t);r.debug(`Channel key ${o} at height ${a} and channel id ${t} -> Channel section key: ${s} (iv ${l}) `);let u=xp.Aes.encryptGcm(s,n.data,l),d={type:O.APP_LEDGER_PRIVATE_CHANNEL_DATA,channelId:t,merkleRootHash:i,encryptedData:u};this.mbUnderConstruction.addSection(d),await this.updateStateWithSection(d)}}if(typeof n.endorser==`string`){if(n.endorser.trim().length===0)throw new i(`Empty endorser provided: should be a non-empty string or undefined`);let e=this.getActorIdFromActorName(n.endorser),t=n.approvalMessage??``,r={type:O.APP_LEDGER_ENDORSEMENT_REQUEST,message:t,endorserId:e};this.mbUnderConstruction.addSection(r),await this.updateStateWithSection(r)}return this.mbUnderConstruction}async createActor(e,t){console.log(`Creating actor ${t} (id ${e})`);let n={type:O.APP_LEDGER_ACTOR_CREATION,id:e,actorType:kC.UNKNOWN,name:t};this.mbUnderConstruction.addSection(n),await this.updateStateWithSection(n)}async inviteActorOnChannel(e,t,n){console.log(`Inviting actor `+e+` on channel `+t);let r=this.state.getChannelIdFromChannelName(t),i=this.getActorIdFromActorName(e),a=await this.getActorPrivateSignatureKey(n),o=await this.vb.getActorIdByPublicSignatureKey(await a.getPublicKey());gS.assert(typeof r==`number`,`Expected channel id of type number: got ${typeof r} for channel ${t}`);let s=i;if(await this.vb.isActorInChannel(r,s))return;let c=await this.vb.getChannelKey(o,r,n),l=await(await this.vb.getPublicEncryptionKeyByActorId(s)).encrypt(c),u=k.getLogger([gC.name]);u.info(`Actor {guestName} invited to channel ${t}`,()=>({guestName:e})),u.debug(`Channel key for channel ${t}: ${c}`);let d={type:O.APP_LEDGER_CHANNEL_INVITATION,channelId:r,hostId:o,guestId:s,encryptedChannelKey:l};this.mbUnderConstruction.addSection(d),await this.updateStateWithSection(d)}async createSharedKey(e,t,n){let{encryptedSharedKey:r,hostGuestSharedKey:i}=await this.generateSharedKeyAndEncryptedSharedKey(e,n),a={type:O.APP_LEDGER_SHARED_SECRET,hostId:t,guestId:n,encryptedSharedKey:r};return this.mbUnderConstruction.addSection(a),await this.updateStateWithSection(a),i}static deriveHostGuestSharedKey(e,t,n){let r=e.getRawPrivateKey(),i=new TextEncoder,a=A.binaryFrom(i.encode(`SHARED_SECRET`),n),o=new Dv,s=A.binaryFrom(r,t),c=o.deriveKeyNoSalt(s,a,32);return Kg.createFromBytes(c)}async generateSharedKeyAndEncryptedSharedKey(t,n){let r=await this.getGenesisSeed(),i=e.deriveHostGuestSharedKey(t,r.toBytes(),n);return{encryptedSharedKey:await(await this.vb.getPublicEncryptionKeyByActorId(n)).encrypt(i.getRawSecretKey()),hostGuestSharedKey:i}}async getGenesisSeed(){return this.vb.isEmpty()?this.mbUnderConstruction.getPreviousHash():await this.vb.getGenesisSeed()}async subscribeActor(e,t,n){if(console.debug(`Subscribing ${e}`),!this.vb.isActorDefined(e)){console.log(`It appears that ${e} does not exist: create it`);let t=this.vb.getNumberOfActors();await this.createActor(t,e)}let r=kC.UNKNOWN,i=this.getActorIdFromActorName(e),a=A.getNullHash(),o={type:O.APP_LEDGER_ACTOR_SUBSCRIPTION,actorId:i,actorType:r,organizationId:a,signatureSchemeId:t.getSignatureSchemeId(),signaturePublicKey:await t.getPublicKeyAsBytes(),pkeSchemeId:n.getSchemeId(),pkePublicKey:await n.getRawPublicKey()};this.mbUnderConstruction.addSection(o),await this.updateStateWithSection(o)}getActorIdFromActorName(e){return this.state.getActorIdByName(e)}},BC=class e{static ED25519_PUBLIC_KEY_TYPE=`tendermint/PubKeyEd25519`;static createFromEd25519PublicKey(t){return new e(e.ED25519_PUBLIC_KEY_TYPE,t)}constructor(e,t){this.type=e,this.publicKey=t}getType(){return this.type}getPublicKey(){return this.publicKey}},VC=class{encodeSignature(e){return e}decodeSignature(e){return e}encodeMessage(e){return e}decodeMessage(e){return e}async encodePublicKey(e){return Vs(JSON.stringify({signatureSchemeId:e.getSignatureSchemeId(),publicKey:ml(await e.getPublicKeyAsBytes())}))}async decodePublicKey(e){let t=JSON.parse(yl(e));if(t&&typeof t.signatureSchemeId==`number`&&typeof t.publicKey==`string`){let e=_l(t.publicKey);return new $v().createPublicSignatureKey(t.signatureSchemeId,e)}else throw`Invalid public key format: expected raw-encoded JSON object with signatureSchemeId and publicKey fields.`}async encodePrivateKey(e){return Vs(JSON.stringify({signatureSchemeId:e.getSignatureSchemeId(),privateKey:ml(e.getPrivateKeyAsBytes())}))}async decodePrivateKey(e){let t=JSON.parse(yl(e));if(t&&typeof t.signatureSchemeId==`number`&&typeof t.privateKey==`string`){let e=_l(t.privateKey);return $v.createPrivateSignatureKey(t.signatureSchemeId,e)}else throw`Invalid public key format: expected raw-encoded JSON object with signatureSchemeId and privateKey fields.`}},HC=new TextEncoder,UC=new TextDecoder;function WC(e){if(Uint8Array.prototype.toBase64)return e.toBase64();let t=32768,n=[];for(let r=0;r<e.length;r+=t)n.push(String.fromCharCode.apply(null,e.subarray(r,r+t)));return btoa(n.join(``))}function GC(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(e);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function KC(e){if(Uint8Array.fromBase64)return Uint8Array.fromBase64(typeof e==`string`?e:UC.decode(e),{alphabet:`base64url`});let t=e;t instanceof Uint8Array&&(t=UC.decode(t)),t=t.replace(/-/g,`+`).replace(/_/g,`/`);try{return GC(t)}catch{throw TypeError(`The input to be decoded is not correctly encoded.`)}}function qC(e){let t=e;return typeof t==`string`&&(t=HC.encode(t)),Uint8Array.prototype.toBase64?t.toBase64({alphabet:`base64url`,omitPadding:!0}):WC(t).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}var JC=class extends Error{static code=`ERR_JOSE_GENERIC`;code=`ERR_JOSE_GENERIC`;constructor(e,t){super(e,t),this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}},YC=class extends JC{static code=`ERR_JOSE_NOT_SUPPORTED`;code=`ERR_JOSE_NOT_SUPPORTED`},XC=e=>typeof e==`object`&&!!e;function ZC(e){if(!XC(e)||Object.prototype.toString.call(e)!==`[object Object]`)return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}var QC=`Invalid or unsupported JWK "alg" (Algorithm) Parameter value`;function $C(e){let t,n;switch(e.kty){case`AKP`:switch(e.alg){case`ML-DSA-44`:case`ML-DSA-65`:case`ML-DSA-87`:t={name:e.alg},n=e.priv?[`sign`]:[`verify`];break;default:throw new YC(QC)}break;case`RSA`:switch(e.alg){case`PS256`:case`PS384`:case`PS512`:t={name:`RSA-PSS`,hash:`SHA-${e.alg.slice(-3)}`},n=e.d?[`sign`]:[`verify`];break;case`RS256`:case`RS384`:case`RS512`:t={name:`RSASSA-PKCS1-v1_5`,hash:`SHA-${e.alg.slice(-3)}`},n=e.d?[`sign`]:[`verify`];break;case`RSA-OAEP`:case`RSA-OAEP-256`:case`RSA-OAEP-384`:case`RSA-OAEP-512`:t={name:`RSA-OAEP`,hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},n=e.d?[`decrypt`,`unwrapKey`]:[`encrypt`,`wrapKey`];break;default:throw new YC(QC)}break;case`EC`:switch(e.alg){case`ES256`:case`ES384`:case`ES512`:t={name:`ECDSA`,namedCurve:{ES256:`P-256`,ES384:`P-384`,ES512:`P-521`}[e.alg]},n=e.d?[`sign`]:[`verify`];break;case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:t={name:`ECDH`,namedCurve:e.crv},n=e.d?[`deriveBits`]:[];break;default:throw new YC(QC)}break;case`OKP`:switch(e.alg){case`Ed25519`:case`EdDSA`:t={name:`Ed25519`},n=e.d?[`sign`]:[`verify`];break;case`ECDH-ES`:case`ECDH-ES+A128KW`:case`ECDH-ES+A192KW`:case`ECDH-ES+A256KW`:t={name:e.crv},n=e.d?[`deriveBits`]:[];break;default:throw new YC(QC)}break;default:throw new YC(`Invalid or unsupported JWK "kty" (Key Type) Parameter value`)}return{algorithm:t,keyUsages:n}}async function ew(e){if(!e.alg)throw TypeError(`"alg" argument is required when "jwk.alg" is not present`);let{algorithm:t,keyUsages:n}=$C(e),r={...e};return r.kty!==`AKP`&&delete r.alg,delete r.use,crypto.subtle.importKey(`jwk`,r,t,e.ext??!(e.d||e.priv),e.key_ops??n)}async function tw(e,t,n){if(!ZC(e))throw TypeError(`JWK must be an object`);let r;switch(t??=e.alg,r??=n?.extractable??e.ext,e.kty){case`oct`:if(typeof e.k!=`string`||!e.k)throw TypeError(`missing "k" (Key Value) Parameter value`);return KC(e.k);case`RSA`:if(`oth`in e&&e.oth!==void 0)throw new YC(`RSA JWK "oth" (Other Primes Info) Parameter value is not supported`);return ew({...e,alg:t,ext:r});case`AKP`:if(typeof e.alg!=`string`||!e.alg)throw TypeError(`missing "alg" (Algorithm) Parameter value`);if(t!==void 0&&t!==e.alg)throw TypeError(`JWK alg and alg option value mismatch`);return ew({...e,ext:r});case`EC`:case`OKP`:return ew({...e,alg:t,ext:r});default:throw new YC(`Unsupported "kty" (Key Type) Parameter value`)}}var nw=class{static async exportPublicSignatureKey(e){if(e instanceof Zv)return await tw({kty:`OKP`,crv:`Ed25519`,alg:`EdDSA`,x:qC(await e.getPublicKeyAsBytes())});throw Error(`Unsupported public key type`)}static async exportPrivateSignatureKey(e){if(e instanceof Qv){let t=e.getPrivateKeyAsBytes(),n=await(await e.getPublicKey()).getPublicKeyAsBytes();return await tw({kty:`OKP`,crv:`Ed25519`,alg:`EdDSA`,d:qC(t),x:qC(n)})}throw Error(`Unsupported key type`)}},rw=`SIG`,iw=`SK`,aw=`PK`,ow=class{bytesEncoder=Sg.bytesToHexEncoder();constructor(e){this.labels=e}async encodePublicKey(e){return Eg.encode(...this.getHCVPublicKeyEncodingPrefix(),this.bytesEncoder.encode(await e.getPublicKeyAsBytes()))}getHCVPrivateKeyEncodingPrefix(){return[rw,...this.labels,iw]}getHCVPublicKeyEncodingPrefix(){return[rw,...this.labels,aw]}},sw=class extends ow{constructor(e){super(e)}async encodePrivateKey(e){return Eg.encode(...this.getHCVPrivateKeyEncodingPrefix(),this.bytesEncoder.encode(e.getPrivateKeyAsBytes()))}},cw=class extends sw{constructor(){super([`MLDSA65`])}async isAcceptingPrivateKeyEncodingRequest(e){return e instanceof $g}async isAcceptingPublicKeyEncodingRequest(e){return e instanceof Qg}},lw=class extends ow{constructor(){super([`PKMS`,`SECP256K1`])}async isAcceptingPrivateKeyEncodingRequest(e){return e instanceof Sy}async isAcceptingPublicKeyEncodingRequest(e){return e instanceof Cy}async encodePrivateKey(e){if(!(e instanceof Sy))throw Error(`Invalid private key type: `+e.constructor.name);let t=e.getKeyId();return Eg.encode(...this.getHCVPrivateKeyEncodingPrefix(),t)}},uw=class extends sw{constructor(){super([`SECP256K1`])}async isAcceptingPrivateKeyEncodingRequest(e){return e instanceof Yv}async isAcceptingPublicKeyEncodingRequest(e){return e instanceof Jv}},dw=class{static defaultEncoder(){return ey.createBase64HCVPkeEncoder()}},fw=class{encodeAsUint8Array(e){return Vs(JSON.stringify({symmetricEncryptionSchemeId:e.getSymmetricEncryptionSchemeId(),key:ml(e.getRawSecretKey())}))}decodeFromUint8Array(e){let t=JSON.parse(yl(e));if(t&&typeof t.symmetricEncryptionSchemeId==`number`&&typeof t.key==`string`){let e=_l(t.key);return new $v().createSymmetricEncryptionKey(t.symmetricEncryptionSchemeId,e)}else throw`Invalid symmetric encryption key format: expected raw-encoded JSON object with symmetricEncryptionSchemeId and key fields.`}};function pw(e,t,n,r,i,a){let o=e[t++]^n[r++],s=e[t++]^n[r++],c=e[t++]^n[r++],l=e[t++]^n[r++],u=e[t++]^n[r++],d=e[t++]^n[r++],f=e[t++]^n[r++],p=e[t++]^n[r++],m=e[t++]^n[r++],h=e[t++]^n[r++],g=e[t++]^n[r++],_=e[t++]^n[r++],v=e[t++]^n[r++],y=e[t++]^n[r++],b=e[t++]^n[r++],ee=e[t++]^n[r++],x=o,te=s,ne=c,re=l,ie=u,ae=d,oe=f,se=p,ce=m,le=h,S=g,ue=_,de=v,fe=y,pe=b,me=ee;for(let e=0;e<8;e+=2)ie^=j(x+de|0,7),ce^=j(ie+x|0,9),de^=j(ce+ie|0,13),x^=j(de+ce|0,18),le^=j(ae+te|0,7),fe^=j(le+ae|0,9),te^=j(fe+le|0,13),ae^=j(te+fe|0,18),pe^=j(S+oe|0,7),ne^=j(pe+S|0,9),oe^=j(ne+pe|0,13),S^=j(oe+ne|0,18),re^=j(me+ue|0,7),se^=j(re+me|0,9),ue^=j(se+re|0,13),me^=j(ue+se|0,18),te^=j(x+re|0,7),ne^=j(te+x|0,9),re^=j(ne+te|0,13),x^=j(re+ne|0,18),oe^=j(ae+ie|0,7),se^=j(oe+ae|0,9),ie^=j(se+oe|0,13),ae^=j(ie+se|0,18),ue^=j(S+le|0,7),ce^=j(ue+S|0,9),le^=j(ce+ue|0,13),S^=j(le+ce|0,18),de^=j(me+pe|0,7),fe^=j(de+me|0,9),pe^=j(fe+de|0,13),me^=j(pe+fe|0,18);i[a++]=o+x|0,i[a++]=s+te|0,i[a++]=c+ne|0,i[a++]=l+re|0,i[a++]=u+ie|0,i[a++]=d+ae|0,i[a++]=f+oe|0,i[a++]=p+se|0,i[a++]=m+ce|0,i[a++]=h+le|0,i[a++]=g+S|0,i[a++]=_+ue|0,i[a++]=v+de|0,i[a++]=y+fe|0,i[a++]=b+pe|0,i[a++]=ee+me|0}function mw(e,t,n,r,i){let a=r+0,o=r+16*i;for(let r=0;r<16;r++)n[o+r]=e[t+(2*i-1)*16+r];for(let r=0;r<i;r++,a+=16,t+=16)pw(n,o,e,t,n,a),r>0&&(o+=16),pw(n,a,e,t+=16,n,o)}function hw(e,t,n){let{N:r,r:i,p:a,dkLen:o,asyncTick:s,maxmem:c,onProgress:l}=Gs({dkLen:32,asyncTick:10,maxmem:1024**3+1024},n);if(ws(r),ws(i),ws(a),ws(o),ws(s),ws(c),l!==void 0&&typeof l!=`function`)throw Error(`progressCb should be function`);let u=128*i,d=u/4,f=2**32;if(r<=1||r&r-1||r>f)throw Error(`Scrypt: N must be larger than 1, a power of 2, and less than 2^32`);if(a<0||a>(f-1)*32/u)throw Error(`Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)`);if(o<0||o>(f-1)*32)throw Error(`Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32`);if(u*(r+a)>c)throw Error(`Scrypt: memused is bigger than maxMem. Expected 128 * r * (N + p) > maxmem of `+c);let p=gv(Wc,e,t,{c:1,dkLen:u*a}),m=ks(p),h=ks(new Uint8Array(u*r)),g=ks(new Uint8Array(u)),_=()=>{};if(l){let e=2*r*a,t=Math.max(Math.floor(e/1e4),1),n=0;_=()=>{n++,l&&(!(n%t)||n===e)&&l(n/e)}}return{N:r,r:i,p:a,dkLen:o,blockSize32:d,V:h,B32:m,B:p,tmp:g,blockMixCb:_,asyncTick:s}}function gw(e,t,n,r,i){let a=gv(Wc,e,n,{c:1,dkLen:t});return As(n,r,i),a}function _w(e,t,n){let{N:r,r:i,p:a,dkLen:o,blockSize32:s,V:c,B32:l,B:u,tmp:d,blockMixCb:f}=hw(e,t,n);Is(l);for(let e=0;e<a;e++){let t=s*e;for(let e=0;e<s;e++)c[e]=l[t+e];for(let e=0,t=0;e<r-1;e++)mw(c,t,c,t+=s,i),f();mw(c,(r-1)*s,l,t,i),f();for(let e=0;e<r;e++){let e=l[t+s-16]%r;for(let n=0;n<s;n++)d[n]=l[t+n]^c[e*s+n];mw(d,0,l,t,i),f()}}return Is(l),gw(e,o,u,c,d)}var vw=class extends vv{getKeyDerivationFunctionSchemeId(){return _v.SCRYPT}deriveKey(e,t,n){return _w(e,t,{N:2**16,r:8,p:1,dkLen:n})}},yw=function(e){return e[e.SECP256K1=Ja.SECP256K1]=`SECP256K1`,e[e.ML_DSA_65=Ja.ML_DSA_65]=`ML_DSA_65`,e}({}),bw=class{constructor(e){this.apiKey=e}async getPkmsCredential(){return this.apiKey}},xw=class{constructor(){}async has(e){return!1}async get(e){return!1}async set(e,t){}},Sw=class{key;constructor(e,t,n){this.key=`${e}|${t}|${n}`}getKey(){return this.key}},Cw=class{map;constructor(){this.map=new Map}async has(e){return this.map.has(e.getKey())}async get(e){return this.map.get(e.getKey())}async set(e,t){this.map.set(e.getKey(),t)}};(async function(){new Cw})();var ww=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`,Tw={verifyFormat:Ew,encodeNumber:Dw,decodeNumber:Ow,encodeToChar:kw,decodeFromChar:Aw,CROCKFORD_CHARS:ww};function Ew(e,t=e.length){return RegExp(`^(${[...ww].join(`|`)}){${t}}$`).test(e)}function Dw(e,t){if(!Number.isInteger(t)||t<1||t>10)throw Error(`Invalid or unsafe size for base32 encoding`);if(!Number.isInteger(e)||e<0||e>=32**t)throw Error(`Invalid number for base32 encoding of size ${t}`);return[...Array(t).keys()].map(t=>kw(e>>t*5&31)).join(``)}function Ow(e){if(e.length==0||e.length>10)throw Error(`Invalid base32 string length`);return[...e].reduceRight((e,t)=>e<<5|Aw(t),0)}function kw(e){let t=ww[e];if(t===void 0)throw Error(`Invalid base32 value`);return t}function Aw(e){let t=ww.indexOf(e);if(e.length!=1||t==-1)throw Error(`Invalid base32 character`);return t}var jw=class{collection;constructor(e){this.collection=e}serialize(e,t){let n=this.collection[e],r=new Hv(n).serialize(t);return new Uint8Array([e,...r])}},Mw=class{collection;constructor(e){this.collection=e}unserialize(e){let t=e[0],n=this.collection[t];if(!n)throw Error(`Unknown message type ${t}: I do not know how to unserialize this message.`);return{type:t,object:new Uv(n).unserialize(e.slice(1))}}},Nw=class{schema;constructor(e){this.schema=e}validate(e){if(this.schema===void 0)throw new o(`Provided schema is undefined: this should not happen`);this.validateObject(this.schema.definition,e)}validateObject(e,t,n=``){for(let r of e){let e=n+(n&&`.`)+r.name,i=t[r.name];if(i===void 0){if(r.optional)continue;throw Error(`field '${e}' is missing`)}if(r.type&32){if(no.getType(i)!=1)throw`'${e}' is not an array`;for(let t in i)this.validateItem(r,i[t],e+`[${t}]`)}else this.validateItem(r,i,e)}}validateItem(e,t,n){if((e.type&31)==2){if(no.getType(t)!=2)throw`'${n}' is not an object`;if(!e.unspecifiedSchema){if(!e.schema)throw`missing definition in schema`;this.validateObject(e.schema.definition,t,n)}}else{let r=new ro(e,t);try{r.check()}catch(e){throw`Error on field '${n}': ${e}`}}}},Pw={getAccountTypeFromIdentifier:Fw,getSpecialAccountTypeIdentifier:Iw,isAllowedTransfer:Lw};function Fw(e){if(e.length!=32)throw Error(`invalid account identifier`);if(e.slice(0,-1).every(e=>e==0)){let t=e[31];if(t==1||!Ur[t])throw Error(`special account format detected, but with an invalid type (${t})`);return t}return 1}function Iw(e){if(e==1||!Ur[e])throw Error(`${e} is not a valid special account type`);let t=new Uint8Array(32);return t[31]=e,t}function Lw(e,t){return Wr[e]>>t&1}var Rw=class e{constructor(e){this.amount=e}static create(t){return new e(t)}getAmount(){return this.amount}toString(){return`${this.amount} €`}},zw=class{static defaultEurosToCMTSTokenConverter(){return new Bw}},Bw=class e{static TOKENS_FOR_ONE_EUROS=100;convert(t){return hn.create(t.getAmount()*e.TOKENS_FOR_ONE_EUROS)}invert(t){return Rw.create(t.getAmount()/e.TOKENS_FOR_ONE_EUROS)}},Vw=class e{constructor(e,t,n){this.verified=e,this.appLedger=t,this.importedProofs=n}static createSuccessfulProofVerificationResult(t,n){return new e(!0,t,_C.some(n))}static createFailedProofVerificationResult(t){return new e(!1,t,_C.none())}isVerified(){return this.verified}getInvolvedBlockHeights(){return this.importedProofs.isSome()?this.importedProofs.unwrap().map(e=>e.height):[]}getApplicationLedgerId(){return this.appLedger.getIdentifier()}async getRecordContainedInBlockAtHeight(e,t){throw Error(`Not implemented`)}},Hw=function(e){return e[e.PARSE_ERROR=-32700]=`PARSE_ERROR`,e[e.INVALID_REQUEST=-32600]=`INVALID_REQUEST`,e[e.METHOD_NOT_FOUND=-32601]=`METHOD_NOT_FOUND`,e[e.INVALID_PARAMS=-32602]=`INVALID_PARAMS`,e[e.INTERNAL_ERROR=-32603]=`INTERNAL_ERROR`,e[e.ENDPOINT_CLOSED_WHILE_NODE_IS_CATCHING_UP=-32603]=`ENDPOINT_CLOSED_WHILE_NODE_IS_CATCHING_UP`,e[e.TX_ALREADY_EXISTS=-32003]=`TX_ALREADY_EXISTS`,e[e.TX_OUT_OF_GAS=-32002]=`TX_OUT_OF_GAS`,e[e.TX_CHECK_FAILED=-32001]=`TX_CHECK_FAILED`,e[e.TX_DELIVER_FAILED=-32e3]=`TX_DELIVER_FAILED`,e}({}),Uw=1,Ww=class e extends iC{constructor(e){super(e)}static createEmptyProof(t){return new e({type:`accountProof`,info:iC.getDefaultInfo(Uw,t),proof:{accounts:[]}})}static fromObject(t){return new e(R(tC,t))}addAccount(e){this.wrapper.proof.accounts.push(e)}getAccounts(){return this.wrapper.proof.accounts}},Gw=1,Kw=class e extends iC{constructor(e){super(e)}static createEmptyProof(t){return new e({type:`microblockProof`,info:iC.getDefaultInfo(Gw,t),proof:{microblocks:[]}})}static fromObject(t){return new e(R(rC,t))}addMicroblock(e){this.wrapper.proof.microblocks.push(e)}getMicroblocks(){return this.wrapper.proof.microblocks}},qw=class{static importProof(e){switch(R(ZS,e),e.type){case`accountProof`:return new Ww(e);case`appLedgerProof`:return new oC(e);case`microblockProof`:return new Kw(e)}}},Jw=class e{log=k.getAbstractProviderLogger(e.name);async loadValidatorNodeVirtualBlockchain(e){let t=new pS(this);return await this.initializeVirtualBlockchain(t,e),t}async loadAccountVirtualBlockchain(e){this.log.debug(`Loading account virtual blockchain with id ${e.encode()}`);let t=new lS(this);return await this.initializeVirtualBlockchain(t,e),t}async loadApplicationLedgerVirtualBlockchain(e){let t=new gC(this);return await this.initializeVirtualBlockchain(t,e),t}async loadApplicationVirtualBlockchain(e){let t=new dS(this);return await this.initializeVirtualBlockchain(t,e),t}async loadOrganizationVirtualBlockchain(e){let t=new sS(this);return await this.initializeVirtualBlockchain(t,e),t}async loadProtocolVirtualBlockchain(e){let t=new hS(this);return await this.initializeVirtualBlockchain(t,e),t}async loadVirtualBlockchain(e){let t=await this.getVirtualBlockchainState(e.toBytes());if(t===null)throw Error(`Virtual Blockchain with hash ${e.encode()} does not exist.`);let n=t.type;switch(n){case H.ACCOUNT_VIRTUAL_BLOCKCHAIN:return await this.loadAccountVirtualBlockchain(e);case H.ORGANIZATION_VIRTUAL_BLOCKCHAIN:return await this.loadOrganizationVirtualBlockchain(e);case H.APPLICATION_VIRTUAL_BLOCKCHAIN:return await this.loadApplicationVirtualBlockchain(e);case H.NODE_VIRTUAL_BLOCKCHAIN:return await this.loadValidatorNodeVirtualBlockchain(e);case H.PROTOCOL_VIRTUAL_BLOCKCHAIN:return await this.loadProtocolVirtualBlockchain(e);case H.APP_LEDGER_VIRTUAL_BLOCKCHAIN:return await this.loadApplicationLedgerVirtualBlockchain(e);default:throw Error(`Unknown virtual blockchain type: ${n}`)}}async loadMicroblockByMicroblockHash(e){this.log.info(`Loading microblock ${e.encode()}`);let t=await this.getMicroblockHeader(e),n=await this.getMicroblockBody(e);if(t===null||n===null)throw Error(`Microblock ${e.encode()} not found`);return tS.loadFromHeaderAndBody(t,n)}async getCurrentFeesFormula(){let e=(await this.getProtocolState()).getFeesCalculationVersion();return Px.getFeesCalculationFormulaByVersion(this,e)}async computeMicroblockGas(e,t={}){let n=t.referenceTimestampInSeconds??A.getTimestampInSeconds(),r=0;if(e.isGenesisMicroblock())r=tS.extractExpirationDayFromGenesisPreviousHash(e.getPreviousHash().toBytes());else{let t=await this.getVirtualBlockchainIdContainingMicroblock(e.getPreviousHash()),n=await this.getVirtualBlockchainState(t.toBytes());if(n===null)throw Error(`Virtual blockchain state not found`);r=n.expirationDay}let i=t.signatureSchemeId??e.getLastSignatureSection().schemeId;if(i===null)throw Error(`Signature scheme ID cannot be null`);return(await this.getCurrentFeesFormula()).computeGas(i,e,r,n)}async initializeVirtualBlockchain(e,t){let n=t.toBytes(),r=await this.getVirtualBlockchainStatus(n);if(r===null)throw new Se(t);if(r.type!==e.getType())throw Error(`Invalid blockchain type loaded`);e.setIdentifier(n),e.setHeight(r.height),e.setExpirationDay(r.expirationDay),e.setInternalState(Ux.createInternalStateFromObject(e.getType(),r.internalState))}},Yw=class e{expirationDate;endless;constructor(e,t){this.expirationDate=e,this.endless=t}static endless(){return new e(_C.none(),!0)}static of(t){return new e(_C.of(t),!1)}static fromDurationInDays(t){let n=new Date;return n.setDate(n.getDate()+t),e.of(n)}isEndless(){return this.endless}getExpirationDate(){return this.expirationDate.unwrap()}},Xw=class e{static logger=k.getMemoryProviderLogger();static instance=new e;static getInstance(){return this.instance}microblockHeaderStore;microblockBodyStore;microblockVbInformationStore;virtualBlockchainStateStore;constructor(){this.microblockHeaderStore=new Map,this.microblockBodyStore=new Map,this.microblockVbInformationStore=new Map,this.virtualBlockchainStateStore=new Map}clear(){e.logger.info(`Clearing`),this.microblockHeaderStore=new Map,this.microblockBodyStore=new Map,this.microblockVbInformationStore=new Map,this.virtualBlockchainStateStore=new Map}async getSerializedInformationOfVirtualBlockchainContainingMicroblock(t){let n=await e.get(this.microblockVbInformationStore,t);return e.logger.info(`getMicroblockVbInformation identifier=${A.binaryToHexa(t)} -> ${n?n.length:0} bytes`),n}async getInformationOfVirtualBlockchainContainingMicroblock(e){let t=await this.getSerializedInformationOfVirtualBlockchainContainingMicroblock(e);return t===null?null:X.decodeVirtualBlockchainInfo(t)}async getMicroblock(e){throw Error(`Method not implemented`)}async getMicroblockHeader(t){let n=await e.get(this.microblockHeaderStore,t);if(n===null)return e.logger.info(`Header not found locally: returning null`),null;{let r=X.decodeMicroblockHeader(n);return e.logger.info(`Header of microblock with identifier=${A.binaryToHexa(t)} found: {header}`,{header:r}),r}}async getSerializedMicroblockHeader(t){let n=await e.get(this.microblockHeaderStore,t);if(n===null)return e.logger.info(`Header not found locally: returning null`),null;{let r=xp.Hashes.sha256(n),i=X.decodeMicroblockHeader(n);return e.logger.info(`Header of microblock with identifier (sha256:${r})=${A.binaryToHexa(t)} found: {header}`,{header:JSON.stringify(i)}),n}}async getMicroblockBody(t){let n=await e.get(this.microblockBodyStore,t);return e.logger.info(`getMicroblockBody identifier=${A.binaryToHexa(t)} -> ${n?n.length:0} bytes`),n}async getSerializedVirtualBlockchainState(t){let n=await e.get(this.virtualBlockchainStateStore,t);return e.logger.info(`getVirtualBlockchainState identifier=${A.binaryToHexa(t)} -> ${n?n.length:0} bytes`),n}async getAccountByPublicKeyHash(e){return null}async setMicroblockVbInformation(t,n){let r=X.decodeVirtualBlockchainInfo(n);return e.logger.info(`Store info of vb identifier=${A.binaryToHexa(t)}: {info}`,{info:r}),await e.set(this.microblockVbInformationStore,t,n)}async setSerializedMicroblockHeader(t,n){let r=X.decodeMicroblockHeader(n);return e.logger.info(`Store header of microblock identifier=${A.binaryToHexa(t)} -> {header}`,{header:r}),await e.set(this.microblockHeaderStore,t,n)}async setSerializedMicroblockBody(t,n){let r=X.decodeMicroblockBody(n);return e.logger.info(`Store body of microblock ${A.binaryToHexa(t)}: {body}`,{body:r}),await e.set(this.microblockBodyStore,t,n)}async setMicroblockHeader(e,t){let n=X.encodeMicroblockHeader(t);await this.setSerializedMicroblockHeader(e,n)}async setMicroblockBody(e,t){let n=X.encodeMicroblockBody(t);await this.setSerializedMicroblockBody(e,n)}async setSerializedVirtualBlockchainState(t,n){let r=X.decodeVirtualBlockchainState(n);return e.logger.info(`Store vb state for vb ${A.binaryToHexa(t)}: {state}`,{state:r}),await e.set(this.virtualBlockchainStateStore,t,n)}static async get(e,t){let n=A.binaryToHexa(t);if(!e.has(n))return null;let r=e.get(n);return r===void 0?null:A.binaryFromHexa(r)}static async set(t,n,r){let i=A.binaryToHexa(n),a=A.binaryToHexa(r),o=t.get(i);o===void 0?e.logger.info(`Storing new entry for key ${i}`):o===a?e.logger.info(`Storing the same data for the same key ${i}`):e.logger.info(`Storing new data for key ${i}`),t.set(i,a)}},Zw=I({jsonrpc:P(`2.0`),id:F(),result:I({node_info:I({protocol_version:I({p2p:L(),block:L(),app:L()}),id:L(),listen_addr:L(),network:L(),version:L(),channels:L(),moniker:L(),other:I({tx_index:L(),rpc_address:L()})}),sync_info:I({latest_block_hash:L(),latest_app_hash:L(),latest_block_height:L(),latest_block_time:L(),earliest_block_hash:L(),earliest_app_hash:L(),earliest_block_height:L(),earliest_block_time:L(),catching_up:Gp()}),validator_info:I({address:L(),pub_key:I({type:L(),value:L()}),voting_power:L()})})}),$=function(e){return e[e.GET_CHAIN_INFORMATION=1]=`GET_CHAIN_INFORMATION`,e[e.GET_BLOCK_INFORMATION=3]=`GET_BLOCK_INFORMATION`,e[e.GET_BLOCK_CONTENT=5]=`GET_BLOCK_CONTENT`,e[e.GET_VIRTUAL_BLOCKCHAIN_STATE=7]=`GET_VIRTUAL_BLOCKCHAIN_STATE`,e[e.GET_VIRTUAL_BLOCKCHAIN_UPDATE=9]=`GET_VIRTUAL_BLOCKCHAIN_UPDATE`,e[e.GET_MICROBLOCK_INFORMATION=11]=`GET_MICROBLOCK_INFORMATION`,e[e.AWAIT_MICROBLOCK_ANCHORING=13]=`AWAIT_MICROBLOCK_ANCHORING`,e[e.GET_MICROBLOCK_BODYS=15]=`GET_MICROBLOCK_BODYS`,e[e.GET_ACCOUNT_STATE=17]=`GET_ACCOUNT_STATE`,e[e.GET_ACCOUNT_HISTORY=19]=`GET_ACCOUNT_HISTORY`,e[e.GET_ACCOUNT_BY_PUBLIC_KEY_HASH=21]=`GET_ACCOUNT_BY_PUBLIC_KEY_HASH`,e[e.GET_VALIDATOR_NODE_BY_ADDRESS=23]=`GET_VALIDATOR_NODE_BY_ADDRESS`,e[e.GET_OBJECT_LIST=25]=`GET_OBJECT_LIST`,e[e.GET_GENESIS_SNAPSHOT=27]=`GET_GENESIS_SNAPSHOT`,e[e.GET_RAW_BLOCK_CONTENT=29]=`GET_RAW_BLOCK_CONTENT`,e[e.GET_BLOCK_MODIFIED_ACCOUNTS=31]=`GET_BLOCK_MODIFIED_ACCOUNTS`,e[e.GET_ACCOUNT_UPDATES=33]=`GET_ACCOUNT_UPDATES`,e[e.GET_MICROBLOCK_INFORMATION_BY_HEIGHT=35]=`GET_MICROBLOCK_INFORMATION_BY_HEIGHT`,e[e.GET_SERIALIZED_MICROBLOCK_BY_HEIGHT=37]=`GET_SERIALIZED_MICROBLOCK_BY_HEIGHT`,e[e.GET_MICROBLOCK_PROOF=39]=`GET_MICROBLOCK_PROOF`,e[e.GET_ACCOUNT_PROOF=41]=`GET_ACCOUNT_PROOF`,e}({}),Qw=I({requestType:P($.GET_CHAIN_INFORMATION)}),$w=I({requestType:P($.GET_BLOCK_INFORMATION),height:z(F(),Ip(),Bp(0))}),eT=I({requestType:P($.GET_BLOCK_CONTENT),height:z(F(),Ip(),Bp(0))}),tT=I({requestType:P($.GET_VIRTUAL_BLOCKCHAIN_STATE),virtualBlockchainId:Mm()}),nT=I({requestType:P($.GET_VIRTUAL_BLOCKCHAIN_UPDATE),virtualBlockchainId:Mm(),knownStateHash:Mm()}),rT=I({requestType:P($.GET_MICROBLOCK_INFORMATION),hash:Mm()}),iT=I({requestType:P($.AWAIT_MICROBLOCK_ANCHORING),hash:Mm()}),aT=I({requestType:P($.GET_MICROBLOCK_BODYS),hashes:N(Mm())}),oT=I({requestType:P($.GET_ACCOUNT_STATE),accountHash:Mm()}),sT=I({requestType:P($.GET_ACCOUNT_HISTORY),accountHash:Mm(),lastHistoryHash:Mm(),maxRecords:z(F(),Ip(),Bp(1))}),cT=I({requestType:P($.GET_ACCOUNT_BY_PUBLIC_KEY_HASH),publicKeyHash:Mm()}),lT=I({requestType:P($.GET_VALIDATOR_NODE_BY_ADDRESS),address:B()}),uT=I({requestType:P($.GET_GENESIS_SNAPSHOT)}),dT=I({requestType:P($.GET_RAW_BLOCK_CONTENT),height:z(F(),Ip(),Bp(0)),partIndex:z(F(),Ip(),Bp(0))}),fT=I({requestType:P($.GET_BLOCK_MODIFIED_ACCOUNTS),height:z(F(),Ip(),Bp(0))}),pT=I({requestType:P($.GET_ACCOUNT_UPDATES),list:N(pg)}),mT=I({requestType:P($.GET_MICROBLOCK_INFORMATION_BY_HEIGHT),virtualBlockchainId:Mm(),height:F()}),hT=I({requestType:P($.GET_SERIALIZED_MICROBLOCK_BY_HEIGHT),virtualBlockchainId:Mm(),height:F()}),gT=I({requestType:P($.GET_MICROBLOCK_PROOF),hash:Mm()}),_T=I({requestType:P($.GET_ACCOUNT_PROOF),accountId:Mm()}),vT=am(`requestType`,[Qw,$w,eT,tT,nT,rT,iT,aT,oT,sT,cT,lT,uT,dT,fT,pT,mT,hT,gT,_T]),yT=function(e){return e[e.ERROR=0]=`ERROR`,e[e.CHAIN_INFORMATION=2]=`CHAIN_INFORMATION`,e[e.BLOCK_INFORMATION=4]=`BLOCK_INFORMATION`,e[e.BLOCK_CONTENT=6]=`BLOCK_CONTENT`,e[e.VIRTUAL_BLOCKCHAIN_STATE=8]=`VIRTUAL_BLOCKCHAIN_STATE`,e[e.VIRTUAL_BLOCKCHAIN_UPDATE=10]=`VIRTUAL_BLOCKCHAIN_UPDATE`,e[e.MICROBLOCK_INFORMATION=12]=`MICROBLOCK_INFORMATION`,e[e.MICROBLOCK_ANCHORING=14]=`MICROBLOCK_ANCHORING`,e[e.MICROBLOCK_BODYS=16]=`MICROBLOCK_BODYS`,e[e.ACCOUNT_STATE=18]=`ACCOUNT_STATE`,e[e.ACCOUNT_HISTORY=20]=`ACCOUNT_HISTORY`,e[e.ACCOUNT_BY_PUBLIC_KEY_HASH=22]=`ACCOUNT_BY_PUBLIC_KEY_HASH`,e[e.VALIDATOR_NODE_BY_ADDRESS=24]=`VALIDATOR_NODE_BY_ADDRESS`,e[e.OBJECT_LIST=26]=`OBJECT_LIST`,e[e.GENESIS_SNAPSHOT=28]=`GENESIS_SNAPSHOT`,e[e.RAW_BLOCK_CONTENT=30]=`RAW_BLOCK_CONTENT`,e[e.BLOCK_MODIFIED_ACCOUNTS=32]=`BLOCK_MODIFIED_ACCOUNTS`,e[e.ACCOUNT_UPDATES=34]=`ACCOUNT_UPDATES`,e[e.SERIALIAZED_MICROBLOCK_BY_HEIGHT=38]=`SERIALIAZED_MICROBLOCK_BY_HEIGHT`,e[e.MICROBLOCK_PROOF=40]=`MICROBLOCK_PROOF`,e[e.ACCOUNT_PROOF=42]=`ACCOUNT_PROOF`,e}({}),bT=I({responseType:P(yT.ERROR),error:L()}),xT=I({responseType:P(yT.CHAIN_INFORMATION),height:z(F(),Ip(),Bp(0)),lastBlockTimestamp:z(F(),Ip(),Bp(0)),microblockCount:z(F(),Ip(),Bp(0)),objectCounts:N(z(F(),Ip(),Bp(0))),protocolVirtualBlockchainId:B()}),ST=I({responseType:P(yT.BLOCK_INFORMATION),hash:Mm(),timestamp:z(F(),Ip(),Bp(0)),proposerAddress:B(),applicationStateHashes:I({vbRadixHash:B(),tokenRadixHash:B(),radixHash:B(),storageHash:B(),appHash:B()}),size:z(F(),Ip(),Bp(0)),microblockCount:z(F(),Ip(),Bp(0))}),CT=I({hash:Mm(),vbId:Mm(),vbType:z(F(),Ip(),Bp(0),Rp(255)),height:z(F(),Ip(),Bp(0)),size:z(F(),Ip(),Bp(0)),sectionCount:z(F(),Ip(),Bp(0))}),wT=I({responseType:P(yT.BLOCK_CONTENT),microblocks:N(CT)}),TT=I({responseType:P(yT.VIRTUAL_BLOCKCHAIN_STATE),serializedVirtualBlockchainState:B()}),ET=I({responseType:P(yT.VIRTUAL_BLOCKCHAIN_UPDATE),exists:Gp(),changed:Gp(),serializedVirtualBlockchainState:B()}),DT=I({responseType:P(yT.MICROBLOCK_INFORMATION),...qh.entries}),OT=I({responseType:P(yT.MICROBLOCK_ANCHORING),...qh.entries}),kT=I({microblockHash:Mm(),microblockBody:Dh}),AT=I({responseType:P(yT.MICROBLOCK_BODYS),list:N(kT)}),jT=I({responseType:P(yT.ACCOUNT_STATE),height:z(F(),Ip(),Bp(0)),balance:z(F(),Ip(),Bp(0)),lastHistoryHash:Mm(),locks:N(sg)}),MT=I({responseType:P(yT.ACCOUNT_HISTORY),list:fg}),NT=I({responseType:P(yT.ACCOUNT_BY_PUBLIC_KEY_HASH),accountHash:Mm()}),PT=I({responseType:P(yT.VALIDATOR_NODE_BY_ADDRESS),validatorNodeHash:Mm()}),FT=I({responseType:P(yT.GENESIS_SNAPSHOT),base64EncodedChunks:N(L())}),IT=I({responseType:P(yT.RAW_BLOCK_CONTENT),partIndex:F(),numberOfParts:F(),serializedMicroblocks:N(B())}),LT=I({responseType:P(yT.BLOCK_MODIFIED_ACCOUNTS),modifiedAccounts:N(B())}),RT=I({responseType:P(yT.ACCOUNT_UPDATES),list:N(mg)}),zT=I({responseType:P(yT.SERIALIAZED_MICROBLOCK_BY_HEIGHT),serializedContent:B()}),BT=I({responseType:P(yT.MICROBLOCK_PROOF),proof:zS}),VT=I({responseType:P(yT.ACCOUNT_PROOF),proof:IS}),HT=am(`responseType`,[bT,xT,ST,wT,IT,TT,ET,DT,OT,AT,jT,MT,NT,PT,FT,LT,RT,zT,BT,VT]),UT=class{static encodeAbciRequest(e){return Cx(R(vT,e))}static decodeAbciRequest(e){return R(vT,Kb(e))}static encodeAbciResponse(e){return Cx(R(HT,e))}static decodeAbciResponse(e){return R(HT,Kb(e))}},WT=class e{static staticLogger=k.getNetworkProviderLogger();logger=e.staticLogger;requestLogger=e.staticLogger.getChild(`request`);responseLogger=e.staticLogger.getChild(`response`);chainId=``;static createFromUrl(t){e.staticLogger.debug(`NetworkProvider constructor -> nodeUrl: ${t}`);try{return new URL(t),new e(t)}catch{throw new i(`Invalid node URL: got ${t}`)}}constructor(e){this.nodeUrl=e}async getChainId(){if(this.chainId===``){let t=new URL(this.nodeUrl);t.pathname=`status`,this.chainId=(await e.query(t))?.result?.node_info?.network??``}return this.chainId}async sendSerializedMicroblock(e){this.requestLogger.info(`Sending serialized microblock (${e.length} bytes)`);let t=await this.broadcastTx(e);return this.responseLogger.info(`Received response: <- {data}`,()=>({data:t?.data})),t}async awaitMicroblockAnchoring(e){let t=A.binaryToHexa(e);return this.requestLogger.info(`Awaiting microblock {hash} to be published...`,()=>({hash:t})),R(qh,await this.abciQuery({requestType:$.AWAIT_MICROBLOCK_ANCHORING,hash:e}))}async getChainInformation(){return this.requestLogger.info(`Requesting chain information`),R(xT,await this.abciQuery({requestType:$.GET_CHAIN_INFORMATION}))}async getBlockInformation(e){this.requestLogger.info(`Requesting block information at height: ${e}`);let t=await this.abciQuery({requestType:$.GET_BLOCK_INFORMATION,height:e});return this.responseLogger.info(`Received block information at height ${e}`),R(ST,t)}async getBlockContent(e){this.requestLogger.info(`Requesting block content for height ${e}`);let t=R(wT,await this.abciQuery({requestType:$.GET_BLOCK_CONTENT,height:e}));return this.responseLogger.info(`Received block content for height ${e}: ${t.microblocks.length} microblocks received`),t}async getValidatorNodeByAddress(e){this.requestLogger.info(`Requesting validator node id for address {address}`,()=>({address:A.binaryToHexa(e)}));let t=await this.abciQuery({requestType:$.GET_VALIDATOR_NODE_BY_ADDRESS,address:e});return this.responseLogger.info(`Receiving validator node id {id}`,()=>({id:A.binaryToHexa(e)})),R(PT,t)}async getAccountState(e){this.requestLogger.info(`Requesting account state for account hash {accountHash}`,()=>({accountHash:A.binaryToHexa(e)}));let t=R(jT,await this.abciQuery({requestType:$.GET_ACCOUNT_STATE,accountHash:e}));return this.responseLogger.info(`Receiving account state: height={height}, balance={balance}`,()=>({height:t.height,balance:hn.createAtomic(t.balance).toString()})),t}async getAccountHistory(e,t,n){this.requestLogger.info(`Requesting account history for account hash: ${A.binaryToHexa(e)}, lastHistoryHash: ${A.binaryToHexa(t)}, maxRecords: ${n}`);let r=R(MT,await this.abciQuery({requestType:$.GET_ACCOUNT_HISTORY,accountHash:e,lastHistoryHash:t,maxRecords:n}));return this.responseLogger.info(`Receiving account history with ${r.list.length} entries`),r}async getAccountByPublicKeyHash(e){this.requestLogger.info(`Requesting account hash by public key hash: ${A.binaryToHexa(e)}`);let t=R(NT,await this.abciQuery({requestType:$.GET_ACCOUNT_BY_PUBLIC_KEY_HASH,publicKeyHash:e}));return this.responseLogger.info(`Received account hash {accountHash}`,()=>({accountHash:A.binaryToHexa(t.accountHash)})),t}async getMicroblockInformation(e){this.requestLogger.info(`Requesting microblock information for hash ${A.binaryToHexa(e)}`);let t=R(DT,await this.abciQuery({requestType:$.GET_MICROBLOCK_INFORMATION,hash:e}));return this.responseLogger.info(`Received microblock information: vbType={vbType}, vbId={vbId}`,()=>({vbType:t.virtualBlockchainType,vbId:A.binaryToHexa(t.virtualBlockchainId)})),this.logger.info(`Received microblock information body hash for microblock ${A.binaryToHexa(e)}: ${A.binaryToHexa(t.header.bodyHash)}`),R(qh,t)}async getSerializedMicroblockByHeight(e,t){this.requestLogger.info(`Requesting microblock for VB ${A.binaryToHexa(e)} at height ${t}`);let n=R(zT,await this.abciQuery({requestType:$.GET_SERIALIZED_MICROBLOCK_BY_HEIGHT,virtualBlockchainId:e,height:t}));return this.responseLogger.info(`Received microblock - size: ${n.serializedContent.length} bytes`),n.serializedContent}async getMicroblockBodys(e){this.requestLogger.info(`Requesting microblock bodys for microblock hashes ${e.length}`),this.requestLogger.info(`Lisf of requested hashes: {hashes}`,()=>({hashes:e.map(e=>A.binaryToHexa(e)).join(`, `)}));let t=R(AT,await this.abciQuery({requestType:$.GET_MICROBLOCK_BODYS,hashes:e}));return this.responseLogger.info(`Returned number of microblock bodys: ${t.list.length}`),t}async getVirtualBlockchainUpdate(e,t){this.requestLogger.info(`Request virtual blockchain update for virtualBlockchainId: ${A.binaryToHexa(e)}`);let n=await this.abciQuery({requestType:$.GET_VIRTUAL_BLOCKCHAIN_UPDATE,virtualBlockchainId:e,knownStateHash:t});return this.responseLogger.info(`Receiving virtual blockchain update`),R(ET,n)}async getSerializedVirtualBlockchainState(e){this.requestLogger.info(`Requesting virtual blockchain state for vb id {vbId}`,()=>({vbId:A.binaryToHexa(e)}));let t=R(TT,await this.abciQuery({requestType:$.GET_VIRTUAL_BLOCKCHAIN_STATE,virtualBlockchainId:e}));return this.responseLogger.info(`Receiving virtual blockchain state: ${t.serializedVirtualBlockchainState.length} bytes`),t.serializedVirtualBlockchainState}static async query(e,t={},n=1e4){let r=new AbortController,i=setTimeout(()=>r.abort(),n);try{let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json; charset=UTF-8`,Accept:`application/json`},body:JSON.stringify(t),signal:r.signal});if(n.status===500)throw console.error(n),new h(`Internal error in the node: ${n.statusText}`);if(!n.ok)throw Error(`HTTP ${n.status}`);return await n.json()}catch(t){throw t?.name===`AbortError`?new h(`Request timeout after ${n}ms`):t?.cause?.code===`ECONNREFUSED`||t?.code===`ECONNREFUSED`||t instanceof TypeError?new g(e):t}finally{clearTimeout(i)}}async broadcastTx(t){let n=new URL(this.nodeUrl);this.logger.info(`broadcastTx -> ${t.length} bytes to ${this.nodeUrl}`);let r=Sg.bytesToBase64Encoder();return await e.query(n,{jsonrpc:`2.0`,id:1,method:`broadcast_tx_sync`,params:{tx:r.encode(t)}})}async abciQuery(t){if(t===void 0)throw new i(`Cannot send an undefined request`);this.logger.debug(`Sending ABCI request:`,t);let n=UT.encodeAbciRequest(t);return await e.sendABCIQueryToNodeServer(this.nodeUrl,n)}static async sendABCIQueryToNodeServer(t,n){e.staticLogger.debug(`Sending ABCI Query to node server at ${t} (${n.length} bytes) `);let r=new URL(t);r.pathname=`abci_query`,r.searchParams.append(`path`,`"/carmentis"`),r.searchParams.append(`data`,`0x`+A.binaryToHexa(n));let i=await e.query(r),a=i?.result?.response?.value;if(typeof a!=`string`)throw this.staticLogger.error(`Invalid response type detected:`,i),this.staticLogger.error(`rawBase64EncodedResponse: `,a),new h(`Invalid response detected`);let o=_g.decodeBinary(a),s=UT.decodeAbciResponse(o);if(s.responseType==yT.ERROR){let t=s.error;throw e.staticLogger.error(`sendABCIQueryToNodeServer <- {*}`,()=>({error:t})),new h(`Remote error: ${t}`)}return e.staticLogger.debug(`Returning ABCI response`),s}static async sendStatusQueryToNodeServer(t){e.staticLogger.debug(`sendStatusQueryToNodeServer -> nodeUrl: ${t}`);let n=new URL(t);n.pathname=`status`;let r=om(Zw,await e.query(n));if(r.success)return e.staticLogger.debug(`sendStatusQueryToNodeServer <- received valid status response`),r.output;throw e.staticLogger.debug(`sendStatusQueryToNodeServer <- parsing error: ${r.issues}`),new h(r.issues.map(e=>e.message).join(`, `))}async getGenesisSnapshot(){this.requestLogger.info(`Requesting genesis snapshot`);let e=R(FT,await this.abciQuery({requestType:$.GET_GENESIS_SNAPSHOT}));return this.responseLogger.info(`Received genesis snapshots containing {chunksNumber} chunks`,()=>({chunksNumber:e.base64EncodedChunks.length})),e}},GT=class e{static logger=k.getMemoryProviderLogger();static instance=new e;static getInstance(){return this.instance}constructor(){}clear(){e.logger.info(`Clearing`)}async getSerializedInformationOfVirtualBlockchainContainingMicroblock(e){return null}async getInformationOfVirtualBlockchainContainingMicroblock(e){return null}async getMicroblock(e){throw Error(`Method not implemented`)}async getMicroblockHeader(e){return null}async getSerializedMicroblockHeader(e){return null}async getMicroblockBody(e){return null}async getSerializedVirtualBlockchainState(e){return null}async getAccountByPublicKeyHash(e){return null}async setMicroblockVbInformation(e,t){}async setSerializedMicroblockHeader(e,t){}async setSerializedMicroblockBody(e,t){}async setMicroblockHeader(e,t){}async setMicroblockBody(e,t){}async setSerializedVirtualBlockchainState(e,t){}},KT=class{constructor(){}getChainId(){throw Error(`Method not implemented.`)}sendSerializedMicroblock(e){throw Error(`Method not implemented.`)}awaitMicroblockAnchoring(e){throw Error(`Method not implemented.`)}getChainInformation(){throw Error(`Method not implemented.`)}getBlockInformation(e){throw Error(`Method not implemented.`)}getBlockContent(e){throw Error(`Method not implemented.`)}getValidatorNodeByAddress(e){throw Error(`Method not implemented.`)}getAccountState(e){throw Error(`Method not implemented.`)}getAccountHistory(e,t,n){throw Error(`Method not implemented.`)}getAccountByPublicKeyHash(e){throw Error(`Method not implemented.`)}getMicroblockInformation(e){return Promise.resolve(null)}getSerializedMicroblockByHeight(e,t){return Promise.resolve(null)}getMicroblockBodys(e){return Promise.resolve(null)}getVirtualBlockchainUpdate(e){throw Error(`Method not implemented.`)}getSerializedVirtualBlockchainState(e){throw Error(`Method not implemented.`)}broadcastTx(e){throw Error(`Method not implemented.`)}abciQuery(e){throw Error(`Method not implemented.`)}getGenesisSnapshot(){throw Error(`Method not implemented.`)}},qT=class{static convertRawPublicKeyIntoAddress(e){return Zc.sha256AsBinary(e).slice(0,20)}},JT=class e extends Jw{logger=k.getProviderLogger();externalProvider;internalProvider;constructor(e,t){super(),this.internalProvider=e,this.externalProvider=t}async awaitMicroblockAnchoring(e){return await this.externalProvider.awaitMicroblockAnchoring(e)}async getChainId(){return await this.externalProvider.getChainId()}async getChainInformation(){return await this.externalProvider.getChainInformation()}async getGenesisSnapshot(){return await this.externalProvider.getGenesisSnapshot()}async getBlockInformation(e){return await this.externalProvider.getBlockInformation(e)}async getBlockContent(e){return await this.externalProvider.getBlockContent(e)}async getAccountState(e){return await this.externalProvider.getAccountState(e)}async getAccountHistory(e,t,n){return await this.externalProvider.getAccountHistory(e,t,n)}async getAccountByPublicKeyHash(t){let n=await this.internalProvider.getAccountByPublicKeyHash(t);if(n!==null)return n;let r=await this.externalProvider.getAccountByPublicKeyHash(t);return k.getLogger([e.name]).debug(`Account hash ${r} is associated to public key hash ${t}`),r.accountHash}async getVirtualBlockchainState(e){this.logger.info(`Getting state for virtual blockchain ${A.binaryToHexa(e)}`);let t=await this.internalProvider.getSerializedVirtualBlockchainState(e);if(t!==null)return this.logger.info(`State for virtual blockchain ${A.binaryToHexa(e)} found locally`),X.decodeVirtualBlockchainState(t);{let t=await this.externalProvider.getSerializedVirtualBlockchainState(e);return t?(this.logger.info(`State for virtual blockchain ${A.binaryToHexa(e)} found remotely`),await this.internalProvider.setSerializedVirtualBlockchainState(e,t),X.decodeVirtualBlockchainState(t)):null}}async getAccountIdByPublicKey(e){let t=await e.getPublicKeyAsBytes(),n=xp.Hashes.sha256AsBinary(t);return await this.getAccountByPublicKeyHash(n)}async getProtocolState(){let e=await this.getProtocolVirtualBlockchainId(),t=await this.getVirtualBlockchainState(e.toBytes());if(t===null)throw Error(`Cannot get protocol parameters from the internal provider`);if(t.type!==H.PROTOCOL_VIRTUAL_BLOCKCHAIN)throw Error(`Expected protocol virtual blockchain, got ${H[t.type]}`);return Bx.createFromObject(t.internalState)}async getProtocolVirtualBlockchainId(){let e=await this.getChainInformation();return Ix.from(e.protocolVirtualBlockchainId)}async getMicroblockInformation(e){let t=await this.internalProvider.getInformationOfVirtualBlockchainContainingMicroblock(e),n=await this.internalProvider.getMicroblockHeader(e);if(t&&n)return{...t,header:n};let r=await this.externalProvider.getMicroblockInformation(e);if(r){let t=X.encodeVirtualBlockchainInfo({virtualBlockchainId:r.virtualBlockchainId,virtualBlockchainType:r.virtualBlockchainType});return await this.internalProvider.setMicroblockVbInformation(e,t),await this.internalProvider.setMicroblockHeader(e,r.header),r}return null}async getListOfMicroblockBody(e){let t=[],n=[],r=0;for(let i of e){let e=await this.internalProvider.getMicroblockBody(i);if(e){let n=X.decodeMicroblockBody(e);t.push({hash:i,body:n})}else n.push(i);r+=1}if(n.length){let r=await this.externalProvider.getMicroblockBodys(n);if(r===null)throw Error(`Unable to load microblock bodies`);for(let{microblockBody:e,microblockHash:n}of r.list){let r=X.encodeMicroblockBody(e);await this.internalProvider.setSerializedMicroblockBody(n,r),t.push({hash:n,body:e})}t.sort((t,n)=>e.indexOf(t.hash)-e.indexOf(n.hash))}return t.map(e=>e.body)}async getMicroblockBody(e){this.logger.info(`Looking for body for microblock ${e.encode()}`);let t=await this.internalProvider.getMicroblockBody(e.toBytes());if(t instanceof Uint8Array)return this.logger.info(`Body for microblock ${e.encode()} found locally`),X.decodeMicroblockBody(t);{let t=await this.externalProvider.getMicroblockBodys([e.toBytes()]);if(t!==null&&t.list.length!==0){let n=t.list[0].microblockBody;return await this.internalProvider.setMicroblockBody(e.toBytes(),n),this.logger.info(`Body for microblock ${e.encode()} found remotely`),n}}return this.logger.warning(`Body for microblock ${e.encode()} not found`),null}async getMicroblockHeader(e){this.logger.info(`Looking for header for microblock ${e.encode()}`);let t=await this.internalProvider.getSerializedMicroblockHeader(e.toBytes());if(t instanceof Uint8Array){let n=xp.Hashes.sha256(t),r=X.decodeMicroblockHeader(t);return this.logger.info(`Header for microblock ${e.encode()} found locally (sha256:${n}): {header}`,{header:JSON.stringify(r)}),r}let n=await this.externalProvider.getMicroblockInformation(e.toBytes());if(n!==null)return this.logger.info(`Header for microblock ${e.encode()} found remotely: {header}:`,{header:n.header}),n.header;throw new te}async getSerializedMicroblockByHeight(e,t){let n=await this.externalProvider.getSerializedMicroblockByHeight(e,t);if(n!==null)return this.logger.info(`Microblock found remotely`),n;throw new te}async getVirtualBlockchainIdContainingMicroblock(e){this.logger.info(`Searching for virtual blockchain containing microblock ${e.encode()}`);let t=await this.internalProvider.getInformationOfVirtualBlockchainContainingMicroblock(e.toBytes());if(t!==null)return Ix.from(t.virtualBlockchainId);{let t=await this.externalProvider.getMicroblockInformation(e.toBytes());if(t!==null)return Ix.from(t.virtualBlockchainId);throw new te}}async getVirtualBlockchainStatus(e){let t=null,n=A.getNullHash(),r=await this.internalProvider.getSerializedVirtualBlockchainState(e);r!==null&&(t=X.decodeVirtualBlockchainState(r),n=$v.createDefaultCryptographicHash().hash(r));let i=await this.externalProvider.getVirtualBlockchainUpdate(e,n);return i.exists?(i.changed&&(await this.internalProvider.setSerializedVirtualBlockchainState(e,i.serializedVirtualBlockchainState),t=X.decodeVirtualBlockchainState(i.serializedVirtualBlockchainState)),t):null}async getAccountIdFromPublicKey(e){let t=new pv,n=await this.externalProvider.getAccountByPublicKeyHash(t.hash(await e.getPublicKeyAsBytes()));return Ix.from(n.accountHash)}async publishMicroblock(e){this.logger.info(`Publishing microblock ${e.getHash().encode()}`);let{microblockData:t}=e.serialize();return await this.externalProvider.sendSerializedMicroblock(t),e.getHash()}async getNodeStatus(e){return WT.sendStatusQueryToNodeServer(e)}async getValidatorNodeIdByAddress(e){return(await this.externalProvider.getValidatorNodeByAddress(e.toBytes())).validatorNodeHash}async getValidatorNodeIdByCometbftPublicKey(e){let t=Sg.bytesToBase64Encoder(),n=qT.convertRawPublicKeyIntoAddress(t.decode(e));return this.getValidatorNodeIdByAddress(Ix.from(n))}},YT=class{static createInMemoryProvider(){return new JT(new Xw,new KT)}static createInMemoryProviderWithExternalProvider(e){return new JT(new Xw,WT.createFromUrl(e))}static createNullInMemoryProviderWithExternalProvider(e){return new JT(new GT,WT.createFromUrl(e))}},XT=class extends WT{constructor(e){super(e)}},ZT=I({jsonrpc:P(`2.0`),id:F(),result:I({query:L(),data:I({type:P(`tendermint/event/NewBlock`),value:I({block:I({header:I({version:I({block:L(),app:$p(L())}),chain_id:L(),height:L(),time:L(),last_block_id:I({hash:L(),parts:I({total:F(),hash:L()})}),last_commit_hash:L(),data_hash:L(),validators_hash:L(),next_validators_hash:L(),consensus_hash:L(),app_hash:L(),last_results_hash:L(),evidence_hash:L(),proposer_address:L()}),data:I({txs:N(L())}),evidence:I({evidence:N(Wp())}),last_commit:I({height:L(),round:F(),block_id:I({hash:L(),parts:I({total:F(),hash:L()})}),signatures:N(I({block_id_flag:F(),validator_address:L(),timestamp:L(),signature:L()}))})}),block_id:I({hash:L(),parts:I({total:F(),hash:L()})}),result_finalize_block:I({validator_updates:$p(rm([Zp(),Wp()])),app_hash:L()})})}),events:I({"tm.event":N(L())})})}),QT=class e{callbacks=[];constructor(e){this.ws=e,e.onmessage=this.onMessage.bind(this),e.onopen=this.onConnect.bind(this),e.onclose=this.onDisconnect.bind(this)}static new(t){return new e(new WebSocket(t))}addCallback(e){this.callbacks.push(e)}onConnect(e){this.ws.send(JSON.stringify({jsonrpc:`2.0`,method:`subscribe`,id:1,params:{query:`tm.event='NewBlock'`}}))}onMessage(e){let t=om(ZT,JSON.parse(e.data));if(t.success){let e=t.output;this.onNewBlock(e)}}onNewBlock(e){for(let t of this.callbacks)t.onNewBlock&&t.onNewBlock(e)}onDisconnect(e){}},$T=class{constructor(e){this.transaction=e}getHeight(){return this.transaction.height}getPreviousHistoryHash(){return Ix.from(this.transaction.previousHistoryHash)}getTimestamp(){return this.transaction.timestamp}transferredAt(){return new Date(this.transaction.timestamp*1e3)}getLinkedAccount(){return Ix.from(this.transaction.linkedAccount)}getAmount(){let e=this.isPositive()?1:-1;return hn.createAtomic(this.transaction.amount*e)}getChainReference(){return this.transaction.chainReference}isPositive(){return!!(this.transaction.type&1)}isNegative(){return!this.isPositive()}isEarnedFees(){return this.isEarnedBlockFees()||this.isEarnedTxFees()}isEarnedBlockFees(){return this.transaction.type===3}isEarnedTxFees(){return this.transaction.type===1}isPaidBlockFees(){return this.transaction.type===2}isPaidTxFees(){return this.transaction.type===0}isReceivedIssuance(){return this.transaction.type===5}isSentIssuance(){return this.transaction.type===4}isSale(){return this.transaction.type==6}isSentPayment(){return this.transaction.type==8}isPaidFees(){return this.isPaidBlockFees()||this.isPaidTxFees()}isPurchase(){return this.transaction.type==7}isReceivedPayment(){return this.transaction.type==9}},eE=class{transactionByHeight;constructor(){this.transactionByHeight=new Map}setTransactionAtHeight(e,t){this.transactionByHeight.set(e,t)}containsTransactions(){return this.transactionByHeight.size>0}getTransactionHeights(){return Array.from(this.transactionByHeight.keys())}getAllTransactions(){return Array.from(this.transactionByHeight.values()).map(e=>new $T(e))}getNumberOfTransactions(){return this.transactionByHeight.size}containsTransactionAtHeight(e){return this.transactionByHeight.has(e)}getTransactionAtHeight(e){let t=this.transactionByHeight.get(e);if(t===void 0)throw new i(`No transaction found at height ${e}`);return new $T(t)}},tE={[H.PROTOCOL_VIRTUAL_BLOCKCHAIN]:`PROTOCOL_VIRTUAL_BLOCKCHAIN`,[H.NODE_VIRTUAL_BLOCKCHAIN]:`NODE_VIRTUAL_BLOCKCHAIN`,[H.APPLICATION_VIRTUAL_BLOCKCHAIN]:`APPLICATION_VIRTUAL_BLOCKCHAIN`,[H.ORGANIZATION_VIRTUAL_BLOCKCHAIN]:`ORGANIZATION_VIRTUAL_BLOCKCHAIN`,[H.APP_LEDGER_VIRTUAL_BLOCKCHAIN]:`APP_LEDGER_VIRTUAL_BLOCKCHAIN`,[H.ACCOUNT_VIRTUAL_BLOCKCHAIN]:`ACCOUNT_VIRTUAL_BLOCKCHAIN`},nE=class{static getVirtualBlockchainLabelFromVirtualBlockchainType(e){return tE[e]}},rE=function(e){return e.AUTH_BY_PUBLIC_KEY=`WALLET_REQUEST_AUTH_BY_PUBLIC_KEY`,e.DATA_APPROVAL=`WALLET_REQUEST_DATA_APPROVAL`,e}({}),iE=function(e){return e.AUTH_BY_PUBLIC_KEY=`WALLET_RESPONSE_AUTH_BY_PUBLIC_KEY`,e.DATA_APPROVAL=`WALLET_RESPONSE_DATA_APPROVAL`,e}({}),aE=I({type:P(rE.AUTH_BY_PUBLIC_KEY),base64EncodedChallenge:L()}),oE=I({type:P(rE.DATA_APPROVAL),anchorRequestId:L(),serverUrl:L()}),sE=am(`type`,[aE,oE]),cE=I({type:P(iE.AUTH_BY_PUBLIC_KEY),publicKey:L(),signature:L()}),lE=I({type:P(iE.DATA_APPROVAL),b64VbHash:L(),b64MbHash:L(),height:F()}),uE=am(`type`,[cE,lE]),dE=100,fE=function(e){return e.REQUEST=`CLIENT_BRIDGE_REQUEST`,e.UPDATE_QR=`CLIENT_BRIDGE_UPDATE_QR`,e.CONNECTION_TOKEN=`CLIENT_BRIDGE_CONNECTION_TOKEN`,e.FORWARDED_ANSWER=`CLIENT_BRIDGE_FORWARDED_ANSWER`,e.GET_CONNECTION_INFO=`CLIENT_BRIDGE_GET_CONNECTION_INFO`,e.ANSWER=`CLIENT_BRIDGE_ANSWER`,e.CONNECTION_INFO=`CLIENT_BRIDGE_CONNECTION_INFO`,e.CONNECTION_ACCEPTED=`CLIENT_BRIDGE_CONNECTION_ACCEPTED`,e.FORWARDED_REQUEST=`CLIENT_BRIDGE_FORWARDED_REQUEST`,e.ERROR=`CLIENT_BRIDGE_ERROR`,e}({}),pE=I({base64EncodedQrId:L(),timestamp:F(),serverUrl:z(L(),Lp(100))}),mE=I({type:P(fE.REQUEST),walletRequest:sE,deviceId:Mm(),withToken:F()}),hE=I({type:P(fE.UPDATE_QR),base64EncodedQrId:L(),timestamp:F()}),gE=I({type:P(fE.CONNECTION_TOKEN),token:Mm()}),_E=I({type:P(fE.FORWARDED_ANSWER),walletResponse:uE}),vE=I({type:P(fE.GET_CONNECTION_INFO),base64EncodedQrId:L()}),yE=I({type:P(fE.ANSWER),walletResponse:uE}),bE=I({type:P(fE.CONNECTION_INFO)}),xE=I({type:P(fE.CONNECTION_ACCEPTED),base64EncodedQrId:L()}),SE=I({type:P(fE.FORWARDED_REQUEST),walletRequest:sE}),CE=I({type:P(fE.ERROR),errorMessage:L()}),wE=am(`type`,[mE,hE,gE,_E,vE,yE,bE,xE,SE,CE]),TE=class{static encode(e){return Cx(R(wE,e))}static decode(e){return R(wE,Kb(e))}},EE=class{static validateClientBridgeMessage(e){return R(wE,e)}},DE=class{static encode(e){return Cx(R(pE,e))}static decode(e){return R(pE,Kb(e))}},OE=tm(L(),I({networkName:$p(L()),nodes:tm(L(),I({nodeName:$p(L()),hostname:L(),rpcEndpoint:L(),p2pEndpoint:L(),trusted:$p(Gp(),!1),nodeId:L()}))})),kE=I({state:Gh,microblockHashes:N(B())}),AE=function(e){return e.APPROVAL_HANDSHAKE=`WALLET_OPERATOR_REQUEST_APPROVAL_HANDSHAKE`,e.ACTOR_KEY=`WALLET_OPERATOR_REQUEST_ACTOR_KEY`,e.APPROVAL_SIGNATURE=`WALLET_OPERATOR_REQUEST_APPROVAL_SIGNATURE`,e}({}),jE=function(e){return e.ERROR=`WALLET_OPERATOR_RESPONSE_ERROR`,e.ACTOR_KEY_REQUIRED=`WALLET_OPERATOR_RESPONSE_ACTOR_KEY_REQUIRED`,e.APPROVAL_DATA=`WALLET_OPERATOR_RESPONSE_APPROVAL_DATA`,e.APPROVAL_SIGNATURE=`WALLET_OPERATOR_RESPONSE_APPROVAL_SIGNATURE`,e}({}),ME=I({type:P(AE.APPROVAL_HANDSHAKE),anchorRequestId:L()}),NE=I({type:P(AE.ACTOR_KEY),anchorRequestId:L(),actorSignaturePublicKey:L(),actorPkePublicKey:L()}),PE=I({type:P(AE.APPROVAL_SIGNATURE),anchorRequestId:L(),b64Signature:L()}),FE=am(`type`,[ME,NE,PE]),IE=I({type:P(jE.ERROR),errorMessage:$p(L(),``)}),LE=I({type:P(jE.ACTOR_KEY_REQUIRED),b64GenesisSeed:L()}),RE=I({type:P(jE.APPROVAL_DATA),b64SerializedMicroblock:L()}),zE=I({type:P(jE.APPROVAL_SIGNATURE),b64VbHash:L(),b64MbHash:L(),height:F()}),BE=am(`type`,[IE,LE,RE,zE]),VE=class{static encodeRequest(e){return Cx(R(sE,e))}static decodeRequest(e){return R(sE,Kb(e))}static encodeResponse(e){return Cx(R(uE,e))}static decodeResponse(e){return R(uE,Kb(e))}},HE=class{static validateWalletRequest(e){return R(sE,e)}static validateWalletResponse(e){return R(uE,e)}},UE=class{constructor(e=new Cg){this.stringEncoder=e}decode(e){let t=this.getPrefix(),n=Eg.decode(e);if(n.matchesKeys(...t))return this.stringEncoder.decode(n.getValue());throw new l(`Invalid seed format`)}encode(e){let t=this.getPrefix();return Eg.encode(...t,this.stringEncoder.encode(e))}getPrefix(){return[`SEED`]}},WE=class extends UE{getPrefix(){return[`ACCOUNT`,`SEED`]}},GE=class e{static createFromAbciResponse(t){return new e(t.list)}constructor(e){this.transactions=e}containsTransactions(){return this.transactions.length>0}getTransactions(){return this.transactions.map(e=>new KE(e))}},KE=class{constructor(e){this.transaction=e}getHeight(){return this.transaction.height}getPreviousHistoryHash(){return Ix.from(this.transaction.previousHistoryHash)}getTimestamp(){return this.transaction.timestamp}transferredAt(){return new Date(this.transaction.timestamp*1e3)}getTransactionTypeLabel(){return this.isEarnedFees()?`Earned fees`:this.isPaidFees()?`Paid fees`:this.isSentPayment()?`Sent payment`:this.isReceivedPayment()?`Received payment`:this.isPurchase()?`Purchase`:this.isSentIssuance()?`Sent issuance`:this.isReceivedIssuance()?`Received issuance`:this.isSale()?`Sale`:`Transaction`}getLinkedAccount(){return Ix.from(this.transaction.linkedAccount)}getAmount(){let e=this.isPositive()?1:-1;return hn.createAtomic(this.transaction.amount*e)}getChainReference(){return this.transaction.chainReference}isPositive(){return!!(this.transaction.type&1)}isNegative(){return!this.isPositive()}isEarnedFees(){return this.isEarnedBlockFees()||this.isEarnedTxFees()}isEarnedBlockFees(){return this.transaction.type===3}isEarnedTxFees(){return this.transaction.type===1}isPaidBlockFees(){return this.transaction.type===2}isPaidTxFees(){return this.transaction.type===0}isReceivedIssuance(){return this.transaction.type===5}isSentIssuance(){return this.transaction.type===4}isSale(){return this.transaction.type==6}isSentPayment(){return this.transaction.type==8}isPaidFees(){return this.isPaidBlockFees()||this.isPaidTxFees()}isPurchase(){return this.transaction.type==7}isReceivedPayment(){return this.transaction.type==9}},qE=class extends UE{getPrefix(){return[`ACTOR`,`SEED`]}},JE=class e{static createFromAccountStateAbciResponse(t){return new e(t.balance,t.locks)}logger=k.getLogger([`accounts`,e.name]);balanceInAtomics;locks;constructor(t=0,n=[]){this.initialBalance=t,this.initialLocks=n,this.balanceInAtomics=t,this.locks=n,this.logger=co([`node`,`accounts`,e.name])}setBalance(e){this.balanceInAtomics=e}getBalanceAsAtomics(){return this.balanceInAtomics}getBalance(){return hn.createAtomic(this.balanceInAtomics)}setLocks(e){this.locks=[...e]}getLocks(){return this.locks}hasNodeStakingLocks(){return this.locks.some(e=>e.type==eg.NodeStaking)}getNodeStakingLocks(){return this.locks.filter(e=>e.type==eg.NodeStaking)}getNodeStakingLock(e){return this.getNodeStakingLocks().find(t=>A.binaryIsEqual(t.parameters.validatorNodeId,e))}getNodeStakingLockOrFail(e){let t=this.getNodeStakingLock(e);if(t==null)throw Error(`Staking not found for node ${A.binaryToHexa(e)}`);return t}getNodeStakingLockAmount(e){let t=this.getNodeStakingLock(e);return t===void 0?0:t.lockedAmountInAtomics}hasEscrowLocks(){return this.locks.some(e=>e.type==eg.Escrow)}getEscrowLocks(){return this.locks.filter(e=>e.type==eg.Escrow)}hasVestingLocks(){return this.locks.some(e=>e.type==eg.Vesting)}getVestingLocks(){return this.locks.filter(e=>e.type==eg.Vesting)}removeExpiredEscrowLocks(){this.removeExpiredLocks(eg.Escrow)}removeExpiredVestingLocks(){this.removeExpiredLocks(eg.Vesting)}removeExpiredStakingLocks(){this.removeExpiredLocks(eg.NodeStaking)}removeExpiredLocks(e){this.locks=this.locks.filter(t=>!(t.type==e&&t.lockedAmountInAtomics==0))}addSpendableTokens(e){this.balanceInAtomics+=e}addVestedTokens(e,t){this.balanceInAtomics+=e,this.locks.push({type:eg.Vesting,lockedAmountInAtomics:e,parameters:t})}addEscrowedTokens(e,t){this.balanceInAtomics+=e,this.locks.push({type:eg.Escrow,lockedAmountInAtomics:e,parameters:t})}removeEscrowLock(e){let t=this.locks.findIndex(t=>t.type==eg.Escrow&&A.binaryIsEqual(t.parameters.escrowIdentifier,e));if(t==-1)throw Error(`Escrow not found`);let n=this.locks[t].lockedAmountInAtomics;return this.locks.splice(t,1),n}addNodeStaking(e,t){let n=this.getBreakdown();if(e<0)throw Error(`Stake amount must be greater than 0`);if(e>n.stakeable)throw Error(`Cannot stake more than ${n.stakeable} atomic units`);let r=this.getNodeStakingLock(t);r===void 0?(this.logger.info(`Creating new staking of ${e} atomics for node ${A.binaryToHexa(t)}`),this.locks.push({type:eg.NodeStaking,lockedAmountInAtomics:e,parameters:{validatorNodeId:t,plannedUnlockAmountInAtomics:0,plannedUnlockTimestamp:0,slashed:!1,plannedSlashingAmountInAtomics:0,plannedSlashingTimestamp:0}})):(this.logger.info(`Adding ${e} atomics to existing staking for node ${A.binaryToHexa(t)}`),r.lockedAmountInAtomics+=e)}planNodeStakingUnlock(e,t,n){let r=this.getNodeStakingLockOrFail(n);if(r.parameters.plannedUnlockAmountInAtomics!=0)throw Error(`There's already a pending staking unlock for this node`);let i=A.addDaysToTimestamp(t,0);this.logger.info(`Planned staking unlock of ${e} atomics on account ${A.binaryToHexa(n)}`),r.parameters.plannedUnlockAmountInAtomics=e,r.parameters.plannedUnlockTimestamp=i}applyNodeStakingUnlocks(e){let t=this.getNodeStakingLocks(),n=0;for(let r of t)if(r.parameters.plannedUnlockTimestamp!=0&&e>=r.parameters.plannedUnlockTimestamp){let e=r.parameters.plannedUnlockAmountInAtomics;this.removeNodeStaking(e,r.parameters.validatorNodeId),n+=e}return this.removeExpiredStakingLocks(),n}setSlashing(e,t){let n=this.getNodeStakingLockOrFail(e);this.logger.info(`Setting slashing of ${n.lockedAmountInAtomics} atomics for node ${A.binaryToHexa(e)}, effective on ${new Date(t*1e3).toISOString()}`),n.parameters.slashed=!0,n.parameters.plannedSlashingAmountInAtomics=n.lockedAmountInAtomics,n.parameters.plannedSlashingTimestamp=t}cancelNodeSlashing(e){let t=this.getNodeStakingLockOrFail(e);t.parameters.slashed?(this.logger.info(`Cancelled slashing of node ${A.binaryToHexa(e)}`),t.parameters.slashed=!1,t.parameters.plannedSlashingAmountInAtomics=0,t.parameters.plannedSlashingTimestamp=0):this.logger.warn(`No pending slashing for node ${A.binaryToHexa(e)}`)}applyNodeSlashing(e){let t=this.getNodeStakingLocks(),n=0;for(let r of t)if(r.parameters.slashed){let t=r.parameters.plannedSlashingAmountInAtomics;t>0&&r.parameters.plannedSlashingTimestamp!=0&&e>=r.parameters.plannedSlashingTimestamp&&(this.logger.info(`Applying slashing of ${t} atomics on node ${A.binaryToHexa(r.parameters.validatorNodeId)}`),r.lockedAmountInAtomics-=t,this.balanceInAtomics-=t,n+=t,r.parameters.slashed=!1,r.parameters.plannedSlashingTimestamp=0,r.parameters.plannedSlashingAmountInAtomics=0)}return this.adjustVesting(),this.removeExpiredStakingLocks(),n}adjustVesting(){let e=this.getBreakdown().vested,t=e-this.balanceInAtomics;if(t>0){let n=this.getVestingLocks(),r=0;for(let i of n){let n=Math.floor(t*i.lockedAmountInAtomics/e);i.lockedAmountInAtomics-=n,r+=n}for(let e of n)r<t&&e.lockedAmountInAtomics>0&&(e.lockedAmountInAtomics--,r++);this.removeExpiredVestingLocks()}}removeNodeStaking(e,t){let n=this.getNodeStakingLockOrFail(t);if(e<0)throw Error(`Unstake amount must be greater than 0`);if(e>n.lockedAmountInAtomics)throw Error(`Cannot unstake more than ${n.lockedAmountInAtomics} atomic units`);n.lockedAmountInAtomics-=e}applyLinearVesting(e){let t=this.getBreakdown().releasable,n=0,r=this.getVestingLocks();for(let i of r){let r=i.parameters.initialVestedAmountInAtomics,a=i.parameters.cliffStartTimestamp,o=i.parameters.cliffDurationDays,s=i.parameters.vestingDurationDays,c=A.addDaysToTimestamp(a,o),l=Math.min(A.timestampDifferenceInDays(c,e),s);if(this.logger.debug(`start date: {cliffStartDate}, initial amount: {initialAmount}, cliff during {cliffDurationDays} day(s), vesting during {vestingDurationDays} day(s)`,()=>({cliffStartDate:new Date(a*1e3).toISOString(),initialAmount:r,cliffDurationDays:o,vestingDurationDays:s})),this.logger.debug(`cliff end date: {cliffEndDay}, today: {today}, elapsed time in vesting: {elapsed} day(s)`,()=>({cliffEndDay:new Date(c*1e3).toISOString(),today:new Date(e*1e3).toISOString(),elapsed:l})),l>0){let e=r-i.lockedAmountInAtomics,a=Math.floor(r*l/s),o=Math.min(a-e,t);this.logger.debug(`already released: ${e}, max. release: ${a}, released today: ${o}`),i.lockedAmountInAtomics-=o,t-=o,n+=o}else this.logger.debug(`nothing is released today`)}return this.removeExpiredVestingLocks(),n}getBreakdown(){let e=new Map;for(let t of this.locks){let n=e.get(t.type)||0;e.set(t.type,n+t.lockedAmountInAtomics)}let t=e.get(eg.Escrow)||0,n=e.get(eg.Vesting)||0,r=e.get(eg.NodeStaking)||0,i=this.balanceInAtomics-r-t,a=Math.max(0,n-r),o=t+Math.max(n,r),s=this.balanceInAtomics-o;return{balance:this.balanceInAtomics,escrowed:t,vested:n,releasable:a,staked:r,stakeable:i,locked:o,spendable:s}}getSpendable(){return hn.createAtomic(this.getBreakdown().spendable)}getVested(){return hn.createAtomic(this.getBreakdown().vested)}getStakeable(){return hn.createAtomic(this.getBreakdown().stakeable)}getStaked(){return hn.createAtomic(this.getBreakdown().staked)}getEscrowed(){return hn.createAtomic(this.getBreakdown().escrowed)}},YE=class{static encoder=new ux({tagUint8Array:!0,mapsAsObjects:!0});static encodeRequest(e){return this.encoder.encode(R(FE,e))}static decodeRequest(e){return R(FE,this.encoder.decode(e))}static encodeResponse(e){return this.encoder.encode(R(BE,e))}static decodeResponse(e){return R(BE,this.encoder.decode(e))}},XE=class{static validateRequest(e){return R(FE,e)}static validateResponse(e){return R(BE,e)}},ZE=class extends UE{getPrefix(){return[`WALLET`,`SEED`]}},QE=class e{signatureSchemeId=Ja.SECP256K1;pkeSchemeId=Ov.ML_KEM_768_AES_256_GCM;constructor(e){this.actorSeed=e}static createFromAccountSeedAndVbSeed(t,n){return new e(A.binaryFrom(t,n))}static parseFromString(t,n=new UE){return new e(n.decode(t))}encode(e=new UE){return e.encode(this.actorSeed)}getSeedAsBytes(){return this.actorSeed}async getPrivateSignatureKey(e=this.signatureSchemeId){let t=$v.createDefaultKDF(),n=this.encoderStringAsBytes(`SIG`),r=t.deriveKeyNoSalt(this.actorSeed,n,32);return $v.createPrivateSignatureKey(e,r)}async getPublicSignatureKey(e=this.signatureSchemeId){return(await this.getPrivateSignatureKey(e)).getPublicKey()}getPrivateDecryptionKey(e=this.pkeSchemeId){let t=$v.createDefaultKDF(),n=this.encoderStringAsBytes(`PKE`),r=t.deriveKeyNoSalt(this.actorSeed,n,64);return $v.createPrivateDecryptionKey(e,r)}async getPublicEncryptionKey(e=this.pkeSchemeId){return(await this.getPrivateDecryptionKey(e)).getPublicKey()}encoderStringAsBytes(e){return new TextEncoder().encode(e)}getSignatureSchemeId(){return this.signatureSchemeId}setSignatureSchemeId(e){this.signatureSchemeId=e}getPkeSchemeId(){return this.pkeSchemeId}setPkeSchemeId(e){this.pkeSchemeId=e}},$E=class e{signatureSchemeId=Ja.SECP256K1;pkeSchemeId=Ov.ML_KEM_768_AES_256_GCM;static createFromWalletSeedAndNonce(t,n){let r=A.binaryFrom(t,n),i=$v.createDefaultKDF(),a=this.encoderStringAsBytes(`ACCOUNT_SEED`);return new e(i.deriveKeyNoSalt(r,a,32))}static parseFromString(t,n=new UE){return new e(n.decode(t))}encode(e=new UE){return e.encode(this.accountSeed)}constructor(e){this.accountSeed=e}deriveActorFromVbSeed(e){return QE.createFromAccountSeedAndVbSeed(this.accountSeed,e)}async getPrivateSignatureKey(t=this.signatureSchemeId){let n=$v.createDefaultKDF(),r=e.encoderStringAsBytes(`SIG_${t}`),i=n.deriveKeyNoSalt(this.accountSeed,r,32);return $v.createPrivateSignatureKey(t,i)}async getPublicSignatureKey(e=this.signatureSchemeId){return(await this.getPrivateSignatureKey(e)).getPublicKey()}async getPrivateDecryptionKey(t=this.pkeSchemeId){let n=$v.createDefaultKDF(),r=e.encoderStringAsBytes(`PKE_${t}`),i=n.deriveKeyNoSalt(this.accountSeed,r,64);return $v.createPrivateDecryptionKey(t,i)}async getPublicEncryptionKey(e=this.pkeSchemeId){return(await this.getPrivateDecryptionKey(e)).getPublicKey()}static encoderStringAsBytes(e){return new TextEncoder().encode(e)}getSeedAsBytes(){return this.accountSeed}getAccountSeed(){return this.accountSeed}static concatWalletSeedWith(e,t){return new Uint8Array([...e,...t])}static numberToUint8Array(e,t=4){let n=new ArrayBuffer(t),r=new DataView(n);return t===1?r.setUint8(0,e):t===2?r.setUint16(0,e,!1):t===4?r.setUint32(0,e,!1):t===8&&r.setBigUint64(0,BigInt(e),!1),new Uint8Array(n)}getActor(e){return QE.createFromAccountSeedAndVbSeed(this.accountSeed,e)}getSignatureSchemeId(){return this.signatureSchemeId}setSignatureSchemeId(e){this.signatureSchemeId=e}getPkeSchemeId(){return this.pkeSchemeId}setPkeSchemeId(e){this.pkeSchemeId=e}},eD=class e{static generateWallet(){return new e(Pu(64))}static fromSeed(t){if(!(t instanceof Uint8Array))throw new i(`Seed must be a Uint8Array, got ${typeof t}`);return new e(t)}static parseFromString(t,n=new UE){if(typeof t!=`string`)throw new i(`Seed must be a string, got ${typeof t}`);return new e(n.decode(t))}encode(e=new UE){return e.encode(this.walletSeed)}constructor(e){this.walletSeed=e}getDefaultAccountCrypto(){return $E.createFromWalletSeedAndNonce(this.walletSeed,0)}async generateActorPrivateSignatureKey(e,t){let n=$v.createDefaultKDF(),r=new Uint8Array([...this.walletSeed,...t]),i=new TextEncoder,a=n.deriveKeyNoSalt(r,i.encode(`SIG`),32);return $v.createPrivateSignatureKey(e,a)}async generateActorPrivateDecryptionKey(e,t){let n=$v.createDefaultKDF(),r=new Uint8Array([...this.walletSeed,...t]),i=new TextEncoder,a=n.deriveKeyNoSalt(r,i.encode(`PKE`),32);return $v.createPrivateDecryptionKey(e,a)}getPrivateSignatureKey(e=Ja.SECP256K1){let t=$v.createDefaultKDF(),n=$v.createSignatureScheme(e).expectedSeedSize(),r=$E.encoderStringAsBytes(`SIG_${e}`),i=t.deriveKeyNoSalt(this.walletSeed,r,n);return $v.createPrivateSignatureKey(e,i)}getDecapsulationKey(e){return new $v().createDecapsulationKey(e,this.walletSeed)}getAccountSeed(e){return this.getAccount(e).getAccountSeed()}getAccount(e){return $E.createFromWalletSeedAndNonce(this.walletSeed,e)}getAccountPrivateSignatureKey(e,t){return $E.createFromWalletSeedAndNonce(this.walletSeed,t).getPrivateSignatureKey(e)}getActorPrivateSignatureKey(e,t,n){return $E.createFromWalletSeedAndNonce(this.walletSeed,n).deriveActorFromVbSeed(t).getPrivateSignatureKey(e)}getVirtualBlockchainDecapsulationKey(e,t){return new $v().createVirtualBlockchainDecapsulationKey(e,this.walletSeed,t)}getSeedAsBytes(){return this.walletSeed}};exports.ACCOUNT_ALLOWED_TRANSFERS=Wr,exports.ACCOUNT_BLOCK_FEES=Hr,exports.ACCOUNT_BURNT_TOKENS=Br,exports.ACCOUNT_CREATION=pa,exports.ACCOUNT_ESCROW_SETTLEMENT=_a,exports.ACCOUNT_ESCROW_TRANSFER=ga,exports.ACCOUNT_HISTORY=ii,exports.ACCOUNT_NAMES=Ur,exports.ACCOUNT_PUBLIC_KEY=da,exports.ACCOUNT_STAKE=va,exports.ACCOUNT_STANDARD=Vr,exports.ACCOUNT_STATE=ri,exports.ACCOUNT_TOKEN_ISSUANCE=fa,exports.ACCOUNT_TRANSFER=ma,exports.ACCOUNT_VESTING_TRANSFER=ha,exports.AES256GCMSymmetricEncryptionKey=Kg,exports.AES256GCMSymmetricEncryptionScheme=Gg,exports.ALL_SCHEMAS=ia,exports.ALL_SECTIONS_SCHEMAS=Wa,exports.APP_CREATION=Oa,exports.APP_DESCRIPTION=ka,exports.APP_LEDGER_ACTOR_CREATION=Pa,exports.APP_LEDGER_ACTOR_SUBSCRIPTION=Ra,exports.APP_LEDGER_ALLOWED_PKE_SCHEMES=Ma,exports.APP_LEDGER_ALLOWED_SIG_SCHEMES=ja,exports.APP_LEDGER_AUTHOR=Va,exports.APP_LEDGER_CHANNEL_CREATION=Fa,exports.APP_LEDGER_CHANNEL_INVITATION=La,exports.APP_LEDGER_CREATION=Na,exports.APP_LEDGER_ENDORSEMENT_REQUEST=Ha,exports.APP_LEDGER_PRIVATE_CHANNEL_DATA=Ba,exports.APP_LEDGER_PUBLIC_CHANNEL_DATA=za,exports.APP_LEDGER_SHARED_SECRET=Ia,exports.ARRAY=sm,exports.AbciQueryEncoder=UT,exports.AbciRequestSchema=vT,exports.AbciRequestType=$,exports.AbciResponseSchema=HT,exports.AbciResponseType=yT,exports.AbstractPrivateDecryptionKey=Mv,exports.AbstractProvider=Jw,exports.AbstractPublicEncryptionKey=jv,exports.AbstractPublicKeyEncryptionScheme=Av,exports.AccountBreakdownSchema=cg,exports.AccountByPublicKeyHashAbciResponseSchema=NT,exports.AccountCreationSectionSchema=Qm,exports.AccountCrypto=$E,exports.AccountEscrowSettlementSectionSchema=nh,exports.AccountEscrowTransferSectionSchema=th,exports.AccountHistoryAbciResponseSchema=MT,exports.AccountHistoryEntrySchema=dg,exports.AccountHistorySchema=fg,exports.AccountHistoryView=eE,exports.AccountInformationSchema=ug,exports.AccountInternalState=Fx,exports.AccountInternalStateUpdater=Wx,exports.AccountMicroblockStructureChecker=cS,exports.AccountNotFoundForAccountHashError=_e,exports.AccountNotFoundForPublicKeyError=ge,exports.AccountNotFoundForPublicKeyHashError=xe,exports.AccountProofAbciResponseSchema=VT,exports.AccountProofEntrySchema=LS,exports.AccountProofObjectSchema=IS,exports.AccountProofSchema=RS,exports.AccountProofWrapper=Ww,exports.AccountPublicKeySectionSchema=Xm,exports.AccountSeedEncoder=WE,exports.AccountStakeSectionSchema=rh,exports.AccountStateAbciResponseSchema=jT,exports.AccountStateSchema=lg,exports.AccountTokenIssuanceSectionSchema=Zm,exports.AccountTransaction=KE,exports.AccountTransactions=GE,exports.AccountTransferSectionSchema=$m,exports.AccountUnstakeSectionSchema=ih,exports.AccountUpdateSchema=mg,exports.AccountUpdatesAbciResponseSchema=RT,exports.AccountVb=lS,exports.AccountVestingTransferSectionSchema=eh,exports.AccountVirtualBlockchainInternalStateSchema=kh,exports.AccountVirtualBlockchainStateSchema=zh,exports.ActorAlreadyDefinedError=re,exports.ActorCrypto=QE,exports.ActorNotDefinedError=oe,exports.ActorNotInvitedError=he,exports.ActorNotSubscribedError=Te,exports.ActorSeedEncoder=qE,exports.ActorType=kC,exports.Aes=ou,exports.AllowedAdditionalWriterSectionSchema=Km,exports.AlreadySubscribedError=S,exports.AppLedgerLocalStateUpdaterV1=Jx,exports.AppLedgerMicroblockBuildRequestSchema=LC,exports.AppLedgerMicroblockBuildRequestValidation=RC,exports.AppLedgerProofSchema=NS,exports.AppLedgerProofVB=vS,exports.AppLedgerProofWrapper=oC,exports.ApplicationCreationSectionSchema=fh,exports.ApplicationDescriptionSectionSchema=ph,exports.ApplicationInternalState=Lx,exports.ApplicationInternalStateUpdater=Gx,exports.ApplicationLedgerActorCreationSectionSchema=_h,exports.ApplicationLedgerActorInvitationStateSchema=Ph,exports.ApplicationLedgerActorSchema=Ih,exports.ApplicationLedgerActorSubscriptionSectionSchema=xh,exports.ApplicationLedgerAllowedPkeSchemesSectionSchema=hh,exports.ApplicationLedgerAllowedSigSchemesSectionSchema=mh,exports.ApplicationLedgerAuthorSectionSchema=wh,exports.ApplicationLedgerChannelCreationSectionSchema=vh,exports.ApplicationLedgerChannelInvitationSectionSchema=bh,exports.ApplicationLedgerChannelSchema=Nh,exports.ApplicationLedgerCreationSectionSchema=gh,exports.ApplicationLedgerEndorsementRequestSectionSchema=Th,exports.ApplicationLedgerInternalState=Rx,exports.ApplicationLedgerInternalStateObjectSchema=Lh,exports.ApplicationLedgerMicroblockBuilder=OC,exports.ApplicationLedgerMicroblockStructureChecker=_S,exports.ApplicationLedgerNotFoundError=Ce,exports.ApplicationLedgerPrivateChannelDataSectionSchema=Ch,exports.ApplicationLedgerPublicChannelDataSectionSchema=Sh,exports.ApplicationLedgerSharedSecretSectionSchema=yh,exports.ApplicationLedgerSharedSecretStateSchema=Fh,exports.ApplicationLedgerVb=gC,exports.ApplicationLedgerVirtualBlockchainStateSchema=Uh,exports.ApplicationMicroblockStructureChecker=uS,exports.ApplicationNotFoundError=ye,exports.ApplicationVBInternalStateObjectSchema=Mh,exports.ApplicationVb=dS,exports.ApplicationVirtualBlockchainStateSchema=Hh,exports.Assertion=gS,exports.AuxiliarySignatureSectionSchema=Gm,exports.AwaitMicroblockAnchoringAbciRequestSchema=iT,exports.BIN256=ym,exports.BINARY=vm,exports.BK_EARNED_BLOCK_FEES=Er,exports.BK_EARNED_TX_FEES=Tr,exports.BK_NAMES=zr,exports.BK_PAID_BLOCK_FEES=gr,exports.BK_PAID_TX_FEES=hr,exports.BK_PLUS=mr,exports.BK_PURCHASE=Or,exports.BK_RECEIVED_ESCROW=jr,exports.BK_RECEIVED_ESCROW_REFUND=Mr,exports.BK_RECEIVED_EXPIRED_ESCROW=Nr,exports.BK_RECEIVED_ISSUANCE=Dr,exports.BK_RECEIVED_PAYMENT=kr,exports.BK_RECEIVED_SLASHED_TOKENS=Pr,exports.BK_RECEIVED_VESTING=Ar,exports.BK_REFERENCES=Rr,exports.BK_REF_BLOCK=Fr,exports.BK_REF_MICROBLOCK=Ir,exports.BK_REF_SECTION=Lr,exports.BK_SALE=vr,exports.BK_SENT_ESCROW=xr,exports.BK_SENT_ESCROW_REFUND=Sr,exports.BK_SENT_EXPIRED_ESCROW=Cr,exports.BK_SENT_ISSUANCE=_r,exports.BK_SENT_PAYMENT=yr,exports.BK_SENT_SLASHED_TOKENS=wr,exports.BK_SENT_VESTING=br,exports.BLOCK_CONTENT=ui,exports.BLOCK_INFORMATION=li,exports.BOOLEAN=dm,exports.BalanceAvailability=JE,exports.Base32=Tw,exports.Base64=_g,exports.BaseHCVSignatureDecoder=Py,exports.BaseHCVSignatureEncoder=ow,exports.BasePrivateSignatureKey=Yg,exports.BasePublicSignatureKey=Xg,exports.BlockContentAbciResponseSchema=wT,exports.BlockInformationAbciResponseSchema=ST,exports.BlockModifiedAccountsAbciResponseSchema=LT,exports.BlockReferenceSchema=Yh,exports.BlockchainError=b,exports.BlockchainUtils=X,exports.BytesSignatureEncoder=VC,exports.BytesToBase64Encoder=Cg,exports.BytesToHexEncoder=wg,exports.CBORCryptoBinaryEncoder=kx,exports.CENTITOKEN=sr,Object.defineProperty(exports,`CHAIN`,{enumerable:!0,get:function(){return Hn}}),exports.CMTSToken=hn,exports.CONTRACT_PARAMETER_SCHEMA=qr,exports.CONTRACT_SCHEMA=Jr,exports.CannotSubscribeError=le,exports.CarmentisError=o,exports.CarmentisErrorCode=n,exports.ChainInformationAbciResponseSchema=xT,exports.ChainReferenceSchema=Qh,exports.ChainReferenceType=Jh,exports.ChannelAlreadyDefinedError=ae,exports.ChannelNotDefinedError=se,exports.ClientBridgeEncoder=TE,exports.ClientBridgeMessageSchema=wE,exports.ClientBridgeMessageSchema_Answer=yE,exports.ClientBridgeMessageSchema_ConnectionAccepted=xE,exports.ClientBridgeMessageSchema_ConnectionInfo=bE,exports.ClientBridgeMessageSchema_ConnectionToken=gE,exports.ClientBridgeMessageSchema_Error=CE,exports.ClientBridgeMessageSchema_ForwardedAnswer=_E,exports.ClientBridgeMessageSchema_ForwardedRequest=SE,exports.ClientBridgeMessageSchema_GetConnectionInfo=vE,exports.ClientBridgeMessageSchema_Request=mE,exports.ClientBridgeMessageSchema_UpdateQr=hE,exports.ClientBridgeMessageType=fE,exports.ClientBridgeValidation=EE,exports.CometBFTErrorCode=Hw,exports.CometBFTNodeWebSocket=QT,exports.CometBFTPublicKey=BC,exports.CometBFTPublicKeyConverter=qT,exports.ConstraintNameByConstraint=iS,exports.Crypto=xp,exports.CryptoEncoderFactory=Ax,exports.CryptoError=d,exports.CryptoSchemeFactory=$v,exports.CryptographicHashSchemeId=fv,exports.CurrencyConverterFactory=zw,exports.CurrentActorNotFoundError=pe,exports.CustomSectionSchema=Um,Object.defineProperty(exports,`DATA`,{enumerable:!0,get:function(){return gn}}),exports.DEF=Ga,exports.DckfSignatureDecoder=zy,exports.DckfSignatureEncoder=Ay,exports.DecryptionError=f,Object.defineProperty(exports,`ECO`,{enumerable:!0,get:function(){return ir}}),exports.ERROR=Kr,Object.defineProperty(exports,`ERRORS`,{enumerable:!0,get:function(){return Ka}}),exports.Economics=Pw,exports.EconomicsError=v,exports.Ed25519PrivateSignatureKey=Qv,exports.Ed25519PublicSignatureKey=Zv,exports.Ed25519SignatureScheme=Xv,exports.EmptyBlockError=u,exports.EncoderFactory=Sg,exports.EnvApiKeyPkmsCredentialProvider=by,exports.ErrorAbciResponseSchema=bT,exports.EscrowLockSchema=ng,exports.EscrowParametersSchema=tg,exports.Euros=Rw,exports.EurosToCMTSConverter=Bw,exports.ExpirationDate=Yw,exports.ExtendedSymmetricEncryptionKey=qg,exports.FORMAT=Vn,exports.FeesCalculationFormulaFactory=Px,exports.FirstFeesFormula=Nx,exports.GAS_ATOMS_PER_GAS=pr,exports.GAS_PER_BYTE=fr,exports.GenericSymmetricKeyEncoder=fw,exports.GenesisSnapshotAbciResponseSchema=FT,exports.GetAccountByPublicKeyHashAbciRequestSchema=cT,exports.GetAccountHistoryAbciRequestSchema=sT,exports.GetAccountProofAbciRequestSchema=_T,exports.GetAccountStateAbciRequestSchema=oT,exports.GetAccountUpdatesAbciRequestSchema=pT,exports.GetBlockContentAbciRequestSchema=eT,exports.GetBlockInformationAbciRequestSchema=$w,exports.GetBlockModifiedAccountsAbciRequestSchema=fT,exports.GetChainInformationAbciRequestSchema=Qw,exports.GetGenesisSnapshotAbciRequestSchema=uT,exports.GetMicroblockBodysAbciRequestSchema=aT,exports.GetMicroblockInformationAbciRequestSchema=rT,exports.GetMicroblockInformationByHeightAbciRequestSchema=mT,exports.GetMicroblockProofAbciRequestSchema=gT,exports.GetRawBlockContentAbciRequestSchema=dT,exports.GetSerializedMicroblockByHeightAbciRequestSchema=hT,exports.GetValidatorNodeByAddressAbciRequestSchema=lT,exports.GetVirtualBlockchainStateAbciRequestSchema=tT,exports.GetVirtualBlockchainUpdateAbciRequestSchema=nT,exports.HASHABLE=Fn,exports.HASHED=zn,exports.HASH_STR=bm,exports.HCVCodec=Eg,exports.HCVDecoded=Tg,exports.HCVPkeEncoder=ey,exports.HKDF=Dv,exports.HandlerBasedSignatureEncoder=By,exports.Hash=Ix,exports.Hashes=Zc,exports.INITIAL_OFFER=lr,exports.IllegalParameterError=i,exports.IllegalStateError=a,exports.IllegalUsageError=r,exports.InternalError=m,exports.InternalStateFactory=Ux,exports.InternalStateUpdaterFactory=Qx,exports.InvalidActorError=ie,exports.InvalidChannelError=fe,exports.InvalidTokenUnitError=y,exports.JsonSchema=pC,exports.JwkSignatureEncoder=nw,exports.KeyDerivationFunction=Tv,exports.KeyDerivationFunctionSchemeId=Ev,exports.KeyExchangeSchemeId=Jg,exports.LOCK_TYPE_COUNT=$h,exports.LockSchema=sg,exports.LockType=eg,exports.Logger=k,exports.MAGIC_STRING=Un,exports.MASKABLE=In,exports.MASKED=Bn,exports.MAXIMUM_GAS_PRICE=dr,exports.MAX_MICROBLOCK_FUTURE_DELAY=er,exports.MAX_MICROBLOCK_PAST_DELAY=$n,exports.MB_STATUS_PREVIOUS_HASH_ERROR=rr,exports.MB_STATUS_TIMESTAMP_ERROR=nr,exports.MB_STATUS_UNRECOVERABLE_ERROR=tr,exports.MICROBLOCK_BODY=gi,exports.MICROBLOCK_HEADER=mi,exports.MICROBLOCK_HEADER_BODY_HASH_OFFSET=fi,exports.MICROBLOCK_HEADER_PREVIOUS_HASH_OFFSET=di,exports.MICROBLOCK_HEADER_SIZE=pi,exports.MICROBLOCK_SECTION=hi,exports.MICROBLOCK_VB_INFORMATION=_i,exports.MILLITOKEN=cr,exports.MINIMUM_GAS_PRICE=ur,exports.MLDSA65HCVSignatureDecoder=Ly,exports.MLDSA65HCVSignatureEncoder=cw,exports.MLDSA65PrivateSignatureKey=$g,exports.MLDSA65PublicSignatureKey=Qg,exports.MLDSA65SignatureScheme=Zg,exports.MLDSA65_TAG=Ey,exports.MLDsa=vd,exports.MLKem=Hd,exports.MSG_ACCOUNT_BY_PUBLIC_KEY_HASH=Bi,exports.MSG_ACCOUNT_HISTORY=Ri,exports.MSG_ACCOUNT_STATE=Ii,exports.MSG_AWAIT_MICROBLOCK_ANCHORING=ji,exports.MSG_BLOCK_CONTENT=wi,exports.MSG_BLOCK_INFORMATION=Si,exports.MSG_CHAIN_INFORMATION=bi,exports.MSG_ERROR=vi,exports.MSG_GENESIS_SNAPSHOT=Ki,exports.MSG_GET_ACCOUNT_BY_PUBLIC_KEY_HASH=zi,exports.MSG_GET_ACCOUNT_HISTORY=Li,exports.MSG_GET_ACCOUNT_STATE=Fi,exports.MSG_GET_BLOCK_CONTENT=Ci,exports.MSG_GET_BLOCK_INFORMATION=xi,exports.MSG_GET_CHAIN_INFORMATION=yi,exports.MSG_GET_GENESIS_SNAPSHOT=Gi,exports.MSG_GET_MICROBLOCK_BODYS=Ni,exports.MSG_GET_MICROBLOCK_INFORMATION=ki,exports.MSG_GET_OBJECT_LIST=Ui,exports.MSG_GET_VALIDATOR_NODE_BY_ADDRESS=Vi,exports.MSG_GET_VIRTUAL_BLOCKCHAIN_STATE=Ti,exports.MSG_GET_VIRTUAL_BLOCKCHAIN_UPDATE=Di,exports.MSG_MICROBLOCK_ANCHORING=Mi,exports.MSG_MICROBLOCK_BODYS=Pi,exports.MSG_MICROBLOCK_INFORMATION=Ai,exports.MSG_OBJECT_LIST=Wi,exports.MSG_VALIDATOR_NODE_BY_ADDRESS=Hi,exports.MSG_VIRTUAL_BLOCKCHAIN_STATE=Ei,exports.MSG_VIRTUAL_BLOCKCHAIN_UPDATE=Oi,exports.MemoryProvider=Xw,exports.MerkleLeaf=cC,exports.MerkleLeafTypeEnum=Q,exports.MerkleRecord=fC,exports.MerkleTree=sC,exports.MessageSerializer=jw,exports.MessageUnserializer=Mw,exports.MicroBlockNotFoundError=te,exports.MicroBlockNotFoundInBlockError=ne,exports.MicroBlockNotFoundInVirtualBlockchainAtHeightError=x,exports.Microblock=tS,exports.MicroblockAnchoringAbciResponseSchema=OT,exports.MicroblockBodyItemSchema=kT,exports.MicroblockBodySchema=Dh,exports.MicroblockBodysAbciResponseSchema=AT,exports.MicroblockConsistencyChecker=vC,exports.MicroblockHeaderSchema=Lm,exports.MicroblockInformationAbciResponseSchema=DT,exports.MicroblockInformationSchema=qh,exports.MicroblockProofAbciResponseSchema=BT,exports.MicroblockProofEntrySchema=BS,exports.MicroblockProofObjectSchema=zS,exports.MicroblockProofSchema=VS,exports.MicroblockProofWrapper=Kw,exports.MicroblockReferenceSchema=Xh,exports.MicroblockStructSchema=eS,exports.MicroblockStructureCheckingError=s,exports.MlKemCiphertextEncoder=Wv,exports.MlKemPrivateDecryptionKey=Kv,exports.MlKemPublicEncryptionKey=Gv,exports.MlKemPublicKeyEncryptionScheme=Nv,exports.NODE_MESSAGES=D,exports.NULL=fm,exports.NUMBER=um,exports.N_VIRTUAL_BLOCKCHAINS=Zn,exports.NativeHCVSignatureDecoder=Fy,exports.NativeHCVSignatureEncoder=sw,exports.NetworkProvider=WT,exports.NetworksFileSchema=OE,exports.NewBlockEventSchema=ZT,exports.NoSharedSecretError=De,exports.NodeConnectionRefusedError=g,exports.NodeEndpointClosedWhileCatchingUpError=_,exports.NodeError=h,exports.NodeStakingLockSchema=og,exports.NodeStakingParametersSchema=ag,exports.NotAllowedPkeSchemeError=de,exports.NotAllowedSignatureSchemeError=ue,exports.NotAuthenticatedError=c,exports.NotImplementedError=ee,exports.NullMemoryProvider=GT,exports.NullNetworkProvider=KT,exports.OBJECT=cm,exports.ORG_CREATION=Ta,exports.ORG_DESCRIPTION=Ea,exports.OnChainChannelSchema=ES,exports.OnChainItemListSchema=OS,exports.OnChainItemSchema=DS,exports.OnChainRecord=hC,exports.Optional=_C,exports.OrganizationCreationSectionSchema=uh,exports.OrganizationDescriptionSectionSchema=dh,exports.OrganizationInternalState=Vx,exports.OrganizationInternalStateUpdater=Zx,exports.OrganizationMicroblockStructureChecker=oS,exports.OrganizationNotFoundError=ve,exports.OrganizationVBInternalStateObjectSchema=Ah,exports.OrganizationVb=sS,exports.OrganizationVirtualBlockchainStateSchema=Bh,exports.PBKDF2=yv,exports.PKMS_TAG=Dy,exports.PROPERTIES=Ln,exports.PROTOCOL_CREATION=ca,exports.PROTOCOL_UPDATE=la,exports.PROTOCOL_VARIABLES=oi,exports.PROTOCOL_VB_STATE=si,exports.PROTOCOL_VERSION=Wn,exports.PUBLIC_KEY_TAG=Oy,exports.ParsingError=l,exports.PasswordBasedKeyDerivationFunction=vv,exports.PasswordBasedKeyDerivationFunctionSchemeId=_v,exports.PkeEncoderFactory=dw,exports.PkmsSecp256k1PrivateSignatureKey=Sy,exports.PkmsSecp256k1PublicSignatureKey=Cy,exports.PkmsSecp256k1SignatureDecoder=Ry,exports.PkmsSecp256k1SignatureEncoder=lw,exports.ProofBlockObjectSchema=PS,exports.ProofBlockSchema=FS,exports.ProofFactory=qw,exports.ProofFieldTypeEnum=kS,exports.ProofInfoSchema=HS,exports.ProofRecord=lC,exports.ProofVerificationFailedError=ce,exports.ProofVerificationResult=Vw,exports.ProofWrapper=iC,exports.ProtocolCreationSectionSchema=qm,exports.ProtocolError=we,exports.ProtocolInternalState=Bx,exports.ProtocolInternalStateUpdater=Xx,exports.ProtocolMicroblockStructureChecker=mS,exports.ProtocolUpdateSchema=Hm,exports.ProtocolUpdateSectionSchema=Jm,exports.ProtocolVBInternalStateObjectSchema=Oh,exports.ProtocolVariablesSchema=Vm,exports.ProtocolVariablesSectionSchema=Ym,exports.ProtocolVb=hS,exports.ProtocolVirtualBlockchainStateSchema=Wh,exports.Provider=JT,exports.ProviderFactory=YT,exports.PublicKeyEncryptionAlgorithmId=kv,exports.PublicKeyEncryptionSchemeId=Ov,exports.RADIX_CST=xC,exports.RECORD_DESCRIPTION=ni,exports.REDACTED=Rn,exports.RPCNodeStatusResponseSchema=Zw,exports.RadixUtils=SC,exports.Random=Xs,exports.RawBlockContentAbciResponseSchema=IT,exports.ReadStream=Vv,exports.Record=mC,exports.RecordActorAssignationSchema=NC,exports.RecordActorSchema=AC,exports.RecordByChannels=uC,exports.RecordChannelAssignationSchema=MC,exports.RecordChannelSchema=jC,exports.RecordHashableFieldSchema=IC,exports.RecordMaskableFieldSchema=FC,exports.RecordMaskedPartSchema=PC,exports.RequestedAccountUpdateSchema=pg,exports.RetentionCostBreakdownSchema=Bm,exports.RetentionCostCalculator=Mx,exports.RetentionPolicySchema=zm,exports.RetentionTierSchema=Rm,Object.defineProperty(exports,`SCHEMAS`,{enumerable:!0,get:function(){return Gr}}),exports.SECP256K1_TAG=Ty,exports.SECRET_KEY_TAG=ky,Object.defineProperty(exports,`SECTIONS`,{enumerable:!0,get:function(){return aa}}),exports.SIGNATURE=oa,exports.SIGNATURE_SCHEMA=sa,exports.SIGNATURE_TAG=wy,exports.STRING=lm,exports.SaltShaker=dC,exports.SchemaSerializer=Hv,exports.SchemaUnserializer=Uv,exports.SchemaValidator=Nw,exports.Scrypt=vw,exports.Secp256k1=pp,exports.Secp256k1HCVSignatureDecoder=Iy,exports.Secp256k1HCVSignatureEncoder=uw,exports.Secp256k1PrivateSignatureKey=Yv,exports.Secp256k1PublicSignatureKey=Jv,exports.Secp256k1SignatureScheme=qv,exports.SectionConstraint=Z,exports.SectionError=me,exports.SectionLabel=qx,exports.SectionNotFoundError=Ee,exports.SectionReferenceSchema=Zh,exports.SectionSchema=Eh,exports.SectionType=O,exports.SeedEncoder=UE,exports.SelfProvidedApiKeyPkmsCredentialProvider=bw,exports.SerializationError=Oe,exports.SerializedMicroblockByHeightAbciResponseSchema=zT,exports.ServerNetworkProvider=XT,exports.Sha256CryptographicHash=pv,exports.SharedKeyDecryptionError=p,exports.SignatureAlgorithmId=yw,exports.SignatureCacheDisabled=xw,exports.SignatureCacheEntry=Sw,exports.SignatureCacheMonothread=Cw,exports.SignatureSchemeId=Ja,exports.SignatureSectionSchema=Wm,exports.SignedAccountPayloadSchema=eC,exports.SignedAppLedgerPayloadSchema=QS,exports.SignedMicroblockPayloadSchema=nC,exports.SignedProofPayloadSchema=XS,exports.StateChecker=DC,exports.StructureChecker=aS,exports.SymmetricEncryptionSchemeId=Wg,exports.TOKEN=or,exports.TOKEN_NAME=ar,exports.TYPE_ARRAY=vn,exports.TYPE_ARRAY_OF=Nn,exports.TYPE_BIN256=An,exports.TYPE_BINARY=kn,exports.TYPE_BOOLEAN=Sn,exports.TYPE_HASH_STR=jn,exports.TYPE_MAIN=Mn,exports.TYPE_NAMES=Pn,exports.TYPE_NULL=Cn,exports.TYPE_NUMBER=xn,exports.TYPE_OBJECT=yn,exports.TYPE_STRING=bn,exports.TYPE_UINT16=Tn,exports.TYPE_UINT24=En,exports.TYPE_UINT32=Dn,exports.TYPE_UINT48=On,exports.TYPE_UINT8=wn,exports.TYPE_UNKNOWN=_n,exports.ThrownErrorMicroblockSearchFailureFallback=nS,exports.TimestampValidationResult=$x,exports.TokenUnit=pn,exports.TokenUnitLabel=mn,exports.Transaction=$T,exports.TransformationTypeEnum=bS,exports.TypeChecker=ro,exports.TypeCheckingFailureError=eo,exports.TypeEnum=SS,exports.TypeManager=no,exports.UINT16=mm,exports.UINT24=hm,exports.UINT32=gm,exports.UINT48=_m,exports.UINT8=pm,exports.Utf8Encoder=Za,exports.Utils=A,exports.VB_ACCOUNT=Kn,exports.VB_APPLICATION=Yn,exports.VB_APP_LEDGER=Xn,exports.VB_NAME=Qn,exports.VB_ORGANIZATION=Jn,exports.VB_PROTOCOL=Gn,exports.VB_STATES=ci,exports.VB_VALIDATOR_NODE=qn,exports.VIRTUAL_BLOCKCHAIN_STATE=ai,exports.VN_APPROVAL=Ca,exports.VN_COMETBFT_PUBLIC_KEY_DECLARATION=xa,exports.VN_CREATION=ba,exports.VN_RPC_ENDPOINT=Sa,exports.ValidatorNodeApprovalSectionSchema=ch,exports.ValidatorNodeByAddressAbciResponseSchema=PT,exports.ValidatorNodeCometbftPublicKeyDeclarationSectionSchema=oh,exports.ValidatorNodeCreationSectionSchema=ah,exports.ValidatorNodeInternalState=Hx,exports.ValidatorNodeInternalStateUpdater=Yx,exports.ValidatorNodeMicroblockStructureChecker=fS,exports.ValidatorNodeNotFoundError=be,exports.ValidatorNodeRpcEndpointSectionSchema=sh,exports.ValidatorNodeSlashingCancellationSectionSchema=lh,exports.ValidatorNodeVBInternalStateObjectSchema=jh,exports.ValidatorNodeVb=pS,exports.ValidatorNodeVirtualBlockchainStateSchema=Vh,exports.VestingLockSchema=ig,exports.VestingParametersSchema=rg,exports.VirtualBlockchain=rS,exports.VirtualBlockchainInfoSchema=Kh,exports.VirtualBlockchainLabel=nE,exports.VirtualBlockchainNotFoundError=Se,exports.VirtualBlockchainSharedPropertiesSchema=Rh,exports.VirtualBlockchainStateAbciResponseSchema=TT,exports.VirtualBlockchainStateSchema=Gh,exports.VirtualBlockchainStatusSchema=kE,exports.VirtualBlockchainType=H,exports.VirtualBlockchainUpdateAbciResponseSchema=ET,exports.WIMSG_ANSWER=$i,exports.WIMSG_CONNECTION_ACCEPTED=ta,exports.WIMSG_CONNECTION_INFO=ea,exports.WIMSG_CONNECTION_TOKEN=Xi,exports.WIMSG_FORWARDED_ANSWER=Zi,exports.WIMSG_FORWARDED_REQUEST=na,exports.WIMSG_GET_CONNECTION_INFO=Qi,exports.WIMSG_REQUEST=Ji,exports.WIMSG_UPDATE_QR=Yi,exports.WI_INVALID_SIGNATURE=qa,exports.WI_MAX_SERVER_URL_LENGTH=dE,exports.WI_MESSAGES=ra,exports.WI_QR_CODE=qi,exports.WalletCrypto=eD,exports.WalletInteractiveAnchoringEncoder=YE,exports.WalletInteractiveAnchoringRequestActorKeySchema=NE,exports.WalletInteractiveAnchoringRequestApprovalHandshakeSchema=ME,exports.WalletInteractiveAnchoringRequestApprovalSignatureSchema=PE,exports.WalletInteractiveAnchoringRequestSchema=FE,exports.WalletInteractiveAnchoringRequestType=AE,exports.WalletInteractiveAnchoringResponseActorKeyRequiredSchema=LE,exports.WalletInteractiveAnchoringResponseApprovalDataSchema=RE,exports.WalletInteractiveAnchoringResponseApprovalSignatureSchema=zE,exports.WalletInteractiveAnchoringResponseErrorSchema=IE,exports.WalletInteractiveAnchoringResponseSchema=BE,exports.WalletInteractiveAnchoringResponseType=jE,exports.WalletInteractiveAnchoringValidation=XE,exports.WalletRequestAuthByPublicKeySchema=aE,exports.WalletRequestBasedApplicationLedgerMicroblockBuilder=zC,exports.WalletRequestDataApprovalSchema=oE,exports.WalletRequestEncoder=VE,exports.WalletRequestSchema=sE,exports.WalletRequestType=rE,exports.WalletRequestValidation=HE,exports.WalletResponseAuthByPublicKeySchema=cE,exports.WalletResponseDataApprovalSchema=lE,exports.WalletResponseSchema=uE,exports.WalletResponseType=iE,exports.WalletSeedEncoder=ZE,exports.WiQrCodeEncoder=DE,exports.WiQrCodeSchema=pE,exports.WrappedAccountProofSchema=tC,exports.WrappedAppLedgerProofSchema=$S,exports.WrappedMicroblockProofSchema=rC,exports.WrappedProofSchema=ZS,exports.WriteStream=Bv,exports.accountId=Nm,exports.array=xm,exports.bin256=Mm,exports.binary=jm,exports.boolean=wm,exports.height=Pm,exports.naturalInt=V,exports.nonNegativeInt=Im,exports.number=Cm,exports.positiveInt=Fm,exports.string=Sm,exports.uint16=Dm,exports.uint24=Om,exports.uint32=km,exports.uint48=Am,exports.uint8=Em,exports.uint8array=B,exports.verifyRadixProof=TC;
|
|
8
|
+
`,t+=` Microblock type: ${this.header.microblockType} or ${this.type}\n`,t+=` Magic String: ${this.header.magicString}\n`,t+=` Fees payer account: ${e.encode(this.header.feesPayerAccount)}\n`,t+=` Height: ${this.header.height}\n`,t+=` Previous Hash: ${e.encode(this.header.previousHash)}\n`,t+=` Timestamp: ${this.header.timestamp}\n`,t+=` Gas: ${this.header.gas}\n`,t+=` Gas Price: ${this.header.gasPrice}\n`,t+=` Body Hash: ${e.encode(this.header.bodyHash)}\n`,t+=` Computed body Hash: ${e.encode(this.computeBodyHash())}\n`,t+=` Sections (${this.sections.length}):\n`,this.sections.forEach((e,n)=>{t+=` Section ${n}:\n`,t+=` Section Type: ${rC.getSectionLabelFromSection(e)} (type ${e.type})\n`,t+=` Section Data: ${A.binaryToHexa(X.encodeSection(e))}\n`}),t}getType(){return this.type}setPreviousHash(e){this.header.previousHash=e.toBytes()}static extractTypeFromGenesisPreviousHash(e){return e[0]}static extractExpirationDayFromGenesisPreviousHash(e){return e[1]<<24|e[2]<<16|e[3]<<8|e[4]}getBodyHashInHeader(){return this.header.bodyHash}isDeclaringConsistentBodyHash(){let e=this.computeBodyHash();return A.binaryIsEqual(e,this.header.bodyHash)}isGenesisMicroblock(){return this.getHeight()===1}setBodyHash(e){this.header.bodyHash=e}computeHash(){let{microblockHash:e}=this.serialize();return e}setMicroblockHash(e){this.hash=e}getLastSignatureSection(){let e=this.sections[this.sections.length-1];if(e.type!==O.SIGNATURE)throw Error(`Last section is not a signature section`);return e}},fC=class{onMicroblockSearchFailureForExceedingHeight(e,t){throw e.isEmpty()?new x(KS.from(A.getNullHash()),t):new x(e.getIdentifier(),t)}},pC=class e{static INITIAL_HEIGHT=1;static staticLogger=k.getVirtualBlockchainLogger();logger=e.staticLogger;internalState;height;identifier;microblockHashByHeight;microblockByHeight;provider;type;merkleRootHash;expirationDay;microblockSearchFailureFallback;onMicroblockInsertionEventListeners=[];constructor(e,t,n){this.internalState=n,this.provider=e,this.microblockHashByHeight=new Map,this.microblockByHeight=new Map,this.type=t,this.merkleRootHash=A.getNullHash(),this.expirationDay=0,this.height=0,this.microblockSearchFailureFallback=new fC}async isAccountIdAllowedToWrite(e){if(this.height===0)return!0;let t=await this.getVirtualBlockchainOwnerId();return A.binaryIsEqual(t.toBytes(),e.toBytes())}getProvider(){return this.provider}addOnMicroblockInsertionEventListener(e){this.onMicroblockInsertionEventListeners.push(e)}getInternalState(){return this.internalState}setInternalState(e){this.internalState=e}setMerkleRootHash(e){this.merkleRootHash=e}getMerkleRootHash(){return this.merkleRootHash}async createMicroblock(){if(this.isEmpty())return new dC(this.type);let e=await this.getLastMicroblock(),t=new dC(this.type);return t.setPreviousHash(e.getHash()),t.setHeight(this.getHeight()+1),t}getLastMicroblock(){return this.getMicroblock(this.getHeight())}setHeight(e){this.height=e}setIdentifier(e){this.logger.debug(`Updating virtual blockchain identifier to ${A.binaryToHexa(e)}`),this.identifier=e}setMicroblockHashes(e){let t=1;for(let n of e)this.microblockHashByHeight.set(t,n),t++}setExpirationDay(e){this.expirationDay=e}async getSerializedVirtualBlockchainState(){return X.encodeVirtualBlockchainState(await this.getVirtualBlockchainState())}async getGenesisSeed(){return(await this.getFirstMicroBlock()).getPreviousHash()}getHeight(){return this.height}getId(){return this.identifier}isVirtualBlockchainIdDefined(){return this.identifier instanceof Uint8Array}async getFirstMicroBlock(){return this.getMicroblock(1)}getAllMicroblockHashes(){let e=[];for(let t of this.microblockHashByHeight.entries())e.push(KS.from(t[1]));return e}async getMicroblock(e){if(this.logger.debug(`Accessing microblock at height ${e} of vb`),e<1)throw new i(`Cannot retrieve microblock at height strictly lower than 1: got ${e}`);if(this.getHeight()<e)return await this.microblockSearchFailureFallback.onMicroblockSearchFailureForExceedingHeight(this,e);let t=this.microblockByHeight.get(e);if(t!==void 0)return t;let n=await this.provider.getSerializedMicroblockByHeight(this.getId(),e);if(n===null)throw Og.bytesToHexEncoder(),Error(`Unable to load microblock at height ${e}`);let r=dC.loadFromSerializedMicroblock(n,this.type);if(r.getHeight()!==e)throw Error(`Received microblock contains an unexpected height: expected ${e}, got ${r.getHeight()} `);this.microblockByHeight.set(e,r);for(let e of this.onMicroblockInsertionEventListeners)e.onMicroblockInserted(this,r);return r}getIdentifier(){if(this.identifier===void 0)throw new a(`You cannot access identifier of an empty virtual blockchain (current height is ${this.height})`);return KS.from(this.identifier)}isEmpty(){return this.getHeight()===0}async appendMicroBlock(e){if(!e||!(e instanceof dC))throw Error(`Microblock cannot be null or undefined`);if(e.getType()!==this.type)throw Error(`Invalid microblock type for append operation`);if(this.isEmpty()&&this.identifier instanceof Uint8Array)throw Error(`Virtual blockchain is empty but is initialized: should not happen`);if(!this.isEmpty()&&!(this.identifier instanceof Uint8Array))throw Error(`Virtual blockchain is empty but has an identifier: should not happen`);let t=this.height+1,n=e.getHeight();if(t!==n)throw Error(`Microblock height mismatch: expected ${t} but got ${n}`);if(!this.isEmpty()){let t=(await this.getLastMicroblock()).getHash().toBytes(),n=e.getPreviousHash().toBytes();if(!A.binaryIsEqual(n,t))throw Error(`Previous hash mismatch: microblock's previous hash ${A.binaryToHexa(n)} does not match the last microblock's hash ${A.binaryToHexa(t)}`)}if(!this.checkMicroblockStructure(e))throw new i(`Provided microblock has an invalid structure`);let r=await this.provider.getProtocolState();this.internalState=await this.updateInternalState(r,this.internalState,e),this.identifier===void 0&&(this.identifier=e.getHash().toBytes()),this.height+=1;let a=e.getHash().toBytes();this.microblockHashByHeight.set(this.height,a),this.microblockByHeight.set(this.height,e),this.logger.debug(`Microblock ${A.binaryToHexa(a)} added to vb (now at height ${this.height} `)}setMicroblockSearchFailureFallback(e){this.microblockSearchFailureFallback=e}getType(){return this.type}getExpirationDay(){return this.expirationDay}},Z=function(e){return e[e.ANY=0]=`ANY`,e[e.ZERO=1]=`ZERO`,e[e.ONE=2]=`ONE`,e[e.AT_MOST_ONE=3]=`AT_MOST_ONE`,e[e.AT_LEAST_ONE=4]=`AT_LEAST_ONE`,e}({}),mC={[Z.ANY]:`Any`,[Z.ONE]:`Exactly one`,[Z.ZERO]:`Exactly zero`,[Z.AT_LEAST_ONE]:`At least one`,[Z.AT_MOST_ONE]:`At most one`},hC=class{microblock;pointer;constructor(e){this.microblock=e,this.pointer=0}isFirstBlock(){return this.microblock.getHeight()==1}expects(e,t){let n=0;for(;!this.endOfList()&&this.currentSection().type==t;)n++,this.pointer++;if(!this.checkConstraint(e,n))throw new s(`expected ${mC[e]} of type ${this.getSectionLabelBySectionType(t)} in section, got ${n}`);return n}group(e,t){let n=new Map,r=0;for(let[e,r]of t)n.set(r,0);for(;!this.endOfList();){let e=this.currentSection().type;if(!t.some(([t,n])=>n==e))break;n.set(e,n.get(e)+1),r++,this.pointer++}if(!this.checkConstraint(e,r))throw new s(`expected ${mC[e]} section(s) in group, got ${r}`);for(let[e,r]of t){let t=n.get(r);if(!this.checkConstraint(e,t))throw new s(`expected ${mC[e]} of type ${this.getSectionLabelBySectionType(r)} in group section, got ${t}`)}}endsHere(){if(!this.endOfList()){let e=this.currentSection().type;throw new s(`Unexpected section ${this.getSectionLabelBySectionType(e)}`)}}currentSection(){return this.microblock.getAllSections()[this.pointer]}endOfList(){return!this.currentSection()}checkConstraint(e,t){switch(e){case Z.ANY:return!0;case Z.ZERO:return t==0;case Z.ONE:return t==1;case Z.AT_LEAST_ONE:return t>=1;case Z.AT_MOST_ONE:return t<=1}return!1}getSectionLabelBySectionType(e){return rC.getSectionLabelFromSectionType(e)}},gC=class{logger=k.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new hC(e);return t.expects(t.isFirstBlock()?Z.ONE:Z.ZERO,O.ORG_CREATION),t.group(Z.AT_LEAST_ONE,[[Z.AT_MOST_ONE,O.ORG_DESCRIPTION],[Z.ANY,O.CUSTOM]]),t.expects(Z.ANY,O.AUXILIARY_SIGNATURE),t.expects(Z.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return typeof e==`string`&&this.logger.error(`Microblock structure error details: ${e}`),e instanceof Error&&(e instanceof s?this.logger.error(`Microblock structure error: ${e.message}`):this.logger.error(`An unexpected error occurred during structure checking: ${e.message} at ${e.stack}`)),!1}}},_C=class e extends pC{static createOrganizationVirtualBlockchain(t){return new e(t)}constructor(e,t=ZS.createInitialState()){super(e,H.ORGANIZATION_VIRTUAL_BLOCKCHAIN,t)}async updateInternalState(e,t,n){let r=e.getOrganizationInternalStateUpdaterVersion();return cC.createOrganizationInternalStateUpdater(r).updateState(this.provider,t,n)}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?A.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType(),merkleRootHash:this.getMerkleRootHash()}}async getVirtualBlockchainOwnerId(){return this.internalState.getAccountId()}checkMicroblockStructure(e){return new gC().checkMicroblockStructure(e)}getAccountId(){return this.internalState.getAccountId()}async getDescription(){let e=this.internalState.getDescriptionHeight(),t=await this.getMicroblock(e);for(let e of t.getAllSections())if(e.type===O.ORG_DESCRIPTION)return e;throw new a(`No description found for the organization`)}},vC=class{logger=k.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new hC(e);return!t.isFirstBlock()&&t.expects(Z.AT_MOST_ONE,O.ACCOUNT_ESCROW_SETTLEMENT)===1||(t.expects(t.isFirstBlock()?Z.ONE:Z.AT_MOST_ONE,O.ACCOUNT_PUBLIC_KEY),t.isFirstBlock()?t.group(Z.ONE,[[Z.AT_MOST_ONE,O.ACCOUNT_TOKEN_ISSUANCE],[Z.AT_MOST_ONE,O.ACCOUNT_CREATION],[Z.ANY,O.CUSTOM]]):t.group(Z.AT_LEAST_ONE,[[Z.ANY,O.ACCOUNT_TRANSFER],[Z.ANY,O.ACCOUNT_VESTING_TRANSFER],[Z.ANY,O.ACCOUNT_STAKE],[Z.ANY,O.ACCOUNT_UNSTAKE],[Z.ANY,O.ACCOUNT_ESCROW_TRANSFER],[Z.ANY,O.CUSTOM]])),t.expects(Z.ANY,O.AUXILIARY_SIGNATURE),t.expects(Z.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return e instanceof Error&&(e instanceof s?this.logger.error(`Invalid microblock structure: ${e.message}`):this.logger.error(`Unexpected error occurred during microblock structure checking: ${e.message} at ${e.stack}`)),!1}}},yC=class extends pC{constructor(e,t=GS.createInitialState()){super(e,H.ACCOUNT_VIRTUAL_BLOCKCHAIN,t)}async updateInternalState(e,t,n){let r=e.getAccountInternalStateUpdaterVersion();return cC.createAccountInternalStateUpdater(r).updateState(this.provider,t,n)}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?A.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType(),merkleRootHash:this.getMerkleRootHash()}}async getVirtualBlockchainOwnerId(){return KS.from(this.getId())}checkMicroblockStructure(e){return new vC().checkMicroblockStructure(e)}async getPublicKey(){let e=this.internalState.getPublicKeyHeight(),t=this.internalState.getPublicKeySchemeId(),n=await this.getMicroblock(e);for(let e of n.getAllSections())if(e.type===O.ACCOUNT_PUBLIC_KEY)return new Jx().createPublicSignatureKey(t,e.publicKey);throw new a(`Account public key not found`)}async isIssuer(){let e=await this.getFirstMicroBlock();for(let t of e.getAllSections())if(t.type===O.ACCOUNT_TOKEN_ISSUANCE)return!0;return!1}static async createAccountCreationMicroblock(e,t,n,r=``){let i=dC.createGenesisAccountMicroblock();return i.addSection({type:O.ACCOUNT_PUBLIC_KEY,publicKey:await e.getPublicKeyAsBytes(),schemeId:e.getSignatureSchemeId()}),i.addSection({type:O.ACCOUNT_CREATION,amount:t.getAmountAsAtomic(),sellerAccount:n}),i}static async createIssuerAccountCreationMicroblock(e){let t=e,n=dC.createGenesisAccountMicroblock();return n.addSection({type:O.ACCOUNT_PUBLIC_KEY,publicKey:await t.getPublicKeyAsBytes(),schemeId:t.getSignatureSchemeId()}),n.addSection({type:O.ACCOUNT_TOKEN_ISSUANCE,amount:lr}),n}},bC=class{logger=k.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new hC(e);return t.expects(t.isFirstBlock()?Z.ONE:Z.ZERO,O.APP_CREATION),t.group(Z.AT_LEAST_ONE,[[Z.AT_MOST_ONE,O.APP_DESCRIPTION],[Z.ANY,O.CUSTOM]]),t.expects(Z.ANY,O.AUXILIARY_SIGNATURE),t.expects(Z.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return e instanceof Error&&(e instanceof s?this.logger.error(`Invalid microblock structure: ${e.message}`):this.logger.error(`Unexpected error occurred during microblock structure checking: ${e.message} at ${e.stack}`)),!1}}},xC=class extends pC{constructor(e,t=qS.createInitialState()){super(e,H.APPLICATION_VIRTUAL_BLOCKCHAIN,t)}async updateInternalState(e,t,n){let r=e.getApplicationInternalStateUpdaterVersion();return cC.createApplicationInternalStateUpdater(r).updateState(this.provider,t,n)}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?A.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType(),merkleRootHash:this.getMerkleRootHash()}}async getVirtualBlockchainOwnerId(){let e=this.internalState.getOrganizationId();return(await this.provider.loadOrganizationVirtualBlockchain(e)).getVirtualBlockchainOwnerId()}checkMicroblockStructure(e){return new bC().checkMicroblockStructure(e)}getOrganizationId(){return this.internalState.getOrganizationId()}async getApplicationDescription(){let e=this.internalState.getDescriptionHeight(),t=await this.getMicroblock(e);for(let e of t.getAllSections())if(e.type==O.APP_DESCRIPTION)return e;throw Error(`Application description not found`)}},SC=class{logger=k.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new hC(e),n=!t.isFirstBlock()&&t.expects(Z.AT_MOST_ONE,O.VN_APPROVAL)===1,r=!n&&!t.isFirstBlock()&&t.expects(Z.AT_MOST_ONE,O.VN_SLASHING_CANCELLATION)===1;return!n&&!r&&(t.expects(t.isFirstBlock()?Z.ONE:Z.ZERO,O.VN_CREATION),t.group(Z.AT_LEAST_ONE,[[Z.AT_MOST_ONE,O.VN_COMETBFT_PUBLIC_KEY_DECLARATION],[Z.AT_MOST_ONE,O.VN_RPC_ENDPOINT],[Z.ANY,O.CUSTOM]])),t.expects(Z.ANY,O.AUXILIARY_SIGNATURE),t.expects(Z.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return e instanceof Error&&(e instanceof s?this.logger.error(`Invalid microblock structure: ${e.message}`):this.logger.error(`Unexpected error occurred during microblock structure checking: ${e.message} at ${e.stack}`)),!1}}},CC=class extends pC{constructor(e,t=QS.createInitialState()){super(e,H.NODE_VIRTUAL_BLOCKCHAIN,t)}async updateInternalState(e,t,n){let r=e.getValidatorNodeInternalStateUpdaterVersion();return cC.createValidatorNodeInternalStateUpdater(r).updateState(this.provider,t,n)}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?A.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType(),merkleRootHash:this.getMerkleRootHash()}}async getVirtualBlockchainOwnerId(){let e=await this.getOrganizationId();return(await this.provider.loadOrganizationVirtualBlockchain(e)).getVirtualBlockchainOwnerId()}async getOrganizationId(){return this.internalState.getOrganizationId()}checkMicroblockStructure(e){return new SC().checkMicroblockStructure(e)}async getCometbftPublicKeyDeclaration(){let e=this.internalState.getCometbftPublicKeyDeclarationHeight();if(e===0)throw new a(`Node has not declared its CometBFT public key yet`);let t=await this.getMicroblock(e);for(let e of t.getAllSections()){if(e.type!==O.VN_COMETBFT_PUBLIC_KEY_DECLARATION)continue;let t=e.cometPublicKey;return{cometbftPublicKeyType:e.cometPublicKeyType,cometbftPublicKey:t}}throw new a(`Node has not declared its CometBFT public key yet`)}async getRpcEndpointDeclaration(){let e=this.internalState.getRpcEndpointHeight();if(e===0)throw new a(`Node has not declared its RPC endpoint yet`);let t=await this.getMicroblock(e);for(let e of t.getAllSections())if(e.type===O.VN_RPC_ENDPOINT)return e.rpcEndpoint;throw new a(`Node has not declared its RPC endpoint yet`)}getNodeDeclarationHeight(){return this.getInternalState().getCometbftPublicKeyDeclarationHeight()}async getOrganizationVirtualBlockchain(){let e=this.internalState.getOrganizationId();return await this.provider.loadOrganizationVirtualBlockchain(e)}},wC=class{logger=k.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new hC(e);return t.expects(t.isFirstBlock()?Z.ONE:Z.ZERO,O.PROTOCOL_CREATION),t.isFirstBlock()||t.group(Z.AT_MOST_ONE,[[Z.ONE,O.PROTOCOL_UPDATE],[Z.ANY,O.CUSTOM]]),t.expects(Z.ANY,O.AUXILIARY_SIGNATURE),t.expects(Z.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return typeof e==`string`&&this.logger.error(`Microblock structure error details: ${e}`),e instanceof Error&&(e instanceof s?this.logger.error(`Microblock structure error: ${e.message}`):this.logger.error(`An unexpected error occurred during structure checking: ${e.message} at ${e.stack}`)),!1}}},TC=class extends pC{constructor(e,t=XS.createInitialState()){super(e,H.PROTOCOL_VIRTUAL_BLOCKCHAIN,t)}checkMicroblockStructure(e){return new wC().checkMicroblockStructure(e)}async updateInternalState(e,t,n){let r=e.getProtocolInternalStateUpdaterVersion();return cC.createProtocolInternalStateUpdater(r).updateState(this.provider,t,n)}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?A.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType(),merkleRootHash:this.getMerkleRootHash()}}async getVirtualBlockchainOwnerId(){let e=await this.getOrganizationId();return(await this.provider.loadOrganizationVirtualBlockchain(e)).getVirtualBlockchainOwnerId()}async getOrganizationId(){let e=(await this.getFirstMicroBlock()).getAllSections();for(let t of e)if(t.type===O.PROTOCOL_CREATION)return KS.from(t.organizationId);throw Error(`Organization ID not found in protocol vb`)}},EC=class{static assert(e,t=`Unspecified verification`){if(!e)throw new m(`Assertion failed: ${t}`)}},DC=class{logger=k.getMicroblockStructureCheckerLogger();checkMicroblockStructure(e){try{let t=new hC(e);return t.expects(t.isFirstBlock()?Z.ONE:Z.ZERO,O.APP_LEDGER_CREATION),t.group(Z.ANY,[[Z.ANY,O.APP_LEDGER_ACTOR_CREATION],[Z.ANY,O.APP_LEDGER_ACTOR_SUBSCRIPTION],[Z.ANY,O.APP_LEDGER_ENDORSEMENT_REQUEST],[Z.ANY,O.APP_LEDGER_AUTHOR],[Z.ANY,O.APP_LEDGER_PUBLIC_CHANNEL_DATA],[Z.ANY,O.APP_LEDGER_PRIVATE_CHANNEL_DATA],[Z.ANY,O.APP_LEDGER_SHARED_SECRET],[Z.ANY,O.APP_LEDGER_CHANNEL_CREATION],[Z.ANY,O.APP_LEDGER_CHANNEL_INVITATION],[Z.ANY,O.ALLOWED_ADDITIONAL_WRITER],[Z.ANY,O.CUSTOM]]),t.expects(Z.ANY,O.AUXILIARY_SIGNATURE),t.expects(Z.ONE,O.SIGNATURE),t.endsHere(),!0}catch(e){return typeof e==`string`&&this.logger.error(`Microblock structure error details: ${e}`),e instanceof Error&&(e instanceof s?this.logger.error(`Microblock structure error: ${e.message}`):this.logger.error(`An unexpected error occurred during structure checking: ${e.message} at ${e.stack}`)),!1}}},OC=class e{identifier;microblocks;constructor(){this.identifier=``,this.microblocks=[]}static fromObject(t){let n=new e;n.setIdentifier(t.id);for(let e of t.microblocks)n.addMicroblock(e.height,e.channels);return n}toObject(){return{id:this.identifier,microblocks:this.microblocks}}setIdentifier(e){this.identifier=e}getIdentifier(){return this.identifier}addMicroblock(e,t){let n={height:e,channels:t};this.microblocks.push(n)}getMicroblock(e){let t=this.microblocks.find(t=>t.height===e);if(!t)throw Error(`no microblock found for height ${e}`);return t}getMicroblocks(){return this.microblocks}},kC=M(lm([L(),P()])),AC=function(e){return e[e.None=0]=`None`,e[e.Hashable=1]=`Hashable`,e[e.Maskable=2]=`Maskable`,e}({}),jC=dm(`type`,[F({type:N(AC.None)}),F({type:N(AC.Hashable)}),F({type:N(AC.Maskable),visibleParts:M(L()),hiddenParts:M(L())})]),MC=function(e){return e[e.String=0]=`String`,e[e.Number=1]=`Number`,e[e.Boolean=2]=`Boolean`,e[e.Null=3]=`Null`,e[e.Array=4]=`Array`,e[e.Object=5]=`Object`,e}({}),NC,PC={channelId:P()};NC=dm(`type`,[F({...PC,type:N(MC.String),value:L(),transformation:jC}),F({...PC,type:N(MC.Number),value:P()}),F({...PC,type:N(MC.Boolean),value:Yp()}),F({...PC,type:N(MC.Null),value:rm()}),F({type:N(MC.Array),value:M(tm(()=>NC))}),F({type:N(MC.Object),value:M(F({key:L(),value:tm(()=>NC)}))})]);var FC=lm([L(),P(),Yp(),rm()]),IC=F({pepper:B(),data:B()}),LC=F({path:kC,value:FC,transformation:I(jC)}),RC=M(LC),Q=function(e){return e[e.Public=0]=`Public`,e[e.Plain=1]=`Plain`,e[e.HashableFromValue=2]=`HashableFromValue`,e[e.Hashable=3]=`Hashable`,e[e.MaskableFromAllParts=4]=`MaskableFromAllParts`,e[e.MaskableFromVisibleParts=5]=`MaskableFromVisibleParts`,e[e.Maskable=6]=`Maskable`,e}({});Q.Public,Q.Plain,Q.HashableFromValue,Q.Hashable,Q.MaskableFromAllParts,Q.MaskableFromVisibleParts,Q.Maskable;var zC=function(e){return e[e.Public=0]=`Public`,e[e.Plain=1]=`Plain`,e[e.HashableAsPlain=2]=`HashableAsPlain`,e[e.HashableAsHash=3]=`HashableAsHash`,e[e.MaskableAsAllParts=4]=`MaskableAsAllParts`,e[e.MaskableAsVisibleParts=5]=`MaskableAsVisibleParts`,e}({}),BC=F({path:kC,type:N(zC.Public),value:FC}),VC={path:kC,index:P()},HC=dm(`type`,[BC,F({...VC,type:N(zC.Plain),salt:L(),value:FC}),F({...VC,type:N(zC.HashableAsPlain),salt:L(),value:FC}),F({...VC,type:N(zC.HashableAsHash),salt:L(),hash:L()}),F({...VC,type:N(zC.MaskableAsAllParts),vSalt:L(),vParts:M(L()),hSalt:L(),hParts:M(L())}),F({...VC,type:N(zC.MaskableAsVisibleParts),vSalt:L(),vParts:M(L()),hHash:L()})]),UC=F({virtualBlockchains:M(F({id:L(),microblocks:M(F({height:P(),channels:M(F({id:P(),isPublic:Yp(),nLeaves:P(),fields:M(HC),witnesses:M(L())}))}))}))}),WC=F({height:P(),vbRadixHash:B(),tokenRadixHash:B(),storageHash:B(),appHash:B()}),GC=F({height:P(),vbRadixHash:L(),tokenRadixHash:L(),storageHash:L(),appHash:L()}),KC=F({block:WC,account:F({virtualBlockchainId:B(),state:hg,radixProof:M(B())})}),qC=F({block:GC,account:F({virtualBlockchainId:L(),serializedState:L(),radixProof:M(L())})}),JC=F({accounts:M(qC)}),YC=F({block:WC,microblock:F({virtualBlockchainId:B(),height:P(),hash:B()}),virtualBlockchain:F({state:Zh,merkleWitnesses:M(B()),radixProof:M(B())})}),XC=F({block:GC,microblock:F({virtualBlockchainId:L(),height:P(),hash:L()}),virtualBlockchain:F({serializedState:L(),merkleWitnesses:M(L()),radixProof:M(L())})}),ZC=F({microblocks:M(XC)}),QC=F({version:P(),chainId:L(),description:L(),date:L(),author:L()}),$C=F({commitment:F({issuedAt:I(L()),digestAlg:I(om([`sha256`])),digestTarget:I(om([`cborProof`])),digest:I(L())}),signer:L(),pubkey:L(),alg:om([`ecdsaSecp256k1`,`mlDsa65`]),sig:L()}),ew=F({type:N(`appLedgerProof`),proof:UC}),tw=F({type:N(`accountProof`),proof:JC}),nw=F({type:N(`microblockProof`),proof:ZC}),rw=dm(`type`,[ew,tw,nw]),iw=F({info:QC}),aw=F({signature:I($C)}),ow=em([rw,iw]),sw=em([ow,aw]),cw=em([ew,iw]),lw=em([cw,aw]),uw=em([tw,iw]),dw=em([uw,aw]),fw=em([nw,iw]),pw=em([fw,aw]),mw=class{wrapper;encoder=new zS;constructor(e){this.wrapper=e}static getDefaultInfo(e,t){return{version:e,chainId:t,description:`This is a Carmentis proof file. Visit www.carmentis.io for more information.`,author:``,date:new Date().toISOString()}}getObject(){return this.wrapper}setVersion(e){this.wrapper.info.version=e}getVersion(){return this.wrapper.info.version}setChainId(e){this.wrapper.info.chainId=e}getChainId(){return this.wrapper.info.chainId}setDescription(e){this.wrapper.info.description=e}getDescription(){return this.wrapper.info.description}setAuthor(e){this.wrapper.info.author=e}getAuthor(){return this.wrapper.info.author}setDate(e){this.wrapper.info.date=e.toISOString()}getDate(){return new Date(this.wrapper.info.date)}sign(e=new Date){let t=this.computeDigest(),n={issuedAt:e.toISOString(),digestAlg:`sha256`,digestTarget:`cborProof`,digest:A.binaryToHexa(t)},r=this.encoder.encode(n);Tp.Hashes.sha256AsBinary(r),this.wrapper.signature={commitment:n,signer:``,pubkey:``,alg:`ecdsaSecp256k1`,sig:``}}verifySignature(){this.computeDigest()}computeDigest(){let{signature:e,...t}=this.wrapper,n=R(ow,t),r=this.encoder.encode(n);return Tp.Hashes.sha256AsBinary(r)}},hw=1,gw=class e extends mw{constructor(e){super(e)}static createEmptyProof(t){return new e({type:`appLedgerProof`,info:mw.getDefaultInfo(hw,t),proof:{virtualBlockchains:[]}})}static fromObject(t){return new e(R(lw,t))}addVirtualBlockchain(e){this.wrapper.proof.virtualBlockchains.push(e.toObject())}getSingleVirtualBlockchainOrFail(){let e=this.getVirtualBlockchains();if(e.length==0)throw Error(`no virtual blockchain is defined in this proof`);if(e.length>1)throw Error(`proofs with multiple virtual blockchains are not supported at this time`);return e[0]}getVirtualBlockchain(e){let t=this.wrapper.proof.virtualBlockchains.find(t=>t.id===e);if(!t)throw Error(`no virtual blockchain found with ID ${e}`);return t}getVirtualBlockchains(){return this.wrapper.proof.virtualBlockchains.map(e=>OC.fromObject(e))}},_w=class{leaves;nLeaves;tree;constructor(){this.leaves=[],this.nLeaves=0,this.tree=[]}addLeaf(e){this.checkHash(e),this.leaves.push(e)}setLeaf(e,t){this.checkHash(t),this.leaves[e]=t}checkHash(e){if(e.length!=32)throw Error(`invalid hash: expected size is 32 bytes, got ${e.length}`)}finalize(e=void 0){this.nLeaves=e===void 0?this.leaves.length:e,this.buildTreeStructure()}getNumberOfLeaves(){return this.nLeaves}getRootHash(){let e=this.tree.length-1;for(let t=0;t<e;t++){let e=this.tree[t];for(let n=0;n<e.length;n+=2)e[n]&&e[n+1]&&(this.tree[t+1][n>>1]=this.mergeHashes(t+1,e[n],e[n+1]))}return this.tree[e][0]}getWitnesses(e){let t=new Set(e),n=this.getWitnessPositions(t),r=[];for(let e=0;e<this.tree[0].length;e++)if(!t.has(e)&&!this.tree[0][e])throw Error(`cannot find leaf at index ${e}`);for(let[e,t]of n){let n=this.tree[e][t];if(!n)throw Error(`cannot find witness hash at depth ${e}, index ${t}`);r.push(n)}return r}setWitnesses(e){let t=new Set;for(let e=0;e<this.nLeaves;e++)this.leaves[e]||t.add(e);let n=this.getWitnessPositions(t);if(e.length!=n.length)throw Error(`invalid witness list: expected ${n.length} witness(es), got ${e.length}`);let r=0;for(let[t,i]of n)this.checkHash(e[r]),this.tree[t][i]=e[r++]}buildTreeStructure(){let e=this.nLeaves;for(this.tree=[];e;){let t=Array(e).fill(null);e>1&&e&1&&(t.push(A.getNullHash()),e++),this.tree.push(t),e>>=1}for(let e=0;e<this.nLeaves;e++)this.leaves[e]&&(this.tree[0][e]=this.leaves[e])}getWitnessPositions(e){let t=this.nLeaves,n=[];for(let r=0;t;r++){let i=new Set;for(let a=0;a<t;a+=2){let o=e.has(a),s=a+1<t&&e.has(a+1);o&&s?i.add(a>>1):(o||s)&&n.push([r,s?a+1:a])}e=i,t=t+ +(t>1)>>1}return n}mergeHashes(e,t,n){let r=new Uint8Array(65);return r[0]=+(e==this.tree.length-1),r.set(t,1),r.set(n,33),Tp.Hashes.sha256AsBinary(r)}},vw=class e{internalData=void 0;encoder=new zS;static fromProofFormat(t){let n=new e;return n.fromProofField(t),n}static fromItemWithPublicData(t){let n=new e;return n.setPublicDataFromValue(t.value),n}static fromItemWithPlainData(t,n){let r=new e,i=t.getSalt();return r.setPlainDataFromValue(i,n.value),r}static fromItemWithHashedData(t,n){let r=new e,i=t.getSalt();return r.setHashedDataFromValue(i,n.value),r}static fromItemWithMaskedData(t,n){let r=new e,i=t.getSalt(),a=t.getSalt();return r.setMaskedDataFromAllParts(i,n.transformation.visibleParts,a,n.transformation.hiddenParts),r}setPublicDataFromValue(e){this.internalData={type:Q.Public,value:e}}setPlainDataFromValue(e,t){this.internalData={type:Q.Plain,salt:e,value:t}}setHashedDataFromValue(e,t){this.internalData={type:Q.HashableFromValue,salt:e,value:t}}setHashedDataFromHash(e,t){this.internalData={type:Q.Hashable,salt:e,hash:t}}setMaskedDataFromAllParts(e,t,n,r){let i={salt:e,parts:t},a={salt:n,parts:r};this.internalData={type:Q.MaskableFromAllParts,visible:i,hidden:a}}setMaskedDataFromVisibleParts(e,t,n){let r={salt:e,parts:t};this.internalData={type:Q.MaskableFromVisibleParts,visible:r,hiddenHash:n}}setToHashed(){let e=this.getInternalData();if(e.type==Q.Hashable)return;if(e.type!=Q.HashableFromValue)throw Error(`this field is not hashable`);let t=this.encoder.encode(e.value),n=Tp.Hashes.sha256AsBinary(t);this.setHashedDataFromHash(e.salt,n)}setToMasked(){let e=this.getInternalData();if(e.type==Q.MaskableFromVisibleParts)return;if(e.type!=Q.MaskableFromAllParts)throw Error(`this field is not maskable`);let t=this.encoder.encode(e.hidden),n=Tp.Hashes.sha256AsBinary(t);this.setMaskedDataFromVisibleParts(e.visible.salt,e.visible.parts,n)}getInternalData(){if(this.internalData===void 0)throw Error(`internal leaf data has not been set`);return this.internalData}fromProofField(e){switch(e.type){case zC.Public:this.setPublicDataFromValue(e.value);break;case zC.Plain:this.setPlainDataFromValue(A.binaryFromHexa(e.salt),e.value);break;case zC.HashableAsPlain:this.setHashedDataFromValue(A.binaryFromHexa(e.salt),e.value);break;case zC.HashableAsHash:this.setHashedDataFromHash(A.binaryFromHexa(e.salt),A.binaryFromHexa(e.hash));break;case zC.MaskableAsAllParts:this.setMaskedDataFromAllParts(A.binaryFromHexa(e.vSalt),e.vParts,A.binaryFromHexa(e.hSalt),e.hParts);break;case zC.MaskableAsVisibleParts:this.setMaskedDataFromVisibleParts(A.binaryFromHexa(e.vSalt),e.vParts,A.binaryFromHexa(e.hHash));break}}toProofFormat(e,t){let n=this.getInternalData();switch(n.type){case Q.Public:return{path:e,type:zC.Public,value:n.value};case Q.Plain:return{path:e,index:t,type:zC.Plain,salt:A.binaryToHexa(n.salt),value:n.value};case Q.HashableFromValue:return{path:e,index:t,type:zC.HashableAsPlain,salt:A.binaryToHexa(n.salt),value:n.value};case Q.Hashable:return{path:e,index:t,type:zC.HashableAsHash,salt:A.binaryToHexa(n.salt),hash:A.binaryToHexa(n.hash)};case Q.MaskableFromAllParts:return{path:e,index:t,type:zC.MaskableAsAllParts,vSalt:A.binaryToHexa(n.visible.salt),vParts:n.visible.parts,hSalt:A.binaryToHexa(n.hidden.salt),hParts:n.hidden.parts};case Q.MaskableFromVisibleParts:return{path:e,index:t,type:zC.MaskableAsVisibleParts,vSalt:A.binaryToHexa(n.visible.salt),vParts:n.visible.parts,hHash:A.binaryToHexa(n.hiddenHash)};default:throw Error(`invalid internal data type ${n.type}`)}}getCommitmentData(){let e=this.getInternalData();switch(e.type){case Q.Public:case Q.Plain:case Q.Hashable:return e;case Q.HashableFromValue:{let t=this.encoder.encode(e.value),n=Tp.Hashes.sha256AsBinary(t);return{type:Q.Hashable,salt:e.salt,hash:n}}case Q.MaskableFromAllParts:{let t=this.encoder.encode(e.visible),n=Tp.Hashes.sha256AsBinary(t),r=this.encoder.encode(e.hidden),i=Tp.Hashes.sha256AsBinary(r);return{type:Q.Maskable,visibleHash:n,hiddenHash:i}}case Q.MaskableFromVisibleParts:{let t=this.encoder.encode(e.visible),n=Tp.Hashes.sha256AsBinary(t);return{type:Q.Maskable,visibleHash:n,hiddenHash:e.hiddenHash}}default:throw Error(`invalid internal data type ${e.type}`)}}getHash(){let e=this.getCommitmentData(),t=this.encoder.encode(e);return Tp.Hashes.sha256AsBinary(t)}getRawValue(){let e=this.getInternalData();switch(e.type){case Q.Public:case Q.Plain:case Q.HashableFromValue:return e.value;case Q.Hashable:return A.binaryToHexa(e.hash);case Q.MaskableFromAllParts:return e.visible.parts.map((t,n)=>n&1?e.hidden.parts[n>>1]:t).join(``);case Q.MaskableFromVisibleParts:return e.visible.parts.join(``);default:throw Error(`invalid internal data type ${e.type}`)}}getTypedValue(){let e=this.getInternalData(),t=this.getRawValue();switch(e.type){case Q.Public:case Q.Plain:case Q.HashableFromValue:case Q.MaskableFromAllParts:return{disclosure:`plain`,value:t};case Q.Hashable:return{disclosure:`hashed`,value:t};case Q.MaskableFromVisibleParts:return{disclosure:`masked`,value:t};default:throw Error(`invalid internal data type ${e.type}`)}}},yw=class e{channelMap;fieldMap;publicChannels;constructor(){this.channelMap=new Map,this.fieldMap=new Map,this.publicChannels=new Set}static fromMerkleRecord(t){let n=new e;return n.setChannelsFromMerkleRecord(t),n}static fromProofChannels(t){let n=new e;return n.setChannelsFromProofChannels(t),n}setChannelsFromMerkleRecord(e){this.publicChannels=e.getPublicChannels();let t=e.getLeavesByChannelMap();for(let[e,n]of t)this.channelMap.set(e,{nLeaves:n.length,leaves:n,tree:new _w,witnesses:[]});this.buildTrees(),this.buildFieldMap()}setChannelsFromProofChannels(e){for(let t of e){let e=[];for(let n of t.fields){let t=vw.fromProofFormat(n),r=n.type==zC.Public?0:n.index;e.push({leaf:t,path:n.path,index:r})}let n=t.witnesses.map(e=>A.binaryFromHexa(e));t.isPublic&&this.publicChannels.add(t.id),this.channelMap.set(t.id,{nLeaves:t.nLeaves,leaves:e,tree:new _w,witnesses:n})}this.buildTrees(),this.buildFieldMap()}toJson(e=!1){let t={},n=[];for(let{leaves:e}of this.channelMap.values())for(let t of e)t!==null&&n.push(t);for(let{path:r,leaf:i}of n){let n=[`root`,...r],a=t;for(let t=0;t<n.length;t++){let r=n[t];if(t==n.length-1)a[r]=e?i.getTypedValue():i.getRawValue();else{let e=typeof n[t+1]==`number`;if(a[r]===void 0)a[r]=e?[]:{};else if(Array.isArray(a[r])!==e){let e=n.slice(0,t+1).join(`.`);throw Error(`${e} is defined as both an array and an object`)}a=a[r]}}}return t.root}buildTrees(){for(let[e,t]of this.channelMap)if(!this.publicChannels.has(e)){for(let e of t.leaves)e!==null&&t.tree.setLeaf(e.index,e.leaf.getHash());t.tree.finalize(t.nLeaves),t.tree.setWitnesses(t.witnesses)}}buildWitnesses(){for(let[e,t]of this.channelMap){if(this.publicChannels.has(e))continue;let n=new Set;for(let e of t.leaves)e!==null&&n.add(e.index);let r=[];for(let e=0;e<t.nLeaves;e++)n.has(e)||r.push(e);t.witnesses=t.tree.getWitnesses(r)}}buildFieldMap(){this.fieldMap.clear();for(let[e,t]of this.channelMap)for(let n=0;n<t.leaves.length;n++){let r=t.leaves[n];if(r===null)continue;let i=r.path,a=JSON.stringify(i);this.fieldMap.set(a,{channelId:e,index:n})}}getLeafByPath(e){let{channelId:t,index:n}=this.getFieldByPath(e),r=this.getChannel(t).leaves[n];if(r===null)throw Error(`this field has been removed`);return r.leaf}getFieldByPath(e){let t=JSON.stringify(e),n=this.fieldMap.get(t);if(n===void 0)throw Error(`unknown path ${t}`);return n}getChannel(e){let t=this.channelMap.get(e);if(t===void 0)throw Error(`unknown channel ID ${e}`);return t}removeField(e){let{channelId:t,index:n}=this.getFieldByPath(e),r=this.getChannel(t);r.leaves[n]=null}setFieldToHashed(e){this.getLeafByPath(e).setToHashed()}setFieldToMasked(e){this.getLeafByPath(e).setToMasked()}getRootHashAsBinary(e){let t=this.getChannel(e);return this.publicChannels.has(e)?A.getNullHash():t.tree.getRootHash()}getRootHashAsHexString(e){let t=this.getRootHashAsBinary(e);return A.binaryToHexa(t)}toProofChannels(){this.buildWitnesses();let e=[];for(let[t,n]of this.channelMap){let r=this.publicChannels.has(t),i=[];for(let e of n.leaves){if(e===null)continue;let t=e.leaf.toProofFormat(e.path,e.index);i.push(t)}let a=n.witnesses.map(e=>A.binaryToHexa(e));e.push({id:t,isPublic:r,nLeaves:n.nLeaves,fields:i,witnesses:a})}return e}},bw=class e{channelMap;publicChannels;constructor(){this.channelMap=new Map,this.publicChannels=new Set}static fromRecord(t){let n=new e;n.setPublicChannels(t.getPublicChannels());let r=t.getItemList();for(let e of r){let t=e.item.channelId,r=n.channelMap.get(t);r===void 0&&(r=[],n.channelMap.set(t,r)),r.push(e)}return n}setChannel(e,t,n){t?this.publicChannels.add(e):this.publicChannels.delete(e),this.channelMap.set(e,n)}setPublicChannels(e){this.publicChannels=e}getPublicChannels(){return this.publicChannels}getChannelIds(){return[...this.channelMap.keys()].sort((e,t)=>e-t)}getFlatItems(e){let t=this.channelMap.get(e);if(t==null)throw Error(`Channel ${e} not found`);return t}},xw=class{pepper;hasNullPepper;sha512;counter;constructor(e){this.pepper=e,this.sha512=new Uint8Array(64),this.counter=0,this.hasNullPepper=this.pepper.every(e=>e==0)}static generatePepper(){return Tp.Random.getBytes(32)}getPepper(){return this.pepper}getSalt(){let e=this.counter&3,t=this.counter++>>2;return!e&&!this.hasNullPepper&&(this.sha512=Tp.Hashes.sha512AsBinary(A.binaryFrom(this.pepper,t))),this.sha512.slice(e<<4,e+1<<4)}},Sw=class e{channelMap;recordByChannels;publicChannels;constructor(){this.channelMap=new Map,this.publicChannels=new Set}static fromRecordByChannels(t,n=void 0){let r=new e;return r.setChannelsFromRecordByChannels(t,n),r}setChannelsFromRecordByChannels(e,t=void 0){this.publicChannels=e.getPublicChannels(),this.recordByChannels=e;let n=this.recordByChannels.getChannelIds();for(let e of n){let n=this.publicChannels.has(e),r=n?A.getNullHash():t===void 0?xw.generatePepper():t.get(e);if(r===void 0)throw Error(`no pepper specified for channel ${e}`);let i=this.recordByChannels.getFlatItems(e);this.storeChannel(e,n,i,r)}}storeChannel(e,t,n,r){let i=this.flatItemsToPositionedLeaves(n,t,r);this.channelMap.set(e,{pepper:r,positionedLeaves:i})}getPublicChannels(){return this.publicChannels}getLeavesByChannelMap(){let e=new Map;for(let[t,n]of this.channelMap)e.set(t,n.positionedLeaves);return e}getRecordByChannels(){let e=this.recordByChannels;if(e===void 0)throw Error(`recordByChannels is not set`);return e}getChannelIds(){return[...this.channelMap.keys()].sort((e,t)=>e-t)}getChannelPepper(e){return this.getChannel(e).pepper}getChannelRootHash(e){let t=this.getChannel(e);if(this.publicChannels.has(e))return A.getNullHash();let n=new _w;for(let e of t.positionedLeaves){let t=e.leaf.getHash();n.addLeaf(t)}return n.finalize(),n.getRootHash()}getChannel(e){let t=this.channelMap.get(e);if(t===void 0)throw Error(`channel ${e} not found`);return t}flatItemsToPositionedLeaves(e,t,n){let r=new xw(n);return e.map((e,n)=>({leaf:this.flatItemToLeaf(r,t,e.item),index:n,path:e.path}))}flatItemToLeaf(e,t,n){let r=n.type==MC.String?n.transformation.type:AC.None;if(t&&r!=AC.None)throw Error(`no transformation may be applied to a public field`);switch(r){case AC.None:return t?vw.fromItemWithPublicData(n):vw.fromItemWithPlainData(e,n);case AC.Hashable:return vw.fromItemWithHashedData(e,n);case AC.Maskable:return vw.fromItemWithMaskedData(e,n);default:throw Error(`unsupported transformation type ${r}`)}}},Cw=tm(()=>lm([L(),P(),Yp(),rm(),M(Cw),sm(L(),Cw)])),ww=class e{itemList;publicChannels;constructor(){this.itemList=[],this.publicChannels=new Set}static fromObject(t){let n=new e,r=R(Cw,t);return n.buildItemListByDfs(r),n}setChannelAsPublic(e){this.publicChannels.add(e)}setChannelAsPrivate(e){this.publicChannels.delete(e)}getPublicChannels(){return this.publicChannels}setChannel(e,t){let n=this.getFieldsByPathString(e);for(let e of n)this.setFieldChannel(e.item,t)}setFieldChannel(e,t){e.channelId=t}setAsHashable(e){let t=this.getFieldsByPathString(e);for(let e of t)this.setFieldAsHashable(e.item)}setFieldAsHashable(e){if(e.type!==MC.String)throw Error(`only a string may be set as hashable`);e.transformation={type:AC.Hashable}}setMaskOnField(e,t){if(e.type!==MC.String)throw Error(`a mask may only be applied to a string`);let n=[],r=[];t.sort((e,t)=>e.start-t.start),t.forEach((i,a)=>{let o=a>0?t[a-1].start:0,s=a>0?t[a-1].end:0;if(i.start<0||i.start>=e.value.length||i.end<=i.start)throw`invalid interval [${[i.start,i.end]}]`;if(i.start<s)throw`overlapping intervals [${[o,s]}] and [${[i.start,i.end]}]`;let c=e.value.slice(i.start,i.end);a&&i.start==s?(n[n.length-1]+=i.replacement,r[r.length-1]+=c):(n.push(e.value.slice(s,i.start),i.replacement),r.push(c)),a==t.length-1&&i.end<e.value.length&&n.push(e.value.slice(i.end))}),e.transformation={type:AC.Maskable,visibleParts:n,hiddenParts:r}}setMaskByPositions(e,t){let n=this.getFieldsByPathString(e);for(let e of n)this.setMaskOnField(e.item,t)}setMaskByRegex(e,t,n){let r=this.getFieldsByPathString(e);for(let e of r)this.setMaskByRegexOnField(e.item,t,n)}setMaskByRegexOnField(e,t,n){if(e.type!==MC.String)throw Error(`a mask may only be applied to a string`);let r=(t.exec(e.value)||[]).slice(1);if(r.join(``)!=e.value)throw`the regular expression ${t} does not capture all string parts`;let i=n.split(/(\$\d+)/).map((e,t)=>({shown:!!(t&1),string:e})).filter(e=>e.string!=``);if(i.length!=r.length||i.some((e,t)=>e.shown&&e.string!=`$`+(t+1)))throw`invalid substitution string "${n}"`;let a=[],o=0;i.forEach((e,t)=>{let n=o+r[t].length;e.shown||a.push({start:o,end:n,replacement:e.string}),o=n}),this.setMaskOnField(e,a)}getItemList(){return this.itemList}getFieldsByPathString(e){let t=e.match(/\[\d+\]|[^.[]+/g)||[];if(t[0]!==`this`)throw Error(`the path should begin with 'this'`);let n=t.slice(1).map(e=>e[0]==`[`?Number(e.slice(1,-1)):e);if(n.some((e,t)=>e==`*`&&t!=n.length-1))throw Error(`a wildcard may only appear at the end of the path`);let r=n[n.length-1]==`*`;return this.itemList.filter(e=>{let t;if(r){if(e.path.length<n.length)return!1;t=n.slice(0,-1)}else{if(e.path.length!=n.length)return!1;t=n}return t.every((t,n)=>t===e.path[n])})}static getValueType(e){if(typeof e==`string`)return MC.String;if(typeof e==`number`)return MC.Number;if(typeof e==`boolean`)return MC.Boolean;if(e===null)return MC.Null;if(Array.isArray(e))return MC.Array;if(typeof e==`object`&&Object.getPrototypeOf(e).isPrototypeOf(Object))return MC.Object;throw Error(`unsupported field type`)}static getPrimitiveValueType(t){let n=e.getValueType(t);if(n==MC.Array||n==MC.Object)throw Error(`expected a primitive value, got an array or an object`);return n}buildItemListByDfs(t,n=[]){switch(e.getValueType(t)){case MC.String:this.addFlatItem(n,this.buildStringItem(t));break;case MC.Number:this.addFlatItem(n,this.buildNumberItem(t));break;case MC.Boolean:this.addFlatItem(n,this.buildBooleanItem(t));break;case MC.Null:this.addFlatItem(n,this.buildNullItem());break;case MC.Array:this.buildArrayItem(t,n);break;case MC.Object:this.buildObjectItem(t,n);break;default:throw Error(`unsupported field type`)}}addFlatItem(e,t){let n={path:e,item:t};this.itemList.push(n)}buildStringItem(e){return{type:MC.String,value:e,transformation:{type:AC.None},channelId:-1}}buildNumberItem(e){return{type:MC.Number,value:e,channelId:-1}}buildBooleanItem(e){return{type:MC.Boolean,value:e,channelId:-1}}buildNullItem(){return{type:MC.Null,value:null,channelId:-1}}buildArrayItem(e,t){e.forEach((e,n)=>{this.buildItemListByDfs(e,[...t,n])})}buildObjectItem(e,t){Object.keys(e).forEach(n=>{let r=e[n];this.buildItemListByDfs(r,[...t,n])})}},Tw=class e{encoder=new zS;channelMap;publicChannels;constructor(){this.channelMap=new Map,this.publicChannels=new Set}static fromMerkleRecord(t){let n=new e;return n.setChannelsFromMerkleRecord(t),n}logger=k.getLogger([e.name]);setChannelsFromMerkleRecord(e){this.publicChannels=e.getPublicChannels();let t=e.getRecordByChannels(),n=e.getChannelIds();for(let r of n){let n=e.getChannelPepper(r),i=e.getChannelRootHash(r),a=t.getFlatItems(r).map(e=>({path:e.path,value:e.item.value,...e.item.transformation?{transformation:e.item.transformation}:{}}));this.channelMap.set(r,{rootHash:i,pepper:n,onChainItems:a})}}getChannelIds(){return[...this.channelMap.keys()].sort((e,t)=>e-t)}getOnChainData(e,t=!1){let n=this.getChannel(e),r=new zS().encode(n.onChainItems),i={pepper:n.pepper,data:r},a=this.encoder.encode(i);return{isPublic:this.publicChannels.has(e),merkleRootHash:n.rootHash,data:a}}addOnChainData(e,t,n,r){if(this.channelMap.has(e))throw Error(`channel ${e} has already been set`);t?this.publicChannels.add(e):this.publicChannels.delete(e);let i=this.encoder.decode(r);R(IC,i);let a=i.pepper,o=this.encoder.decode(i.data);R(RC,o),this.channelMap.set(e,{rootHash:n,pepper:a,onChainItems:o})}toMerkleRecord(e=!0){let t=new bw,n=new Map;for(let[e,r]of this.channelMap){let i=r.onChainItems.map(t=>{let n={channelId:e,type:ww.getPrimitiveValueType(t.value),value:t.value,...t.transformation?{transformation:t.transformation}:{}};return{path:t.path,item:n}}),a=this.publicChannels.has(e);t.setChannel(e,a,i),n.set(e,r.pepper)}let r=Sw.fromRecordByChannels(t,n);if(e){for(let[e,t]of this.channelMap)if(!this.publicChannels.has(e)){let n=r.getChannelRootHash(e);if(!A.binaryIsEqual(n,t.rootHash))throw Error(`inconsistent Merkle root hash for private channel ${e} (computed ${A.binaryToHexa(n)}, on-chain value is ${A.binaryToHexa(t.rootHash)})`)}}return r}getChannel(e){let t=this.channelMap.get(e);if(t===void 0)throw Error(`channel ${e} not found`);return t}},Ew=class e extends pC{static createApplicationLedgerVirtualBlockchain(t){return new e(t)}draftModeEnabled=!1;constructor(e,t=JS.createInitialState()){super(e,H.APP_LEDGER_VIRTUAL_BLOCKCHAIN,t)}async isAccountIdAllowedToWrite(e){if(this.getHeight()===0)return!0;let t=await this.getVirtualBlockchainOwnerId(),n=this.internalState.getAdditionalAllowedWriters();return[t.toBytes(),...n].some(t=>A.binaryIsEqual(t,e.toBytes()))}async getVirtualBlockchainState(){let e=this.getHeight(),t=e===0?A.getNullHash():(await this.getLastMicroblock()).getHash().toBytes();return{expirationDay:this.getExpirationDay(),height:e,internalState:this.internalState.toObject(),lastMicroblockHash:t,type:this.getType(),merkleRootHash:this.getMerkleRootHash()}}async getVirtualBlockchainOwnerId(){let e=this.internalState.getApplicationId();return(await this.provider.loadApplicationVirtualBlockchain(e)).getVirtualBlockchainOwnerId()}async updateInternalState(e,t,n){let r=e.getApplicationLedgerInternalStateUpdaterVersion();return cC.createApplicationLedgerInternalStateUpdater(r).updateState(this.provider,this.internalState,n)}checkMicroblockStructure(e){return this.draftModeEnabled?!0:new DC().checkMicroblockStructure(e)}enableDraftMode(){this.draftModeEnabled=!0}disableDraftMode(){this.draftModeEnabled=!1}setInternalState(e){this.internalState=e}isActorDefined(e){return this.internalState.isActorDefinedByName(e)}actorIsSubscribed(e){return this.getActor(e).subscribed}getInternalState(){return this.internalState}async getActorIdByPublicSignatureKey(t){let n=k.getLogger([e.name]),r=this.internalState,i=t.getPublicKeyAsBytes();for(let e=0;e<r.getNumberOfActors();e++){let t=r.getActorById(e);if(n.debug(`Search current actor id: loop index ${e}`),t.subscribed)try{let r=await this.getMicroblock(t.signatureKeyHeight);for(let a of r.getAllSections()){if(a.type!==O.APP_LEDGER_ACTOR_SUBSCRIPTION)continue;let{actorId:r}=a;if(r!==e)continue;let{signaturePublicKey:o}=a;if(!A.binaryIsEqual(o,await i)){n.debug(`Public signature key mismatch for actor ${t.name} (id ${e})`,{actor:t});continue}return n.debug(`Matching public signature key: {actor.name} (id ${e})`,{actor:t}),e}}catch(e){if(e instanceof x)n.debug(`{e}`,{e});else if(e instanceof Ee)n.debug(`{e}`,{e});else throw e}}throw n.debug(`Current actor not found`),new pe}async getPublicEncryptionKeyByActorId(e){let t=this.internalState.getActorById(e).pkeKeyHeight;if(typeof t==`number`&&t!==0){let n=await this.getMicroblock(t);for(let t of n.getAllSections()){if(t.type!==O.APP_LEDGER_ACTOR_SUBSCRIPTION||t.actorId!=e)continue;let n=t.pkePublicKey,r=t.pkeSchemeId;return Jx.createPublicEncryptionKey(r,n)}}throw new Te(e,this.getActorNameById(e))}async getPublicSignatureKeyByActorId(e){let t=this.internalState.getActorById(e).signatureKeyHeight;if(typeof t==`number`&&t!==0){let n=await this.getMicroblock(t);for(let t of n.getAllSections()){if(t.type!==O.APP_LEDGER_ACTOR_SUBSCRIPTION||t.actorId!=e)continue;let n=t.signaturePublicKey,r=t.signatureSchemeId;return Jx.createPublicSignatureKey(r,n)}}throw new we(`Actor ${e} has not subscribed to a public signature key.`)}async getExistingSharedKey(e,t){let n=this.internalState.getActorById(t).sharedSecrets.find(t=>t.peerActorId==e);if(n===void 0)return;let r=await this.getMicroblock(n.height);for(let n of r.getAllSections())if(n.type===O.APP_LEDGER_SHARED_SECRET&&!(n.hostId!==e||n.guestId!==t))return n.encryptedSharedKey;throw new De(t,e)}getChannelIdByChannelName(e){return this.internalState.getChannelIdFromChannelName(e)}getActorNameById(e){return this.internalState.getActorById(e).name}getChannelNameById(e){return this.internalState.getChannelFromChannelId(e).name}getActorIdFromActorName(e){return this.internalState.getActorIdByName(e)}getActor(e){return this.internalState.getActorByName(e)}getAllActors(){return this.internalState.getAllActors()}getAllChannels(){return this.internalState.getAllChannels()}async getOrganizationId(){let e=this.getApplicationId();return(await this.provider.loadApplicationVirtualBlockchain(e)).getOrganizationId()}getApplicationId(){return this.internalState.getApplicationId()}getNumberOfChannels(){return this.internalState.getNumberOfChannels()}getChannelById(e){return this.internalState.getChannelFromChannelId(e)}getNumberOfActors(){return this.internalState.getNumberOfActors()}async getMicroblockMerkleRecord(t,n){let r=await this.getMicroblock(t),i=[];for(let e of r.getAllSections()){if(e.type!==O.APP_LEDGER_PUBLIC_CHANNEL_DATA)continue;let{channelId:t,data:n}=e;i.push({channelId:t,isPublic:!0,merkleRootHash:A.getNullHash(),data:n})}let a=k.getLogger([e.name]);if(n!==void 0){let o=await(await n.getPrivateSignatureKey()).getPublicKey(),s;try{s=await this.getActorIdByPublicSignatureKey(o)}catch(t){if(t instanceof pe)k.getLogger([e.name]).debug(`Unabled to recover private channels: {e}`,{e:t});else throw t}if(typeof s==`number`)for(let e of r.getAllSections()){if(e.type!==O.APP_LEDGER_PRIVATE_CHANNEL_DATA)continue;let{channelId:r,encryptedData:o,merkleRootHash:c}=e;try{let e=await this.getChannelKey(s,r,n),l=this.deriveChannelSectionKey(e,t,r),u=this.deriveChannelSectionIv(e,t,r);a.debug(`Channel key for channel id ${r} and Channel section key at height ${t} derived `);let d=Tp.Aes.decryptGcm(l,o,u);a.debug(`Allowed to access private channel {channelName} (channel id={channelId})`,()=>({channelName:this.getChannelNameById(r),channelId:r})),i.push({channelId:r,isPublic:!1,merkleRootHash:c,data:d})}catch(e){if(e instanceof f||e instanceof he)a.debug(`Access to private channel {channelName} forbidden (channel id={channelId}): {e}`,()=>({e,channelName:this.getChannelNameById(r),channelId:r}));else throw e}}}else console.warn(`No private channel loaded: no private decryption key provided.`);let o=new Tw;for(let e of i)o.addOnChainData(e.channelId,e.isPublic,e.merkleRootHash,e.data);return o.toMerkleRecord(!1)}deriveChannelSectionKey(e,t,n){return this.deriveChannelSectionMaterial(e,`CHANNEL_SECTION_KEY`,t,n,32)}deriveChannelSectionIv(e,t,n){return this.deriveChannelSectionMaterial(e,`CHANNEL_SECTION_IV`,t,n,12)}deriveChannelSectionMaterial(e,t,n,r,i){let a=new Uint8Array,o=new TextEncoder,s=A.binaryFrom(o.encode(t),o.encode(`HEIGHT`),new Uint8Array(A.intToByteArray(n,6)),o.encode(`CHANNEL_ID`),new Uint8Array(A.intToByteArray(r,6)));return new Nv().deriveKey(e,a,s,i)}async getChannelKey(e,t,n){if(EC.assert(Number.isInteger(e),`Expected actor id with type number`),EC.assert(Number.isInteger(t),`Expected channel id of type number: got ${typeof t}`),this.internalState.getChannelCreatorIdFromChannelId(t)===e){let e=n.getSeedAsBytes();return await this.deriveChannelKey(e,t)}let r=await n.getPrivateDecryptionKey();return await this.getChannelKeyFromInvitation(e,t,r)}async deriveChannelKey(e,t){let n=await this.getGenesisSeed(),r=new TextEncoder,i=A.binaryFrom(r.encode(`CHANNEL_KEY`),r.encode(`GENESIS_SEED`),n.toBytes(),r.encode(`CHANNEL_ID`),new Uint8Array(A.intToByteArray(t,6)));return new Nv().deriveKeyNoSalt(e,i,32)}async getChannelKeyFromInvitation(e,t,n){EC.assert(Number.isInteger(e),`Expected actor id with type number`),EC.assert(Number.isInteger(t),`Expected channel id of type number: got ${typeof t}`);let r=this.internalState.getActorById(e).invitations.find(e=>e.channelId==t);if(!r){let n=this.internalState.getActorById(e).name,r=this.internalState.getChannelFromChannelId(t).name;throw new he(n,r)}let i=await this.getMicroblock(r.height),a;for(let n of i.getAllSections())n.type===O.APP_LEDGER_CHANNEL_INVITATION&&(n.guestId!==e||n.channelId!==t||(a=n));if(a===void 0)throw new he(e,t);let o=a.encryptedChannelKey;return await n.decrypt(o)}async exportProof(e,t){let n=new OC;n.setIdentifier(A.binaryToHexa(this.getIdentifier().toBytes()));for(let e=1;e<=this.getHeight();e++){let r=await this.getMicroblockMerkleRecord(e,t),i=yw.fromMerkleRecord(r).toProofChannels();n.addMicroblock(e,i)}let r=await this.provider.getChainId(),i=gw.createEmptyProof(r);return i.setAuthor(e.author),i.addVirtualBlockchain(n),i.getObject()}async importProof(e){let t=[],n=gw.fromObject(e).getSingleVirtualBlockchainOrFail().getMicroblocks();for(let e of n){let n=e.height,r=await this.getMicroblock(n),i=[];for(let e of r.getAllSections())if(e.type===O.APP_LEDGER_PUBLIC_CHANNEL_DATA){let{channelId:t}=e;i.push({channelId:t,merkleRootHash:A.getNullHash()})}else if(e.type===O.APP_LEDGER_PRIVATE_CHANNEL_DATA){let{channelId:t,merkleRootHash:n}=e;i.push({channelId:t,merkleRootHash:n})}let a=yw.fromProofChannels(e.channels);for(let e of i){let t=a.getRootHashAsBinary(e.channelId);if(!A.binaryIsEqual(e.merkleRootHash,t)){let n=A.binaryToHexa(t),r=A.binaryToHexa(e.merkleRootHash);throw new ce(e.channelId,n,r)}}t.push({height:n,data:a.toJson()})}return t}async getRecord(e,t){let n=await this.getMicroblockMerkleRecord(e,t);return yw.fromMerkleRecord(n).toJson()}async isActorInChannel(e,t){return this.internalState.getActorById(t).invitations.some(t=>t.channelId==e)}},Dw=class e{constructor(e){this.value=e}static of(t){return new e(t)}static some(t){return new e(t)}static none(){return new e(null)}map(t){return this.value===null?e.none():e.some(t(this.value))}unwrap(){if(this.value===null)throw Error(`Called unwrap on a None value`);return this.value}unwrapOrThrow(e){if(this.value===null)throw e;return this.value}unwrapOr(e){return this.value===null?e:this.value}isSome(){return this.value!==null}isNone(){return this.value===null}},Ow=class{_error=Dw.none();hash;header;verificationState={isMicroblockParsingCompleted:!1};constructor(e,t){this.provider=e,this.checkedMicroblock=t}async checkVirtualBlockchainConsistencyOrFail(){if(this.verificationState.isMicroblockParsingCompleted)throw new a(`You have already called parseMicroblock() method. You can only call it once.`);if(!this.checkedMicroblock.isDeclaringConsistentBodyHash())throw Error(`inconsistent body hash detected for microblock hash ${A.binaryToHexa(this.checkedMicroblock.getHashAsBytes())}`);let e=this.checkedMicroblock.getType(),t=0,n,r=this.checkedMicroblock.getPreviousHash().toBytes();if(this.checkedMicroblock.isGenesisMicroblock()){let t=r;e=dC.extractTypeFromGenesisPreviousHash(t),n=this.checkedMicroblock.getHash()}else{let e=await this.provider.getMicroblockHeader(KS.from(r));if(!e)throw Error(`previous microblock ${A.binaryToHexa(r)} not found`);if(this.checkedMicroblock.getHeight()!=e.height+1)throw Error(`inconsistent microblock height (expected ${e.height+1}, got ${this.checkedMicroblock.getHeight()})`);let t=X.computeMicroblockHashFromHeader(e);n=await this.provider.getVirtualBlockchainIdContainingMicroblock(KS.from(t))}let i;if(this.checkedMicroblock.isGenesisMicroblock()){switch(e){case H.ORGANIZATION_VIRTUAL_BLOCKCHAIN:i=new _C(this.provider);break;case H.ACCOUNT_VIRTUAL_BLOCKCHAIN:i=new yC(this.provider);break;case H.APPLICATION_VIRTUAL_BLOCKCHAIN:i=new xC(this.provider);break;case H.NODE_VIRTUAL_BLOCKCHAIN:i=new CC(this.provider);break;case H.PROTOCOL_VIRTUAL_BLOCKCHAIN:i=new TC(this.provider);break;case H.APP_LEDGER_VIRTUAL_BLOCKCHAIN:i=new Ew(this.provider);break;default:throw Error(`Unknown virtual blockchain type: ${e}`)}let n=this.checkedMicroblock.getPreviousHash().toBytes();t=dC.extractExpirationDayFromGenesisPreviousHash(n),i.setExpirationDay(t)}else switch(e){case H.ORGANIZATION_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadOrganizationVirtualBlockchain(n);break;case H.ACCOUNT_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadAccountVirtualBlockchain(n);break;case H.APPLICATION_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadApplicationVirtualBlockchain(n);break;case H.NODE_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadValidatorNodeVirtualBlockchain(n);break;case H.PROTOCOL_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadProtocolVirtualBlockchain(n);break;case H.APP_LEDGER_VIRTUAL_BLOCKCHAIN:i=await this.provider.loadApplicationLedgerVirtualBlockchain(n);break;default:throw Error(`Unknown virtual blockchain type: ${e}`)}await i.appendMicroBlock(this.checkedMicroblock),this.verificationState={isMicroblockParsingCompleted:!0,virtualBlockchain:i}}checkTimestampOrFail(e){if(this.verificationState.isMicroblockParsingCompleted===!1)throw new a(`You have already called reconstructMicroblockAndVirtualBlockchain() method. You can only call it once.`);let t=this.checkedMicroblock;e||=A.getTimestampInSeconds();let n=t.isTemporallyCloseTo(e);if(n===lC.TOO_FAR_IN_THE_PAST)throw Error(`timestamp is too far in the past (header:${t.getTimestamp()} / current:${e})`);if(n===lC.TOO_FAR_IN_THE_FUTURE)throw Error(`timestamp is too far in the future (header:${t.getTimestamp()} / current:${e})`)}async checkGasOrFail(e=A.getTimestampInSeconds()){if(this.verificationState.isMicroblockParsingCompleted===!1)throw new a(`You have already called reconstructMicroblockAndVirtualBlockchain() method. You can only call it once.`);let t=this.checkedMicroblock,n=await this.provider.computeMicroblockGas(t,{referenceTimestampInSeconds:e}),r=t.getGas();if(r!=n)throw Error(`Computed gas ${n} is not equal to declared gas ${r} `)}get virtualBlockchain(){if(this.verificationState.isMicroblockParsingCompleted)return this.verificationState.virtualBlockchain;throw new a(`Virtual blockchain not initialized.`)}getVirtualBlockchain(){return this.virtualBlockchain}getMicroblock(){return this.checkedMicroblock}getHash(){return this.hash}getError(){return this._error}containsError(){return this._error.isSome()}get error(){return this.containsError()?this._error.unwrap().toString():``}},kw=2,Aw=32,jw={CACHE_HORIZON:kw,HASH_SIZE:Aw,ROOT_ANCHORING_HASH:new Uint8Array(Aw)},Mw={keyDifference:Nw,getHashList:Pw};function Nw(e,t,n){for(let r=e;r<jw.HASH_SIZE*2;r++)if((t[r>>1]^n[2+(r>>1)-(e>>1)])>>4*(r&1)&15)return!0;return!1}function Pw(e,t){let n=[],r=2;for(let i=0;i<16;i++)n.push(e&1<<i?t.slice(r,r+=jw.HASH_SIZE):null);return n}function Fw(e,t,n){return Iw(e,t,n,null,0)?Tp.Hashes.sha256AsBinary(n[0]):null}function Iw(e,t,n,r,i){if(i===jw.HASH_SIZE*2)return r===null||t===null?r===null&&t===null:A.binaryIsEqual(r,t);let a=n[i];if(i&&(r===null||!A.binaryIsEqual(Tp.Hashes.sha256AsBinary(a),r)))return!1;let o=a[0]<<8|a[1];if(o){let r=Mw.getHashList(o,a),s=e[i>>1]>>4*(i&1)&15;return o&1<<s?Iw(e,t,n,r[s],i+1):t===null}if(Mw.keyDifference(i,e,a))return t===null;let s=jw.HASH_SIZE*2+1-i>>1;return t!==null&&A.binaryIsEqual(a.slice(2+s),t)}var Lw=class e{static verifyAccountProofFromObject(t){let n=t.account.state,r=X.encodeAccountState(n),i=Tp.Hashes.sha256AsBinary(r);return e.verifyRadixProof(t.account.virtualBlockchainId,i,t.account.radixProof,t.block.tokenRadixHash),e.verifyAppHash(t.block)}static verifyAccountProofFromJson(t){let{block:n,account:r}=t,i=r.radixProof.map(e=>A.binaryFromHexa(e)),a=Cg.decodeBinary(r.serializedState,Cg.BASE64),o=X.decodeAccountState(a),s={block:e.decodeJsonBlock(n),account:{virtualBlockchainId:A.binaryFromHexa(r.virtualBlockchainId),state:o,radixProof:i}};return e.verifyAccountProofFromObject(s)}static verifyMicroblockProofFromObject(t){let n=33-Math.clz32(t.virtualBlockchain.state.height-1),r=t.virtualBlockchain.merkleWitnesses,i=t.microblock.height-1,a=t.microblock.hash;if(r.length!==n-1)throw Error(`State proof failure: inconsistent list of Merkle witnesses`);for(let t=0;t<n-1;t++){let n=r[t];a=i>>>t&1?e.mergeHashes(n,a):e.mergeHashes(a,n)}let o=t.virtualBlockchain.state;if(!A.binaryIsEqual(o.merkleRootHash,a))throw Error(`State proof failure: invalid Merkle root hash`);let s=X.encodeVirtualBlockchainState(o),c=Tp.Hashes.sha256AsBinary(s);return e.verifyRadixProof(t.microblock.virtualBlockchainId,c,t.virtualBlockchain.radixProof,t.block.vbRadixHash),e.verifyAppHash(t.block)}static verifyMicroblockProofFromJson(t){let{block:n,microblock:r,virtualBlockchain:i}=t,a=i.merkleWitnesses.map(e=>A.binaryFromHexa(e)),o=i.radixProof.map(e=>A.binaryFromHexa(e)),s=Cg.decodeBinary(i.serializedState,Cg.BASE64),c=X.decodeVirtualBlockchainState(s),l={block:e.decodeJsonBlock(n),microblock:{virtualBlockchainId:A.binaryFromHexa(r.virtualBlockchainId),height:r.height,hash:A.binaryFromHexa(r.hash)},virtualBlockchain:{state:c,merkleWitnesses:a,radixProof:o}};return e.verifyMicroblockProofFromObject(l)}static decodeJsonBlock(e){return{height:e.height,vbRadixHash:A.binaryFromHexa(e.vbRadixHash),tokenRadixHash:A.binaryFromHexa(e.tokenRadixHash),storageHash:A.binaryFromHexa(e.storageHash),appHash:A.binaryFromHexa(e.appHash)}}static mergeHashes(e,t){let n=new Uint8Array(64);return n.set(e,0),n.set(t,32),Tp.Hashes.sha256AsBinary(n)}static verifyRadixProof(e,t,n,r){let i=Fw(e,t,n);if(i===null)throw Error(`State proof failure: inconsistent Radix proof`);if(!A.binaryIsEqual(i,r))throw Error(`State proof failure: invalid Radix root hash`)}static verifyAppHash(e){let t=Tp.Hashes.sha256AsBinary(A.binaryFrom(e.vbRadixHash,e.tokenRadixHash)),n=Tp.Hashes.sha256AsBinary(A.binaryFrom(t,e.storageHash));if(!A.binaryIsEqual(n,e.appHash))throw Error(`State proof failure: computed app hash does not match the one declared in the block`);return n}},Rw=class{stateUpdater;constructor(e,t,n){this.mbUnderConstruction=e,this.vb=t,this.provider=n}onMicroblockSearchFailureForExceedingHeight(e,t){if(e.getHeight()+1===t)return Promise.resolve(this.mbUnderConstruction);throw new x(e.getIdentifier(),t)}getBuiltMicroblock(){return this.mbUnderConstruction}async updateStateWithSection(e){if(!this.stateUpdater){let e=await this.provider.getProtocolState();this.stateUpdater=cC.createApplicationLedgerInternalStateUpdater(e.getApplicationLedgerInternalStateUpdaterVersion())}this.vb.setInternalState(await this.stateUpdater.updateStateFromSection(this.provider,this.vb.getInternalState(),e,this.mbUnderConstruction.getHeight()))}getInternalState(){return this.vb.getInternalState()}},zw=function(e){return e[e.UNKNOWN=0]=`UNKNOWN`,e[e.WALLET=1]=`WALLET`,e[e.OPERATOR=2]=`OPERATOR`,e}({}),Bw=F({name:L()}),Vw=F({name:L(),public:Yp()}),Hw=F({fieldPath:L(),channelName:L()}),Uw=F({actorName:L(),channelName:L()}),Ww=F({position:P(),length:P(),replacementString:L()}),Gw=F({fieldPath:L(),maskedParts:M(Ww)}),Kw=F({fieldPath:L()}),qw=F({virtualBlockchainId:I(L()),data:Jp(),actors:I(M(Bw)),channels:I(M(Vw)),channelAssignations:I(M(Hw)),actorAssignations:I(M(Uw)),hashableFields:I(M(Kw)),maskableFields:I(M(Gw)),author:L(),endorser:I(L()),approvalMessage:I(L())}),Jw=class{static validate(e){return R(qw,e)}static safeParse(e){return fm(qw,e)}static is(e){return qp(qw,e)}},Yw=class e extends Rw{logger=k.getLogger([e.name]);static async createFromVirtualBlockchain(t,n){let r=await n.createMicroblock(),i=new e(r,n);if(n.setMicroblockSearchFailureFallback(i),n.isEmpty()){let e={type:O.APP_LEDGER_CREATION,applicationId:t.toBytes()};r.addSection(e),await i.updateStateWithSection(e)}return i}usedSignatureSchemeId=Ja.SECP256K1;usedPkeSchemeId=Pv.ML_KEM_768_AES_256_GCM;constructor(e,t){super(e,t,t.getProvider())}get state(){return this.getInternalState()}getActorPrivateSignatureKey(e){return e.getPrivateSignatureKey(this.usedSignatureSchemeId)}getActorPrivateDecryptionKey(e){return e.getPrivateDecryptionKey(this.usedPkeSchemeId)}async createMicroblockFromStateUpdateRequest(e,t){let n=Jw.validate(t),r=await this.getActorPrivateDecryptionKey(e),a=await this.getActorPrivateSignatureKey(e),o=this.state.getNumberOfActors();for(let e of n.actors||[]){console.log(this.state.getAllActors());let t=e.name;this.vb.isActorDefined(t)?console.log(`Skipping actor creation: ${t} already created`):(await this.createActor(o,e.name),o+=1)}let s=n.author,c=this.getActorIdFromActorName(s);if(this.vb.isEmpty()){let e=await r.getPublicKey();await this.subscribeActor(s,await a.getPublicKey(),e)}let l=this.state.getNumberOfChannels();for(let e of n.channels||[]){let t={type:O.APP_LEDGER_CHANNEL_CREATION,id:l,isPrivate:!e.public,creatorId:c,name:e.name};this.mbUnderConstruction.addSection(t),await this.updateStateWithSection(t),l+=1}let u=ww.fromObject(n.data);for(let e of n.channelAssignations||[]){let t=this.state.getChannelIdFromChannelName(e.channelName);u.setChannel(e.fieldPath,t)}for(let t of n.actorAssignations||[]){let n=t.channelName,r=t.actorName;await this.inviteActorOnChannel(r,n,e)}for(let e of n.hashableFields||[])u.setAsHashable(e.fieldPath);for(let e of n.maskableFields||[]){let t=e.maskedParts.map(e=>({start:e.position,end:e.position+e.length,replacement:e.replacementString}));u.setMaskByPositions(e.fieldPath,t)}let d=this.state.getAllChannels();for(let e in d){let t=Number(e);d[t].isPrivate||u.setChannelAsPublic(Number(t))}let f=bw.fromRecord(u),p=Sw.fromRecordByChannels(f),m=Tw.fromMerkleRecord(p),h=m.getChannelIds();for(let t of h){let n=m.getOnChainData(t),{isPublic:r,merkleRootHash:i}=n;if(r){let e={type:O.APP_LEDGER_PUBLIC_CHANNEL_DATA,channelId:t,data:n.data};this.mbUnderConstruction.addSection(e),await this.updateStateWithSection(e)}else{let r=k.getLogger([`critical`]),a=this.vb.getHeight()+1,o=await this.vb.getChannelKey(c,t,e),s=this.vb.deriveChannelSectionKey(o,a,t),l=this.vb.deriveChannelSectionIv(o,a,t);r.debug(`Channel key ${o} at height ${a} and channel id ${t} -> Channel section key: ${s} (iv ${l}) `);let u=Tp.Aes.encryptGcm(s,n.data,l),d={type:O.APP_LEDGER_PRIVATE_CHANNEL_DATA,channelId:t,merkleRootHash:i,encryptedData:u};this.mbUnderConstruction.addSection(d),await this.updateStateWithSection(d)}}if(typeof n.endorser==`string`){if(n.endorser.trim().length===0)throw new i(`Empty endorser provided: should be a non-empty string or undefined`);let e=this.getActorIdFromActorName(n.endorser),t=n.approvalMessage??``,r={type:O.APP_LEDGER_ENDORSEMENT_REQUEST,message:t,endorserId:e};this.mbUnderConstruction.addSection(r),await this.updateStateWithSection(r)}return this.mbUnderConstruction}async createActor(e,t){console.log(`Creating actor ${t} (id ${e})`);let n={type:O.APP_LEDGER_ACTOR_CREATION,id:e,actorType:zw.UNKNOWN,name:t};this.mbUnderConstruction.addSection(n),await this.updateStateWithSection(n)}async inviteActorOnChannel(e,t,n){console.log(`Inviting actor `+e+` on channel `+t);let r=this.state.getChannelIdFromChannelName(t),i=this.getActorIdFromActorName(e),a=await this.getActorPrivateSignatureKey(n),o=await this.vb.getActorIdByPublicSignatureKey(await a.getPublicKey());EC.assert(typeof r==`number`,`Expected channel id of type number: got ${typeof r} for channel ${t}`);let s=i;if(await this.vb.isActorInChannel(r,s))return;let c=await this.vb.getChannelKey(o,r,n),l=await(await this.vb.getPublicEncryptionKeyByActorId(s)).encrypt(c),u=k.getLogger([Ew.name]);u.info(`Actor {guestName} invited to channel ${t}`,()=>({guestName:e})),u.debug(`Channel key for channel ${t}: ${c}`);let d={type:O.APP_LEDGER_CHANNEL_INVITATION,channelId:r,hostId:o,guestId:s,encryptedChannelKey:l};this.mbUnderConstruction.addSection(d),await this.updateStateWithSection(d)}async createSharedKey(e,t,n){let{encryptedSharedKey:r,hostGuestSharedKey:i}=await this.generateSharedKeyAndEncryptedSharedKey(e,n),a={type:O.APP_LEDGER_SHARED_SECRET,hostId:t,guestId:n,encryptedSharedKey:r};return this.mbUnderConstruction.addSection(a),await this.updateStateWithSection(a),i}static deriveHostGuestSharedKey(e,t,n){let r=e.getRawPrivateKey(),i=new TextEncoder,a=A.binaryFrom(i.encode(`SHARED_SECRET`),n),o=new Nv,s=A.binaryFrom(r,t),c=o.deriveKeyNoSalt(s,a,32);return Qg.createFromBytes(c)}async generateSharedKeyAndEncryptedSharedKey(t,n){let r=await this.getGenesisSeed(),i=e.deriveHostGuestSharedKey(t,r.toBytes(),n);return{encryptedSharedKey:await(await this.vb.getPublicEncryptionKeyByActorId(n)).encrypt(i.getRawSecretKey()),hostGuestSharedKey:i}}async getGenesisSeed(){return this.vb.isEmpty()?this.mbUnderConstruction.getPreviousHash():await this.vb.getGenesisSeed()}async subscribeActor(e,t,n){if(console.debug(`Subscribing ${e}`),!this.vb.isActorDefined(e)){console.log(`It appears that ${e} does not exist: create it`);let t=this.vb.getNumberOfActors();await this.createActor(t,e)}let r=zw.UNKNOWN,i=this.getActorIdFromActorName(e),a=A.getNullHash(),o={type:O.APP_LEDGER_ACTOR_SUBSCRIPTION,actorId:i,actorType:r,organizationId:a,signatureSchemeId:t.getSignatureSchemeId(),signaturePublicKey:await t.getPublicKeyAsBytes(),pkeSchemeId:n.getSchemeId(),pkePublicKey:await n.getRawPublicKey()};this.mbUnderConstruction.addSection(o),await this.updateStateWithSection(o)}getActorIdFromActorName(e){return this.state.getActorIdByName(e)}},Xw=class e{static ED25519_PUBLIC_KEY_TYPE=`tendermint/PubKeyEd25519`;static createFromEd25519PublicKey(t){return new e(e.ED25519_PUBLIC_KEY_TYPE,t)}constructor(e,t){this.type=e,this.publicKey=t}getType(){return this.type}getPublicKey(){return this.publicKey}},Zw=class{encodeSignature(e){return e}decodeSignature(e){return e}encodeMessage(e){return e}decodeMessage(e){return e}async encodePublicKey(e){return Hs(JSON.stringify({signatureSchemeId:e.getSignatureSchemeId(),publicKey:hl(await e.getPublicKeyAsBytes())}))}async decodePublicKey(e){let t=JSON.parse(bl(e));if(t&&typeof t.signatureSchemeId==`number`&&typeof t.publicKey==`string`){let e=vl(t.publicKey);return new Jx().createPublicSignatureKey(t.signatureSchemeId,e)}else throw`Invalid public key format: expected raw-encoded JSON object with signatureSchemeId and publicKey fields.`}async encodePrivateKey(e){return Hs(JSON.stringify({signatureSchemeId:e.getSignatureSchemeId(),privateKey:hl(e.getPrivateKeyAsBytes())}))}async decodePrivateKey(e){let t=JSON.parse(bl(e));if(t&&typeof t.signatureSchemeId==`number`&&typeof t.privateKey==`string`){let e=vl(t.privateKey);return Jx.createPrivateSignatureKey(t.signatureSchemeId,e)}else throw`Invalid public key format: expected raw-encoded JSON object with signatureSchemeId and privateKey fields.`}},Qw=class{static async exportPublicSignatureKey(e){if(e instanceof ry)return await Ly({kty:`OKP`,crv:`Ed25519`,alg:`EdDSA`,x:ky(await e.getPublicKeyAsBytes())});throw Error(`Unsupported public key type`)}static async exportPrivateSignatureKey(e){if(e instanceof iy){let t=e.getPrivateKeyAsBytes(),n=await(await e.getPublicKey()).getPublicKeyAsBytes();return await Ly({kty:`OKP`,crv:`Ed25519`,alg:`EdDSA`,d:ky(t),x:ky(n)})}throw Error(`Unsupported key type`)}},$w=`SIG`,eT=`SK`,tT=`PK`,nT=class{bytesEncoder=Og.bytesToHexEncoder();constructor(e){this.labels=e}async encodePublicKey(e){return Mg.encode(...this.getHCVPublicKeyEncodingPrefix(),this.bytesEncoder.encode(await e.getPublicKeyAsBytes()))}getHCVPrivateKeyEncodingPrefix(){return[$w,...this.labels,eT]}getHCVPublicKeyEncodingPrefix(){return[$w,...this.labels,tT]}},rT=class extends nT{constructor(e){super(e)}async encodePrivateKey(e){return Mg.encode(...this.getHCVPrivateKeyEncodingPrefix(),this.bytesEncoder.encode(e.getPrivateKeyAsBytes()))}},iT=class extends rT{constructor(){super([`MLDSA65`])}async isAcceptingPrivateKeyEncodingRequest(e){return e instanceof a_}async isAcceptingPublicKeyEncodingRequest(e){return e instanceof i_}},aT=class extends nT{constructor(){super([`PKMS`,`SECP256K1`])}async isAcceptingPrivateKeyEncodingRequest(e){return e instanceof _S}async isAcceptingPublicKeyEncodingRequest(e){return e instanceof vS}async encodePrivateKey(e){if(!(e instanceof _S))throw Error(`Invalid private key type: `+e.constructor.name);let t=e.getKeyId();return Mg.encode(...this.getHCVPrivateKeyEncodingPrefix(),t)}},oT=class extends rT{constructor(){super([`SECP256K1`])}async isAcceptingPrivateKeyEncodingRequest(e){return e instanceof ty}async isAcceptingPublicKeyEncodingRequest(e){return e instanceof ey}},sT=class{static defaultEncoder(){return Yx.createBase64HCVPkeEncoder()}},cT=class{encodeAsUint8Array(e){return Hs(JSON.stringify({symmetricEncryptionSchemeId:e.getSymmetricEncryptionSchemeId(),key:hl(e.getRawSecretKey())}))}decodeFromUint8Array(e){let t=JSON.parse(bl(e));if(t&&typeof t.symmetricEncryptionSchemeId==`number`&&typeof t.key==`string`){let e=vl(t.key);return new Jx().createSymmetricEncryptionKey(t.symmetricEncryptionSchemeId,e)}else throw`Invalid symmetric encryption key format: expected raw-encoded JSON object with symmetricEncryptionSchemeId and key fields.`}};function lT(e,t,n,r,i,a){let o=e[t++]^n[r++],s=e[t++]^n[r++],c=e[t++]^n[r++],l=e[t++]^n[r++],u=e[t++]^n[r++],d=e[t++]^n[r++],f=e[t++]^n[r++],p=e[t++]^n[r++],m=e[t++]^n[r++],h=e[t++]^n[r++],g=e[t++]^n[r++],_=e[t++]^n[r++],v=e[t++]^n[r++],y=e[t++]^n[r++],b=e[t++]^n[r++],ee=e[t++]^n[r++],x=o,te=s,ne=c,re=l,ie=u,ae=d,oe=f,se=p,ce=m,le=h,S=g,ue=_,de=v,fe=y,pe=b,me=ee;for(let e=0;e<8;e+=2)ie^=Ns(x+de|0,7),ce^=Ns(ie+x|0,9),de^=Ns(ce+ie|0,13),x^=Ns(de+ce|0,18),le^=Ns(ae+te|0,7),fe^=Ns(le+ae|0,9),te^=Ns(fe+le|0,13),ae^=Ns(te+fe|0,18),pe^=Ns(S+oe|0,7),ne^=Ns(pe+S|0,9),oe^=Ns(ne+pe|0,13),S^=Ns(oe+ne|0,18),re^=Ns(me+ue|0,7),se^=Ns(re+me|0,9),ue^=Ns(se+re|0,13),me^=Ns(ue+se|0,18),te^=Ns(x+re|0,7),ne^=Ns(te+x|0,9),re^=Ns(ne+te|0,13),x^=Ns(re+ne|0,18),oe^=Ns(ae+ie|0,7),se^=Ns(oe+ae|0,9),ie^=Ns(se+oe|0,13),ae^=Ns(ie+se|0,18),ue^=Ns(S+le|0,7),ce^=Ns(ue+S|0,9),le^=Ns(ce+ue|0,13),S^=Ns(le+ce|0,18),de^=Ns(me+pe|0,7),fe^=Ns(de+me|0,9),pe^=Ns(fe+de|0,13),me^=Ns(pe+fe|0,18);i[a++]=o+x|0,i[a++]=s+te|0,i[a++]=c+ne|0,i[a++]=l+re|0,i[a++]=u+ie|0,i[a++]=d+ae|0,i[a++]=f+oe|0,i[a++]=p+se|0,i[a++]=m+ce|0,i[a++]=h+le|0,i[a++]=g+S|0,i[a++]=_+ue|0,i[a++]=v+de|0,i[a++]=y+fe|0,i[a++]=b+pe|0,i[a++]=ee+me|0}function uT(e,t,n,r,i){let a=r+0,o=r+16*i;for(let r=0;r<16;r++)n[o+r]=e[t+(2*i-1)*16+r];for(let r=0;r<i;r++,a+=16,t+=16)lT(n,o,e,t,n,a),r>0&&(o+=16),lT(n,a,e,t+=16,n,o)}function dT(e,t,n){let{N:r,r:i,p:a,dkLen:o,asyncTick:s,maxmem:c,onProgress:l}=Ks({dkLen:32,asyncTick:10,maxmem:1024**3+1024},n);if(ws(r),ws(i),ws(a),ws(o),ws(s),ws(c),l!==void 0&&typeof l!=`function`)throw Error(`progressCb should be function`);let u=128*i,d=u/4,f=2**32;if(r<=1||r&r-1||r>f)throw Error(`Scrypt: N must be larger than 1, a power of 2, and less than 2^32`);if(a<0||a>(f-1)*32/u)throw Error(`Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)`);if(o<0||o>(f-1)*32)throw Error(`Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32`);if(u*(r+a)>c)throw Error(`Scrypt: memused is bigger than maxMem. Expected 128 * r * (N + p) > maxmem of `+c);let p=Sv(Gc,e,t,{c:1,dkLen:u*a}),m=ks(p),h=ks(new Uint8Array(u*r)),g=ks(new Uint8Array(u)),_=()=>{};if(l){let e=2*r*a,t=Math.max(Math.floor(e/1e4),1),n=0;_=()=>{n++,l&&(!(n%t)||n===e)&&l(n/e)}}return{N:r,r:i,p:a,dkLen:o,blockSize32:d,V:h,B32:m,B:p,tmp:g,blockMixCb:_,asyncTick:s}}function fT(e,t,n,r,i){let a=Sv(Gc,e,n,{c:1,dkLen:t});return As(n,r,i),a}function pT(e,t,n){let{N:r,r:i,p:a,dkLen:o,blockSize32:s,V:c,B32:l,B:u,tmp:d,blockMixCb:f}=dT(e,t,n);Ls(l);for(let e=0;e<a;e++){let t=s*e;for(let e=0;e<s;e++)c[e]=l[t+e];for(let e=0,t=0;e<r-1;e++)uT(c,t,c,t+=s,i),f();uT(c,(r-1)*s,l,t,i),f();for(let e=0;e<r;e++){let e=l[t+s-16]%r;for(let n=0;n<s;n++)d[n]=l[t+n]^c[e*s+n];uT(d,0,l,t,i),f()}}return Ls(l),fT(e,o,u,c,d)}var mT=class extends wv{getKeyDerivationFunctionSchemeId(){return Cv.SCRYPT}deriveKey(e,t,n){return pT(e,t,{N:2**16,r:8,p:1,dkLen:n})}},hT=function(e){return e[e.SECP256K1=Ja.SECP256K1]=`SECP256K1`,e[e.ML_DSA_65=Ja.ML_DSA_65]=`ML_DSA_65`,e}({}),gT=class{constructor(e){this.apiKey=e}async getPkmsCredential(){return this.apiKey}},_T=Symbol.for(`@ts-pattern/matcher`),vT=Symbol.for(`@ts-pattern/isVariadic`),yT=`@ts-pattern/anonymous-select-key`,bT=e=>!!(e&&typeof e==`object`),xT=e=>e&&!!e[_T],ST=(e,t,n)=>{if(xT(e)){let{matched:r,selections:i}=e[_T]().match(t);return r&&i&&Object.keys(i).forEach(e=>n(e,i[e])),r}if(bT(e)){if(!bT(t))return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let r=[],i=[],a=[];for(let t of e.keys()){let n=e[t];xT(n)&&n[vT]?a.push(n):a.length?i.push(n):r.push(n)}if(a.length){if(a.length>1)throw Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");if(t.length<r.length+i.length)return!1;let e=t.slice(0,r.length),o=i.length===0?[]:t.slice(-i.length),s=t.slice(r.length,i.length===0?1/0:-i.length);return r.every((t,r)=>ST(t,e[r],n))&&i.every((e,t)=>ST(e,o[t],n))&&(a.length===0||ST(a[0],s,n))}return e.length===t.length&&e.every((e,r)=>ST(e,t[r],n))}return Reflect.ownKeys(e).every(r=>{let i=e[r];return(r in t||xT(a=i)&&a[_T]().matcherType===`optional`)&&ST(i,t[r],n);var a})}return Object.is(t,e)},CT=e=>{var t;return bT(e)?xT(e)?(t=e[_T]()).getSelectionKeys?.call(t)??[]:wT(Array.isArray(e)?e:Object.values(e),CT):[]},wT=(e,t)=>e.reduce((e,n)=>e.concat(t(n)),[]);function TT(e){return Object.assign(e,{optional:()=>DT(e),and:t=>OT(e,t),or:t=>kT(e,t),select:t=>t===void 0?jT(e):jT(t,e)})}function ET(e){return Object.assign((e=>Object.assign(e,{[Symbol.iterator](){let t=0,n=[{value:Object.assign(e,{[vT]:!0}),done:!1},{done:!0,value:void 0}];return{next:()=>n[t++]??n.at(-1)}}}))(e),{optional:()=>ET(DT(e)),select:t=>ET(t===void 0?jT(e):jT(t,e))})}function DT(e){return TT({[_T]:()=>({match:t=>{let n={},r=(e,t)=>{n[e]=t};return t===void 0?(CT(e).forEach(e=>r(e,void 0)),{matched:!0,selections:n}):{matched:ST(e,t,r),selections:n}},getSelectionKeys:()=>CT(e),matcherType:`optional`})})}function OT(...e){return TT({[_T]:()=>({match:t=>{let n={},r=(e,t)=>{n[e]=t};return{matched:e.every(e=>ST(e,t,r)),selections:n}},getSelectionKeys:()=>wT(e,CT),matcherType:`and`})})}function kT(...e){return TT({[_T]:()=>({match:t=>{let n={},r=(e,t)=>{n[e]=t};return wT(e,CT).forEach(e=>r(e,void 0)),{matched:e.some(e=>ST(e,t,r)),selections:n}},getSelectionKeys:()=>wT(e,CT),matcherType:`or`})})}function AT(e){return{[_T]:()=>({match:t=>({matched:!!e(t)})})}}function jT(...e){let t=typeof e[0]==`string`?e[0]:void 0,n=e.length===2?e[1]:typeof e[0]==`string`?void 0:e[0];return TT({[_T]:()=>({match:e=>{let r={[t??yT]:e};return{matched:n===void 0||ST(n,e,(e,t)=>{r[e]=t}),selections:r}},getSelectionKeys:()=>[t??yT].concat(n===void 0?[]:CT(n))})})}function MT(e){return!0}function NT(e){return typeof e==`number`}function PT(e){return typeof e==`string`}function FT(e){return typeof e==`bigint`}TT(AT(MT)),TT(AT(MT));var IT=e=>Object.assign(TT(e),{startsWith:t=>{return IT(OT(e,(n=t,AT(e=>PT(e)&&e.startsWith(n)))));var n},endsWith:t=>{return IT(OT(e,(n=t,AT(e=>PT(e)&&e.endsWith(n)))));var n},minLength:t=>IT(OT(e,(e=>AT(t=>PT(t)&&t.length>=e))(t))),length:t=>IT(OT(e,(e=>AT(t=>PT(t)&&t.length===e))(t))),maxLength:t=>IT(OT(e,(e=>AT(t=>PT(t)&&t.length<=e))(t))),includes:t=>{return IT(OT(e,(n=t,AT(e=>PT(e)&&e.includes(n)))));var n},regex:t=>{return IT(OT(e,(n=t,AT(e=>PT(e)&&!!e.match(n)))));var n}});IT(AT(PT));var LT=e=>Object.assign(TT(e),{between:(t,n)=>LT(OT(e,((e,t)=>AT(n=>NT(n)&&e<=n&&t>=n))(t,n))),lt:t=>LT(OT(e,(e=>AT(t=>NT(t)&&t<e))(t))),gt:t=>LT(OT(e,(e=>AT(t=>NT(t)&&t>e))(t))),lte:t=>LT(OT(e,(e=>AT(t=>NT(t)&&t<=e))(t))),gte:t=>LT(OT(e,(e=>AT(t=>NT(t)&&t>=e))(t))),int:()=>LT(OT(e,AT(e=>NT(e)&&Number.isInteger(e)))),finite:()=>LT(OT(e,AT(e=>NT(e)&&Number.isFinite(e)))),positive:()=>LT(OT(e,AT(e=>NT(e)&&e>0))),negative:()=>LT(OT(e,AT(e=>NT(e)&&e<0)))});LT(AT(NT));var RT=e=>Object.assign(TT(e),{between:(t,n)=>RT(OT(e,((e,t)=>AT(n=>FT(n)&&e<=n&&t>=n))(t,n))),lt:t=>RT(OT(e,(e=>AT(t=>FT(t)&&t<e))(t))),gt:t=>RT(OT(e,(e=>AT(t=>FT(t)&&t>e))(t))),lte:t=>RT(OT(e,(e=>AT(t=>FT(t)&&t<=e))(t))),gte:t=>RT(OT(e,(e=>AT(t=>FT(t)&&t>=e))(t))),positive:()=>RT(OT(e,AT(e=>FT(e)&&e>0))),negative:()=>RT(OT(e,AT(e=>FT(e)&&e<0)))});RT(AT(FT)),TT(AT(function(e){return typeof e==`boolean`})),TT(AT(function(e){return typeof e==`symbol`})),TT(AT(function(e){return e==null})),TT(AT(function(e){return e!=null}));var zT=class extends Error{constructor(e){let t;try{t=JSON.stringify(e)}catch{t=e}super(`Pattern matching error: no pattern matches value ${t}`),this.input=void 0,this.input=e}},BT={matched:!1,value:void 0};function VT(e){return new HT(e,BT)}var HT=class e{constructor(e,t){this.input=void 0,this.state=void 0,this.input=e,this.state=t}with(...t){if(this.state.matched)return this;let n=t[t.length-1],r=[t[0]],i;t.length===3&&typeof t[1]==`function`?i=t[1]:t.length>2&&r.push(...t.slice(1,t.length-1));let a=!1,o={},s=(e,t)=>{a=!0,o[e]=t},c=!r.some(e=>ST(e,this.input,s))||i&&!i(this.input)?BT:{matched:!0,value:n(a?yT in o?o[yT]:o:this.input,this.input)};return new e(this.input,c)}when(t,n){if(this.state.matched)return this;let r=!!t(this.input);return new e(this.input,r?{matched:!0,value:n(this.input,this.input)}:BT)}otherwise(e){return this.state.matched?this.state.value:e(this.input)}exhaustive(e=UT){return this.state.matched?this.state.value:e(this.input)}run(){return this.exhaustive()}returnType(){return this}narrow(){return this}};function UT(e){throw new zT(e)}var WT=function(e){return e.HEX=`hex`,e.BASE64=`base64`,e.BASE64URL=`base64url`,e}({}),GT=class{static decode(e,t){return VT(t).with(WT.BASE64,()=>Yg.from(e,`base64`)).with(WT.HEX,()=>Yg.from(e,`hex`)).with(WT.BASE64URL,()=>Yg.from(e,`base64url`)).exhaustive()}static encode(e,t){return VT(t).with(WT.BASE64,()=>Yg.from(e).toString(`base64`)).with(WT.HEX,()=>Yg.from(e).toString(`hex`)).with(WT.BASE64URL,()=>Yg.from(e).toString(`base64url`)).exhaustive()}},KT=class{signatureEncoding=WT.HEX;setSignatureEncoding(e){return this.signatureEncoding=e,this}async sign(e,t,n){let r=GT.decode(n,t),i=await e.sign(r);return GT.encode(i,this.signatureEncoding)}},qT=class{signatureEncoding=WT.HEX;setSignatureEncoding(e){return this.signatureEncoding=e,this}async verify(e,t,n,r){let i=GT.decode(n,t),a=GT.decode(r,this.signatureEncoding);return await e.verify(i,a)}},JT=class{constructor(e){this.signatureType=e}getSignatureType(){return this.signatureType}},YT=class extends JT{constructor(e){super(e.signatureType),this.signatureObject=e}getContext(){return this.signatureObject.context}getPayload(){return this.signatureObject.payload}getSignatureObject(){return this.signatureObject}},XT=function(e){return e.JSON_CANONICAL=`json-canonical`,e.CBOR=`cbor`,e}({}),ZT=`$`;function QT(e,t){let n=``,r=t&&t.include,i=t&&t.exclude;i&&typeof i==`string`&&(i=[i]),r&&r.sort();let a=new WeakMap,o=t&&t.allowCircular,s=t&&t.filterUndefined,c=t&&t.undefinedInArrayToNull;return l(e,ZT),n;function l(e,t){if(typeof e!=`object`||!e||e.toJSON!=null){if(typeof e==`number`&&!Number.isFinite(e))throw Error(`Non-finite number (${e}) is not permitted in JSON (RFC 8785 \xA73.2.2.3)`);n+=JSON.stringify(e)}else if(Array.isArray(e)){let r=a.get(e);if(r!==void 0&&t.startsWith(r)){if(!o)throw Error(`Circular reference detected`);n+=`"[Circular:`+r+`]"`;return}a.set(e,t),n+=`[`;let i=!1;e.forEach((e,r)=>{i&&(n+=`,`),i=!0,c&&e===void 0&&(e=null),l(e,`${t}[${r}]`)}),n+=`]`}else{let c=a.get(e);if(c!==void 0&&t.startsWith(c)){if(!o)throw Error(`Circular reference detected`);n+=`"[Circular:`+c+`]"`;return}a.set(e,t),n+=`{`;let u=!1,d=r=>{i&&i.includes(r)||(u&&(n+=`,`),u=!0,n+=JSON.stringify(r),n+=`:`,l(e[r],`${t}.${r}`))};if(t===ZT&&r)r.forEach(t=>{e.hasOwnProperty(t)&&d(t)});else{let t=Object.keys(e);s&&(t=t.filter(t=>e[t]!==void 0)),t.sort(),t.forEach(e=>{d(e)})}n+=`}`}}}function $T(e,t){return QT(e,{allowCircular:t,filterUndefined:!0,undefinedInArrayToNull:!0})}var eE=class{static encode(e,t){return VT(t).with(XT.JSON_CANONICAL,()=>new TextEncoder().encode($T(e))).with(XT.CBOR,()=>new zS().encode(e)).exhaustive()}},tE=nm({signedAt:P(),purpose:L(),target:I(L()),requestedAt:I(P()),notValidBefore:I(P()),notValidAfter:I(P()),allowOnChain:I(Yp()),organizationId:I(L()),applicationId:I(L()),applicationLedgerId:I(L()),applicationLedgerLatestMicroblockHash:I(L())}),nE=function(e){return e.JSON_CANONICAL_UTF8=`json-canonical+utf8`,e.JWS=`jws`,e}({}),rE=nm({signatureType:N(nE.JSON_CANONICAL_UTF8),signature:L(),signatureEncoding:I(Zp(WT)),publicKey:I(L()),context:tE,payload:I(um())}),iE=nm({signatureType:N(nE.JWS),jws:L(),publicKey:I(L())}),aE=dm(`signatureType`,[rE,iE]),oE=nm({verifiedAt:I(P()),shouldBeValidOnChain:im(Yp())}),sE=dm(`verified`,[F({verified:N(!0),context:tE,payload:um()}),F({verified:N(!1),errors:M(L())})]),cE=class{signatureEncoding=WT.BASE64;includePayload=!0;includePublicKey=!0;includeSignatureEncoding=!0;location=void 0;setSignatureEncoding(e){return this.signatureEncoding=e,this}setIncludePayload(e){return this.includePayload=e,this.location=void 0,this}setIncludePublicKey(e){return this.includePublicKey=e,this}setIncludeSignatureEncoding(e){return this.includeSignatureEncoding=e,this}setPayloadLocation(e){this.location=e,this.includePayload=!1}async sign(e,t,n){let r=BS.defaultStringSignatureEncoder(),i=this.includePublicKey?await r.encodePublicKey(await e.getPublicKey()):void 0,a=eE.encode({context:t,payload:n},XT.JSON_CANONICAL),o=await e.sign(a),s=GT.encode(o,this.signatureEncoding);return{signatureType:nE.JSON_CANONICAL_UTF8,context:t,signature:s,...this.location,...this.includePayload&&{payload:n},...this.includePublicKey&&{publicKey:i},...this.includeSignatureEncoding&&{signatureEncoding:this.signatureEncoding}}}},lE=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`;function uE(e){let t=pE(e),n=new TextDecoder().decode(t);return JSON.parse(n)}function dE(e){let t=``;for(let n=0;n<e.length;n+=3){let r=e[n],i=n+1<e.length?e[n+1]:void 0,a=n+2<e.length?e[n+2]:void 0;t+=lE[r>>2],t+=lE[(r&3)<<4|(i??0)>>4],i!==void 0&&(t+=lE[(i&15)<<2|(a??0)>>6]),a!==void 0&&(t+=lE[a&63])}return t}function fE(e){return dE(new TextEncoder().encode(e))}function pE(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t+`=`.repeat((4-t.length%4)%4),r=atob(n),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return i}function mE(e){if(e.alg)return e.alg;if(e.kty===`OKP`){if(e.crv===`Ed25519`)return`EdDSA`;if(e.crv===`X25519`)throw Error(`X25519 keys are for key agreement, not signing`)}if(e.kty===`EC`)switch(e.crv){case`P-256`:return`ES256`;case`P-384`:return`ES384`;case`P-521`:return`ES512`;case`secp256k1`:return`ES256K`;default:throw Error(`Unsupported EC curve for JWS: ${e.crv}`)}if(e.kty===`RSA`)return`RS256`;if(e.kty===`AKP`){if(e.crv)return e.crv;throw Error(`AKP key requires "alg" or "crv" to determine JWS algorithm`)}throw Error(`Cannot determine JWS algorithm from JWK (kty=${e.kty}, crv=${e.crv})`)}function hE(e){let t={};return e.signedAt!==void 0&&(t.iat=e.signedAt),e.notValidBefore!==void 0&&(t.nbf=e.notValidBefore),e.notValidAfter!==void 0&&(t.exp=e.notValidAfter),e.target!==void 0&&(t.aud=e.target),t}var gE=class extends JT{jws;context;payload;constructor(e){super(e.signatureType),this.signature=e,this.jws=this.signature.jws;let[t,n,r]=this.jws.split(`.`);this.context=R(tE,uE(t).context),this.payload=uE(n)}getContext(){return this.context}getPayload(){return this.payload}getJws(){return this.jws}},_E=class{static parse(e){let t=R(aE,e);if(t.signatureType===nE.JSON_CANONICAL_UTF8)return new YT(t);if(t.signatureType===nE.JWS)return new gE(t);throw Error(`Unknown signature type`)}},vE=class{static invalidSignature(){return{verified:!1,errors:[`Invalid signature`]}}static malformed(){return{verified:!1,errors:[`Malformed signature`]}}static verified(e,t){return{verified:!0,context:e,payload:t}}static notValidYet(){return{verified:!1,errors:[`Not valid yet`]}}static expired(){return{verified:!1,errors:[`Expired`]}}static allowedOnChainNotMatch(){return{verified:!1,errors:[`Allowed on chain not match`]}}},yE=class{payload;setPayload(e){return this.payload=e,this}async verify(e,t,n={}){switch(t.getSignatureType()){case nE.JSON_CANONICAL_UTF8:return this.verifyJsonCanonical(e,t,n);case nE.JWS:return this.verifyJws(e,t,n);default:throw Error(`Unsupported signature type: ${t.getSignatureType()}`)}}async verifyJsonCanonical(e,t,n){let r=t.getSignatureObject(),i=r.context,a=this.checkContext(i,n);if(a)return a;let o=r.payload??this.payload,s=eE.encode({context:r.context,payload:o},XT.JSON_CANONICAL),c=GT.decode(r.signature,r.signatureEncoding??WT.BASE64);return await e.verify(s,c)?vE.verified(r.context,o):vE.invalidSignature()}async verifyJws(e,t,n){let r=t.getJws().split(`.`);if(r.length!==3)return console.warn(`Malformed compact JWS: expected 3 parts, got ${r.length}`),vE.malformed();let[i,a,o]=r,s=`${i}.${a}`,c=new TextEncoder().encode(s),l=pE(o);if(!await e.verify(c,l))return vE.invalidSignature();let u=t.getPayload(),d=t.getContext();return this.checkContext(d,n)||vE.verified(d,u)}checkContext(e,t){let n=t.verifiedAt??Date.now();if(e.notValidBefore&&e.notValidBefore>n)return vE.notValidYet();if(e.notValidAfter&&e.notValidAfter<n)return vE.expired();if(typeof t.shouldBeValidOnChain==`boolean`&&t.shouldBeValidOnChain!==e.allowOnChain)return vE.allowedOnChainNotMatch()}},bE=class{includePublicKey=!0;typ=`JWT`;async sign(e,t,n){if(typeof n!=`object`||!n||Array.isArray(n))throw TypeError(`JWS payload must be a flat, plain object so it can be inlined as JWT claims`);let r=e.getPrivateJwk(),i=mE(r),a=hE(t),o=Object.keys(a).find(e=>e in n);if(o)throw Error(`Payload defines reserved claim "${o}", already derived from the signature context`);let s={alg:i,typ:this.typ,...r.kid?{kid:r.kid}:{},context:t,...a},c=`${fE(JSON.stringify(s))}.${fE(JSON.stringify(n))}`,l=new TextEncoder().encode(c),u=`${c}.${dE(await e.sign(l))}`,d;return this.includePublicKey&&(d=await BS.defaultStringSignatureEncoder().encodePublicKey(await e.getPublicKey())),{signatureType:nE.JWS,jws:u,...d!==void 0&&{publicKey:d}}}},xE=class{constructor(){}async has(e){return!1}async get(e){return!1}async set(e,t){}},SE=class{key;constructor(e,t,n){this.key=`${e}|${t}|${n}`}getKey(){return this.key}},CE=class{map;constructor(){this.map=new Map}async has(e){return this.map.has(e.getKey())}async get(e){return this.map.get(e.getKey())}async set(e,t){this.map.set(e.getKey(),t)}};(async function(){new CE})();var wE=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`,TE={verifyFormat:EE,encodeNumber:DE,decodeNumber:OE,encodeToChar:kE,decodeFromChar:AE,CROCKFORD_CHARS:wE};function EE(e,t=e.length){return RegExp(`^(${[...wE].join(`|`)}){${t}}$`).test(e)}function DE(e,t){if(!Number.isInteger(t)||t<1||t>10)throw Error(`Invalid or unsafe size for base32 encoding`);if(!Number.isInteger(e)||e<0||e>=32**t)throw Error(`Invalid number for base32 encoding of size ${t}`);return[...Array(t).keys()].map(t=>kE(e>>t*5&31)).join(``)}function OE(e){if(e.length==0||e.length>10)throw Error(`Invalid base32 string length`);return[...e].reduceRight((e,t)=>e<<5|AE(t),0)}function kE(e){let t=wE[e];if(t===void 0)throw Error(`Invalid base32 value`);return t}function AE(e){let t=wE.indexOf(e);if(e.length!=1||t==-1)throw Error(`Invalid base32 character`);return t}var jE=class{collection;constructor(e){this.collection=e}serialize(e,t){let n=this.collection[e],r=new Jv(n).serialize(t);return new Uint8Array([e,...r])}},ME=class{collection;constructor(e){this.collection=e}unserialize(e){let t=e[0],n=this.collection[t];if(!n)throw Error(`Unknown message type ${t}: I do not know how to unserialize this message.`);return{type:t,object:new Yv(n).unserialize(e.slice(1))}}},NE=class{schema;constructor(e){this.schema=e}validate(e){if(this.schema===void 0)throw new o(`Provided schema is undefined: this should not happen`);this.validateObject(this.schema.definition,e)}validateObject(e,t,n=``){for(let r of e){let e=n+(n&&`.`)+r.name,i=t[r.name];if(i===void 0){if(r.optional)continue;throw Error(`field '${e}' is missing`)}if(r.type&32){if(no.getType(i)!=1)throw`'${e}' is not an array`;for(let t in i)this.validateItem(r,i[t],e+`[${t}]`)}else this.validateItem(r,i,e)}}validateItem(e,t,n){if((e.type&31)==2){if(no.getType(t)!=2)throw`'${n}' is not an object`;if(!e.unspecifiedSchema){if(!e.schema)throw`missing definition in schema`;this.validateObject(e.schema.definition,t,n)}}else{let r=new ro(e,t);try{r.check()}catch(e){throw`Error on field '${n}': ${e}`}}}},PE={getAccountTypeFromIdentifier:FE,getSpecialAccountTypeIdentifier:IE,isAllowedTransfer:LE};function FE(e){if(e.length!=32)throw Error(`invalid account identifier`);if(e.slice(0,-1).every(e=>e==0)){let t=e[31];if(t==1||!Ur[t])throw Error(`special account format detected, but with an invalid type (${t})`);return t}return 1}function IE(e){if(e==1||!Ur[e])throw Error(`${e} is not a valid special account type`);let t=new Uint8Array(32);return t[31]=e,t}function LE(e,t){return Wr[e]>>t&1}var RE=class e{constructor(e){this.amount=e}static create(t){return new e(t)}getAmount(){return this.amount}toString(){return`${this.amount} €`}},zE=class{static defaultEurosToCMTSTokenConverter(){return new BE}},BE=class e{static TOKENS_FOR_ONE_EUROS=100;convert(t){return hn.create(t.getAmount()*e.TOKENS_FOR_ONE_EUROS)}invert(t){return RE.create(t.getAmount()/e.TOKENS_FOR_ONE_EUROS)}},VE=class e{constructor(e,t,n){this.verified=e,this.appLedger=t,this.importedProofs=n}static createSuccessfulProofVerificationResult(t,n){return new e(!0,t,Dw.some(n))}static createFailedProofVerificationResult(t){return new e(!1,t,Dw.none())}isVerified(){return this.verified}getInvolvedBlockHeights(){return this.importedProofs.isSome()?this.importedProofs.unwrap().map(e=>e.height):[]}getApplicationLedgerId(){return this.appLedger.getIdentifier()}async getRecordContainedInBlockAtHeight(e,t){throw Error(`Not implemented`)}},HE=function(e){return e[e.PARSE_ERROR=-32700]=`PARSE_ERROR`,e[e.INVALID_REQUEST=-32600]=`INVALID_REQUEST`,e[e.METHOD_NOT_FOUND=-32601]=`METHOD_NOT_FOUND`,e[e.INVALID_PARAMS=-32602]=`INVALID_PARAMS`,e[e.INTERNAL_ERROR=-32603]=`INTERNAL_ERROR`,e[e.ENDPOINT_CLOSED_WHILE_NODE_IS_CATCHING_UP=-32603]=`ENDPOINT_CLOSED_WHILE_NODE_IS_CATCHING_UP`,e[e.TX_ALREADY_EXISTS=-32003]=`TX_ALREADY_EXISTS`,e[e.TX_OUT_OF_GAS=-32002]=`TX_OUT_OF_GAS`,e[e.TX_CHECK_FAILED=-32001]=`TX_CHECK_FAILED`,e[e.TX_DELIVER_FAILED=-32e3]=`TX_DELIVER_FAILED`,e}({}),UE=1,WE=class e extends mw{constructor(e){super(e)}static createEmptyProof(t){return new e({type:`accountProof`,info:mw.getDefaultInfo(UE,t),proof:{accounts:[]}})}static fromObject(t){return new e(R(dw,t))}addAccount(e){this.wrapper.proof.accounts.push(e)}getAccounts(){return this.wrapper.proof.accounts}},GE=1,KE=class e extends mw{constructor(e){super(e)}static createEmptyProof(t){return new e({type:`microblockProof`,info:mw.getDefaultInfo(GE,t),proof:{microblocks:[]}})}static fromObject(t){return new e(R(pw,t))}addMicroblock(e){this.wrapper.proof.microblocks.push(e)}getMicroblocks(){return this.wrapper.proof.microblocks}},qE=class{static importProof(e){switch(R(sw,e),e.type){case`accountProof`:return new WE(e);case`appLedgerProof`:return new gw(e);case`microblockProof`:return new KE(e)}}},JE=class e{log=k.getAbstractProviderLogger(e.name);async loadValidatorNodeVirtualBlockchain(e){let t=new CC(this);return await this.initializeVirtualBlockchain(t,e),t}async loadAccountVirtualBlockchain(e){this.log.debug(`Loading account virtual blockchain with id ${e.encode()}`);let t=new yC(this);return await this.initializeVirtualBlockchain(t,e),t}async loadApplicationLedgerVirtualBlockchain(e){let t=new Ew(this);return await this.initializeVirtualBlockchain(t,e),t}async loadApplicationVirtualBlockchain(e){let t=new xC(this);return await this.initializeVirtualBlockchain(t,e),t}async loadOrganizationVirtualBlockchain(e){let t=new _C(this);return await this.initializeVirtualBlockchain(t,e),t}async loadProtocolVirtualBlockchain(e){let t=new TC(this);return await this.initializeVirtualBlockchain(t,e),t}async loadVirtualBlockchain(e){let t=await this.getVirtualBlockchainState(e.toBytes());if(t===null)throw Error(`Virtual Blockchain with hash ${e.encode()} does not exist.`);let n=t.type;switch(n){case H.ACCOUNT_VIRTUAL_BLOCKCHAIN:return await this.loadAccountVirtualBlockchain(e);case H.ORGANIZATION_VIRTUAL_BLOCKCHAIN:return await this.loadOrganizationVirtualBlockchain(e);case H.APPLICATION_VIRTUAL_BLOCKCHAIN:return await this.loadApplicationVirtualBlockchain(e);case H.NODE_VIRTUAL_BLOCKCHAIN:return await this.loadValidatorNodeVirtualBlockchain(e);case H.PROTOCOL_VIRTUAL_BLOCKCHAIN:return await this.loadProtocolVirtualBlockchain(e);case H.APP_LEDGER_VIRTUAL_BLOCKCHAIN:return await this.loadApplicationLedgerVirtualBlockchain(e);default:throw Error(`Unknown virtual blockchain type: ${n}`)}}async loadMicroblockByMicroblockHash(e){this.log.info(`Loading microblock ${e.encode()}`);let t=await this.getMicroblockHeader(e),n=await this.getMicroblockBody(e);if(t===null||n===null)throw Error(`Microblock ${e.encode()} not found`);return dC.loadFromHeaderAndBody(t,n)}async getCurrentFeesFormula(){let e=(await this.getProtocolState()).getFeesCalculationVersion();return WS.getFeesCalculationFormulaByVersion(this,e)}async computeMicroblockGas(e,t={}){let n=t.referenceTimestampInSeconds??A.getTimestampInSeconds(),r=0;if(e.isGenesisMicroblock())r=dC.extractExpirationDayFromGenesisPreviousHash(e.getPreviousHash().toBytes());else{let t=await this.getVirtualBlockchainIdContainingMicroblock(e.getPreviousHash()),n=await this.getVirtualBlockchainState(t.toBytes());if(n===null)throw Error(`Virtual blockchain state not found`);r=n.expirationDay}let i=t.signatureSchemeId??e.getLastSignatureSection().schemeId;if(i===null)throw Error(`Signature scheme ID cannot be null`);return(await this.getCurrentFeesFormula()).computeGas(i,e,r,n)}async initializeVirtualBlockchain(e,t){let n=t.toBytes(),r=await this.getVirtualBlockchainStatus(n);if(r===null)throw new Se(t);if(r.type!==e.getType())throw Error(`Invalid blockchain type loaded`);e.setIdentifier(n),e.setHeight(r.height),e.setExpirationDay(r.expirationDay),e.setInternalState($S.createInternalStateFromObject(e.getType(),r.internalState))}},YE=class e{expirationDate;endless;constructor(e,t){this.expirationDate=e,this.endless=t}static endless(){return new e(Dw.none(),!0)}static of(t){return new e(Dw.of(t),!1)}static fromDurationInDays(t){let n=new Date;return n.setDate(n.getDate()+t),e.of(n)}isEndless(){return this.endless}getExpirationDate(){return this.expirationDate.unwrap()}},XE=class e{static logger=k.getMemoryProviderLogger();static instance=new e;static getInstance(){return this.instance}microblockHeaderStore;microblockBodyStore;microblockVbInformationStore;virtualBlockchainStateStore;constructor(){this.microblockHeaderStore=new Map,this.microblockBodyStore=new Map,this.microblockVbInformationStore=new Map,this.virtualBlockchainStateStore=new Map}clear(){e.logger.info(`Clearing`),this.microblockHeaderStore=new Map,this.microblockBodyStore=new Map,this.microblockVbInformationStore=new Map,this.virtualBlockchainStateStore=new Map}async getSerializedInformationOfVirtualBlockchainContainingMicroblock(t){let n=await e.get(this.microblockVbInformationStore,t);return e.logger.info(`getMicroblockVbInformation identifier=${A.binaryToHexa(t)} -> ${n?n.length:0} bytes`),n}async getInformationOfVirtualBlockchainContainingMicroblock(e){let t=await this.getSerializedInformationOfVirtualBlockchainContainingMicroblock(e);return t===null?null:X.decodeVirtualBlockchainInfo(t)}async getMicroblock(e){throw Error(`Method not implemented`)}async getMicroblockHeader(t){let n=await e.get(this.microblockHeaderStore,t);if(n===null)return e.logger.info(`Header not found locally: returning null`),null;{let r=X.decodeMicroblockHeader(n);return e.logger.info(`Header of microblock with identifier=${A.binaryToHexa(t)} found: {header}`,{header:r}),r}}async getSerializedMicroblockHeader(t){let n=await e.get(this.microblockHeaderStore,t);if(n===null)return e.logger.info(`Header not found locally: returning null`),null;{let r=Tp.Hashes.sha256(n),i=X.decodeMicroblockHeader(n);return e.logger.info(`Header of microblock with identifier (sha256:${r})=${A.binaryToHexa(t)} found: {header}`,{header:JSON.stringify(i)}),n}}async getMicroblockBody(t){let n=await e.get(this.microblockBodyStore,t);return e.logger.info(`getMicroblockBody identifier=${A.binaryToHexa(t)} -> ${n?n.length:0} bytes`),n}async getSerializedVirtualBlockchainState(t){let n=await e.get(this.virtualBlockchainStateStore,t);return e.logger.info(`getVirtualBlockchainState identifier=${A.binaryToHexa(t)} -> ${n?n.length:0} bytes`),n}async getAccountByPublicKeyHash(e){return null}async setMicroblockVbInformation(t,n){let r=X.decodeVirtualBlockchainInfo(n);return e.logger.info(`Store info of vb identifier=${A.binaryToHexa(t)}: {info}`,{info:r}),await e.set(this.microblockVbInformationStore,t,n)}async setSerializedMicroblockHeader(t,n){let r=X.decodeMicroblockHeader(n);return e.logger.info(`Store header of microblock identifier=${A.binaryToHexa(t)} -> {header}`,{header:r}),await e.set(this.microblockHeaderStore,t,n)}async setSerializedMicroblockBody(t,n){let r=X.decodeMicroblockBody(n);return e.logger.info(`Store body of microblock ${A.binaryToHexa(t)}: {body}`,{body:r}),await e.set(this.microblockBodyStore,t,n)}async setMicroblockHeader(e,t){let n=X.encodeMicroblockHeader(t);await this.setSerializedMicroblockHeader(e,n)}async setMicroblockBody(e,t){let n=X.encodeMicroblockBody(t);await this.setSerializedMicroblockBody(e,n)}async setSerializedVirtualBlockchainState(t,n){let r=X.decodeVirtualBlockchainState(n);return e.logger.info(`Store vb state for vb ${A.binaryToHexa(t)}: {state}`,{state:r}),await e.set(this.virtualBlockchainStateStore,t,n)}static async get(e,t){let n=A.binaryToHexa(t);if(!e.has(n))return null;let r=e.get(n);return r===void 0?null:A.binaryFromHexa(r)}static async set(t,n,r){let i=A.binaryToHexa(n),a=A.binaryToHexa(r),o=t.get(i);o===void 0?e.logger.info(`Storing new entry for key ${i}`):o===a?e.logger.info(`Storing the same data for the same key ${i}`):e.logger.info(`Storing new data for key ${i}`),t.set(i,a)}},ZE=F({jsonrpc:N(`2.0`),id:P(),result:F({node_info:F({protocol_version:F({p2p:L(),block:L(),app:L()}),id:L(),listen_addr:L(),network:L(),version:L(),channels:L(),moniker:L(),other:F({tx_index:L(),rpc_address:L()})}),sync_info:F({latest_block_hash:L(),latest_app_hash:L(),latest_block_height:L(),latest_block_time:L(),earliest_block_hash:L(),earliest_app_hash:L(),earliest_block_height:L(),earliest_block_time:L(),catching_up:Yp()}),validator_info:F({address:L(),pub_key:F({type:L(),value:L()}),voting_power:L()})})}),$=function(e){return e[e.GET_CHAIN_INFORMATION=1]=`GET_CHAIN_INFORMATION`,e[e.GET_BLOCK_INFORMATION=3]=`GET_BLOCK_INFORMATION`,e[e.GET_BLOCK_CONTENT=5]=`GET_BLOCK_CONTENT`,e[e.GET_VIRTUAL_BLOCKCHAIN_STATE=7]=`GET_VIRTUAL_BLOCKCHAIN_STATE`,e[e.GET_VIRTUAL_BLOCKCHAIN_UPDATE=9]=`GET_VIRTUAL_BLOCKCHAIN_UPDATE`,e[e.GET_MICROBLOCK_INFORMATION=11]=`GET_MICROBLOCK_INFORMATION`,e[e.AWAIT_MICROBLOCK_ANCHORING=13]=`AWAIT_MICROBLOCK_ANCHORING`,e[e.GET_MICROBLOCK_BODYS=15]=`GET_MICROBLOCK_BODYS`,e[e.GET_ACCOUNT_STATE=17]=`GET_ACCOUNT_STATE`,e[e.GET_ACCOUNT_HISTORY=19]=`GET_ACCOUNT_HISTORY`,e[e.GET_ACCOUNT_BY_PUBLIC_KEY_HASH=21]=`GET_ACCOUNT_BY_PUBLIC_KEY_HASH`,e[e.GET_VALIDATOR_NODE_BY_ADDRESS=23]=`GET_VALIDATOR_NODE_BY_ADDRESS`,e[e.GET_OBJECT_LIST=25]=`GET_OBJECT_LIST`,e[e.GET_GENESIS_SNAPSHOT=27]=`GET_GENESIS_SNAPSHOT`,e[e.GET_RAW_BLOCK_CONTENT=29]=`GET_RAW_BLOCK_CONTENT`,e[e.GET_BLOCK_MODIFIED_ACCOUNTS=31]=`GET_BLOCK_MODIFIED_ACCOUNTS`,e[e.GET_ACCOUNT_UPDATES=33]=`GET_ACCOUNT_UPDATES`,e[e.GET_MICROBLOCK_INFORMATION_BY_HEIGHT=35]=`GET_MICROBLOCK_INFORMATION_BY_HEIGHT`,e[e.GET_SERIALIZED_MICROBLOCK_BY_HEIGHT=37]=`GET_SERIALIZED_MICROBLOCK_BY_HEIGHT`,e[e.GET_MICROBLOCK_PROOF=39]=`GET_MICROBLOCK_PROOF`,e[e.GET_ACCOUNT_PROOF=41]=`GET_ACCOUNT_PROOF`,e}({}),QE=F({requestType:N($.GET_CHAIN_INFORMATION)}),$E=F({requestType:N($.GET_BLOCK_INFORMATION),height:z(P(),Bp(),Wp(0))}),eD=F({requestType:N($.GET_BLOCK_CONTENT),height:z(P(),Bp(),Wp(0))}),tD=F({requestType:N($.GET_VIRTUAL_BLOCKCHAIN_STATE),virtualBlockchainId:Rm()}),nD=F({requestType:N($.GET_VIRTUAL_BLOCKCHAIN_UPDATE),virtualBlockchainId:Rm(),knownStateHash:Rm()}),rD=F({requestType:N($.GET_MICROBLOCK_INFORMATION),hash:Rm()}),iD=F({requestType:N($.AWAIT_MICROBLOCK_ANCHORING),hash:Rm()}),aD=F({requestType:N($.GET_MICROBLOCK_BODYS),hashes:M(Rm())}),oD=F({requestType:N($.GET_ACCOUNT_STATE),accountHash:Rm()}),sD=F({requestType:N($.GET_ACCOUNT_HISTORY),accountHash:Rm(),lastHistoryHash:Rm(),maxRecords:z(P(),Bp(),Wp(1))}),cD=F({requestType:N($.GET_ACCOUNT_BY_PUBLIC_KEY_HASH),publicKeyHash:Rm()}),lD=F({requestType:N($.GET_VALIDATOR_NODE_BY_ADDRESS),address:B()}),uD=F({requestType:N($.GET_GENESIS_SNAPSHOT)}),dD=F({requestType:N($.GET_RAW_BLOCK_CONTENT),height:z(P(),Bp(),Wp(0)),partIndex:z(P(),Bp(),Wp(0))}),fD=F({requestType:N($.GET_BLOCK_MODIFIED_ACCOUNTS),height:z(P(),Bp(),Wp(0))}),pD=F({requestType:N($.GET_ACCOUNT_UPDATES),list:M(yg)}),mD=F({requestType:N($.GET_MICROBLOCK_INFORMATION_BY_HEIGHT),virtualBlockchainId:Rm(),height:P()}),hD=F({requestType:N($.GET_SERIALIZED_MICROBLOCK_BY_HEIGHT),virtualBlockchainId:Rm(),height:P()}),gD=F({requestType:N($.GET_MICROBLOCK_PROOF),hash:Rm()}),_D=F({requestType:N($.GET_ACCOUNT_PROOF),accountId:Rm()}),vD=dm(`requestType`,[QE,$E,eD,tD,nD,rD,iD,aD,oD,sD,cD,lD,uD,dD,fD,pD,mD,hD,gD,_D]),yD=function(e){return e[e.ERROR=0]=`ERROR`,e[e.CHAIN_INFORMATION=2]=`CHAIN_INFORMATION`,e[e.BLOCK_INFORMATION=4]=`BLOCK_INFORMATION`,e[e.BLOCK_CONTENT=6]=`BLOCK_CONTENT`,e[e.VIRTUAL_BLOCKCHAIN_STATE=8]=`VIRTUAL_BLOCKCHAIN_STATE`,e[e.VIRTUAL_BLOCKCHAIN_UPDATE=10]=`VIRTUAL_BLOCKCHAIN_UPDATE`,e[e.MICROBLOCK_INFORMATION=12]=`MICROBLOCK_INFORMATION`,e[e.MICROBLOCK_ANCHORING=14]=`MICROBLOCK_ANCHORING`,e[e.MICROBLOCK_BODYS=16]=`MICROBLOCK_BODYS`,e[e.ACCOUNT_STATE=18]=`ACCOUNT_STATE`,e[e.ACCOUNT_HISTORY=20]=`ACCOUNT_HISTORY`,e[e.ACCOUNT_BY_PUBLIC_KEY_HASH=22]=`ACCOUNT_BY_PUBLIC_KEY_HASH`,e[e.VALIDATOR_NODE_BY_ADDRESS=24]=`VALIDATOR_NODE_BY_ADDRESS`,e[e.OBJECT_LIST=26]=`OBJECT_LIST`,e[e.GENESIS_SNAPSHOT=28]=`GENESIS_SNAPSHOT`,e[e.RAW_BLOCK_CONTENT=30]=`RAW_BLOCK_CONTENT`,e[e.BLOCK_MODIFIED_ACCOUNTS=32]=`BLOCK_MODIFIED_ACCOUNTS`,e[e.ACCOUNT_UPDATES=34]=`ACCOUNT_UPDATES`,e[e.SERIALIAZED_MICROBLOCK_BY_HEIGHT=38]=`SERIALIAZED_MICROBLOCK_BY_HEIGHT`,e[e.MICROBLOCK_PROOF=40]=`MICROBLOCK_PROOF`,e[e.ACCOUNT_PROOF=42]=`ACCOUNT_PROOF`,e}({}),bD=F({responseType:N(yD.ERROR),error:L()}),xD=F({responseType:N(yD.CHAIN_INFORMATION),height:z(P(),Bp(),Wp(0)),lastBlockTimestamp:z(P(),Bp(),Wp(0)),microblockCount:z(P(),Bp(),Wp(0)),objectCounts:M(z(P(),Bp(),Wp(0))),protocolVirtualBlockchainId:B()}),SD=F({responseType:N(yD.BLOCK_INFORMATION),hash:Rm(),timestamp:z(P(),Bp(),Wp(0)),proposerAddress:B(),applicationStateHashes:F({vbRadixHash:B(),tokenRadixHash:B(),radixHash:B(),storageHash:B(),appHash:B()}),size:z(P(),Bp(),Wp(0)),microblockCount:z(P(),Bp(),Wp(0))}),CD=F({hash:Rm(),vbId:Rm(),vbType:z(P(),Bp(),Wp(0),Hp(255)),height:z(P(),Bp(),Wp(0)),size:z(P(),Bp(),Wp(0)),sectionCount:z(P(),Bp(),Wp(0))}),wD=F({responseType:N(yD.BLOCK_CONTENT),microblocks:M(CD)}),TD=F({responseType:N(yD.VIRTUAL_BLOCKCHAIN_STATE),serializedVirtualBlockchainState:B()}),ED=F({responseType:N(yD.VIRTUAL_BLOCKCHAIN_UPDATE),exists:Yp(),changed:Yp(),serializedVirtualBlockchainState:B()}),DD=F({responseType:N(yD.MICROBLOCK_INFORMATION),...$h.entries}),OD=F({responseType:N(yD.MICROBLOCK_ANCHORING),...$h.entries}),kD=F({microblockHash:Rm(),microblockBody:Nh}),AD=F({responseType:N(yD.MICROBLOCK_BODYS),list:M(kD)}),jD=F({responseType:N(yD.ACCOUNT_STATE),height:z(P(),Bp(),Wp(0)),balance:z(P(),Bp(),Wp(0)),lastHistoryHash:Rm(),locks:M(pg)}),MD=F({responseType:N(yD.ACCOUNT_HISTORY),list:vg}),ND=F({responseType:N(yD.ACCOUNT_BY_PUBLIC_KEY_HASH),accountHash:Rm()}),PD=F({responseType:N(yD.VALIDATOR_NODE_BY_ADDRESS),validatorNodeHash:Rm()}),FD=F({responseType:N(yD.GENESIS_SNAPSHOT),base64EncodedChunks:M(L())}),ID=F({responseType:N(yD.RAW_BLOCK_CONTENT),partIndex:P(),numberOfParts:P(),serializedMicroblocks:M(B())}),LD=F({responseType:N(yD.BLOCK_MODIFIED_ACCOUNTS),modifiedAccounts:M(B())}),RD=F({responseType:N(yD.ACCOUNT_UPDATES),list:M(bg)}),zD=F({responseType:N(yD.SERIALIAZED_MICROBLOCK_BY_HEIGHT),serializedContent:B()}),BD=F({responseType:N(yD.MICROBLOCK_PROOF),proof:YC}),VD=F({responseType:N(yD.ACCOUNT_PROOF),proof:KC}),HD=dm(`responseType`,[bD,xD,SD,wD,ID,TD,ED,DD,OD,AD,jD,MD,ND,PD,FD,LD,RD,zD,BD,VD]),UD=class{static encodeAbciRequest(e){return Rx(R(vD,e))}static decodeAbciRequest(e){return R(vD,sx(e))}static encodeAbciResponse(e){return Rx(R(HD,e))}static decodeAbciResponse(e){return R(HD,sx(e))}},WD=class e{static staticLogger=k.getNetworkProviderLogger();logger=e.staticLogger;requestLogger=e.staticLogger.getChild(`request`);responseLogger=e.staticLogger.getChild(`response`);chainId=``;static createFromUrl(t){e.staticLogger.debug(`NetworkProvider constructor -> nodeUrl: ${t}`);try{return new URL(t),new e(t)}catch{throw new i(`Invalid node URL: got ${t}`)}}constructor(e){this.nodeUrl=e}async getChainId(){if(this.chainId===``){let t=new URL(this.nodeUrl);t.pathname=`status`,this.chainId=(await e.query(t))?.result?.node_info?.network??``}return this.chainId}async sendSerializedMicroblock(e){this.requestLogger.info(`Sending serialized microblock (${e.length} bytes)`);let t=await this.broadcastTx(e);return this.responseLogger.info(`Received response: <- {data}`,()=>({data:t?.data})),t}async awaitMicroblockAnchoring(e){let t=A.binaryToHexa(e);return this.requestLogger.info(`Awaiting microblock {hash} to be published...`,()=>({hash:t})),R($h,await this.abciQuery({requestType:$.AWAIT_MICROBLOCK_ANCHORING,hash:e}))}async getChainInformation(){return this.requestLogger.info(`Requesting chain information`),R(xD,await this.abciQuery({requestType:$.GET_CHAIN_INFORMATION}))}async getBlockInformation(e){this.requestLogger.info(`Requesting block information at height: ${e}`);let t=await this.abciQuery({requestType:$.GET_BLOCK_INFORMATION,height:e});return this.responseLogger.info(`Received block information at height ${e}`),R(SD,t)}async getBlockContent(e){this.requestLogger.info(`Requesting block content for height ${e}`);let t=R(wD,await this.abciQuery({requestType:$.GET_BLOCK_CONTENT,height:e}));return this.responseLogger.info(`Received block content for height ${e}: ${t.microblocks.length} microblocks received`),t}async getValidatorNodeByAddress(e){this.requestLogger.info(`Requesting validator node id for address {address}`,()=>({address:A.binaryToHexa(e)}));let t=await this.abciQuery({requestType:$.GET_VALIDATOR_NODE_BY_ADDRESS,address:e});return this.responseLogger.info(`Receiving validator node id {id}`,()=>({id:A.binaryToHexa(e)})),R(PD,t)}async getAccountState(e){this.requestLogger.info(`Requesting account state for account hash {accountHash}`,()=>({accountHash:A.binaryToHexa(e)}));let t=R(jD,await this.abciQuery({requestType:$.GET_ACCOUNT_STATE,accountHash:e}));return this.responseLogger.info(`Receiving account state: height={height}, balance={balance}`,()=>({height:t.height,balance:hn.createAtomic(t.balance).toString()})),t}async getAccountHistory(e,t,n){this.requestLogger.info(`Requesting account history for account hash: ${A.binaryToHexa(e)}, lastHistoryHash: ${A.binaryToHexa(t)}, maxRecords: ${n}`);let r=R(MD,await this.abciQuery({requestType:$.GET_ACCOUNT_HISTORY,accountHash:e,lastHistoryHash:t,maxRecords:n}));return this.responseLogger.info(`Receiving account history with ${r.list.length} entries`),r}async getAccountByPublicKeyHash(e){this.requestLogger.info(`Requesting account hash by public key hash: ${A.binaryToHexa(e)}`);let t=R(ND,await this.abciQuery({requestType:$.GET_ACCOUNT_BY_PUBLIC_KEY_HASH,publicKeyHash:e}));return this.responseLogger.info(`Received account hash {accountHash}`,()=>({accountHash:A.binaryToHexa(t.accountHash)})),t}async getMicroblockInformation(e){this.requestLogger.info(`Requesting microblock information for hash ${A.binaryToHexa(e)}`);let t=R(DD,await this.abciQuery({requestType:$.GET_MICROBLOCK_INFORMATION,hash:e}));return this.responseLogger.info(`Received microblock information: vbType={vbType}, vbId={vbId}`,()=>({vbType:t.virtualBlockchainType,vbId:A.binaryToHexa(t.virtualBlockchainId)})),this.logger.info(`Received microblock information body hash for microblock ${A.binaryToHexa(e)}: ${A.binaryToHexa(t.header.bodyHash)}`),R($h,t)}async getSerializedMicroblockByHeight(e,t){this.requestLogger.info(`Requesting microblock for VB ${A.binaryToHexa(e)} at height ${t}`);let n=R(zD,await this.abciQuery({requestType:$.GET_SERIALIZED_MICROBLOCK_BY_HEIGHT,virtualBlockchainId:e,height:t}));return this.responseLogger.info(`Received microblock - size: ${n.serializedContent.length} bytes`),n.serializedContent}async getMicroblockBodys(e){this.requestLogger.info(`Requesting microblock bodys for microblock hashes ${e.length}`),this.requestLogger.info(`Lisf of requested hashes: {hashes}`,()=>({hashes:e.map(e=>A.binaryToHexa(e)).join(`, `)}));let t=R(AD,await this.abciQuery({requestType:$.GET_MICROBLOCK_BODYS,hashes:e}));return this.responseLogger.info(`Returned number of microblock bodys: ${t.list.length}`),t}async getVirtualBlockchainUpdate(e,t){this.requestLogger.info(`Request virtual blockchain update for virtualBlockchainId: ${A.binaryToHexa(e)}`);let n=await this.abciQuery({requestType:$.GET_VIRTUAL_BLOCKCHAIN_UPDATE,virtualBlockchainId:e,knownStateHash:t});return this.responseLogger.info(`Receiving virtual blockchain update`),R(ED,n)}async getSerializedVirtualBlockchainState(e){this.requestLogger.info(`Requesting virtual blockchain state for vb id {vbId}`,()=>({vbId:A.binaryToHexa(e)}));let t=R(TD,await this.abciQuery({requestType:$.GET_VIRTUAL_BLOCKCHAIN_STATE,virtualBlockchainId:e}));return this.responseLogger.info(`Receiving virtual blockchain state: ${t.serializedVirtualBlockchainState.length} bytes`),t.serializedVirtualBlockchainState}static async query(e,t={},n=1e4){let r=new AbortController,i=setTimeout(()=>r.abort(),n);try{let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json; charset=UTF-8`,Accept:`application/json`},body:JSON.stringify(t),signal:r.signal});if(n.status===500)throw console.error(n),new h(`Internal error in the node: ${n.statusText}`);if(!n.ok)throw Error(`HTTP ${n.status}`);return await n.json()}catch(t){throw t?.name===`AbortError`?new h(`Request timeout after ${n}ms`):t?.cause?.code===`ECONNREFUSED`||t?.code===`ECONNREFUSED`||t instanceof TypeError?new g(e):t}finally{clearTimeout(i)}}async broadcastTx(t){let n=new URL(this.nodeUrl);this.logger.info(`broadcastTx -> ${t.length} bytes to ${this.nodeUrl}`);let r=Og.bytesToBase64Encoder();return await e.query(n,{jsonrpc:`2.0`,id:1,method:`broadcast_tx_sync`,params:{tx:r.encode(t)}})}async abciQuery(t){if(t===void 0)throw new i(`Cannot send an undefined request`);this.logger.debug(`Sending ABCI request:`,t);let n=UD.encodeAbciRequest(t);return await e.sendABCIQueryToNodeServer(this.nodeUrl,n)}static async sendABCIQueryToNodeServer(t,n){e.staticLogger.debug(`Sending ABCI Query to node server at ${t} (${n.length} bytes) `);let r=new URL(t);r.pathname=`abci_query`,r.searchParams.append(`path`,`"/carmentis"`),r.searchParams.append(`data`,`0x`+A.binaryToHexa(n));let i=await e.query(r),a=i?.result?.response?.value;if(typeof a!=`string`)throw this.staticLogger.error(`Invalid response type detected:`,i),this.staticLogger.error(`rawBase64EncodedResponse: `,a),new h(`Invalid response detected`);let o=Cg.decodeBinary(a),s=UD.decodeAbciResponse(o);if(s.responseType==yD.ERROR){let t=s.error;throw e.staticLogger.error(`sendABCIQueryToNodeServer <- {*}`,()=>({error:t})),new h(`Remote error: ${t}`)}return e.staticLogger.debug(`Returning ABCI response`),s}static async sendStatusQueryToNodeServer(t){e.staticLogger.debug(`sendStatusQueryToNodeServer -> nodeUrl: ${t}`);let n=new URL(t);n.pathname=`status`;let r=fm(ZE,await e.query(n));if(r.success)return e.staticLogger.debug(`sendStatusQueryToNodeServer <- received valid status response`),r.output;throw e.staticLogger.debug(`sendStatusQueryToNodeServer <- parsing error: ${r.issues}`),new h(r.issues.map(e=>e.message).join(`, `))}async getGenesisSnapshot(){this.requestLogger.info(`Requesting genesis snapshot`);let e=R(FD,await this.abciQuery({requestType:$.GET_GENESIS_SNAPSHOT}));return this.responseLogger.info(`Received genesis snapshots containing {chunksNumber} chunks`,()=>({chunksNumber:e.base64EncodedChunks.length})),e}},GD=class e{static logger=k.getMemoryProviderLogger();static instance=new e;static getInstance(){return this.instance}constructor(){}clear(){e.logger.info(`Clearing`)}async getSerializedInformationOfVirtualBlockchainContainingMicroblock(e){return null}async getInformationOfVirtualBlockchainContainingMicroblock(e){return null}async getMicroblock(e){throw Error(`Method not implemented`)}async getMicroblockHeader(e){return null}async getSerializedMicroblockHeader(e){return null}async getMicroblockBody(e){return null}async getSerializedVirtualBlockchainState(e){return null}async getAccountByPublicKeyHash(e){return null}async setMicroblockVbInformation(e,t){}async setSerializedMicroblockHeader(e,t){}async setSerializedMicroblockBody(e,t){}async setMicroblockHeader(e,t){}async setMicroblockBody(e,t){}async setSerializedVirtualBlockchainState(e,t){}},KD=class{constructor(){}getChainId(){throw Error(`Method not implemented.`)}sendSerializedMicroblock(e){throw Error(`Method not implemented.`)}awaitMicroblockAnchoring(e){throw Error(`Method not implemented.`)}getChainInformation(){throw Error(`Method not implemented.`)}getBlockInformation(e){throw Error(`Method not implemented.`)}getBlockContent(e){throw Error(`Method not implemented.`)}getValidatorNodeByAddress(e){throw Error(`Method not implemented.`)}getAccountState(e){throw Error(`Method not implemented.`)}getAccountHistory(e,t,n){throw Error(`Method not implemented.`)}getAccountByPublicKeyHash(e){throw Error(`Method not implemented.`)}getMicroblockInformation(e){return Promise.resolve(null)}getSerializedMicroblockByHeight(e,t){return Promise.resolve(null)}getMicroblockBodys(e){return Promise.resolve(null)}getVirtualBlockchainUpdate(e){throw Error(`Method not implemented.`)}getSerializedVirtualBlockchainState(e){throw Error(`Method not implemented.`)}broadcastTx(e){throw Error(`Method not implemented.`)}abciQuery(e){throw Error(`Method not implemented.`)}getGenesisSnapshot(){throw Error(`Method not implemented.`)}},qD=class{static convertRawPublicKeyIntoAddress(e){return Qc.sha256AsBinary(e).slice(0,20)}},JD=class e extends JE{logger=k.getProviderLogger();externalProvider;internalProvider;constructor(e,t){super(),this.internalProvider=e,this.externalProvider=t}async awaitMicroblockAnchoring(e){return await this.externalProvider.awaitMicroblockAnchoring(e)}async getChainId(){return await this.externalProvider.getChainId()}async getChainInformation(){return await this.externalProvider.getChainInformation()}async getGenesisSnapshot(){return await this.externalProvider.getGenesisSnapshot()}async getBlockInformation(e){return await this.externalProvider.getBlockInformation(e)}async getBlockContent(e){return await this.externalProvider.getBlockContent(e)}async getAccountState(e){return await this.externalProvider.getAccountState(e)}async getAccountHistory(e,t,n){return await this.externalProvider.getAccountHistory(e,t,n)}async getAccountByPublicKeyHash(t){let n=await this.internalProvider.getAccountByPublicKeyHash(t);if(n!==null)return n;let r=await this.externalProvider.getAccountByPublicKeyHash(t);return k.getLogger([e.name]).debug(`Account hash ${r} is associated to public key hash ${t}`),r.accountHash}async getVirtualBlockchainState(e){this.logger.info(`Getting state for virtual blockchain ${A.binaryToHexa(e)}`);let t=await this.internalProvider.getSerializedVirtualBlockchainState(e);if(t!==null)return this.logger.info(`State for virtual blockchain ${A.binaryToHexa(e)} found locally`),X.decodeVirtualBlockchainState(t);{let t=await this.externalProvider.getSerializedVirtualBlockchainState(e);return t?(this.logger.info(`State for virtual blockchain ${A.binaryToHexa(e)} found remotely`),await this.internalProvider.setSerializedVirtualBlockchainState(e,t),X.decodeVirtualBlockchainState(t)):null}}async getAccountIdByPublicKey(e){let t=await e.getPublicKeyAsBytes(),n=Tp.Hashes.sha256AsBinary(t);return await this.getAccountByPublicKeyHash(n)}async getProtocolState(){let e=await this.getProtocolVirtualBlockchainId(),t=await this.getVirtualBlockchainState(e.toBytes());if(t===null)throw Error(`Cannot get protocol parameters from the internal provider`);if(t.type!==H.PROTOCOL_VIRTUAL_BLOCKCHAIN)throw Error(`Expected protocol virtual blockchain, got ${H[t.type]}`);return XS.createFromObject(t.internalState)}async getProtocolVirtualBlockchainId(){let e=await this.getChainInformation();return KS.from(e.protocolVirtualBlockchainId)}async getMicroblockInformation(e){let t=await this.internalProvider.getInformationOfVirtualBlockchainContainingMicroblock(e),n=await this.internalProvider.getMicroblockHeader(e);if(t&&n)return{...t,header:n};let r=await this.externalProvider.getMicroblockInformation(e);if(r){let t=X.encodeVirtualBlockchainInfo({virtualBlockchainId:r.virtualBlockchainId,virtualBlockchainType:r.virtualBlockchainType});return await this.internalProvider.setMicroblockVbInformation(e,t),await this.internalProvider.setMicroblockHeader(e,r.header),r}return null}async getListOfMicroblockBody(e){let t=[],n=[],r=0;for(let i of e){let e=await this.internalProvider.getMicroblockBody(i);if(e){let n=X.decodeMicroblockBody(e);t.push({hash:i,body:n})}else n.push(i);r+=1}if(n.length){let r=await this.externalProvider.getMicroblockBodys(n);if(r===null)throw Error(`Unable to load microblock bodies`);for(let{microblockBody:e,microblockHash:n}of r.list){let r=X.encodeMicroblockBody(e);await this.internalProvider.setSerializedMicroblockBody(n,r),t.push({hash:n,body:e})}t.sort((t,n)=>e.indexOf(t.hash)-e.indexOf(n.hash))}return t.map(e=>e.body)}async getMicroblockBody(e){this.logger.info(`Looking for body for microblock ${e.encode()}`);let t=await this.internalProvider.getMicroblockBody(e.toBytes());if(t instanceof Uint8Array)return this.logger.info(`Body for microblock ${e.encode()} found locally`),X.decodeMicroblockBody(t);{let t=await this.externalProvider.getMicroblockBodys([e.toBytes()]);if(t!==null&&t.list.length!==0){let n=t.list[0].microblockBody;return await this.internalProvider.setMicroblockBody(e.toBytes(),n),this.logger.info(`Body for microblock ${e.encode()} found remotely`),n}}return this.logger.warning(`Body for microblock ${e.encode()} not found`),null}async getMicroblockHeader(e){this.logger.info(`Looking for header for microblock ${e.encode()}`);let t=await this.internalProvider.getSerializedMicroblockHeader(e.toBytes());if(t instanceof Uint8Array){let n=Tp.Hashes.sha256(t),r=X.decodeMicroblockHeader(t);return this.logger.info(`Header for microblock ${e.encode()} found locally (sha256:${n}): {header}`,{header:JSON.stringify(r)}),r}let n=await this.externalProvider.getMicroblockInformation(e.toBytes());if(n!==null)return this.logger.info(`Header for microblock ${e.encode()} found remotely: {header}:`,{header:n.header}),n.header;throw new te}async getSerializedMicroblockByHeight(e,t){let n=await this.externalProvider.getSerializedMicroblockByHeight(e,t);if(n!==null)return this.logger.info(`Microblock found remotely`),n;throw new te}async getVirtualBlockchainIdContainingMicroblock(e){this.logger.info(`Searching for virtual blockchain containing microblock ${e.encode()}`);let t=await this.internalProvider.getInformationOfVirtualBlockchainContainingMicroblock(e.toBytes());if(t!==null)return KS.from(t.virtualBlockchainId);{let t=await this.externalProvider.getMicroblockInformation(e.toBytes());if(t!==null)return KS.from(t.virtualBlockchainId);throw new te}}async getVirtualBlockchainStatus(e){let t=null,n=A.getNullHash(),r=await this.internalProvider.getSerializedVirtualBlockchainState(e);r!==null&&(t=X.decodeVirtualBlockchainState(r),n=Jx.createDefaultCryptographicHash().hash(r));let i=await this.externalProvider.getVirtualBlockchainUpdate(e,n);return i.exists?(i.changed&&(await this.internalProvider.setSerializedVirtualBlockchainState(e,i.serializedVirtualBlockchainState),t=X.decodeVirtualBlockchainState(i.serializedVirtualBlockchainState)),t):null}async getAccountIdFromPublicKey(e){let t=new yv,n=await this.externalProvider.getAccountByPublicKeyHash(t.hash(await e.getPublicKeyAsBytes()));return KS.from(n.accountHash)}async publishMicroblock(e){this.logger.info(`Publishing microblock ${e.getHash().encode()}`);let{microblockData:t}=e.serialize();return await this.externalProvider.sendSerializedMicroblock(t),e.getHash()}async getNodeStatus(e){return WD.sendStatusQueryToNodeServer(e)}async getValidatorNodeIdByAddress(e){return(await this.externalProvider.getValidatorNodeByAddress(e.toBytes())).validatorNodeHash}async getValidatorNodeIdByCometbftPublicKey(e){let t=Og.bytesToBase64Encoder(),n=qD.convertRawPublicKeyIntoAddress(t.decode(e));return this.getValidatorNodeIdByAddress(KS.from(n))}},YD=class{static createInMemoryProvider(){return new JD(new XE,new KD)}static createInMemoryProviderWithExternalProvider(e){return new JD(new XE,WD.createFromUrl(e))}static createNullInMemoryProviderWithExternalProvider(e){return new JD(new GD,WD.createFromUrl(e))}},XD=class extends WD{constructor(e){super(e)}},ZD=F({jsonrpc:N(`2.0`),id:P(),result:F({query:L(),data:F({type:N(`tendermint/event/NewBlock`),value:F({block:F({header:F({version:F({block:L(),app:I(L())}),chain_id:L(),height:L(),time:L(),last_block_id:F({hash:L(),parts:F({total:P(),hash:L()})}),last_commit_hash:L(),data_hash:L(),validators_hash:L(),next_validators_hash:L(),consensus_hash:L(),app_hash:L(),last_results_hash:L(),evidence_hash:L(),proposer_address:L()}),data:F({txs:M(L())}),evidence:F({evidence:M(Jp())}),last_commit:F({height:L(),round:P(),block_id:F({hash:L(),parts:F({total:P(),hash:L()})}),signatures:M(F({block_id_flag:P(),validator_address:L(),timestamp:L(),signature:L()}))})}),block_id:F({hash:L(),parts:F({total:P(),hash:L()})}),result_finalize_block:F({validator_updates:I(lm([rm(),Jp()])),app_hash:L()})})}),events:F({"tm.event":M(L())})})}),QD=class e{callbacks=[];constructor(e){this.ws=e,e.onmessage=this.onMessage.bind(this),e.onopen=this.onConnect.bind(this),e.onclose=this.onDisconnect.bind(this)}static new(t){return new e(new WebSocket(t))}addCallback(e){this.callbacks.push(e)}onConnect(e){this.ws.send(JSON.stringify({jsonrpc:`2.0`,method:`subscribe`,id:1,params:{query:`tm.event='NewBlock'`}}))}onMessage(e){let t=fm(ZD,JSON.parse(e.data));if(t.success){let e=t.output;this.onNewBlock(e)}}onNewBlock(e){for(let t of this.callbacks)t.onNewBlock&&t.onNewBlock(e)}onDisconnect(e){}},$D=F({x509Base64Der:L()}),eO=class e{static fromObject(t){return new e(R($D,t))}constructor(e){this.certificateTag=e}getX509Base64Der(){return this.certificateTag.x509Base64Der}},tO=class{constructor(e){this.transaction=e}getHeight(){return this.transaction.height}getPreviousHistoryHash(){return KS.from(this.transaction.previousHistoryHash)}getTimestamp(){return this.transaction.timestamp}transferredAt(){return new Date(this.transaction.timestamp*1e3)}getLinkedAccount(){return KS.from(this.transaction.linkedAccount)}getAmount(){let e=this.isPositive()?1:-1;return hn.createAtomic(this.transaction.amount*e)}getChainReference(){return this.transaction.chainReference}isPositive(){return!!(this.transaction.type&1)}isNegative(){return!this.isPositive()}isEarnedFees(){return this.isEarnedBlockFees()||this.isEarnedTxFees()}isEarnedBlockFees(){return this.transaction.type===3}isEarnedTxFees(){return this.transaction.type===1}isPaidBlockFees(){return this.transaction.type===2}isPaidTxFees(){return this.transaction.type===0}isReceivedIssuance(){return this.transaction.type===5}isSentIssuance(){return this.transaction.type===4}isSale(){return this.transaction.type==6}isSentPayment(){return this.transaction.type==8}isPaidFees(){return this.isPaidBlockFees()||this.isPaidTxFees()}isPurchase(){return this.transaction.type==7}isReceivedPayment(){return this.transaction.type==9}},nO=class{transactionByHeight;constructor(){this.transactionByHeight=new Map}setTransactionAtHeight(e,t){this.transactionByHeight.set(e,t)}containsTransactions(){return this.transactionByHeight.size>0}getTransactionHeights(){return Array.from(this.transactionByHeight.keys())}getAllTransactions(){return Array.from(this.transactionByHeight.values()).map(e=>new tO(e))}getNumberOfTransactions(){return this.transactionByHeight.size}containsTransactionAtHeight(e){return this.transactionByHeight.has(e)}getTransactionAtHeight(e){let t=this.transactionByHeight.get(e);if(t===void 0)throw new i(`No transaction found at height ${e}`);return new tO(t)}},rO={[H.PROTOCOL_VIRTUAL_BLOCKCHAIN]:`PROTOCOL_VIRTUAL_BLOCKCHAIN`,[H.NODE_VIRTUAL_BLOCKCHAIN]:`NODE_VIRTUAL_BLOCKCHAIN`,[H.APPLICATION_VIRTUAL_BLOCKCHAIN]:`APPLICATION_VIRTUAL_BLOCKCHAIN`,[H.ORGANIZATION_VIRTUAL_BLOCKCHAIN]:`ORGANIZATION_VIRTUAL_BLOCKCHAIN`,[H.APP_LEDGER_VIRTUAL_BLOCKCHAIN]:`APP_LEDGER_VIRTUAL_BLOCKCHAIN`,[H.ACCOUNT_VIRTUAL_BLOCKCHAIN]:`ACCOUNT_VIRTUAL_BLOCKCHAIN`},iO=class{static getVirtualBlockchainLabelFromVirtualBlockchainType(e){return rO[e]}},aO=aE,oO=function(e){return e.AUTH_BY_PUBLIC_KEY=`WALLET_REQUEST_AUTH_BY_PUBLIC_KEY`,e.DATA_APPROVAL=`WALLET_REQUEST_DATA_APPROVAL`,e}({}),sO=function(e){return e.AUTH_BY_PUBLIC_KEY=`WALLET_RESPONSE_AUTH_BY_PUBLIC_KEY`,e.DATA_APPROVAL=`WALLET_RESPONSE_DATA_APPROVAL`,e}({}),cO=F({type:N(oO.AUTH_BY_PUBLIC_KEY),base64EncodedChallenge:L()}),lO=F({type:N(oO.DATA_APPROVAL),anchorRequestId:L(),serverUrl:L()}),uO=dm(`type`,[cO,lO]),dO=F({type:N(sO.AUTH_BY_PUBLIC_KEY),publicKey:L(),signature:L()}),fO=F({type:N(sO.DATA_APPROVAL),b64VbHash:L(),b64MbHash:L(),height:P()}),pO=dm(`type`,[dO,fO]),mO=100,hO=function(e){return e.REQUEST=`CLIENT_BRIDGE_REQUEST`,e.UPDATE_QR=`CLIENT_BRIDGE_UPDATE_QR`,e.CONNECTION_TOKEN=`CLIENT_BRIDGE_CONNECTION_TOKEN`,e.FORWARDED_ANSWER=`CLIENT_BRIDGE_FORWARDED_ANSWER`,e.GET_CONNECTION_INFO=`CLIENT_BRIDGE_GET_CONNECTION_INFO`,e.ANSWER=`CLIENT_BRIDGE_ANSWER`,e.CONNECTION_INFO=`CLIENT_BRIDGE_CONNECTION_INFO`,e.CONNECTION_ACCEPTED=`CLIENT_BRIDGE_CONNECTION_ACCEPTED`,e.FORWARDED_REQUEST=`CLIENT_BRIDGE_FORWARDED_REQUEST`,e.ERROR=`CLIENT_BRIDGE_ERROR`,e}({}),gO=F({base64EncodedQrId:L(),timestamp:P(),serverUrl:z(L(),Vp(100))}),_O=F({type:N(hO.REQUEST),walletRequest:uO,deviceId:Rm(),withToken:P()}),vO=F({type:N(hO.UPDATE_QR),base64EncodedQrId:L(),timestamp:P()}),yO=F({type:N(hO.CONNECTION_TOKEN),token:Rm()}),bO=F({type:N(hO.FORWARDED_ANSWER),walletResponse:pO}),xO=F({type:N(hO.GET_CONNECTION_INFO),base64EncodedQrId:L()}),SO=F({type:N(hO.ANSWER),walletResponse:pO}),CO=F({type:N(hO.CONNECTION_INFO)}),wO=F({type:N(hO.CONNECTION_ACCEPTED),base64EncodedQrId:L()}),TO=F({type:N(hO.FORWARDED_REQUEST),walletRequest:uO}),EO=F({type:N(hO.ERROR),errorMessage:L()}),DO=dm(`type`,[_O,vO,yO,bO,xO,SO,CO,wO,TO,EO]),OO=class{static encode(e){return Rx(R(DO,e))}static decode(e){return R(DO,sx(e))}},kO=class{static validateClientBridgeMessage(e){return R(DO,e)}},AO=class{static encode(e){return Rx(R(gO,e))}static decode(e){return R(gO,sx(e))}},jO=sm(L(),F({networkName:I(L()),nodes:sm(L(),F({nodeName:I(L()),hostname:L(),rpcEndpoint:L(),p2pEndpoint:L(),trusted:I(Yp(),!1),nodeId:L()}))})),MO=F({state:Zh,microblockHashes:M(B())}),NO=function(e){return e.APPROVAL_HANDSHAKE=`WALLET_OPERATOR_REQUEST_APPROVAL_HANDSHAKE`,e.ACTOR_KEY=`WALLET_OPERATOR_REQUEST_ACTOR_KEY`,e.APPROVAL_SIGNATURE=`WALLET_OPERATOR_REQUEST_APPROVAL_SIGNATURE`,e}({}),PO=function(e){return e.ERROR=`WALLET_OPERATOR_RESPONSE_ERROR`,e.ACTOR_KEY_REQUIRED=`WALLET_OPERATOR_RESPONSE_ACTOR_KEY_REQUIRED`,e.APPROVAL_DATA=`WALLET_OPERATOR_RESPONSE_APPROVAL_DATA`,e.APPROVAL_SIGNATURE=`WALLET_OPERATOR_RESPONSE_APPROVAL_SIGNATURE`,e}({}),FO=F({type:N(NO.APPROVAL_HANDSHAKE),anchorRequestId:L()}),IO=F({type:N(NO.ACTOR_KEY),anchorRequestId:L(),actorSignaturePublicKey:L(),actorPkePublicKey:L()}),LO=F({type:N(NO.APPROVAL_SIGNATURE),anchorRequestId:L(),b64Signature:L()}),RO=dm(`type`,[FO,IO,LO]),zO=F({type:N(PO.ERROR),errorMessage:I(L(),``)}),BO=F({type:N(PO.ACTOR_KEY_REQUIRED),b64GenesisSeed:L()}),VO=F({type:N(PO.APPROVAL_DATA),b64SerializedMicroblock:L()}),HO=F({type:N(PO.APPROVAL_SIGNATURE),b64VbHash:L(),b64MbHash:L(),height:P()}),UO=dm(`type`,[zO,BO,VO,HO]),WO=class{static encodeRequest(e){return Rx(R(uO,e))}static decodeRequest(e){return R(uO,sx(e))}static encodeResponse(e){return Rx(R(pO,e))}static decodeResponse(e){return R(pO,sx(e))}},GO=class{static validateWalletRequest(e){return R(uO,e)}static validateWalletResponse(e){return R(pO,e)}},KO=class{constructor(e=new kg){this.stringEncoder=e}decode(e){let t=this.getPrefix(),n=Mg.decode(e);if(n.matchesKeys(...t))return this.stringEncoder.decode(n.getValue());throw new l(`Invalid seed format`)}encode(e){let t=this.getPrefix();return Mg.encode(...t,this.stringEncoder.encode(e))}getPrefix(){return[`SEED`]}},qO=class extends KO{getPrefix(){return[`ACCOUNT`,`SEED`]}},JO=class e{static createFromAbciResponse(t){return new e(t.list)}constructor(e){this.transactions=e}containsTransactions(){return this.transactions.length>0}getTransactions(){return this.transactions.map(e=>new YO(e))}},YO=class{constructor(e){this.transaction=e}getHeight(){return this.transaction.height}getPreviousHistoryHash(){return KS.from(this.transaction.previousHistoryHash)}getTimestamp(){return this.transaction.timestamp}transferredAt(){return new Date(this.transaction.timestamp*1e3)}getTransactionTypeLabel(){return this.isEarnedFees()?`Earned fees`:this.isPaidFees()?`Paid fees`:this.isSentPayment()?`Sent payment`:this.isReceivedPayment()?`Received payment`:this.isPurchase()?`Purchase`:this.isSentIssuance()?`Sent issuance`:this.isReceivedIssuance()?`Received issuance`:this.isSale()?`Sale`:`Transaction`}getLinkedAccount(){return KS.from(this.transaction.linkedAccount)}getAmount(){let e=this.isPositive()?1:-1;return hn.createAtomic(this.transaction.amount*e)}getChainReference(){return this.transaction.chainReference}isPositive(){return!!(this.transaction.type&1)}isNegative(){return!this.isPositive()}isEarnedFees(){return this.isEarnedBlockFees()||this.isEarnedTxFees()}isEarnedBlockFees(){return this.transaction.type===3}isEarnedTxFees(){return this.transaction.type===1}isPaidBlockFees(){return this.transaction.type===2}isPaidTxFees(){return this.transaction.type===0}isReceivedIssuance(){return this.transaction.type===5}isSentIssuance(){return this.transaction.type===4}isSale(){return this.transaction.type==6}isSentPayment(){return this.transaction.type==8}isPaidFees(){return this.isPaidBlockFees()||this.isPaidTxFees()}isPurchase(){return this.transaction.type==7}isReceivedPayment(){return this.transaction.type==9}},XO=class extends KO{getPrefix(){return[`ACTOR`,`SEED`]}},ZO=class e{static createFromAccountStateAbciResponse(t){return new e(t.balance,t.locks)}logger=k.getLogger([`accounts`,e.name]);balanceInAtomics;locks;constructor(t=0,n=[]){this.initialBalance=t,this.initialLocks=n,this.balanceInAtomics=t,this.locks=n,this.logger=co([`node`,`accounts`,e.name])}setBalance(e){this.balanceInAtomics=e}getBalanceAsAtomics(){return this.balanceInAtomics}getBalance(){return hn.createAtomic(this.balanceInAtomics)}setLocks(e){this.locks=[...e]}getLocks(){return this.locks}hasNodeStakingLocks(){return this.locks.some(e=>e.type==og.NodeStaking)}getNodeStakingLocks(){return this.locks.filter(e=>e.type==og.NodeStaking)}getNodeStakingLock(e){return this.getNodeStakingLocks().find(t=>A.binaryIsEqual(t.parameters.validatorNodeId,e))}getNodeStakingLockOrFail(e){let t=this.getNodeStakingLock(e);if(t==null)throw Error(`Staking not found for node ${A.binaryToHexa(e)}`);return t}getNodeStakingLockAmount(e){let t=this.getNodeStakingLock(e);return t===void 0?0:t.lockedAmountInAtomics}hasEscrowLocks(){return this.locks.some(e=>e.type==og.Escrow)}getEscrowLocks(){return this.locks.filter(e=>e.type==og.Escrow)}hasVestingLocks(){return this.locks.some(e=>e.type==og.Vesting)}getVestingLocks(){return this.locks.filter(e=>e.type==og.Vesting)}removeExpiredEscrowLocks(){this.removeExpiredLocks(og.Escrow)}removeExpiredVestingLocks(){this.removeExpiredLocks(og.Vesting)}removeExpiredStakingLocks(){this.removeExpiredLocks(og.NodeStaking)}removeExpiredLocks(e){this.locks=this.locks.filter(t=>!(t.type==e&&t.lockedAmountInAtomics==0))}addSpendableTokens(e){this.balanceInAtomics+=e}addVestedTokens(e,t){this.balanceInAtomics+=e,this.locks.push({type:og.Vesting,lockedAmountInAtomics:e,parameters:t})}addEscrowedTokens(e,t){this.balanceInAtomics+=e,this.locks.push({type:og.Escrow,lockedAmountInAtomics:e,parameters:t})}removeEscrowLock(e){let t=this.locks.findIndex(t=>t.type==og.Escrow&&A.binaryIsEqual(t.parameters.escrowIdentifier,e));if(t==-1)throw Error(`Escrow not found`);let n=this.locks[t].lockedAmountInAtomics;return this.locks.splice(t,1),n}addNodeStaking(e,t){let n=this.getBreakdown();if(e<0)throw Error(`Stake amount must be greater than 0`);if(e>n.stakeable)throw Error(`Cannot stake more than ${n.stakeable} atomic units`);let r=this.getNodeStakingLock(t);r===void 0?(this.logger.info(`Creating new staking of ${e} atomics for node ${A.binaryToHexa(t)}`),this.locks.push({type:og.NodeStaking,lockedAmountInAtomics:e,parameters:{validatorNodeId:t,plannedUnlockAmountInAtomics:0,plannedUnlockTimestamp:0,slashed:!1,plannedSlashingAmountInAtomics:0,plannedSlashingTimestamp:0}})):(this.logger.info(`Adding ${e} atomics to existing staking for node ${A.binaryToHexa(t)}`),r.lockedAmountInAtomics+=e)}planNodeStakingUnlock(e,t,n){let r=this.getNodeStakingLockOrFail(n);if(r.parameters.plannedUnlockAmountInAtomics!=0)throw Error(`There's already a pending staking unlock for this node`);let i=A.addDaysToTimestamp(t,0);this.logger.info(`Planned staking unlock of ${e} atomics on account ${A.binaryToHexa(n)}`),r.parameters.plannedUnlockAmountInAtomics=e,r.parameters.plannedUnlockTimestamp=i}applyNodeStakingUnlocks(e){let t=this.getNodeStakingLocks(),n=0;for(let r of t)if(r.parameters.plannedUnlockTimestamp!=0&&e>=r.parameters.plannedUnlockTimestamp){let e=r.parameters.plannedUnlockAmountInAtomics;this.removeNodeStaking(e,r.parameters.validatorNodeId),n+=e}return this.removeExpiredStakingLocks(),n}setSlashing(e,t){let n=this.getNodeStakingLockOrFail(e);this.logger.info(`Setting slashing of ${n.lockedAmountInAtomics} atomics for node ${A.binaryToHexa(e)}, effective on ${new Date(t*1e3).toISOString()}`),n.parameters.slashed=!0,n.parameters.plannedSlashingAmountInAtomics=n.lockedAmountInAtomics,n.parameters.plannedSlashingTimestamp=t}cancelNodeSlashing(e){let t=this.getNodeStakingLockOrFail(e);t.parameters.slashed?(this.logger.info(`Cancelled slashing of node ${A.binaryToHexa(e)}`),t.parameters.slashed=!1,t.parameters.plannedSlashingAmountInAtomics=0,t.parameters.plannedSlashingTimestamp=0):this.logger.warn(`No pending slashing for node ${A.binaryToHexa(e)}`)}applyNodeSlashing(e){let t=this.getNodeStakingLocks(),n=0;for(let r of t)if(r.parameters.slashed){let t=r.parameters.plannedSlashingAmountInAtomics;t>0&&r.parameters.plannedSlashingTimestamp!=0&&e>=r.parameters.plannedSlashingTimestamp&&(this.logger.info(`Applying slashing of ${t} atomics on node ${A.binaryToHexa(r.parameters.validatorNodeId)}`),r.lockedAmountInAtomics-=t,this.balanceInAtomics-=t,n+=t,r.parameters.slashed=!1,r.parameters.plannedSlashingTimestamp=0,r.parameters.plannedSlashingAmountInAtomics=0)}return this.adjustVesting(),this.removeExpiredStakingLocks(),n}adjustVesting(){let e=this.getBreakdown().vested,t=e-this.balanceInAtomics;if(t>0){let n=this.getVestingLocks(),r=0;for(let i of n){let n=Math.floor(t*i.lockedAmountInAtomics/e);i.lockedAmountInAtomics-=n,r+=n}for(let e of n)r<t&&e.lockedAmountInAtomics>0&&(e.lockedAmountInAtomics--,r++);this.removeExpiredVestingLocks()}}removeNodeStaking(e,t){let n=this.getNodeStakingLockOrFail(t);if(e<0)throw Error(`Unstake amount must be greater than 0`);if(e>n.lockedAmountInAtomics)throw Error(`Cannot unstake more than ${n.lockedAmountInAtomics} atomic units`);n.lockedAmountInAtomics-=e}applyLinearVesting(e){let t=this.getBreakdown().releasable,n=0,r=this.getVestingLocks();for(let i of r){let r=i.parameters.initialVestedAmountInAtomics,a=i.parameters.cliffStartTimestamp,o=i.parameters.cliffDurationDays,s=i.parameters.vestingDurationDays,c=A.addDaysToTimestamp(a,o),l=Math.min(A.timestampDifferenceInDays(c,e),s);if(this.logger.debug(`start date: {cliffStartDate}, initial amount: {initialAmount}, cliff during {cliffDurationDays} day(s), vesting during {vestingDurationDays} day(s)`,()=>({cliffStartDate:new Date(a*1e3).toISOString(),initialAmount:r,cliffDurationDays:o,vestingDurationDays:s})),this.logger.debug(`cliff end date: {cliffEndDay}, today: {today}, elapsed time in vesting: {elapsed} day(s)`,()=>({cliffEndDay:new Date(c*1e3).toISOString(),today:new Date(e*1e3).toISOString(),elapsed:l})),l>0){let e=r-i.lockedAmountInAtomics,a=Math.floor(r*l/s),o=Math.min(a-e,t);this.logger.debug(`already released: ${e}, max. release: ${a}, released today: ${o}`),i.lockedAmountInAtomics-=o,t-=o,n+=o}else this.logger.debug(`nothing is released today`)}return this.removeExpiredVestingLocks(),n}getBreakdown(){let e=new Map;for(let t of this.locks){let n=e.get(t.type)||0;e.set(t.type,n+t.lockedAmountInAtomics)}let t=e.get(og.Escrow)||0,n=e.get(og.Vesting)||0,r=e.get(og.NodeStaking)||0,i=this.balanceInAtomics-r-t,a=Math.max(0,n-r),o=t+Math.max(n,r),s=this.balanceInAtomics-o;return{balance:this.balanceInAtomics,escrowed:t,vested:n,releasable:a,staked:r,stakeable:i,locked:o,spendable:s}}getSpendable(){return hn.createAtomic(this.getBreakdown().spendable)}getVested(){return hn.createAtomic(this.getBreakdown().vested)}getStakeable(){return hn.createAtomic(this.getBreakdown().stakeable)}getStaked(){return hn.createAtomic(this.getBreakdown().staked)}getEscrowed(){return hn.createAtomic(this.getBreakdown().escrowed)}},QO=class{static encoder=new Tx({tagUint8Array:!0,mapsAsObjects:!0});static encodeRequest(e){return this.encoder.encode(R(RO,e))}static decodeRequest(e){return R(RO,this.encoder.decode(e))}static encodeResponse(e){return this.encoder.encode(R(UO,e))}static decodeResponse(e){return R(UO,this.encoder.decode(e))}},$O=class{static validateRequest(e){return R(RO,e)}static validateResponse(e){return R(UO,e)}},ek=class extends KO{getPrefix(){return[`WALLET`,`SEED`]}},tk=class e{signatureSchemeId=Ja.SECP256K1;pkeSchemeId=Pv.ML_KEM_768_AES_256_GCM;constructor(e){this.actorSeed=e}static encoderStringAsBytes(e){return new TextEncoder().encode(e)}static createFromAccountSeedAndVbSeed(t,n){let r=t,i=Jx.createDefaultKDF(),a=A.binaryFrom(this.encoderStringAsBytes(`ACTOR_SEED`),this.encoderStringAsBytes(`VB_SEED`),n);return new e(i.deriveKeyNoSalt(r,a,32))}static parseFromString(t,n=new KO){return new e(n.decode(t))}encode(e=new KO){return e.encode(this.actorSeed)}getSeedAsBytes(){return this.actorSeed}async getPrivateSignatureKey(e=this.signatureSchemeId){let t=Jx.createDefaultKDF(),n=A.binaryFrom(this.encoderStringAsBytes(`SIG`),new Uint8Array(A.intToByteArray(e,6))),r=t.deriveKeyNoSalt(this.actorSeed,n,32);return Jx.createPrivateSignatureKey(e,r)}async getPublicSignatureKey(e=this.signatureSchemeId){return(await this.getPrivateSignatureKey(e)).getPublicKey()}getPrivateDecryptionKey(e=this.pkeSchemeId){let t=Jx.createDefaultKDF(),n=A.binaryFrom(this.encoderStringAsBytes(`PKE`),new Uint8Array(A.intToByteArray(e,6))),r=t.deriveKeyNoSalt(this.actorSeed,n,64);return Jx.createPrivateDecryptionKey(e,r)}async getPublicEncryptionKey(e=this.pkeSchemeId){return(await this.getPrivateDecryptionKey(e)).getPublicKey()}encoderStringAsBytes(e){return new TextEncoder().encode(e)}getSignatureSchemeId(){return this.signatureSchemeId}setSignatureSchemeId(e){this.signatureSchemeId=e}getPkeSchemeId(){return this.pkeSchemeId}setPkeSchemeId(e){this.pkeSchemeId=e}},nk=class e{signatureSchemeId=Ja.SECP256K1;pkeSchemeId=Pv.ML_KEM_768_AES_256_GCM;static createFromWalletSeedAndNonce(t,n){let r=A.binaryFrom(t,n),i=Jx.createDefaultKDF(),a=this.encoderStringAsBytes(`ACCOUNT_SEED`);return new e(i.deriveKeyNoSalt(r,a,32))}static parseFromString(t,n=new KO){return new e(n.decode(t))}encode(e=new KO){return e.encode(this.accountSeed)}constructor(e){this.accountSeed=e}deriveActorFromVbSeed(e){return tk.createFromAccountSeedAndVbSeed(this.accountSeed,e)}async getPrivateSignatureKey(t=this.signatureSchemeId){let n=Jx.createDefaultKDF(),r=e.encoderStringAsBytes(`SIG_${t}`),i=n.deriveKeyNoSalt(this.accountSeed,r,32);return Jx.createPrivateSignatureKey(t,i)}async getPublicSignatureKey(e=this.signatureSchemeId){return(await this.getPrivateSignatureKey(e)).getPublicKey()}async getPrivateDecryptionKey(t=this.pkeSchemeId){let n=Jx.createDefaultKDF(),r=e.encoderStringAsBytes(`PKE_${t}`),i=n.deriveKeyNoSalt(this.accountSeed,r,64);return Jx.createPrivateDecryptionKey(t,i)}async getPublicEncryptionKey(e=this.pkeSchemeId){return(await this.getPrivateDecryptionKey(e)).getPublicKey()}static encoderStringAsBytes(e){return new TextEncoder().encode(e)}getSeedAsBytes(){return this.accountSeed}getAccountSeed(){return this.accountSeed}static concatWalletSeedWith(e,t){return new Uint8Array([...e,...t])}static numberToUint8Array(e,t=4){let n=new ArrayBuffer(t),r=new DataView(n);return t===1?r.setUint8(0,e):t===2?r.setUint16(0,e,!1):t===4?r.setUint32(0,e,!1):t===8&&r.setBigUint64(0,BigInt(e),!1),new Uint8Array(n)}getActor(e){return tk.createFromAccountSeedAndVbSeed(this.accountSeed,e)}getSignatureSchemeId(){return this.signatureSchemeId}setSignatureSchemeId(e){this.signatureSchemeId=e}getPkeSchemeId(){return this.pkeSchemeId}setPkeSchemeId(e){this.pkeSchemeId=e}},rk=class e{static generateWallet(){return new e(Fu(64))}static fromSeed(t){if(!(t instanceof Uint8Array))throw new i(`Seed must be a Uint8Array, got ${typeof t}`);return new e(t)}static parseFromString(t,n=new KO){if(typeof t!=`string`)throw new i(`Seed must be a string, got ${typeof t}`);return new e(n.decode(t))}encode(e=new KO){return e.encode(this.walletSeed)}constructor(e){this.walletSeed=e}getDefaultAccountCrypto(){return nk.createFromWalletSeedAndNonce(this.walletSeed,0)}getAccount(e){return nk.createFromWalletSeedAndNonce(this.walletSeed,e)}getSeedAsBytes(){return this.walletSeed}};exports.ACCOUNT_ALLOWED_TRANSFERS=Wr,exports.ACCOUNT_BLOCK_FEES=Hr,exports.ACCOUNT_BURNT_TOKENS=Br,exports.ACCOUNT_CREATION=pa,exports.ACCOUNT_ESCROW_SETTLEMENT=_a,exports.ACCOUNT_ESCROW_TRANSFER=ga,exports.ACCOUNT_HISTORY=ii,exports.ACCOUNT_NAMES=Ur,exports.ACCOUNT_PUBLIC_KEY=da,exports.ACCOUNT_STAKE=va,exports.ACCOUNT_STANDARD=Vr,exports.ACCOUNT_STATE=ri,exports.ACCOUNT_TOKEN_ISSUANCE=fa,exports.ACCOUNT_TRANSFER=ma,exports.ACCOUNT_VESTING_TRANSFER=ha,exports.AES256GCMSymmetricEncryptionKey=Qg,exports.AES256GCMSymmetricEncryptionScheme=Zg,exports.ALL_SCHEMAS=ia,exports.ALL_SECTIONS_SCHEMAS=Wa,exports.APP_CREATION=Oa,exports.APP_DESCRIPTION=ka,exports.APP_LEDGER_ACTOR_CREATION=Pa,exports.APP_LEDGER_ACTOR_SUBSCRIPTION=Ra,exports.APP_LEDGER_ALLOWED_PKE_SCHEMES=Ma,exports.APP_LEDGER_ALLOWED_SIG_SCHEMES=ja,exports.APP_LEDGER_AUTHOR=Va,exports.APP_LEDGER_CHANNEL_CREATION=Fa,exports.APP_LEDGER_CHANNEL_INVITATION=La,exports.APP_LEDGER_CREATION=Na,exports.APP_LEDGER_ENDORSEMENT_REQUEST=Ha,exports.APP_LEDGER_PRIVATE_CHANNEL_DATA=Ba,exports.APP_LEDGER_PUBLIC_CHANNEL_DATA=za,exports.APP_LEDGER_SHARED_SECRET=Ia,exports.ARRAY=pm,exports.AbciQueryEncoder=UD,exports.AbciRequestSchema=vD,exports.AbciRequestType=$,exports.AbciResponseSchema=HD,exports.AbciResponseType=yD,exports.AbstractPrivateDecryptionKey=Rv,exports.AbstractProvider=JE,exports.AbstractPublicEncryptionKey=Lv,exports.AbstractPublicKeyEncryptionScheme=Iv,exports.AccountBreakdownSchema=mg,exports.AccountByPublicKeyHashAbciResponseSchema=ND,exports.AccountCreationSectionSchema=ih,exports.AccountCrypto=nk,exports.AccountEscrowSettlementSectionSchema=ch,exports.AccountEscrowTransferSectionSchema=sh,exports.AccountHistoryAbciResponseSchema=MD,exports.AccountHistoryEntrySchema=_g,exports.AccountHistorySchema=vg,exports.AccountHistoryView=nO,exports.AccountInformationSchema=gg,exports.AccountInternalState=GS,exports.AccountInternalStateUpdater=eC,exports.AccountMicroblockStructureChecker=vC,exports.AccountNotFoundForAccountHashError=_e,exports.AccountNotFoundForPublicKeyError=ge,exports.AccountNotFoundForPublicKeyHashError=xe,exports.AccountProofAbciResponseSchema=VD,exports.AccountProofEntrySchema=qC,exports.AccountProofObjectSchema=KC,exports.AccountProofSchema=JC,exports.AccountProofWrapper=WE,exports.AccountPublicKeySectionSchema=nh,exports.AccountSeedEncoder=qO,exports.AccountStakeSectionSchema=lh,exports.AccountStateAbciResponseSchema=jD,exports.AccountStateSchema=hg,exports.AccountTokenIssuanceSectionSchema=rh,exports.AccountTransaction=YO,exports.AccountTransactions=JO,exports.AccountTransferSectionSchema=ah,exports.AccountUnstakeSectionSchema=uh,exports.AccountUpdateSchema=bg,exports.AccountUpdatesAbciResponseSchema=RD,exports.AccountVb=yC,exports.AccountVestingTransferSectionSchema=oh,exports.AccountVirtualBlockchainInternalStateSchema=Fh,exports.AccountVirtualBlockchainStateSchema=Gh,exports.ActorAlreadyDefinedError=re,exports.ActorCrypto=tk,exports.ActorNotDefinedError=oe,exports.ActorNotInvitedError=he,exports.ActorNotSubscribedError=Te,exports.ActorSeedEncoder=XO,exports.ActorType=zw,exports.Aes=su,exports.AllowedAdditionalWriterSectionSchema=Qm,exports.AlreadySubscribedError=S,exports.AppLedgerLocalStateUpdaterV1=iC,exports.AppLedgerMicroblockBuildRequestSchema=qw,exports.AppLedgerMicroblockBuildRequestValidation=Jw,exports.AppLedgerProofSchema=UC,exports.AppLedgerProofVB=OC,exports.AppLedgerProofWrapper=gw,exports.ApplicationCreationSectionSchema=vh,exports.ApplicationDescriptionSectionSchema=yh,exports.ApplicationInternalState=qS,exports.ApplicationInternalStateUpdater=tC,exports.ApplicationLedgerActorCreationSectionSchema=Ch,exports.ApplicationLedgerActorInvitationStateSchema=Bh,exports.ApplicationLedgerActorSchema=Hh,exports.ApplicationLedgerActorSubscriptionSectionSchema=Dh,exports.ApplicationLedgerAllowedPkeSchemesSectionSchema=xh,exports.ApplicationLedgerAllowedSigSchemesSectionSchema=bh,exports.ApplicationLedgerAuthorSectionSchema=Ah,exports.ApplicationLedgerChannelCreationSectionSchema=wh,exports.ApplicationLedgerChannelInvitationSectionSchema=Eh,exports.ApplicationLedgerChannelSchema=zh,exports.ApplicationLedgerCreationSectionSchema=Sh,exports.ApplicationLedgerEndorsementRequestSectionSchema=jh,exports.ApplicationLedgerInternalState=JS,exports.ApplicationLedgerInternalStateObjectSchema=Uh,exports.ApplicationLedgerMicroblockBuilder=Rw,exports.ApplicationLedgerMicroblockStructureChecker=DC,exports.ApplicationLedgerNotFoundError=Ce,exports.ApplicationLedgerPrivateChannelDataSectionSchema=kh,exports.ApplicationLedgerPublicChannelDataSectionSchema=Oh,exports.ApplicationLedgerSharedSecretSectionSchema=Th,exports.ApplicationLedgerSharedSecretStateSchema=Vh,exports.ApplicationLedgerVb=Ew,exports.ApplicationLedgerVirtualBlockchainStateSchema=Yh,exports.ApplicationMicroblockStructureChecker=bC,exports.ApplicationNotFoundError=ye,exports.ApplicationVBInternalStateObjectSchema=Rh,exports.ApplicationVb=xC,exports.ApplicationVirtualBlockchainStateSchema=Jh,exports.Assertion=EC,exports.AuxiliarySignatureSectionSchema=Zm,exports.AwaitMicroblockAnchoringAbciRequestSchema=iD,exports.BIN256=Tm,exports.BINARY=wm,exports.BK_EARNED_BLOCK_FEES=Er,exports.BK_EARNED_TX_FEES=Tr,exports.BK_NAMES=zr,exports.BK_PAID_BLOCK_FEES=gr,exports.BK_PAID_TX_FEES=hr,exports.BK_PLUS=mr,exports.BK_PURCHASE=Or,exports.BK_RECEIVED_ESCROW=jr,exports.BK_RECEIVED_ESCROW_REFUND=Mr,exports.BK_RECEIVED_EXPIRED_ESCROW=Nr,exports.BK_RECEIVED_ISSUANCE=Dr,exports.BK_RECEIVED_PAYMENT=kr,exports.BK_RECEIVED_SLASHED_TOKENS=Pr,exports.BK_RECEIVED_VESTING=Ar,exports.BK_REFERENCES=Rr,exports.BK_REF_BLOCK=Fr,exports.BK_REF_MICROBLOCK=Ir,exports.BK_REF_SECTION=Lr,exports.BK_SALE=vr,exports.BK_SENT_ESCROW=xr,exports.BK_SENT_ESCROW_REFUND=Sr,exports.BK_SENT_EXPIRED_ESCROW=Cr,exports.BK_SENT_ISSUANCE=_r,exports.BK_SENT_PAYMENT=yr,exports.BK_SENT_SLASHED_TOKENS=wr,exports.BK_SENT_VESTING=br,exports.BLOCK_CONTENT=ui,exports.BLOCK_INFORMATION=li,exports.BOOLEAN=_m,exports.BalanceAvailability=ZO,exports.Base32=TE,exports.Base64=Cg,exports.BaseHCVSignatureDecoder=MS,exports.BaseHCVSignatureEncoder=nT,exports.BasePrivateSignatureKey=t_,exports.BasePublicSignatureKey=n_,exports.BinaryEncoder=GT,exports.BinaryEncoding=WT,exports.BinarySigner=KT,exports.BinaryVerifier=qT,exports.BlockContentAbciResponseSchema=wD,exports.BlockInformationAbciResponseSchema=SD,exports.BlockModifiedAccountsAbciResponseSchema=LD,exports.BlockReferenceSchema=tg,exports.BlockchainError=b,exports.BlockchainUtils=X,exports.BytesSignatureEncoder=Zw,exports.BytesToBase64Encoder=kg,exports.BytesToHexEncoder=Ag,exports.CBORCryptoBinaryEncoder=zS,exports.CENTITOKEN=sr,Object.defineProperty(exports,`CHAIN`,{enumerable:!0,get:function(){return Hn}}),exports.CMTSToken=hn,exports.CONTRACT_PARAMETER_SCHEMA=qr,exports.CONTRACT_SCHEMA=Jr,exports.CannotSubscribeError=le,exports.CarmentisError=o,exports.CarmentisErrorCode=n,exports.CertificateTagHandler=eO,exports.CertificateTagSchema=$D,exports.ChainInformationAbciResponseSchema=xD,exports.ChainReferenceSchema=ig,exports.ChainReferenceType=eg,exports.ChannelAlreadyDefinedError=ae,exports.ChannelNotDefinedError=se,exports.ClientBridgeEncoder=OO,exports.ClientBridgeMessageSchema=DO,exports.ClientBridgeMessageSchema_Answer=SO,exports.ClientBridgeMessageSchema_ConnectionAccepted=wO,exports.ClientBridgeMessageSchema_ConnectionInfo=CO,exports.ClientBridgeMessageSchema_ConnectionToken=yO,exports.ClientBridgeMessageSchema_Error=EO,exports.ClientBridgeMessageSchema_ForwardedAnswer=bO,exports.ClientBridgeMessageSchema_ForwardedRequest=TO,exports.ClientBridgeMessageSchema_GetConnectionInfo=xO,exports.ClientBridgeMessageSchema_Request=_O,exports.ClientBridgeMessageSchema_UpdateQr=vO,exports.ClientBridgeMessageType=hO,exports.ClientBridgeValidation=kO,exports.CometBFTErrorCode=HE,exports.CometBFTNodeWebSocket=QD,exports.CometBFTPublicKey=Xw,exports.CometBFTPublicKeyConverter=qD,exports.ConstraintNameByConstraint=mC,exports.Crypto=Tp,exports.CryptoEncoderFactory=BS,exports.CryptoError=d,exports.CryptoSchemeFactory=Jx,exports.CryptographicHashSchemeId=vv,exports.CurrencyConverterFactory=zE,exports.CurrentActorNotFoundError=pe,exports.CustomSectionSchema=Ym,Object.defineProperty(exports,`DATA`,{enumerable:!0,get:function(){return gn}}),exports.DEF=Ga,exports.DID_TAG=TS,exports.DckfSignatureDecoder=LS,exports.DckfSignatureEncoder=OS,exports.DecryptionError=f,Object.defineProperty(exports,`ECO`,{enumerable:!0,get:function(){return ir}}),exports.ERROR=Kr,Object.defineProperty(exports,`ERRORS`,{enumerable:!0,get:function(){return Ka}}),exports.Economics=PE,exports.EconomicsError=v,exports.Ed25519PrivateSignatureKey=iy,exports.Ed25519PublicSignatureKey=ry,exports.Ed25519SignatureScheme=ny,exports.EmptyBlockError=u,exports.EncoderFactory=Og,exports.EnvApiKeyPkmsCredentialProvider=hS,exports.ErrorAbciResponseSchema=bD,exports.EscrowLockSchema=cg,exports.EscrowParametersSchema=sg,exports.Euros=RE,exports.EurosToCMTSConverter=BE,exports.ExpirationDate=YE,exports.ExtendedSymmetricEncryptionKey=$g,exports.FORMAT=Vn,exports.FeesCalculationFormulaFactory=WS,exports.FirstFeesFormula=US,exports.GAS_ATOMS_PER_GAS=pr,exports.GAS_PER_BYTE=fr,exports.GenericSymmetricKeyEncoder=cT,exports.GenesisSnapshotAbciResponseSchema=FD,exports.GetAccountByPublicKeyHashAbciRequestSchema=cD,exports.GetAccountHistoryAbciRequestSchema=sD,exports.GetAccountProofAbciRequestSchema=_D,exports.GetAccountStateAbciRequestSchema=oD,exports.GetAccountUpdatesAbciRequestSchema=pD,exports.GetBlockContentAbciRequestSchema=eD,exports.GetBlockInformationAbciRequestSchema=$E,exports.GetBlockModifiedAccountsAbciRequestSchema=fD,exports.GetChainInformationAbciRequestSchema=QE,exports.GetGenesisSnapshotAbciRequestSchema=uD,exports.GetMicroblockBodysAbciRequestSchema=aD,exports.GetMicroblockInformationAbciRequestSchema=rD,exports.GetMicroblockInformationByHeightAbciRequestSchema=mD,exports.GetMicroblockProofAbciRequestSchema=gD,exports.GetRawBlockContentAbciRequestSchema=dD,exports.GetSerializedMicroblockByHeightAbciRequestSchema=hD,exports.GetValidatorNodeByAddressAbciRequestSchema=lD,exports.GetVirtualBlockchainStateAbciRequestSchema=tD,exports.GetVirtualBlockchainUpdateAbciRequestSchema=nD,exports.HASHABLE=Fn,exports.HASHED=zn,exports.HASH_STR=Em,exports.HCVCodec=Mg,exports.HCVDecoded=jg,exports.HCVPkeEncoder=Yx,exports.HKDF=Nv,exports.HandlerBasedSignatureEncoder=RS,exports.Hash=KS,exports.Hashes=Qc,exports.INITIAL_OFFER=lr,exports.IllegalParameterError=i,exports.IllegalStateError=a,exports.IllegalUsageError=r,exports.InternalError=m,exports.InternalStateFactory=$S,exports.InternalStateUpdaterFactory=cC,exports.InvalidActorError=ie,exports.InvalidChannelError=fe,exports.InvalidTokenUnitError=y,exports.JWK_TAG=ES,exports.JsonCanonicalUtf8Signature=YT,exports.JsonCanonicalUtf8SignatureSchema=rE,exports.JsonCanonicalUtf8Signer=cE,exports.JsonCanonicalizationMethod=XT,exports.JsonEncoder=eE,exports.JsonSchema=Cw,exports.JsonSignature=JT,exports.JsonSignatureParser=_E,exports.JsonSignatureVerifier=yE,exports.JwkPrivateSignatureKey=DS,exports.JwkPublicSignatureKey=qx,exports.JwkSignatureEncoder=Qw,exports.JwkSignatureScheme=Ry,exports.JwsSignature=gE,exports.JwsSignatureSchema=iE,exports.JwsSigner=bE,exports.KeyDerivationFunction=jv,exports.KeyDerivationFunctionSchemeId=Mv,exports.KeyExchangeSchemeId=e_,exports.LOCK_TYPE_COUNT=ag,exports.LockSchema=pg,exports.LockType=og,exports.Logger=k,exports.MAGIC_STRING=Un,exports.MASKABLE=In,exports.MASKED=Bn,exports.MAXIMUM_GAS_PRICE=dr,exports.MAX_MICROBLOCK_FUTURE_DELAY=er,exports.MAX_MICROBLOCK_PAST_DELAY=$n,exports.MB_STATUS_PREVIOUS_HASH_ERROR=rr,exports.MB_STATUS_TIMESTAMP_ERROR=nr,exports.MB_STATUS_UNRECOVERABLE_ERROR=tr,exports.MICROBLOCK_BODY=gi,exports.MICROBLOCK_HEADER=mi,exports.MICROBLOCK_HEADER_BODY_HASH_OFFSET=fi,exports.MICROBLOCK_HEADER_PREVIOUS_HASH_OFFSET=di,exports.MICROBLOCK_HEADER_SIZE=pi,exports.MICROBLOCK_SECTION=hi,exports.MICROBLOCK_VB_INFORMATION=_i,exports.MILLITOKEN=cr,exports.MINIMUM_GAS_PRICE=ur,exports.MLDSA65HCVSignatureDecoder=FS,exports.MLDSA65HCVSignatureEncoder=iT,exports.MLDSA65PrivateSignatureKey=a_,exports.MLDSA65PublicSignatureKey=i_,exports.MLDSA65SignatureScheme=r_,exports.MLDSA65_TAG=xS,exports.MLDsa=xd,exports.MLKem=Gd,exports.MSG_ACCOUNT_BY_PUBLIC_KEY_HASH=Bi,exports.MSG_ACCOUNT_HISTORY=Ri,exports.MSG_ACCOUNT_STATE=Ii,exports.MSG_AWAIT_MICROBLOCK_ANCHORING=ji,exports.MSG_BLOCK_CONTENT=wi,exports.MSG_BLOCK_INFORMATION=Si,exports.MSG_CHAIN_INFORMATION=bi,exports.MSG_ERROR=vi,exports.MSG_GENESIS_SNAPSHOT=Ki,exports.MSG_GET_ACCOUNT_BY_PUBLIC_KEY_HASH=zi,exports.MSG_GET_ACCOUNT_HISTORY=Li,exports.MSG_GET_ACCOUNT_STATE=Fi,exports.MSG_GET_BLOCK_CONTENT=Ci,exports.MSG_GET_BLOCK_INFORMATION=xi,exports.MSG_GET_CHAIN_INFORMATION=yi,exports.MSG_GET_GENESIS_SNAPSHOT=Gi,exports.MSG_GET_MICROBLOCK_BODYS=Ni,exports.MSG_GET_MICROBLOCK_INFORMATION=ki,exports.MSG_GET_OBJECT_LIST=Ui,exports.MSG_GET_VALIDATOR_NODE_BY_ADDRESS=Vi,exports.MSG_GET_VIRTUAL_BLOCKCHAIN_STATE=Ti,exports.MSG_GET_VIRTUAL_BLOCKCHAIN_UPDATE=Di,exports.MSG_MICROBLOCK_ANCHORING=Mi,exports.MSG_MICROBLOCK_BODYS=Pi,exports.MSG_MICROBLOCK_INFORMATION=Ai,exports.MSG_OBJECT_LIST=Wi,exports.MSG_VALIDATOR_NODE_BY_ADDRESS=Hi,exports.MSG_VIRTUAL_BLOCKCHAIN_STATE=Ei,exports.MSG_VIRTUAL_BLOCKCHAIN_UPDATE=Oi,exports.MemoryProvider=XE,exports.MerkleLeaf=vw,exports.MerkleLeafTypeEnum=Q,exports.MerkleRecord=Sw,exports.MerkleTree=_w,exports.MessageSerializer=jE,exports.MessageUnserializer=ME,exports.MicroBlockNotFoundError=te,exports.MicroBlockNotFoundInBlockError=ne,exports.MicroBlockNotFoundInVirtualBlockchainAtHeightError=x,exports.Microblock=dC,exports.MicroblockAnchoringAbciResponseSchema=OD,exports.MicroblockBodyItemSchema=kD,exports.MicroblockBodySchema=Nh,exports.MicroblockBodysAbciResponseSchema=AD,exports.MicroblockConsistencyChecker=Ow,exports.MicroblockHeaderSchema=Um,exports.MicroblockInformationAbciResponseSchema=DD,exports.MicroblockInformationSchema=$h,exports.MicroblockProofAbciResponseSchema=BD,exports.MicroblockProofEntrySchema=XC,exports.MicroblockProofObjectSchema=YC,exports.MicroblockProofSchema=ZC,exports.MicroblockProofWrapper=KE,exports.MicroblockReferenceSchema=ng,exports.MicroblockStructSchema=uC,exports.MicroblockStructureCheckingError=s,exports.MlKemCiphertextEncoder=Xv,exports.MlKemPrivateDecryptionKey=Qv,exports.MlKemPublicEncryptionKey=Zv,exports.MlKemPublicKeyEncryptionScheme=zv,exports.NODE_MESSAGES=D,exports.NULL=vm,exports.NUMBER=gm,exports.N_VIRTUAL_BLOCKCHAINS=Zn,exports.NativeHCVSignatureDecoder=NS,exports.NativeHCVSignatureEncoder=rT,exports.NetworkProvider=WD,exports.NetworksFileSchema=jO,exports.NewBlockEventSchema=ZD,exports.NoSharedSecretError=De,exports.NodeConnectionRefusedError=g,exports.NodeEndpointClosedWhileCatchingUpError=_,exports.NodeError=h,exports.NodeStakingLockSchema=fg,exports.NodeStakingParametersSchema=dg,exports.NotAllowedPkeSchemeError=de,exports.NotAllowedSignatureSchemeError=ue,exports.NotAuthenticatedError=c,exports.NotImplementedError=ee,exports.NullMemoryProvider=GD,exports.NullNetworkProvider=KD,exports.OBJECT=mm,exports.ORG_CREATION=Ta,exports.ORG_DESCRIPTION=Ea,exports.OnChainChannelSchema=IC,exports.OnChainItemListSchema=RC,exports.OnChainItemSchema=LC,exports.OnChainRecord=Tw,exports.Optional=Dw,exports.OrganizationCreationSectionSchema=gh,exports.OrganizationDescriptionSectionSchema=_h,exports.OrganizationInternalState=ZS,exports.OrganizationInternalStateUpdater=sC,exports.OrganizationMicroblockStructureChecker=gC,exports.OrganizationNotFoundError=ve,exports.OrganizationVBInternalStateObjectSchema=Ih,exports.OrganizationVb=_C,exports.OrganizationVirtualBlockchainStateSchema=Kh,exports.PBKDF2=Tv,exports.PKMS_TAG=SS,exports.PROPERTIES=Ln,exports.PROTOCOL_CREATION=ca,exports.PROTOCOL_UPDATE=la,exports.PROTOCOL_VARIABLES=oi,exports.PROTOCOL_VB_STATE=si,exports.PROTOCOL_VERSION=Wn,exports.PUBLIC_KEY_TAG=CS,exports.ParsingError=l,exports.PasswordBasedKeyDerivationFunction=wv,exports.PasswordBasedKeyDerivationFunctionSchemeId=Cv,exports.PkeEncoderFactory=sT,exports.PkmsSecp256k1PrivateSignatureKey=_S,exports.PkmsSecp256k1PublicSignatureKey=vS,exports.PkmsSecp256k1SignatureDecoder=IS,exports.PkmsSecp256k1SignatureEncoder=aT,exports.ProofBlockObjectSchema=WC,exports.ProofBlockSchema=GC,exports.ProofFactory=qE,exports.ProofFieldTypeEnum=zC,exports.ProofInfoSchema=QC,exports.ProofRecord=yw,exports.ProofVerificationFailedError=ce,exports.ProofVerificationResult=VE,exports.ProofWrapper=mw,exports.ProtocolCreationSectionSchema=$m,exports.ProtocolError=we,exports.ProtocolInternalState=XS,exports.ProtocolInternalStateUpdater=oC,exports.ProtocolMicroblockStructureChecker=wC,exports.ProtocolUpdateSchema=Jm,exports.ProtocolUpdateSectionSchema=eh,exports.ProtocolVBInternalStateObjectSchema=Ph,exports.ProtocolVariablesSchema=qm,exports.ProtocolVariablesSectionSchema=th,exports.ProtocolVb=TC,exports.ProtocolVirtualBlockchainStateSchema=Xh,exports.Provider=JD,exports.ProviderFactory=YD,exports.PublicKeyEncryptionAlgorithmId=Fv,exports.PublicKeyEncryptionSchemeId=Pv,exports.RADIX_CST=jw,exports.RECORD_DESCRIPTION=ni,exports.REDACTED=Rn,exports.RPCNodeStatusResponseSchema=ZE,exports.RadixUtils=Mw,exports.Random=Zs,exports.RawBlockContentAbciResponseSchema=ID,exports.ReadStream=qv,exports.Record=ww,exports.RecordActorAssignationSchema=Uw,exports.RecordActorSchema=Bw,exports.RecordByChannels=bw,exports.RecordChannelAssignationSchema=Hw,exports.RecordChannelSchema=Vw,exports.RecordHashableFieldSchema=Kw,exports.RecordMaskableFieldSchema=Gw,exports.RecordMaskedPartSchema=Ww,exports.RequestedAccountUpdateSchema=yg,exports.RetentionCostBreakdownSchema=Km,exports.RetentionCostCalculator=HS,exports.RetentionPolicySchema=Gm,exports.RetentionTierSchema=Wm,Object.defineProperty(exports,`SCHEMAS`,{enumerable:!0,get:function(){return Gr}}),exports.SECP256K1_TAG=bS,exports.SECRET_KEY_TAG=wS,Object.defineProperty(exports,`SECTIONS`,{enumerable:!0,get:function(){return aa}}),exports.SIGNATURE=oa,exports.SIGNATURE_SCHEMA=sa,exports.SIGNATURE_TAG=yS,exports.STRING=hm,exports.SaltShaker=xw,exports.SchemaSerializer=Jv,exports.SchemaUnserializer=Yv,exports.SchemaValidator=NE,exports.Scrypt=mT,exports.Secp256k1=_p,exports.Secp256k1HCVSignatureDecoder=PS,exports.Secp256k1HCVSignatureEncoder=oT,exports.Secp256k1PrivateSignatureKey=ty,exports.Secp256k1PublicSignatureKey=ey,exports.Secp256k1SignatureScheme=$v,exports.SectionConstraint=Z,exports.SectionError=me,exports.SectionLabel=rC,exports.SectionNotFoundError=Ee,exports.SectionReferenceSchema=rg,exports.SectionSchema=Mh,exports.SectionType=O,exports.SeedEncoder=KO,exports.SelfProvidedApiKeyPkmsCredentialProvider=gT,exports.SerializationError=Oe,exports.SerializedMicroblockByHeightAbciResponseSchema=zD,exports.ServerNetworkProvider=XD,exports.Sha256CryptographicHash=yv,exports.SharedKeyDecryptionError=p,exports.SignatureAlgorithmId=hT,exports.SignatureCacheDisabled=xE,exports.SignatureCacheEntry=SE,exports.SignatureCacheMonothread=CE,exports.SignatureContextSchema=tE,exports.SignatureObjectSchema=aE,exports.SignatureSchemeId=Ja,exports.SignatureSectionSchema=Xm,exports.SignatureTagSchema=aO,exports.SignatureType=nE,exports.SignatureVerificationContextSchema=oE,exports.SignatureVerificationSchema=sE,exports.SignatureVerificationUtils=vE,exports.SignedAccountPayloadSchema=uw,exports.SignedAppLedgerPayloadSchema=cw,exports.SignedMicroblockPayloadSchema=fw,exports.SignedProofPayloadSchema=ow,exports.StateChecker=Lw,exports.StructureChecker=hC,exports.SymmetricEncryptionSchemeId=Xg,exports.TOKEN=or,exports.TOKEN_NAME=ar,exports.TYPE_ARRAY=vn,exports.TYPE_ARRAY_OF=Nn,exports.TYPE_BIN256=An,exports.TYPE_BINARY=kn,exports.TYPE_BOOLEAN=Sn,exports.TYPE_HASH_STR=jn,exports.TYPE_MAIN=Mn,exports.TYPE_NAMES=Pn,exports.TYPE_NULL=Cn,exports.TYPE_NUMBER=xn,exports.TYPE_OBJECT=yn,exports.TYPE_STRING=bn,exports.TYPE_UINT16=Tn,exports.TYPE_UINT24=En,exports.TYPE_UINT32=Dn,exports.TYPE_UINT48=On,exports.TYPE_UINT8=wn,exports.TYPE_UNKNOWN=_n,exports.ThrownErrorMicroblockSearchFailureFallback=fC,exports.TimestampValidationResult=lC,exports.TokenUnit=pn,exports.TokenUnitLabel=mn,exports.Transaction=tO,exports.TransformationTypeEnum=AC,exports.TypeChecker=ro,exports.TypeCheckingFailureError=eo,exports.TypeEnum=MC,exports.TypeManager=no,exports.UINT16=bm,exports.UINT24=xm,exports.UINT32=Sm,exports.UINT48=Cm,exports.UINT8=ym,exports.Utf8Encoder=Za,exports.Utils=A,exports.VB_ACCOUNT=Kn,exports.VB_APPLICATION=Yn,exports.VB_APP_LEDGER=Xn,exports.VB_NAME=Qn,exports.VB_ORGANIZATION=Jn,exports.VB_PROTOCOL=Gn,exports.VB_STATES=ci,exports.VB_VALIDATOR_NODE=qn,exports.VIRTUAL_BLOCKCHAIN_STATE=ai,exports.VN_APPROVAL=Ca,exports.VN_COMETBFT_PUBLIC_KEY_DECLARATION=xa,exports.VN_CREATION=ba,exports.VN_RPC_ENDPOINT=Sa,exports.ValidatorNodeApprovalSectionSchema=mh,exports.ValidatorNodeByAddressAbciResponseSchema=PD,exports.ValidatorNodeCometbftPublicKeyDeclarationSectionSchema=fh,exports.ValidatorNodeCreationSectionSchema=dh,exports.ValidatorNodeInternalState=QS,exports.ValidatorNodeInternalStateUpdater=aC,exports.ValidatorNodeMicroblockStructureChecker=SC,exports.ValidatorNodeNotFoundError=be,exports.ValidatorNodeRpcEndpointSectionSchema=ph,exports.ValidatorNodeSlashingCancellationSectionSchema=hh,exports.ValidatorNodeVBInternalStateObjectSchema=Lh,exports.ValidatorNodeVb=CC,exports.ValidatorNodeVirtualBlockchainStateSchema=qh,exports.VestingLockSchema=ug,exports.VestingParametersSchema=lg,exports.VirtualBlockchain=pC,exports.VirtualBlockchainInfoSchema=Qh,exports.VirtualBlockchainLabel=iO,exports.VirtualBlockchainNotFoundError=Se,exports.VirtualBlockchainSharedPropertiesSchema=Wh,exports.VirtualBlockchainStateAbciResponseSchema=TD,exports.VirtualBlockchainStateSchema=Zh,exports.VirtualBlockchainStatusSchema=MO,exports.VirtualBlockchainType=H,exports.VirtualBlockchainUpdateAbciResponseSchema=ED,exports.WIMSG_ANSWER=$i,exports.WIMSG_CONNECTION_ACCEPTED=ta,exports.WIMSG_CONNECTION_INFO=ea,exports.WIMSG_CONNECTION_TOKEN=Xi,exports.WIMSG_FORWARDED_ANSWER=Zi,exports.WIMSG_FORWARDED_REQUEST=na,exports.WIMSG_GET_CONNECTION_INFO=Qi,exports.WIMSG_REQUEST=Ji,exports.WIMSG_UPDATE_QR=Yi,exports.WI_INVALID_SIGNATURE=qa,exports.WI_MAX_SERVER_URL_LENGTH=mO,exports.WI_MESSAGES=ra,exports.WI_QR_CODE=qi,exports.WalletCrypto=rk,exports.WalletInteractiveAnchoringEncoder=QO,exports.WalletInteractiveAnchoringRequestActorKeySchema=IO,exports.WalletInteractiveAnchoringRequestApprovalHandshakeSchema=FO,exports.WalletInteractiveAnchoringRequestApprovalSignatureSchema=LO,exports.WalletInteractiveAnchoringRequestSchema=RO,exports.WalletInteractiveAnchoringRequestType=NO,exports.WalletInteractiveAnchoringResponseActorKeyRequiredSchema=BO,exports.WalletInteractiveAnchoringResponseApprovalDataSchema=VO,exports.WalletInteractiveAnchoringResponseApprovalSignatureSchema=HO,exports.WalletInteractiveAnchoringResponseErrorSchema=zO,exports.WalletInteractiveAnchoringResponseSchema=UO,exports.WalletInteractiveAnchoringResponseType=PO,exports.WalletInteractiveAnchoringValidation=$O,exports.WalletRequestAuthByPublicKeySchema=cO,exports.WalletRequestBasedApplicationLedgerMicroblockBuilder=Yw,exports.WalletRequestDataApprovalSchema=lO,exports.WalletRequestEncoder=WO,exports.WalletRequestSchema=uO,exports.WalletRequestType=oO,exports.WalletRequestValidation=GO,exports.WalletResponseAuthByPublicKeySchema=dO,exports.WalletResponseDataApprovalSchema=fO,exports.WalletResponseSchema=pO,exports.WalletResponseType=sO,exports.WalletSeedEncoder=ek,exports.WiQrCodeEncoder=AO,exports.WiQrCodeSchema=gO,exports.WrappedAccountProofSchema=dw,exports.WrappedAppLedgerProofSchema=lw,exports.WrappedMicroblockProofSchema=pw,exports.WrappedProofSchema=sw,exports.WriteStream=Kv,exports.accountId=zm,exports.array=Dm,exports.base64UrlToBytes=pE,exports.base64UrlToObject=uE,exports.bin256=Rm,exports.binary=Lm,exports.boolean=Am,exports.bytesToBase64Url=dE,exports.createJwkSigner=Hy,exports.createJwkVerifier=Uy,exports.decodeSignatureJwk=Kx,exports.deriveJwtClaimsFromSignatureContext=hE,exports.determineJwsAlgorithm=mE,exports.encodeSignatureJwk=Gx,exports.extractPrivateJwk=xy,exports.extractPublicJwk=by,exports.generateSignatureJwk=Wy,exports.getSubtle=zy,exports.height=Bm,exports.naturalInt=V,exports.nonNegativeInt=Hm,exports.number=km,exports.positiveInt=Vm,exports.requireJwkMember=Cy,exports.resolveJwkSignatureAlgorithm=fy,exports.resolveJwkSignatureAlgorithmByName=vy,exports.sortJwkMembers=Sy,exports.string=Om,exports.uint16=Nm,exports.uint24=Pm,exports.uint32=Fm,exports.uint48=Im,exports.uint8=Mm,exports.uint8array=B,exports.utf8StringToBase64Url=fE,exports.verifyRadixProof=Fw;
|