@mikeargento/bitgraph-player 0.10.0 → 0.12.0
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-web/verify.html +5 -5
- package/package.json +2 -2
package/dist-web/verify.html
CHANGED
|
@@ -136,7 +136,7 @@ h1.bg-page-title { font-size: clamp(26px, 6vw, 40px); font-weight: 600; letter-s
|
|
|
136
136
|
</div>
|
|
137
137
|
</main>
|
|
138
138
|
<script>
|
|
139
|
-
"use strict";(()=>{var mc=Object.create;var si=Object.defineProperty;var gc=Object.getOwnPropertyDescriptor;var bc=Object.getOwnPropertyNames;var yc=Object.getPrototypeOf,wc=Object.prototype.hasOwnProperty;var xc=(t,e)=>()=>(t&&(e=t(t=0)),e);var no=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Ec=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of bc(e))!wc.call(t,r)&&r!==n&&si(t,r,{get:()=>e[r],enumerable:!(o=gc(e,r))||o.enumerable});return t};var Bc=(t,e,n)=>(n=t!=null?mc(yc(t)):{},Ec(e||!t||!t.__esModule?si(n,"default",{value:t,enumerable:!0}):n,t));var fi=no(un=>{"use strict";y();un.byteLength=Ac;un.toByteArray=kc;un.fromByteArray=Hc;var ve=[],pe=[],vc=typeof Uint8Array<"u"?Uint8Array:Array,oo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(ft=0,ai=oo.length;ft<ai;++ft)ve[ft]=oo[ft],pe[oo.charCodeAt(ft)]=ft;var ft,ai;pe[45]=62;pe[95]=63;function ci(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");n===-1&&(n=e);var o=n===e?0:4-n%4;return[n,o]}function Ac(t){var e=ci(t),n=e[0],o=e[1];return(n+o)*3/4-o}function Ic(t,e,n){return(e+n)*3/4-n}function kc(t){var e,n=ci(t),o=n[0],r=n[1],i=new vc(Ic(t,o,r)),s=0,a=r>0?o-4:o,c;for(c=0;c<a;c+=4)e=pe[t.charCodeAt(c)]<<18|pe[t.charCodeAt(c+1)]<<12|pe[t.charCodeAt(c+2)]<<6|pe[t.charCodeAt(c+3)],i[s++]=e>>16&255,i[s++]=e>>8&255,i[s++]=e&255;return r===2&&(e=pe[t.charCodeAt(c)]<<2|pe[t.charCodeAt(c+1)]>>4,i[s++]=e&255),r===1&&(e=pe[t.charCodeAt(c)]<<10|pe[t.charCodeAt(c+1)]<<4|pe[t.charCodeAt(c+2)]>>2,i[s++]=e>>8&255,i[s++]=e&255),i}function Sc(t){return ve[t>>18&63]+ve[t>>12&63]+ve[t>>6&63]+ve[t&63]}function Tc(t,e,n){for(var o,r=[],i=e;i<n;i+=3)o=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),r.push(Sc(o));return r.join("")}function Hc(t){for(var e,n=t.length,o=n%3,r=[],i=16383,s=0,a=n-o;s<a;s+=i)r.push(Tc(t,s,s+i>a?a:s+i));return o===1?(e=t[n-1],r.push(ve[e>>2]+ve[e<<4&63]+"==")):o===2&&(e=(t[n-2]<<8)+t[n-1],r.push(ve[e>>10]+ve[e>>4&63]+ve[e<<2&63]+"=")),r.join("")}});var ui=no(ro=>{y();ro.read=function(t,e,n,o,r){var i,s,a=r*8-o-1,c=(1<<a)-1,f=c>>1,u=-7,d=n?r-1:0,h=n?-1:1,l=t[e+d];for(d+=h,i=l&(1<<-u)-1,l>>=-u,u+=a;u>0;i=i*256+t[e+d],d+=h,u-=8);for(s=i&(1<<-u)-1,i>>=-u,u+=o;u>0;s=s*256+t[e+d],d+=h,u-=8);if(i===0)i=1-f;else{if(i===c)return s?NaN:(l?-1:1)*(1/0);s=s+Math.pow(2,o),i=i-f}return(l?-1:1)*s*Math.pow(2,i-o)};ro.write=function(t,e,n,o,r,i){var s,a,c,f=i*8-r-1,u=(1<<f)-1,d=u>>1,h=r===23?Math.pow(2,-24)-Math.pow(2,-77):0,l=o?0:i-1,m=o?1:-1,p=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+d>=1?e+=h/c:e+=h*Math.pow(2,1-d),e*c>=2&&(s++,c/=2),s+d>=u?(a=0,s=u):s+d>=1?(a=(e*c-1)*Math.pow(2,r),s=s+d):(a=e*Math.pow(2,d-1)*Math.pow(2,r),s=0));r>=8;t[n+l]=a&255,l+=m,a/=256,r-=8);for(s=s<<r|a,f+=r;f>0;t[n+l]=s&255,l+=m,s/=256,f-=8);t[n+l-m]|=p*128}});var Si=no(It=>{"use strict";y();var io=fi(),vt=ui(),di=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;It.Buffer=g;It.SlowBuffer=Nc;It.INSPECT_MAX_BYTES=50;var dn=2147483647;It.kMaxLength=dn;g.TYPED_ARRAY_SUPPORT=Cc();!g.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 Cc(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(g.prototype,"parent",{enumerable:!0,get:function(){if(g.isBuffer(this))return this.buffer}});Object.defineProperty(g.prototype,"offset",{enumerable:!0,get:function(){if(g.isBuffer(this))return this.byteOffset}});function Ne(t){if(t>dn)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,g.prototype),e}function g(t,e,n){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return fo(t)}return mi(t,e,n)}g.poolSize=8192;function mi(t,e,n){if(typeof t=="string")return $c(t,e);if(ArrayBuffer.isView(t))return Pc(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Ae(t,ArrayBuffer)||t&&Ae(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ae(t,SharedArrayBuffer)||t&&Ae(t.buffer,SharedArrayBuffer)))return ao(t,e,n);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let o=t.valueOf&&t.valueOf();if(o!=null&&o!==t)return g.from(o,e,n);let r=Dc(t);if(r)return r;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return g.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}g.from=function(t,e,n){return mi(t,e,n)};Object.setPrototypeOf(g.prototype,Uint8Array.prototype);Object.setPrototypeOf(g,Uint8Array);function gi(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function Rc(t,e,n){return gi(t),t<=0?Ne(t):e!==void 0?typeof n=="string"?Ne(t).fill(e,n):Ne(t).fill(e):Ne(t)}g.alloc=function(t,e,n){return Rc(t,e,n)};function fo(t){return gi(t),Ne(t<0?0:uo(t)|0)}g.allocUnsafe=function(t){return fo(t)};g.allocUnsafeSlow=function(t){return fo(t)};function $c(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!g.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let n=bi(t,e)|0,o=Ne(n),r=o.write(t,e);return r!==n&&(o=o.slice(0,r)),o}function so(t){let e=t.length<0?0:uo(t.length)|0,n=Ne(e);for(let o=0;o<e;o+=1)n[o]=t[o]&255;return n}function Pc(t){if(Ae(t,Uint8Array)){let e=new Uint8Array(t);return ao(e.buffer,e.byteOffset,e.byteLength)}return so(t)}function ao(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let o;return e===void 0&&n===void 0?o=new Uint8Array(t):n===void 0?o=new Uint8Array(t,e):o=new Uint8Array(t,e,n),Object.setPrototypeOf(o,g.prototype),o}function Dc(t){if(g.isBuffer(t)){let e=uo(t.length)|0,n=Ne(e);return n.length===0||t.copy(n,0,0,e),n}if(t.length!==void 0)return typeof t.length!="number"||lo(t.length)?Ne(0):so(t);if(t.type==="Buffer"&&Array.isArray(t.data))return so(t.data)}function uo(t){if(t>=dn)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+dn.toString(16)+" bytes");return t|0}function Nc(t){return+t!=t&&(t=0),g.alloc(+t)}g.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==g.prototype};g.compare=function(e,n){if(Ae(e,Uint8Array)&&(e=g.from(e,e.offset,e.byteLength)),Ae(n,Uint8Array)&&(n=g.from(n,n.offset,n.byteLength)),!g.isBuffer(e)||!g.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===n)return 0;let o=e.length,r=n.length;for(let i=0,s=Math.min(o,r);i<s;++i)if(e[i]!==n[i]){o=e[i],r=n[i];break}return o<r?-1:r<o?1:0};g.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}};g.concat=function(e,n){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return g.alloc(0);let o;if(n===void 0)for(n=0,o=0;o<e.length;++o)n+=e[o].length;let r=g.allocUnsafe(n),i=0;for(o=0;o<e.length;++o){let s=e[o];if(Ae(s,Uint8Array))i+s.length>r.length?(g.isBuffer(s)||(s=g.from(s)),s.copy(r,i)):Uint8Array.prototype.set.call(r,s,i);else if(g.isBuffer(s))s.copy(r,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=s.length}return r};function bi(t,e){if(g.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Ae(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let n=t.length,o=arguments.length>2&&arguments[2]===!0;if(!o&&n===0)return 0;let r=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return co(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return ki(t).length;default:if(r)return o?-1:co(t).length;e=(""+e).toLowerCase(),r=!0}}g.byteLength=bi;function Mc(t,e,n){let o=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,e>>>=0,n<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return qc(this,e,n);case"utf8":case"utf-8":return wi(this,e,n);case"ascii":return Vc(this,e,n);case"latin1":case"binary":return zc(this,e,n);case"base64":return jc(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Gc(this,e,n);default:if(o)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),o=!0}}g.prototype._isBuffer=!0;function ut(t,e,n){let o=t[e];t[e]=t[n],t[n]=o}g.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let n=0;n<e;n+=2)ut(this,n,n+1);return this};g.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let n=0;n<e;n+=4)ut(this,n,n+3),ut(this,n+1,n+2);return this};g.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let n=0;n<e;n+=8)ut(this,n,n+7),ut(this,n+1,n+6),ut(this,n+2,n+5),ut(this,n+3,n+4);return this};g.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?wi(this,0,e):Mc.apply(this,arguments)};g.prototype.toLocaleString=g.prototype.toString;g.prototype.equals=function(e){if(!g.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:g.compare(this,e)===0};g.prototype.inspect=function(){let e="",n=It.INSPECT_MAX_BYTES;return e=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(e+=" ... "),"<Buffer "+e+">"};di&&(g.prototype[di]=g.prototype.inspect);g.prototype.compare=function(e,n,o,r,i){if(Ae(e,Uint8Array)&&(e=g.from(e,e.offset,e.byteLength)),!g.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(n===void 0&&(n=0),o===void 0&&(o=e?e.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),n<0||o>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&n>=o)return 0;if(r>=i)return-1;if(n>=o)return 1;if(n>>>=0,o>>>=0,r>>>=0,i>>>=0,this===e)return 0;let s=i-r,a=o-n,c=Math.min(s,a),f=this.slice(r,i),u=e.slice(n,o);for(let d=0;d<c;++d)if(f[d]!==u[d]){s=f[d],a=u[d];break}return s<a?-1:a<s?1:0};function yi(t,e,n,o,r){if(t.length===0)return-1;if(typeof n=="string"?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,lo(n)&&(n=r?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(r)return-1;n=t.length-1}else if(n<0)if(r)n=0;else return-1;if(typeof e=="string"&&(e=g.from(e,o)),g.isBuffer(e))return e.length===0?-1:hi(t,e,n,o,r);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?r?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):hi(t,[e],n,o,r);throw new TypeError("val must be string, number or Buffer")}function hi(t,e,n,o,r){let i=1,s=t.length,a=e.length;if(o!==void 0&&(o=String(o).toLowerCase(),o==="ucs2"||o==="ucs-2"||o==="utf16le"||o==="utf-16le")){if(t.length<2||e.length<2)return-1;i=2,s/=2,a/=2,n/=2}function c(u,d){return i===1?u[d]:u.readUInt16BE(d*i)}let f;if(r){let u=-1;for(f=n;f<s;f++)if(c(t,f)===c(e,u===-1?0:f-u)){if(u===-1&&(u=f),f-u+1===a)return u*i}else u!==-1&&(f-=f-u),u=-1}else for(n+a>s&&(n=s-a),f=n;f>=0;f--){let u=!0;for(let d=0;d<a;d++)if(c(t,f+d)!==c(e,d)){u=!1;break}if(u)return f}return-1}g.prototype.includes=function(e,n,o){return this.indexOf(e,n,o)!==-1};g.prototype.indexOf=function(e,n,o){return yi(this,e,n,o,!0)};g.prototype.lastIndexOf=function(e,n,o){return yi(this,e,n,o,!1)};function Lc(t,e,n,o){n=Number(n)||0;let r=t.length-n;o?(o=Number(o),o>r&&(o=r)):o=r;let i=e.length;o>i/2&&(o=i/2);let s;for(s=0;s<o;++s){let a=parseInt(e.substr(s*2,2),16);if(lo(a))return s;t[n+s]=a}return s}function Oc(t,e,n,o){return hn(co(e,t.length-n),t,n,o)}function Fc(t,e,n,o){return hn(Xc(e),t,n,o)}function Uc(t,e,n,o){return hn(ki(e),t,n,o)}function _c(t,e,n,o){return hn(Jc(e,t.length-n),t,n,o)}g.prototype.write=function(e,n,o,r){if(n===void 0)r="utf8",o=this.length,n=0;else if(o===void 0&&typeof n=="string")r=n,o=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(o)?(o=o>>>0,r===void 0&&(r="utf8")):(r=o,o=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let i=this.length-n;if((o===void 0||o>i)&&(o=i),e.length>0&&(o<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let s=!1;for(;;)switch(r){case"hex":return Lc(this,e,n,o);case"utf8":case"utf-8":return Oc(this,e,n,o);case"ascii":case"latin1":case"binary":return Fc(this,e,n,o);case"base64":return Uc(this,e,n,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _c(this,e,n,o);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}};g.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function jc(t,e,n){return e===0&&n===t.length?io.fromByteArray(t):io.fromByteArray(t.slice(e,n))}function wi(t,e,n){n=Math.min(t.length,n);let o=[],r=e;for(;r<n;){let i=t[r],s=null,a=i>239?4:i>223?3:i>191?2:1;if(r+a<=n){let c,f,u,d;switch(a){case 1:i<128&&(s=i);break;case 2:c=t[r+1],(c&192)===128&&(d=(i&31)<<6|c&63,d>127&&(s=d));break;case 3:c=t[r+1],f=t[r+2],(c&192)===128&&(f&192)===128&&(d=(i&15)<<12|(c&63)<<6|f&63,d>2047&&(d<55296||d>57343)&&(s=d));break;case 4:c=t[r+1],f=t[r+2],u=t[r+3],(c&192)===128&&(f&192)===128&&(u&192)===128&&(d=(i&15)<<18|(c&63)<<12|(f&63)<<6|u&63,d>65535&&d<1114112&&(s=d))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,o.push(s>>>10&1023|55296),s=56320|s&1023),o.push(s),r+=a}return Kc(o)}var li=4096;function Kc(t){let e=t.length;if(e<=li)return String.fromCharCode.apply(String,t);let n="",o=0;for(;o<e;)n+=String.fromCharCode.apply(String,t.slice(o,o+=li));return n}function Vc(t,e,n){let o="";n=Math.min(t.length,n);for(let r=e;r<n;++r)o+=String.fromCharCode(t[r]&127);return o}function zc(t,e,n){let o="";n=Math.min(t.length,n);for(let r=e;r<n;++r)o+=String.fromCharCode(t[r]);return o}function qc(t,e,n){let o=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>o)&&(n=o);let r="";for(let i=e;i<n;++i)r+=Qc[t[i]];return r}function Gc(t,e,n){let o=t.slice(e,n),r="";for(let i=0;i<o.length-1;i+=2)r+=String.fromCharCode(o[i]+o[i+1]*256);return r}g.prototype.slice=function(e,n){let o=this.length;e=~~e,n=n===void 0?o:~~n,e<0?(e+=o,e<0&&(e=0)):e>o&&(e=o),n<0?(n+=o,n<0&&(n=0)):n>o&&(n=o),n<e&&(n=e);let r=this.subarray(e,n);return Object.setPrototypeOf(r,g.prototype),r};function J(t,e,n){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}g.prototype.readUintLE=g.prototype.readUIntLE=function(e,n,o){e=e>>>0,n=n>>>0,o||J(e,n,this.length);let r=this[e],i=1,s=0;for(;++s<n&&(i*=256);)r+=this[e+s]*i;return r};g.prototype.readUintBE=g.prototype.readUIntBE=function(e,n,o){e=e>>>0,n=n>>>0,o||J(e,n,this.length);let r=this[e+--n],i=1;for(;n>0&&(i*=256);)r+=this[e+--n]*i;return r};g.prototype.readUint8=g.prototype.readUInt8=function(e,n){return e=e>>>0,n||J(e,1,this.length),this[e]};g.prototype.readUint16LE=g.prototype.readUInt16LE=function(e,n){return e=e>>>0,n||J(e,2,this.length),this[e]|this[e+1]<<8};g.prototype.readUint16BE=g.prototype.readUInt16BE=function(e,n){return e=e>>>0,n||J(e,2,this.length),this[e]<<8|this[e+1]};g.prototype.readUint32LE=g.prototype.readUInt32LE=function(e,n){return e=e>>>0,n||J(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};g.prototype.readUint32BE=g.prototype.readUInt32BE=function(e,n){return e=e>>>0,n||J(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};g.prototype.readBigUInt64LE=Ye(function(e){e=e>>>0,At(e,"offset");let n=this[e],o=this[e+7];(n===void 0||o===void 0)&&Kt(e,this.length-8);let r=n+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+o*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))});g.prototype.readBigUInt64BE=Ye(function(e){e=e>>>0,At(e,"offset");let n=this[e],o=this[e+7];(n===void 0||o===void 0)&&Kt(e,this.length-8);let r=n*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+o;return(BigInt(r)<<BigInt(32))+BigInt(i)});g.prototype.readIntLE=function(e,n,o){e=e>>>0,n=n>>>0,o||J(e,n,this.length);let r=this[e],i=1,s=0;for(;++s<n&&(i*=256);)r+=this[e+s]*i;return i*=128,r>=i&&(r-=Math.pow(2,8*n)),r};g.prototype.readIntBE=function(e,n,o){e=e>>>0,n=n>>>0,o||J(e,n,this.length);let r=n,i=1,s=this[e+--r];for(;r>0&&(i*=256);)s+=this[e+--r]*i;return i*=128,s>=i&&(s-=Math.pow(2,8*n)),s};g.prototype.readInt8=function(e,n){return e=e>>>0,n||J(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};g.prototype.readInt16LE=function(e,n){e=e>>>0,n||J(e,2,this.length);let o=this[e]|this[e+1]<<8;return o&32768?o|4294901760:o};g.prototype.readInt16BE=function(e,n){e=e>>>0,n||J(e,2,this.length);let o=this[e+1]|this[e]<<8;return o&32768?o|4294901760:o};g.prototype.readInt32LE=function(e,n){return e=e>>>0,n||J(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};g.prototype.readInt32BE=function(e,n){return e=e>>>0,n||J(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};g.prototype.readBigInt64LE=Ye(function(e){e=e>>>0,At(e,"offset");let n=this[e],o=this[e+7];(n===void 0||o===void 0)&&Kt(e,this.length-8);let r=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(o<<24);return(BigInt(r)<<BigInt(32))+BigInt(n+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});g.prototype.readBigInt64BE=Ye(function(e){e=e>>>0,At(e,"offset");let n=this[e],o=this[e+7];(n===void 0||o===void 0)&&Kt(e,this.length-8);let r=(n<<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+o)});g.prototype.readFloatLE=function(e,n){return e=e>>>0,n||J(e,4,this.length),vt.read(this,e,!0,23,4)};g.prototype.readFloatBE=function(e,n){return e=e>>>0,n||J(e,4,this.length),vt.read(this,e,!1,23,4)};g.prototype.readDoubleLE=function(e,n){return e=e>>>0,n||J(e,8,this.length),vt.read(this,e,!0,52,8)};g.prototype.readDoubleBE=function(e,n){return e=e>>>0,n||J(e,8,this.length),vt.read(this,e,!1,52,8)};function ce(t,e,n,o,r,i){if(!g.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||e<i)throw new RangeError('"value" argument is out of bounds');if(n+o>t.length)throw new RangeError("Index out of range")}g.prototype.writeUintLE=g.prototype.writeUIntLE=function(e,n,o,r){if(e=+e,n=n>>>0,o=o>>>0,!r){let a=Math.pow(2,8*o)-1;ce(this,e,n,o,a,0)}let i=1,s=0;for(this[n]=e&255;++s<o&&(i*=256);)this[n+s]=e/i&255;return n+o};g.prototype.writeUintBE=g.prototype.writeUIntBE=function(e,n,o,r){if(e=+e,n=n>>>0,o=o>>>0,!r){let a=Math.pow(2,8*o)-1;ce(this,e,n,o,a,0)}let i=o-1,s=1;for(this[n+i]=e&255;--i>=0&&(s*=256);)this[n+i]=e/s&255;return n+o};g.prototype.writeUint8=g.prototype.writeUInt8=function(e,n,o){return e=+e,n=n>>>0,o||ce(this,e,n,1,255,0),this[n]=e&255,n+1};g.prototype.writeUint16LE=g.prototype.writeUInt16LE=function(e,n,o){return e=+e,n=n>>>0,o||ce(this,e,n,2,65535,0),this[n]=e&255,this[n+1]=e>>>8,n+2};g.prototype.writeUint16BE=g.prototype.writeUInt16BE=function(e,n,o){return e=+e,n=n>>>0,o||ce(this,e,n,2,65535,0),this[n]=e>>>8,this[n+1]=e&255,n+2};g.prototype.writeUint32LE=g.prototype.writeUInt32LE=function(e,n,o){return e=+e,n=n>>>0,o||ce(this,e,n,4,4294967295,0),this[n+3]=e>>>24,this[n+2]=e>>>16,this[n+1]=e>>>8,this[n]=e&255,n+4};g.prototype.writeUint32BE=g.prototype.writeUInt32BE=function(e,n,o){return e=+e,n=n>>>0,o||ce(this,e,n,4,4294967295,0),this[n]=e>>>24,this[n+1]=e>>>16,this[n+2]=e>>>8,this[n+3]=e&255,n+4};function xi(t,e,n,o,r){Ii(e,o,r,t,n,7);let i=Number(e&BigInt(4294967295));t[n++]=i,i=i>>8,t[n++]=i,i=i>>8,t[n++]=i,i=i>>8,t[n++]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s=s>>8,t[n++]=s,s=s>>8,t[n++]=s,s=s>>8,t[n++]=s,n}function Ei(t,e,n,o,r){Ii(e,o,r,t,n,7);let i=Number(e&BigInt(4294967295));t[n+7]=i,i=i>>8,t[n+6]=i,i=i>>8,t[n+5]=i,i=i>>8,t[n+4]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s=s>>8,t[n+2]=s,s=s>>8,t[n+1]=s,s=s>>8,t[n]=s,n+8}g.prototype.writeBigUInt64LE=Ye(function(e,n=0){return xi(this,e,n,BigInt(0),BigInt("0xffffffffffffffff"))});g.prototype.writeBigUInt64BE=Ye(function(e,n=0){return Ei(this,e,n,BigInt(0),BigInt("0xffffffffffffffff"))});g.prototype.writeIntLE=function(e,n,o,r){if(e=+e,n=n>>>0,!r){let c=Math.pow(2,8*o-1);ce(this,e,n,o,c-1,-c)}let i=0,s=1,a=0;for(this[n]=e&255;++i<o&&(s*=256);)e<0&&a===0&&this[n+i-1]!==0&&(a=1),this[n+i]=(e/s>>0)-a&255;return n+o};g.prototype.writeIntBE=function(e,n,o,r){if(e=+e,n=n>>>0,!r){let c=Math.pow(2,8*o-1);ce(this,e,n,o,c-1,-c)}let i=o-1,s=1,a=0;for(this[n+i]=e&255;--i>=0&&(s*=256);)e<0&&a===0&&this[n+i+1]!==0&&(a=1),this[n+i]=(e/s>>0)-a&255;return n+o};g.prototype.writeInt8=function(e,n,o){return e=+e,n=n>>>0,o||ce(this,e,n,1,127,-128),e<0&&(e=255+e+1),this[n]=e&255,n+1};g.prototype.writeInt16LE=function(e,n,o){return e=+e,n=n>>>0,o||ce(this,e,n,2,32767,-32768),this[n]=e&255,this[n+1]=e>>>8,n+2};g.prototype.writeInt16BE=function(e,n,o){return e=+e,n=n>>>0,o||ce(this,e,n,2,32767,-32768),this[n]=e>>>8,this[n+1]=e&255,n+2};g.prototype.writeInt32LE=function(e,n,o){return e=+e,n=n>>>0,o||ce(this,e,n,4,2147483647,-2147483648),this[n]=e&255,this[n+1]=e>>>8,this[n+2]=e>>>16,this[n+3]=e>>>24,n+4};g.prototype.writeInt32BE=function(e,n,o){return e=+e,n=n>>>0,o||ce(this,e,n,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[n]=e>>>24,this[n+1]=e>>>16,this[n+2]=e>>>8,this[n+3]=e&255,n+4};g.prototype.writeBigInt64LE=Ye(function(e,n=0){return xi(this,e,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});g.prototype.writeBigInt64BE=Ye(function(e,n=0){return Ei(this,e,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Bi(t,e,n,o,r,i){if(n+o>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function vi(t,e,n,o,r){return e=+e,n=n>>>0,r||Bi(t,e,n,4,34028234663852886e22,-34028234663852886e22),vt.write(t,e,n,o,23,4),n+4}g.prototype.writeFloatLE=function(e,n,o){return vi(this,e,n,!0,o)};g.prototype.writeFloatBE=function(e,n,o){return vi(this,e,n,!1,o)};function Ai(t,e,n,o,r){return e=+e,n=n>>>0,r||Bi(t,e,n,8,17976931348623157e292,-17976931348623157e292),vt.write(t,e,n,o,52,8),n+8}g.prototype.writeDoubleLE=function(e,n,o){return Ai(this,e,n,!0,o)};g.prototype.writeDoubleBE=function(e,n,o){return Ai(this,e,n,!1,o)};g.prototype.copy=function(e,n,o,r){if(!g.isBuffer(e))throw new TypeError("argument should be a Buffer");if(o||(o=0),!r&&r!==0&&(r=this.length),n>=e.length&&(n=e.length),n||(n=0),r>0&&r<o&&(r=o),r===o||e.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(o<0||o>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-n<r-o&&(r=e.length-n+o);let i=r-o;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,o,r):Uint8Array.prototype.set.call(e,this.subarray(o,r),n),i};g.prototype.fill=function(e,n,o,r){if(typeof e=="string"){if(typeof n=="string"?(r=n,n=0,o=this.length):typeof o=="string"&&(r=o,o=this.length),r!==void 0&&typeof r!="string")throw new TypeError("encoding must be a string");if(typeof r=="string"&&!g.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(e.length===1){let s=e.charCodeAt(0);(r==="utf8"&&s<128||r==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(n<0||this.length<n||this.length<o)throw new RangeError("Out of range index");if(o<=n)return this;n=n>>>0,o=o===void 0?this.length:o>>>0,e||(e=0);let i;if(typeof e=="number")for(i=n;i<o;++i)this[i]=e;else{let s=g.isBuffer(e)?e:g.from(e,r),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<o-n;++i)this[i+n]=s[i%a]}return this};var Bt={};function ho(t,e,n){Bt[t]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(r){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:r,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}ho("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);ho("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);ho("ERR_OUT_OF_RANGE",function(t,e,n){let o=`The value of "${t}" is out of range.`,r=n;return Number.isInteger(n)&&Math.abs(n)>2**32?r=pi(String(n)):typeof n=="bigint"&&(r=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(r=pi(r)),r+="n"),o+=` It must be ${e}. Received ${r}`,o},RangeError);function pi(t){let e="",n=t.length,o=t[0]==="-"?1:0;for(;n>=o+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function Wc(t,e,n){At(e,"offset"),(t[e]===void 0||t[e+n]===void 0)&&Kt(e,t.length-(n+1))}function Ii(t,e,n,o,r,i){if(t>n||t<e){let s=typeof e=="bigint"?"n":"",a;throw i>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(i+1)*8}${s}`:a=`>= -(2${s} ** ${(i+1)*8-1}${s}) and < 2 ** ${(i+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${n}${s}`,new Bt.ERR_OUT_OF_RANGE("value",a,t)}Wc(o,r,i)}function At(t,e){if(typeof t!="number")throw new Bt.ERR_INVALID_ARG_TYPE(e,"number",t)}function Kt(t,e,n){throw Math.floor(t)!==t?(At(t,n),new Bt.ERR_OUT_OF_RANGE(n||"offset","an integer",t)):e<0?new Bt.ERR_BUFFER_OUT_OF_BOUNDS:new Bt.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}var Zc=/[^+/0-9A-Za-z-_]/g;function Yc(t){if(t=t.split("=")[0],t=t.trim().replace(Zc,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function co(t,e){e=e||1/0;let n,o=t.length,r=null,i=[];for(let s=0;s<o;++s){if(n=t.charCodeAt(s),n>55295&&n<57344){if(!r){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}else if(s+1===o){(e-=3)>-1&&i.push(239,191,189);continue}r=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),r=n;continue}n=(r-55296<<10|n-56320)+65536}else r&&(e-=3)>-1&&i.push(239,191,189);if(r=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,n&63|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return i}function Xc(t){let e=[];for(let n=0;n<t.length;++n)e.push(t.charCodeAt(n)&255);return e}function Jc(t,e){let n,o,r,i=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)n=t.charCodeAt(s),o=n>>8,r=n%256,i.push(r),i.push(o);return i}function ki(t){return io.toByteArray(Yc(t))}function hn(t,e,n,o){let r;for(r=0;r<o&&!(r+n>=e.length||r>=t.length);++r)e[r+n]=t[r];return r}function Ae(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function lo(t){return t!==t}var Qc=(function(){let t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){let o=n*16;for(let r=0;r<16;++r)e[o+r]=t[n]+t[r]}return e})();function Ye(t){return typeof BigInt>"u"?ef:t}function ef(){throw new Error("BigInt not supported")}});var B,y=xc(()=>{"use strict";B=Bc(Si(),1);globalThis.Buffer=B.Buffer});y();y();var tf={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:ne,n:ln,Gx:Ti,Gy:Hi,a:po,d:mo}=tf,nf=8n,Vt=32,go=64,me=(t="")=>{throw new Error(t)},of=t=>typeof t=="bigint",Ni=t=>typeof t=="string",rf=t=>t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array",St=(t,e)=>!rf(t)||typeof e=="number"&&e>0&&t.length!==e?me("Uint8Array expected"):t,bn=t=>new Uint8Array(t),xo=t=>Uint8Array.from(t),Mi=(t,e)=>t.toString(16).padStart(e,"0"),Eo=t=>Array.from(St(t)).map(e=>Mi(e,2)).join(""),Me={_0:48,_9:57,A:65,F:70,a:97,f:102},Ci=t=>{if(t>=Me._0&&t<=Me._9)return t-Me._0;if(t>=Me.A&&t<=Me.F)return t-(Me.A-10);if(t>=Me.a&&t<=Me.f)return t-(Me.a-10)},Bo=t=>{let e="hex invalid";if(!Ni(t))return me(e);let n=t.length,o=n/2;if(n%2)return me(e);let r=bn(o);for(let i=0,s=0;i<o;i++,s+=2){let a=Ci(t.charCodeAt(s)),c=Ci(t.charCodeAt(s+1));if(a===void 0||c===void 0)return me(e);r[i]=a*16+c}return r},pn=(t,e)=>St(Ni(t)?Bo(t):xo(St(t)),e),Li=()=>globalThis?.crypto,sf=()=>Li()?.subtle??me("crypto.subtle must be defined"),bo=(...t)=>{let e=bn(t.reduce((o,r)=>o+St(r).length,0)),n=0;return t.forEach(o=>{e.set(o,n),n+=o.length}),e},af=(t=Vt)=>Li().getRandomValues(bn(t)),mn=BigInt,dt=(t,e,n,o="bad number: out of range")=>of(t)&&e<=t&&t<n?t:me(o),T=(t,e=ne)=>{let n=t%e;return n>=0n?n:e+n},cf=t=>T(t,ln),Oi=(t,e)=>{(t===0n||e<=0n)&&me("no inverse n="+t+" mod="+e);let n=T(t,e),o=e,r=0n,i=1n,s=1n,a=0n;for(;n!==0n;){let c=o/n,f=o%n,u=r-s*c,d=i-a*c;o=n,n=f,r=s,i=a,s=u,a=d}return o===1n?T(r,e):me("no inverse")};var Ri=t=>t instanceof Le?t:me("Point expected"),yo=2n**256n,Le=class t{static BASE;static ZERO;ex;ey;ez;et;constructor(e,n,o,r){let i=yo;this.ex=dt(e,0n,i),this.ey=dt(n,0n,i),this.ez=dt(o,1n,i),this.et=dt(r,0n,i),Object.freeze(this)}static fromAffine(e){return new t(e.x,e.y,1n,T(e.x*e.y))}static fromBytes(e,n=!1){let o=mo,r=xo(St(e,Vt)),i=e[31];r[31]=i&-129;let s=vo(r);dt(s,0n,n?yo:ne);let c=T(s*s),f=T(c-1n),u=T(o*c+1n),{isValid:d,value:h}=df(f,u);d||me("bad point: y not sqrt");let l=(h&1n)===1n,m=(i&128)!==0;return!n&&h===0n&&m&&me("bad point: x==0, isLastByteOdd"),m!==l&&(h=T(-h)),new t(h,s,1n,T(h*s))}assertValidity(){let e=po,n=mo,o=this;if(o.is0())throw new Error("bad point: ZERO");let{ex:r,ey:i,ez:s,et:a}=o,c=T(r*r),f=T(i*i),u=T(s*s),d=T(u*u),h=T(c*e),l=T(u*T(h+f)),m=T(d+T(n*T(c*f)));if(l!==m)throw new Error("bad point: equation left != right (1)");let p=T(r*i),w=T(s*a);if(p!==w)throw new Error("bad point: equation left != right (2)");return this}equals(e){let{ex:n,ey:o,ez:r}=this,{ex:i,ey:s,ez:a}=Ri(e),c=T(n*a),f=T(i*r),u=T(o*a),d=T(s*r);return c===f&&u===d}is0(){return this.equals(kt)}negate(){return new t(T(-this.ex),this.ey,this.ez,T(-this.et))}double(){let{ex:e,ey:n,ez:o}=this,r=po,i=T(e*e),s=T(n*n),a=T(2n*T(o*o)),c=T(r*i),f=e+n,u=T(T(f*f)-i-s),d=c+s,h=d-a,l=c-s,m=T(u*h),p=T(d*l),w=T(u*l),b=T(h*d);return new t(m,p,b,w)}add(e){let{ex:n,ey:o,ez:r,et:i}=this,{ex:s,ey:a,ez:c,et:f}=Ri(e),u=po,d=mo,h=T(n*s),l=T(o*a),m=T(i*d*f),p=T(r*c),w=T((n+o)*(s+a)-h-l),b=T(p-m),k=T(p+m),v=T(l-u*h),O=T(w*b),z=T(k*v),S=T(w*v),U=T(b*k);return new t(O,z,U,S)}multiply(e,n=!0){if(!n&&(e===0n||this.is0()))return kt;if(dt(e,1n,ln),e===1n)return this;if(this.equals(Tt))return yf(e).p;let o=kt,r=Tt;for(let i=this;e>0n;i=i.double(),e>>=1n)e&1n?o=o.add(i):n&&(r=r.add(i));return o}toAffine(){let{ex:e,ey:n,ez:o}=this;if(this.equals(kt))return{x:0n,y:1n};let r=Oi(o,ne);return T(o*r)!==1n&&me("invalid inverse"),{x:T(e*r),y:T(n*r)}}toBytes(){let{x:e,y:n}=this.assertValidity().toAffine(),o=ff(n);return o[31]|=e&1n?128:0,o}toHex(){return Eo(this.toBytes())}clearCofactor(){return this.multiply(mn(nf),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.multiply(ln/2n,!1).double();return ln%2n&&(e=e.add(this)),e.is0()}static fromHex(e,n){return t.fromBytes(pn(e),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}toRawBytes(){return this.toBytes()}},Tt=new Le(Ti,Hi,1n,T(Ti*Hi)),kt=new Le(0n,1n,1n,0n);Le.BASE=Tt;Le.ZERO=kt;var ff=t=>Bo(Mi(dt(t,0n,yo),go)).reverse(),vo=t=>mn("0x"+Eo(xo(St(t)).reverse())),Ie=(t,e)=>{let n=t;for(;e-- >0n;)n*=n,n%=ne;return n},uf=t=>{let n=t*t%ne*t%ne,o=Ie(n,2n)*n%ne,r=Ie(o,1n)*t%ne,i=Ie(r,5n)*r%ne,s=Ie(i,10n)*i%ne,a=Ie(s,20n)*s%ne,c=Ie(a,40n)*a%ne,f=Ie(c,80n)*c%ne,u=Ie(f,80n)*c%ne,d=Ie(u,10n)*i%ne;return{pow_p_5_8:Ie(d,2n)*t%ne,b2:n}},$i=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,df=(t,e)=>{let n=T(e*e*e),o=T(n*n*e),r=uf(t*o).pow_p_5_8,i=T(t*n*r),s=T(e*i*i),a=i,c=T(i*$i),f=s===t,u=s===T(-t),d=s===T(-t*$i);return f&&(i=a),(u||d)&&(i=c),(T(i)&1n)===1n&&(i=T(-i)),{isValid:f||u,value:i}},hf=t=>cf(vo(t)),lf=(...t)=>yn.sha512Async(...t);var pf=t=>lf(t.hashable).then(t.finish);var Fi={zip215:!0},mf=(t,e,n,o=Fi)=>{t=pn(t,go),e=pn(e),n=pn(n,Vt);let{zip215:r}=o,i,s,a,c,f=Uint8Array.of();try{i=Le.fromHex(n,r),s=Le.fromHex(t.slice(0,Vt),r),a=vo(t.slice(Vt,go)),c=Tt.multiply(a,!1),f=bo(s.toBytes(),i.toBytes(),e)}catch{}return{hashable:f,finish:d=>{if(c==null||!r&&i.isSmallOrder())return!1;let h=hf(d);return s.add(i.multiply(h,!1)).add(c.negate()).clearCofactor().is0()}}},Ao=async(t,e,n,o=Fi)=>pf(mf(t,e,n,o));var yn={sha512Async:async(...t)=>{let e=sf(),n=bo(...t);return bn(await e.digest("SHA-512",n.buffer))},sha512Sync:void 0,bytesToHex:Eo,hexToBytes:Bo,concatBytes:bo,mod:T,invert:Oi,randomBytes:af};var gn=8,gf=256,Ui=Math.ceil(gf/gn)+1,wo=2**(gn-1),bf=()=>{let t=[],e=Tt,n=e;for(let o=0;o<Ui;o++){n=e,t.push(n);for(let r=1;r<wo;r++)n=n.add(e),t.push(n);e=n.double()}return t},Pi,Di=(t,e)=>{let n=e.negate();return t?n:e},yf=t=>{let e=Pi||(Pi=bf()),n=kt,o=Tt,r=2**gn,i=r,s=mn(r-1),a=mn(gn);for(let c=0;c<Ui;c++){let f=Number(t&s);t>>=a,f>wo&&(f-=i,t+=1n);let u=c*wo,d=u,h=u+Math.abs(f)-1,l=c%2!==0,m=f<0;f===0?o=o.add(Di(l,e[d])):n=n.add(Di(m,e[h]))}return{p:n,f:o}};y();y();y();function xf(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Io(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function ht(t,...e){if(!xf(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Ct(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function wn(t,e){ht(t);let n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function _i(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function ke(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function xn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function we(t,e){return t<<32-e|t>>>e}var Ef=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Bf(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function vf(t){for(let e=0;e<t.length;e++)t[e]=Bf(t[e]);return t}var ko=Ef?t=>t:vf;function Af(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function zt(t){return typeof t=="string"&&(t=Af(t)),ht(t),t}var Ht=class{};function qt(t){let e=o=>t().update(zt(o)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function If(t,e,n,o){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,o);let r=BigInt(32),i=BigInt(4294967295),s=Number(n>>r&i),a=Number(n&i),c=o?4:0,f=o?0:4;t.setUint32(e+c,s,o),t.setUint32(e+f,a,o)}function ji(t,e,n){return t&e^~t&n}function Ki(t,e,n){return t&e^t&n^e&n}var Gt=class extends Ht{constructor(e,n,o,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=n,this.padOffset=o,this.isLE=r,this.buffer=new Uint8Array(e),this.view=xn(this.buffer)}update(e){Ct(this),e=zt(e),ht(e);let{view:n,buffer:o,blockLen:r}=this,i=e.length;for(let s=0;s<i;){let a=Math.min(r-this.pos,i-s);if(a===r){let c=xn(e);for(;r<=i-s;s+=r)this.process(c,s);continue}o.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===r&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ct(this),wn(e,this),this.finished=!0;let{buffer:n,view:o,blockLen:r,isLE:i}=this,{pos:s}=this;n[s++]=128,ke(this.buffer.subarray(s)),this.padOffset>r-s&&(this.process(o,0),s=0);for(let d=s;d<r;d++)n[d]=0;If(o,r-8,BigInt(this.length*8),i),this.process(o,0);let a=xn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,u[d],i)}digest(){let{buffer:e,outputLen:n}=this;this.digestInto(e);let o=e.slice(0,n);return this.destroy(),o}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:n,buffer:o,length:r,finished:i,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=i,e.length=r,e.pos=a,r%n&&e.buffer.set(o),e}clone(){return this._cloneInto()}},Oe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Q=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);y();var En=BigInt(4294967295),Vi=BigInt(32);function kf(t,e=!1){return e?{h:Number(t&En),l:Number(t>>Vi&En)}:{h:Number(t>>Vi&En)|0,l:Number(t&En)|0}}function Bn(t,e=!1){let n=t.length,o=new Uint32Array(n),r=new Uint32Array(n);for(let i=0;i<n;i++){let{h:s,l:a}=kf(t[i],e);[o[i],r[i]]=[s,a]}return[o,r]}var So=(t,e,n)=>t>>>n,To=(t,e,n)=>t<<32-n|e>>>n,lt=(t,e,n)=>t>>>n|e<<32-n,pt=(t,e,n)=>t<<32-n|e>>>n,Wt=(t,e,n)=>t<<64-n|e>>>n-32,Zt=(t,e,n)=>t>>>n-32|e<<64-n;var zi=(t,e,n)=>t<<n|e>>>32-n,qi=(t,e,n)=>e<<n|t>>>32-n,Gi=(t,e,n)=>e<<n-32|t>>>64-n,Wi=(t,e,n)=>t<<n-32|e>>>64-n;function Se(t,e,n,o){let r=(e>>>0)+(o>>>0);return{h:t+n+(r/2**32|0)|0,l:r|0}}var Zi=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),Yi=(t,e,n,o)=>e+n+o+(t/2**32|0)|0,Xi=(t,e,n,o)=>(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),Ji=(t,e,n,o,r)=>e+n+o+r+(t/2**32|0)|0,Qi=(t,e,n,o,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0)+(r>>>0),es=(t,e,n,o,r,i)=>e+n+o+r+i+(t/2**32|0)|0;var Tf=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]),Xe=new Uint32Array(64),vn=class extends Gt{constructor(e=32){super(64,e,8,!1),this.A=Oe[0]|0,this.B=Oe[1]|0,this.C=Oe[2]|0,this.D=Oe[3]|0,this.E=Oe[4]|0,this.F=Oe[5]|0,this.G=Oe[6]|0,this.H=Oe[7]|0}get(){let{A:e,B:n,C:o,D:r,E:i,F:s,G:a,H:c}=this;return[e,n,o,r,i,s,a,c]}set(e,n,o,r,i,s,a,c){this.A=e|0,this.B=n|0,this.C=o|0,this.D=r|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,n){for(let d=0;d<16;d++,n+=4)Xe[d]=e.getUint32(n,!1);for(let d=16;d<64;d++){let h=Xe[d-15],l=Xe[d-2],m=we(h,7)^we(h,18)^h>>>3,p=we(l,17)^we(l,19)^l>>>10;Xe[d]=p+Xe[d-7]+m+Xe[d-16]|0}let{A:o,B:r,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let d=0;d<64;d++){let h=we(a,6)^we(a,11)^we(a,25),l=u+h+ji(a,c,f)+Tf[d]+Xe[d]|0,p=(we(o,2)^we(o,13)^we(o,22))+Ki(o,r,i)|0;u=f,f=c,c=a,a=s+l|0,s=i,i=r,r=o,o=l+p|0}o=o+this.A|0,r=r+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(o,r,i,s,a,c,f,u)}roundClean(){ke(Xe)}destroy(){this.set(0,0,0,0,0,0,0,0),ke(this.buffer)}};var ts=Bn(["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"].map(t=>BigInt(t))),Hf=ts[0],Cf=ts[1],Je=new Uint32Array(80),Qe=new Uint32Array(80),Ho=class extends Gt{constructor(e=64){super(128,e,16,!1),this.Ah=Q[0]|0,this.Al=Q[1]|0,this.Bh=Q[2]|0,this.Bl=Q[3]|0,this.Ch=Q[4]|0,this.Cl=Q[5]|0,this.Dh=Q[6]|0,this.Dl=Q[7]|0,this.Eh=Q[8]|0,this.El=Q[9]|0,this.Fh=Q[10]|0,this.Fl=Q[11]|0,this.Gh=Q[12]|0,this.Gl=Q[13]|0,this.Hh=Q[14]|0,this.Hl=Q[15]|0}get(){let{Ah:e,Al:n,Bh:o,Bl:r,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:d,Fl:h,Gh:l,Gl:m,Hh:p,Hl:w}=this;return[e,n,o,r,i,s,a,c,f,u,d,h,l,m,p,w]}set(e,n,o,r,i,s,a,c,f,u,d,h,l,m,p,w){this.Ah=e|0,this.Al=n|0,this.Bh=o|0,this.Bl=r|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=d|0,this.Fl=h|0,this.Gh=l|0,this.Gl=m|0,this.Hh=p|0,this.Hl=w|0}process(e,n){for(let v=0;v<16;v++,n+=4)Je[v]=e.getUint32(n),Qe[v]=e.getUint32(n+=4);for(let v=16;v<80;v++){let O=Je[v-15]|0,z=Qe[v-15]|0,S=lt(O,z,1)^lt(O,z,8)^So(O,z,7),U=pt(O,z,1)^pt(O,z,8)^To(O,z,7),F=Je[v-2]|0,G=Qe[v-2]|0,q=lt(F,G,19)^Wt(F,G,61)^So(F,G,6),le=pt(F,G,19)^Zt(F,G,61)^To(F,G,6),N=Xi(U,le,Qe[v-7],Qe[v-16]),se=Ji(N,S,q,Je[v-7],Je[v-16]);Je[v]=se|0,Qe[v]=N|0}let{Ah:o,Al:r,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:d,El:h,Fh:l,Fl:m,Gh:p,Gl:w,Hh:b,Hl:k}=this;for(let v=0;v<80;v++){let O=lt(d,h,14)^lt(d,h,18)^Wt(d,h,41),z=pt(d,h,14)^pt(d,h,18)^Zt(d,h,41),S=d&l^~d&p,U=h&m^~h&w,F=Qi(k,z,U,Cf[v],Qe[v]),G=es(F,b,O,S,Hf[v],Je[v]),q=F|0,le=lt(o,r,28)^Wt(o,r,34)^Wt(o,r,39),N=pt(o,r,28)^Zt(o,r,34)^Zt(o,r,39),se=o&i^o&a^i&a,oe=r&s^r&c^s&c;b=p|0,k=w|0,p=l|0,w=m|0,l=d|0,m=h|0,{h:d,l:h}=Se(f|0,u|0,G|0,q|0),f=a|0,u=c|0,a=i|0,c=s|0,i=o|0,s=r|0;let L=Zi(q,N,oe);o=Yi(L,G,le,se),r=L|0}({h:o,l:r}=Se(this.Ah|0,this.Al|0,o|0,r|0)),{h:i,l:s}=Se(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=Se(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=Se(this.Dh|0,this.Dl|0,f|0,u|0),{h:d,l:h}=Se(this.Eh|0,this.El|0,d|0,h|0),{h:l,l:m}=Se(this.Fh|0,this.Fl|0,l|0,m|0),{h:p,l:w}=Se(this.Gh|0,this.Gl|0,p|0,w|0),{h:b,l:k}=Se(this.Hh|0,this.Hl|0,b|0,k|0),this.set(o,r,i,s,a,c,f,u,d,h,l,m,p,w,b,k)}roundClean(){ke(Je,Qe)}destroy(){ke(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var ns=qt(()=>new vn);var An=qt(()=>new Ho);y();y();y();function fe(t){return()=>{throw new Error(`${t} is not available in the browser verifier`)}}var os=fe("fs.createReadStream"),dl=fe("fs.readFileSync"),hl=fe("fs.existsSync"),ll=fe("fs.writeFileSync"),Rf=fe("fs.open"),$f=fe("fs.readdir"),rs=fe("fs.readFile"),Pf=fe("fs.stat"),pl=fe("fs.mkdir"),ml=fe("fs.writeFile"),is=fe("path.join"),gl=fe("path.basename"),ss=fe("zlib.createGunzip"),Df=fe("zlib.gzipSync");y();var _=ns;y();y();y();y();y();y();y();var Nf=t=>t/2**32|0,Mf=t=>t>>>0;function as(t,e,n,o){let r=Nf(n),i=Mf(n);t.setUint32(e,o?i:r,o),t.setUint32(e+4,o?r:i,o)}y();function In(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}var Co=t=>t?`"${t}" `:"";function Fe(t,e=""){if(typeof t!="number")throw new TypeError(Co(e)+"expected number, got "+typeof t);if(!Number.isSafeInteger(t)||t<0)throw new RangeError(Co(e)+"expected integer >= 0, got "+t);return t}function Te(t,e,n=""){if(In(t)&&(e===void 0||t.length===e))return t;e!==void 0&&Fe(e,"length");let o=In(t),r=e!==void 0?` of length ${e}`:"",i=o?`length=${t.length}`:`type=${typeof t}`,s=Co(n)+"expected Uint8Array"+r+", got "+i;throw o?new RangeError(s):new TypeError(s)}function kn(t){if(typeof t!="function"||typeof t.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(Fe(t.outputLen),Fe(t.blockLen),t.outputLen<1||t.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}var cs=(t,e)=>{if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError((e==="object"?"":`"${e}" `)+"expected object, got type="+typeof t)};function Rt(t,e=!0){if(t.destroyed)throw new Error("hash was destroyed");if(e&&t.finished)throw new Error("digest() was already called")}function Sn(t,e){Te(t,void 0,"output");let n=e.outputLen;if(!(t.length>=n))throw new RangeError('"output" expected length >= '+n)}function Yt(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Tn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function xe(t,e){return t<<32-e|t>>>e}var us=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Lf=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Hn(t){if(Te(t),us)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=Lf[t[n]];return e}function fs(t){return t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0}function Ro(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);if(us)try{return Uint8Array.fromHex(t)}catch(r){throw r instanceof SyntaxError?new RangeError(r.message):r}let e=t.length,n=e/2;if(e%2)throw new RangeError("hex string expected, got unpadded hex of length "+e);let o=new Uint8Array(n);for(let r=0,i=0;r<n;r++,i+=2){let s=fs(t.charCodeAt(i)),a=fs(t.charCodeAt(i+1));if(s===void 0||a===void 0){let c=t[i]+t[i+1];throw new RangeError('hex string expected, got non-hex character "'+c+'" at index '+i)}o[r]=s*16+a}return o}function ds(...t){let e=0;for(let o=0;o<t.length;o++){let r=t[o];Te(r),e+=r.length}let n=new Uint8Array(e);for(let o=0,r=0;o<t.length;o++){let i=t[o];n.set(i,r),r+=i.length}return n}function Of(t,e,n="opts"){return cs(t,"defaults"),e!==void 0&&cs(e,n),Object.assign(t,e)}function hs(t,e={}){if(typeof t!="function")throw new TypeError('"hashCons" expected function, got type='+typeof t);e=Of({},e,"info");let n=(r,i)=>t(i).update(r).digest(),o=t(void 0);return n.outputLen=o.outputLen,n.blockLen=o.blockLen,n.canXOF=o.canXOF,n.create=r=>t(r),Object.assign(n,e),Object.freeze(n)}function ls(t=32){Fe(t,"bytesLength");let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(t>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${t}`);return e.getRandomValues(new Uint8Array(t))}var ps=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function ms(t,e,n){return t&e^~t&n}function gs(t,e,n){return t&e^t&n^e&n}var Cn=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,n,o,r){this.blockLen=e,this.outputLen=n,this.padOffset=o,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Tn(this.buffer)}update(e){Rt(this),Te(e);let{view:n,buffer:o,blockLen:r}=this,i=e.length,s=!1;for(let a=0;a<i;){let c=Math.min(r-this.pos,i-a);if(c===r){let f=Tn(e);for(;r<=i-a;a+=r)this.process(f,a);s=!0;continue}o.set(a===0&&c===i?e:e.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===r&&(this.process(n,0),this.pos=0,s=!0)}return this.length+=e.length,s&&this.roundClean(),this}digestInto(e){Rt(this),Sn(e,this),this.finished=!0;let{buffer:n,view:o,blockLen:r,isLE:i}=this,{pos:s}=this;n[s++]=128,n.fill(0,s),this.padOffset>r-s&&(this.process(o,0),n.fill(0)),as(o,r-8,this.length*8,i),this.process(o,0),this.roundClean();let a=e===n?o:Tn(e),c=this.outputLen,f=c/4,u=this.get();if(c%4||f>u.length)throw new Error("invalid outputLen");for(let d=0;d<f;d++)a.setUint32(4*d,u[d],i)}digest(){let{buffer:e,outputLen:n}=this;this.digestInto(e);let o=e.slice(0,n);return this.destroy(),o}_cloneIntoMeta(e){let{buffer:n,length:o,finished:r,destroyed:i,pos:s}=this;return e.destroyed=i,e.finished=r,e.length=o,e.pos=s,s&&e.buffer.set(n),e}clone(){return this._cloneInto()}},bs=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Ff=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]),et=new Uint32Array(64),$o=class extends Cn{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(e,n){super(64,e,8,!1),this.A=n[0]|0,this.B=n[1]|0,this.C=n[2]|0,this.D=n[3]|0,this.E=n[4]|0,this.F=n[5]|0,this.G=n[6]|0,this.H=n[7]|0}get(){let{A:e,B:n,C:o,D:r,E:i,F:s,G:a,H:c}=this;return[e,n,o,r,i,s,a,c]}set(e,n,o,r,i,s,a,c){this.A=e|0,this.B=n|0,this.C=o|0,this.D=r|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,n){for(let d=0;d<16;d++,n+=4)et[d]=e.getUint32(n,!1);for(let d=16;d<64;d++){let h=et[d-15],l=et[d-2],m=xe(h,7)^xe(h,18)^h>>>3,p=xe(l,17)^xe(l,19)^l>>>10;et[d]=p+et[d-7]+m+et[d-16]|0}let{A:o,B:r,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let d=0;d<64;d++){let h=xe(a,6)^xe(a,11)^xe(a,25),l=u+h+ms(a,c,f)+Ff[d]+et[d]|0,p=(xe(o,2)^xe(o,13)^xe(o,22))+gs(o,r,i)|0;u=f,f=c,c=a,a=s+l|0,s=i,i=r,r=o,o=l+p|0}o=o+this.A|0,r=r+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(o,r,i,s,a,c,f,u)}roundClean(){Yt(et)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Yt(this.buffer)}},Po=class extends $o{constructor(){super(32,bs)}};var ys=hs(()=>new Po,ps(1));y();function $n(t,e,n=()=>{}){if(!Array.isArray(t))throw new TypeError(`"${e}" expected array, got type=${typeof t}`);for(let o=0;o<t.length;o++)n(t[o],`${e}[${o}]`);return t}var X=(t,e,n)=>Te(t,e,n),Do=Fe;function xs(t,e=""){if(typeof t!="string"){let n=e&&`"${e}" `;throw new TypeError(n+"expected string, got type="+typeof t)}return t}function tt(t,e="object"){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError(e==="object"?"expected valid options object":`"${e}" expected object, got type=${typeof t}`);return t}function mt(t,e){if(typeof t!="function")throw new TypeError(`"${e}" is invalid: expected function, got ${typeof t}`);return t}var No=Hn,Ue=(...t)=>ds(...t),Pn=t=>Ro(t),$t=In,Dn=t=>ls(t),Rn=BigInt(0),ws=BigInt(1),Uf=t=>t?`"${t}" `:"";function He(t,e=""){if(typeof t!="boolean")throw new TypeError(Uf(e)+"expected boolean, got type="+typeof t);return t}function Nn(t){if(typeof t=="bigint"){if(!nt(t))throw new RangeError("positive bigint expected, got "+t)}else Do(t);return t}function Pt(t,e=""){if(typeof t!="number"){let n=e&&`"${e}" `;throw new TypeError(n+"expected number, got type="+typeof t)}if(!Number.isSafeInteger(t)){let n=e&&`"${e}" `;throw new RangeError(n+"expected safe integer, got "+t)}}function Xt(t){let e=Nn(t).toString(16);return e.length&1?"0"+e:e}function Es(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);return t===""?Rn:BigInt("0x"+t)}function Ce(t){return Es(Hn(t))}function Mo(t){return Es(Hn(_f(Te(t)).reverse()))}function Mn(t,e){if(Fe(e),e===0)throw new Error("zero output length is invalid");t=Nn(t);let n=e*2,o=t.toString(16);if(o.length>n)throw new RangeError("number is too large");return Ro(o.padStart(n,"0"))}function Lo(t,e){return Mn(t,e).reverse()}function _f(t){return Uint8Array.from(X(t))}function nt(t){return typeof t=="bigint"&&Rn<=t}function Oo(t,e,n){return nt(t)&&nt(e)&&nt(n)&&e<=t&&t<n}function Fo(t,e,n,o){if(!Oo(e,n,o))throw new RangeError("expected valid "+t+": "+n+" <= n < "+o+", got "+e)}function Dt(t){if(t<Rn)throw new Error("expected non-negative bigint, got "+t);return t===Rn?0:t.toString(2).length}var Jt=t=>(Pt(t,"n"),(ws<<BigInt(t))-ws);function Bs(t,e,n){if(Fe(t,"hashLen"),Fe(e,"qByteLen"),typeof n!="function")throw new TypeError("hmacFn must be a function");let o=w=>new Uint8Array(w),r=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=o(t),f=o(t),u=0,d=()=>{c.fill(1),f.fill(0),u=0},h=(...w)=>n(f,Ue(c,...w)),l=(w=r)=>{f=h(i,w),c=h(),w.length!==0&&(f=h(s,w),c=h())},m=()=>{if(u++>=a)throw new Error("drbg: tried max amount of iterations");let w=0,b=[];for(;w<e;){c=h();let k=c.slice();b.push(k),w+=c.length}return Ue(...b)};return(w,b)=>{d(),l(w);let k;for(;(k=b(m()))===void 0;)l();return d(),k}}function ot(t,e={},n={},o="object"){tt(t,o),tt(e,"fields"),tt(n,"optFields");function r(s,a,c){let f=o==="object"?`param "${String(s)}"`:`"${o}.${String(s)}"`,u=t[s];if(!Object.hasOwn(t,s)&&(c?u!==void 0:a!=="function"))throw new TypeError(`${f} is invalid: expected own property`);if(c&&u===void 0)return;let d=typeof u;if(d!==a||u===null)throw new TypeError(`${f} is invalid: expected ${a}, got ${d}`)}let i=(s,a)=>Object.entries(s).forEach(([c,f])=>r(c,f,a));i(e,!1),i(n,!0)}y();y();var ee=BigInt(0),V=BigInt(1),rt=BigInt(2),ks=BigInt(3),Uo=BigInt(4),Ss=BigInt(5),jf=BigInt(7),Ts=BigInt(8),Kf=BigInt(9),Vf=BigInt(15),Hs=BigInt(16),zf=BigInt("0x10000000000000000");function de(t,e){if(e<=ee)throw new Error("mod: expected positive modulus, got "+e);let n=t%e;return n>=ee?n:e+n}function Cs(t,e,n){if(n<=V)throw new Error("pow: expected modulus > 1, got "+n);if(typeof e!="bigint")throw new TypeError("invalid exponent: expected bigint, got "+typeof e);if(e<ee)throw new Error("invalid exponent, negatives unsupported");if(e===ee)return V;if(e===V)return t;let o=t%n;if(o<ee&&(o+=n),e<zf){let a=V;for(;e>ee;)e&V&&(a=a*o%n),o=o*o%n,e>>=V;return a}let r=[];for(;e>ee;)r.push(Number(e&Vf)),e>>=Uo;let i=new Array(16);i[0]=V,i[1]=o;for(let a=2;a<16;a++)i[a]=i[a-1]*o%n;let s=i[r[r.length-1]];for(let a=r.length-2;a>=0;a--){s=s*s%n,s=s*s%n,s=s*s%n,s=s*s%n;let c=r[a];c!==0&&(s=s*i[c]%n)}return s}function vs(t,e){if(t===ee)throw new Error("invert: expected non-zero number");if(e<=V)throw new Error("invert: expected modulus > 1, got "+e);let n=de(t,e),o=e,r=ee,i=V;for(;n!==ee;){let a=o/n,c=o-n*a,f=r-i*a;o=n,n=c,r=i,i=f}if(o!==V)throw new Error("invert: does not exist");return de(r,e)}function Rs(t,e){if(e<=V)throw new Error("invertCt: expected prime modulus > 1, got "+e);let n=de(t,e);if(n===ee)throw new Error("invertCt: expected non-zero number");let o=Cs(n,e-rt,e);if(de(n*o,e)!==V)throw new Error("invertCt: does not exist");return o}function _o(t,e,n){let o=t;if(!o.eql(o.sqr(e),n))throw new Error("Cannot find square root")}function jo(t,e){if((t&V)===ee)throw new Error(e+": expected odd modulus, got "+t)}function $s(t,e){let n=t,o=(n.ORDER+V)/Uo,r=n.pow(e,o);return _o(n,r,e),r}function qf(t,e){let n=t,o=(n.ORDER-Ss)/Ts,r=n.mul(e,rt),i=n.pow(r,o),s=n.mul(e,i),a=n.mul(n.mul(s,rt),i),c=n.mul(s,n.sub(a,n.ONE));return _o(n,c,e),c}function Gf(t){let e=On(t),n=Ps(t),o=n(e,e.neg(e.ONE)),r=n(e,o),i=n(e,e.neg(o)),s=(t+jf)/Hs;return((a,c)=>{let f=a,u=f.pow(c,s),d=f.mul(u,o),h=f.mul(u,r),l=f.mul(u,i),m=f.eql(f.sqr(d),c),p=f.eql(f.sqr(h),c);u=f.cmov(u,d,m),d=f.cmov(l,h,p);let w=f.eql(f.sqr(d),c),b=f.cmov(u,d,w);return _o(f,b,c),b})}function Ps(t){if(t<ks)throw new Error("sqrt is not defined for small field");jo(t,"tonelliShanks");let e=t-V,n=0;for(;e%rt===ee;)e/=rt,n++;let o=rt,r=On(t);for(;As(r,o)===1;)if(o++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return $s;let i=r.pow(o,e),s=(e+V)/rt;return function(c,f){let u=c;if(u.is0(f))return f;if(As(u,f)!==1)throw new Error("Cannot find square root");let d=n,h=u.mul(u.ONE,i),l=u.pow(f,e),m=u.pow(f,s);for(;!u.eql(l,u.ONE);){if(u.is0(l))throw new Error("Cannot find square root: probably non-prime P");let p=1,w=u.sqr(l);for(;!u.eql(w,u.ONE);)if(p++,w=u.sqr(w),p===d)throw new Error("Cannot find square root");let b=V<<BigInt(d-p-1),k=u.pow(h,b);d=p,h=u.sqr(k),l=u.mul(l,h),m=u.mul(m,k)}return m}}function Wf(t){return jo(t,"Fp.sqrt"),t%Uo===ks?$s:t%Ts===Ss?qf:t%Hs===Kf?Gf(t):Ps(t)}var Zf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Nt(t){if(tt(t,"field"),typeof t.ORDER!="bigint")throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof t.ORDER);Pt(t.BYTES,"BYTES"),Pt(t.BITS,"BITS");for(let e of Zf)mt(t[e],"field."+e);if(t.BYTES<1||t.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(t.ORDER<=V)throw new Error("invalid field: expected ORDER > 1, got "+t.ORDER);return t}function Ko(t,e,n=!1){Nt(t),$n(e,"nums"),He(n,"passZero");let o=t,r=new Array(e.length).fill(n?o.ZERO:void 0),i=e.reduce((a,c,f)=>o.is0(c)?a:(r[f]=a,o.mul(a,c)),o.ONE),s=o.inv(i);return e.reduceRight((a,c,f)=>o.is0(c)?a:(r[f]=o.mul(a,r[f]),o.mul(a,c)),s),r}function As(t,e){Nt(t);let n=t;jo(n.ORDER,"FpLegendre");let o=(n.ORDER-V)/rt,r=n.pow(e,o),i=n.eql(r,n.ONE),s=n.eql(r,n.ZERO),a=n.eql(r,n.neg(n.ONE));if(!i&&!s&&!a)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function Yf(t,e){if(e!==void 0&&Do(e),t<=ee)throw new Error("invalid n length: expected positive n, got "+t);if(e!==void 0&&e<1)throw new Error("invalid n length: expected positive bit length, got "+e);let n=Dt(t);if(e!==void 0&&e<n)throw new Error(`invalid n length: expected nBitLength (${e}) >= bitLen(n) (${n})`);let o=e!==void 0?e:n,r=Math.ceil(o/8);return{nBitLength:o,nByteLength:r}}var Is=new WeakMap,Ln=class{ORDER;BITS;BYTES;isLE;ZERO=ee;ONE=V;_lengths;_mod;constructor(e,n={}){if(e<=V)throw new Error("invalid field: expected ORDER > 1, got "+e);let o;this.isLE=!1,n!=null&&typeof n=="object"&&(typeof n.BITS=="number"&&(o=n.BITS),typeof n.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:n.sqrt,enumerable:!0}),typeof n.isLE=="boolean"&&(this.isLE=n.isLE),n.allowedLengths&&(this._lengths=Object.freeze(n.allowedLengths.slice())),typeof n.modFromBytes=="boolean"&&(this._mod=n.modFromBytes));let{nBitLength:r,nByteLength:i}=Yf(e,o);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=r,this.BYTES=i,Object.freeze(this)}create(e){return de(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof e);return ee<=e&&e<this.ORDER}is0(e){return e===ee}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&V)===V}neg(e){return de(-e,this.ORDER)}eql(e,n){return e===n}sqr(e){return de(e*e,this.ORDER)}add(e,n){return de(e+n,this.ORDER)}sub(e,n){return de(e-n,this.ORDER)}mul(e,n){return de(e*n,this.ORDER)}pow(e,n){return Cs(e,n,this.ORDER)}div(e,n){return de(e*vs(n,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,n){return e+n}subN(e,n){return e-n}mulN(e,n){return e*n}inv(e){return vs(e,this.ORDER)}sqrt(e){let n=Is.get(this);return n||Is.set(this,n=Wf(this.ORDER)),n(this,e)}toBytes(e){return this.isLE?Lo(e,this.BYTES):Mn(e,this.BYTES)}fromBytes(e,n=!1){X(e);let{_lengths:o,BYTES:r,isLE:i,ORDER:s,_mod:a}=this;if(o){if(e.length<1||!o.includes(e.length)||e.length>r)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let f=new Uint8Array(r);f.set(e,i?0:f.length-e.length),e=f}if(e.length!==r)throw new Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let c=i?Mo(e):Ce(e);if(a&&(c=de(c,s)),!n&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(e){return Ko(this,e,!0)}cmov(e,n,o){return He(o,"condition"),o?n:e}};function On(t,e={}){return Object.freeze(Ln.prototype),new Ln(t,e)}function Ds(t){if(typeof t!="bigint")throw new Error("field order must be bigint");if(t<=V)throw new Error("field order must be greater than 1");let e=Dt(t-V);return Math.ceil(e/8)}function Fn(t){let e=Ds(t);return e+Math.ceil(e/2)}function Vo(t,e,n=!1){X(t);let o=t.length,r=Ds(e),i=Math.max(Fn(e),16);if(o<i||o>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+o);let s=n?Mo(t):Ce(t),a=de(s,e-V)+V;return n?Lo(a,r):Mn(a,r)}var Go=BigInt(0),Qt=BigInt(1),Xf=BigInt(4),zo=16,Ns=128,Jf=5,Ms=2**31;function Mt(t){let e=t;if(typeof e!="function")throw new TypeError('"Point" expected constructor, got type='+typeof t);mt(e.fromAffine,"Point.fromAffine"),mt(e.fromBytes,"Point.fromBytes"),mt(e.fromHex,"Point.fromHex"),tt(e.BASE,"Point.BASE"),tt(e.ZERO,"Point.ZERO"),Nt(e.Fp),Nt(e.Fn)}function Os(t,e){Mt(t),Fs(e,t);let n=Ko(t.Fp,e.map(o=>o.Z));return e.map((o,r)=>t.fromAffine(o.toAffine(n[r])))}function Qf(t,e,n=1){if(!Number.isSafeInteger(t)||t<n||t>e)throw new Error("invalid window size, expected ["+n+".."+e+"], got W="+t)}function eu(t,e){let n=t*(4*e+128);if(n>Ms)throw new Error("invalid window size: table would need ~"+Math.ceil(n/2**20)+" MiB, max "+Ms/2**20+" MiB")}function Wo(t,e){if(t!==void 0){mt(t,"randomBytes");try{let n=t(e);if(!$t(n)||n.length!==e)return}catch{return}return t}}function Fs(t,e){$n(t,"points"),t.forEach((n,o)=>{if(!(n instanceof e))throw new Error("invalid point at index "+o)})}function tu(t,e,n){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((o,r)=>{if(!(n===void 0?e.isValid(o):nt(o)&&o<n))throw new Error("invalid scalar at index "+r)})}var Us=new WeakMap;function qo(t){return Us.get(t)||1}function nu(t,e){let n=t.double(),o=[t];for(let r=1;r<e;r++)o.push(o[r-1].add(n));return o}function ou(t,e){let n=2**e,o=n/2,r=BigInt(n-1),i=[];for(;t>Go;){let s=0;t&Qt&&(s=Number(t&r),s>=o&&(s-=n),t-=BigInt(s)),i.push(s),t>>=Qt}return i}function ru(t,e,n){let o=2**e,r=o/2,i=BigInt(o-1),s=BigInt(e),a=[];for(let c=0;c<n;c++){let f=Number(t&i);t>>=s,f>r&&(f-=o,t+=Qt),a.push(f)}if(t!==Go)throw new Error("invalid wnaf");return a}function iu(t,e,n){let o=0;for(let i of n)o=Math.max(o,i.length);let r=t;for(let i=o-1;i>=0;i--){i!==o-1&&(r=r.double());for(let s=0;s<n.length;s++){let a=n[s][i];if(a){let c=e[s][Math.abs(a)-1>>1];r=r.add(a<0?c.negate():c)}}}return r}var Un=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(e,n){Mt(e),this.randomBytes=Wo(n,zo),this.Point=e,this.BASE=e.BASE,this.ZERO=e.ZERO,this.bits=e.Fn.BITS}buildWnafTable(e,n,o){let r=Math.ceil(o/n)+1,i=2**(n-1),s=[],a=e;for(let c=0;c<r;c++){let f=a;for(let u=0;u<i;u++)s.push(f),f=f.add(a);a=s[s.length-1].double()}return{W:n,bits:o,windows:r,comp:s}}wnafCachedCT(e,n){let{W:o,windows:r,comp:i}=e,s=2**(o-1),a=ru(n,o,r),c=this.ZERO,f=this.BASE;for(let u=0;u<r;u++){let d=a[u],h=u*s,l=Math.abs(d)-1,m=i[h];for(let w=1;w<s;w++)m=w===l?i[h+w]:m;let p=m.negate();d===0?f=f.add(i[h]):c=c.add(d<0?p:m)}return{p:c,f}}getWnafPrecomputes(e,n,o,r){let i=this.wnafPrecomputes.get(n),s=i?.find(a=>a.W===e&&a.bits===o);return s||(s=this.buildWnafTable(n,e,o),typeof r=="function"&&(s={...s,comp:r(s.comp)}),i||(i=[],this.wnafPrecomputes.set(n,i)),i.push(s)),s}assertPoint(e){if(!(e instanceof this.Point))throw new TypeError('"point" expected Point instance, got type='+typeof e)}validateMulInput(e,n){if(this.assertPoint(e),!Oo(n,Qt,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(e,n,o,r){let i=qo(e);return i===1?this.fixedWindowCT(e,n,o):this.wnafCachedCT(this.getWnafPrecomputes(i,e,o,r),n)}mulCT(e,n,o){return this.validateMulInput(e,n),this.runCT(e,n,this.bits,o)}mulCTBlinded(e,n,o){if(this.validateMulInput(e,n),this.randomBytes===void 0)throw new Error("randomBytes is required for scalar blinding");let r=this.Point.Fn.BITS+Ns,i=this.randomBytes(zo);if(!$t(i)||i.length!==zo)throw new Error("randomBytes returned invalid byte array");i[0]=i[0]&63|128;let s=n+Ce(i)*this.Point.Fn.ORDER;return this.runCT(e,s,r,o)}fixedWindowCT(e,n,o){let r=Jf,i=1<<r,s=Jt(r),a=new Array(i);a[0]=this.ZERO;for(let u=1;u<i;u++)a[u]=a[u-1].add(e);let c=Math.ceil(o/r),f=this.ZERO;for(let u=c-1;u>=0;u--){if(u!==c-1)for(let l=0;l<r;l++)f=f.double();let d=Number(n>>BigInt(u*r)&s),h=a[0];for(let l=1;l<i;l++)h=l===d?a[l]:h;f=f.add(h)}return{p:f,f}}shouldBlind(e,n){return this.randomBytes===void 0?!1:n===Qt?!0:e!==this.BASE?!1:(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(e,n,o,r){return this.shouldBlind(e,o)?this.mulCTBlinded(e,n,r):this.mulCT(e,n,r)}mulUnsafe(e,n,o){if(this.assertPoint(e),!nt(n))throw new Error("invalid scalar");let r=qo(e);if(r===1||n>=this.Point.Fn.ORDER)return _n(this.Point,[e],[n],!0);let i=this.getWnafPrecomputes(r,e,this.bits,o);return this.wnafCachedCT(i,n).p}setWindowSize(e,n){this.assertPoint(e),Qf(n,this.bits);let o=Math.ceil((this.bits+Ns)/n)+1;eu(o*2**(n-1),this.Point.Fp.BYTES),Us.set(e,n),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return qo(e)!==1}};function _n(t,e,n,o=!1){if(Mt(t),Fs(e,t),He(o,"allowOversized"),tu(n,t.Fn,o?t.Fn.ORDER**Xf:void 0),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let r=e.map(s=>nu(s,4)),i=n.map(s=>ou(s,4));return iu(t.ZERO,r,i)}function Ls(t,e,n){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Nt(e),e}else return On(t,{isLE:n})}function _s(t,e,n={},o){if(t!=="weierstrass"&&t!=="edwards")throw new Error('expected curve type "weierstrass" or "edwards"');if(o===void 0&&(o=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);ot(n);for(let c of["p","n","h"]){let f=e[c];if(!(nt(f)&&f!==Go))throw new Error(`CURVE.${c} must be positive bigint`)}let r=Ls(e.p,n.Fp,o),i=Ls(e.n,n.Fn,o),a=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let c of a)if(!r.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:r,Fn:i}}function js(t,e){return function(o){let r=t(o);return{secretKey:r,publicKey:e(r)}}}y();y();var jn=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,n){if(kn(e),Te(n,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,r=new Uint8Array(o);r.set(n.length>o?e.create().update(n).digest():n);for(let i=0;i<r.length;i++)r[i]^=54;this.iHash.update(r),this.oHash=e.create();for(let i=0;i<r.length;i++)r[i]^=106;this.oHash.update(r),Yt(r)}update(e){return Rt(this),this.iHash.update(e),this}digestInto(e){Rt(this),Sn(e,this),this.finished=!0;let n=e.subarray(0,this.outputLen);this.iHash.digestInto(n),this.oHash.update(n),this.oHash.digestInto(n),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:n,iHash:o,finished:r,destroyed:i,blockLen:s,outputLen:a,canXOF:c}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.canXOF=c,e.oHash=n._cloneInto(e.oHash),e.iHash=o._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Ks=(()=>{let t=((e,n,o)=>new jn(e,n).update(o).digest());return t.create=(e,n)=>new jn(e,n),t})();y();var su=BigInt(0),Zo=class extends Error{constructor(e=""){super(e)}},_e={Err:Zo,_tlv:{encode:(t,e)=>{let{Err:n}=_e;if(Pt(t,"tag"),t<0||t>255)throw new n("tlv.encode: wrong tag");if(xs(e,"data"),e.length&1)throw new n("tlv.encode: unpadded data");let o=e.length/2,r=Xt(o);if(r.length/2&128)throw new n("tlv.encode: long form length too big");let i=o>127?Xt(r.length/2|128):"";return Xt(t)+i+r+e},decode(t,e){let{Err:n}=_e;e=X(e,void 0,"DER data");let o=0;if(t<0||t>255)throw new n("tlv.decode: wrong tag");if(e.length<2||e[o++]!==t)throw new n("tlv.decode: wrong tlv");let r=e[o++],i=!!(r&128),s=0;if(!i)s=r;else{let c=r&127;if(!c)throw new n("tlv.decode(long): indefinite length not supported");if(c>4)throw new n("tlv.decode(long): byte length is too big");let f=e.subarray(o,o+c);if(f.length!==c)throw new n("tlv.decode: length bytes not complete");if(f[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(let u of f)s=s<<8|u;if(o+=c,s<128)throw new n("tlv.decode(long): not minimal encoding")}let a=e.subarray(o,o+s);if(a.length!==s)throw new n("tlv.decode: wrong value length");return{v:a,l:e.subarray(o+s)}}},_int:{encode(t){let{Err:e}=_e;if(Nn(t),t<su)throw new e("integer: negative integers are not allowed");let n=Xt(t);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return n},decode(t){let{Err:e}=_e;if(t.length<1)throw new e("invalid signature integer: empty");if(t[0]&128)throw new e("invalid signature integer: negative");if(t.length>1&&t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Ce(t)}},toSig(t){let{Err:e,_int:n,_tlv:o}=_e,r=X(t,void 0,"signature"),{v:i,l:s}=o.decode(48,r);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=o.decode(2,i),{v:f,l:u}=o.decode(2,c);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(f)}},hexFromSig(t){let{_tlv:e,_int:n}=_e;ot(t,{r:"bigint",s:"bigint"},{},"sig");let o=e.encode(2,n.encode(t.r)),r=e.encode(2,n.encode(t.s)),i=o+r;return e.encode(48,i)}},Yo=(Object.freeze(_e._tlv),Object.freeze(_e._int),Object.freeze(_e));var Vs=(t,e)=>(t+(t>=0?e:-e)/zs)/e;function au(t,e,n){Fo("scalar",t,je,n);let[[o,r],[i,s]]=e,a=Vs(s*t,n),c=Vs(-r*t,n),f=t-a*o-c*i,u=-a*r-c*s,d=f<je,h=u<je;d&&(f=-f),h&&(u=-u);let l=Jt(Math.ceil(Dt(n)/2))+gt;if(f<je||f>=l||u<je||u>=l)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:d,k1:f,k2neg:h,k2:u}}function Qo(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Xo(t,e){ot(t);let n={};for(let o of Object.keys(e))n[o]=t[o]===void 0?e[o]:t[o];return He(n.lowS,"lowS"),He(n.prehash,"prehash"),n.format!==void 0&&Qo(n.format),n}var je=BigInt(0),gt=BigInt(1),zs=BigInt(2),Jo=BigInt(3),cu=BigInt(4);function qs(t,e={}){let n=_s("weierstrass",t,e),o=n.Fp,r=n.Fn,i=n.CURVE,{h:s,n:a}=i;ot(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});let{endo:c,allowInfinityPoint:f}=e,u=e.randomBytes===void 0?Dn:e.randomBytes;if(c&&(!o.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let d=Ws(o,r);function h(){if(!o.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l(L,E,A){if(f&&E.is0())return Uint8Array.of(0);let{x:C,y:D}=E.toAffine(),I=o.toBytes(C);if(He(A,"isCompressed"),A){h();let x=!o.isOdd(D);return Ue(Gs(x),I)}else return Ue(Uint8Array.of(4),I,o.toBytes(D))}function m(L){X(L,void 0,"Point");let{publicKey:E,publicKeyUncompressed:A}=d,C=L.length,D=L[0],I=L.subarray(1);if(f&&C===1&&D===0)return{x:o.ZERO,y:o.ZERO};if(C===E&&(D===2||D===3)){let x=o.fromBytes(I);if(!o.isValid(x))throw new Error("bad point: is not on curve, wrong x");let H=v(x),R;try{R=o.sqrt(H)}catch(K){let j=K instanceof Error?": "+K.message:"";throw new Error("bad point: is not on curve, sqrt error"+j)}h();let M=o.isOdd(R);return(D&1)===1!==M&&(R=o.neg(R)),{x,y:R}}else if(C===A&&D===4){let x=o.BYTES,H=o.fromBytes(I.subarray(0,x)),R=o.fromBytes(I.subarray(x,x*2));if(!O(H,R))throw new Error("bad point: is not on curve");return{x:H,y:R}}else throw new Error(`bad point: got length ${C}, expected compressed=${E} or uncompressed=${A}`)}let p=e.toBytes===void 0?l:e.toBytes,w=e.fromBytes===void 0?m:e.fromBytes,b=o.mul(i.b,Jo),k=o.is0(i.a)?L=>o.ZERO:L=>o.mul(i.a,L);function v(L){let E=o.sqr(L),A=o.mul(E,L);return o.add(o.add(A,o.mul(L,i.a)),i.b)}function O(L,E){let A=o.sqr(E),C=v(L);return o.eql(A,C)}if(!O(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let z=o.mul(o.pow(i.a,Jo),cu),S=o.mul(o.sqr(i.b),BigInt(27));if(o.is0(o.add(z,S)))throw new Error("bad curve params: a or b");function U(L,E,A=!1){if(!o.isValid(E)||A&&o.is0(E))throw new Error(`bad point coordinate ${L}`);return E}function F(L){if(!(L instanceof N))throw new Error("Weierstrass Point expected")}function G(L){if(!c||!c.basises)throw new Error("no endo");return au(L,c.basises,r.ORDER)}function q(L,E,A,C){if(!r.isValid(C))throw new RangeError("invalid scalar: out of range");if(c){let{k1neg:D,k1:I,k2neg:x,k2:H}=G(C),R=new N(o.mul(A.X,c.beta),A.Y,A.Z);L.push(D?A.negate():A,x?R.negate():R),E.push(I,H)}else L.push(A),E.push(C)}let le=new WeakSet;class N{static BASE=new N(i.Gx,i.Gy,o.ONE);static ZERO=new N(o.ZERO,o.ONE,o.ZERO);static Fp=o;static Fn=r;X;Y;Z;constructor(E,A,C){this.X=U("x",E),this.Y=U("y",A,!0),this.Z=U("z",C),Object.freeze(this)}static CURVE(){return i}static fromAffine(E){let{x:A,y:C}=E||{};if(!E||!o.isValid(A)||!o.isValid(C))throw new Error("invalid affine point");if(E instanceof N)throw new Error("projective point not allowed");return o.is0(A)&&o.is0(C)?N.ZERO:new N(A,C,o.ONE)}static fromBytes(E){let A=N.fromAffine(w(X(E,void 0,"point")));return A.assertValidity(),A}static fromHex(E){return N.fromBytes(Pn(E))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(E=6,A=!0){return oe.setWindowSize(this,E),A||this.multiply(Jo),this}assertValidity(){let E=this;if(E.is0()){if(e.allowInfinityPoint&&o.is0(E.X)&&o.eql(E.Y,o.ONE)&&o.is0(E.Z))return;throw new Error("bad point: ZERO")}if(le.has(E))return;let{x:A,y:C}=E.toAffine();if(!o.isValid(A)||!o.isValid(C))throw new Error("bad point: x or y not field elements");if(!O(A,C))throw new Error("bad point: equation left != right");if(!E.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");le.add(E)}hasEvenY(){let{y:E}=this.toAffine();if(!o.isOdd)throw new Error("Field doesn't support isOdd");return!o.isOdd(E)}equals(E){F(E);let{X:A,Y:C,Z:D}=this,{X:I,Y:x,Z:H}=E,R=o.eql(o.mul(A,H),o.mul(I,D)),M=o.eql(o.mul(C,H),o.mul(x,D));return R&&M}negate(){return new N(this.X,o.neg(this.Y),this.Z)}double(){let{X:E,Y:A,Z:C}=this,D=o.ZERO,I=o.ZERO,x=o.ZERO,H=o.mul(E,E),R=o.mul(A,A),M=o.mul(C,C),P=o.mul(E,A);return P=o.add(P,P),x=o.mul(E,C),x=o.add(x,x),D=k(x),I=o.mul(b,M),I=o.add(D,I),D=o.sub(R,I),I=o.add(R,I),I=o.mul(D,I),D=o.mul(P,D),x=o.mul(b,x),M=k(M),P=o.sub(H,M),P=k(P),P=o.add(P,x),x=o.add(H,H),H=o.add(x,H),H=o.add(H,M),H=o.mul(H,P),I=o.add(I,H),M=o.mul(A,C),M=o.add(M,M),H=o.mul(M,P),D=o.sub(D,H),x=o.mul(M,R),x=o.add(x,x),x=o.add(x,x),new N(D,I,x)}add(E){F(E);let{X:A,Y:C,Z:D}=this,{X:I,Y:x,Z:H}=E,R=o.ZERO,M=o.ZERO,P=o.ZERO,K=o.mul(A,I),j=o.mul(C,x),Z=o.mul(D,H),ae=o.add(A,C),W=o.add(I,x);ae=o.mul(ae,W),W=o.add(K,j),ae=o.sub(ae,W),W=o.add(A,D);let te=o.add(I,H);return W=o.mul(W,te),te=o.add(K,Z),W=o.sub(W,te),te=o.add(C,D),R=o.add(x,H),te=o.mul(te,R),R=o.add(j,Z),te=o.sub(te,R),P=k(W),R=o.mul(b,Z),P=o.add(R,P),R=o.sub(j,P),P=o.add(j,P),M=o.mul(R,P),j=o.add(K,K),j=o.add(j,K),Z=k(Z),W=o.mul(b,W),j=o.add(j,Z),Z=o.sub(K,Z),Z=k(Z),W=o.add(W,Z),K=o.mul(j,W),M=o.add(M,K),K=o.mul(te,W),R=o.mul(ae,R),R=o.sub(R,K),K=o.mul(ae,j),P=o.mul(te,P),P=o.add(P,K),new N(R,M,P)}subtract(E){return F(E),this.add(E.negate())}is0(){return this.equals(N.ZERO)}multiply(E){if(!r.isValidNot0(E))throw new RangeError("invalid scalar: out of range");let{p:A,f:C}=oe.mulSecret(this,E,s,se);return se([A,C])[0]}multiplyUnsafe(E){let A=this,C=E;if(!r.isValid(C))throw new RangeError("invalid scalar: out of range");if(C===je||A.is0())return N.ZERO;if(C===gt)return A;if(oe.hasWindowSize(this))return oe.mulUnsafe(A,C,se);let D=[],I=[];return q(D,I,A,C),_n(N,D,I)}mulAddUnsafe(E,A,C){F(A);let D=[],I=[];return q(D,I,this,E),q(D,I,A,C),_n(N,D,I)}toAffine(E){let A=this,C=E;if(C!=null&&!o.isValid(C))throw new RangeError('"invertedZ" expected valid field element');let{X:D,Y:I,Z:x}=A;if(o.eql(x,o.ONE))return{x:D,y:I};let H=A.is0();C==null&&(C=H?o.ONE:o.inv(x));let R=o.mul(D,C),M=o.mul(I,C),P=o.mul(x,C);if(H)return{x:o.ZERO,y:o.ZERO};if(!o.eql(P,o.ONE))throw new Error("invZ was invalid");return{x:R,y:M}}isTorsionFree(){let{isTorsionFree:E}=e;return s===gt?!0:E?E(N,this):oe.mulUnsafe(this,a).is0()}clearCofactor(){let{clearCofactor:E}=e;return s===gt?this:E?E(N,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===gt?this.is0():this.clearCofactor().is0()}toBytes(E=!0){return He(E,"isCompressed"),this.assertValidity(),p(N,this,E)}toHex(E=!0){return No(this.toBytes(E))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let se=L=>Os(N,L),oe=new Un(N,u);return oe.bits>=6&&N.BASE.precompute(6),Object.freeze(N.prototype),Object.freeze(N),N}function Gs(t){return Uint8Array.of(t?2:3)}function Ws(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function fu(t,e={}){Mt(t);let{Fn:n}=t,o=e.randomBytes===void 0?Dn:e.randomBytes,r=Object.assign(Ws(t.Fp,n),{seed:Math.max(Fn(n.ORDER),16)});function i(l){try{let m=n.fromBytes(l);return n.isValidNot0(m)}catch{return!1}}function s(l,m){let{publicKey:p,publicKeyUncompressed:w}=r;try{let b=l.length;return m===!0&&b!==p||m===!1&&b!==w?!1:!!t.fromBytes(l)}catch{return!1}}function a(l){return l=l===void 0?o(r.seed):l,Vo(X(l,r.seed,"seed"),n.ORDER)}function c(l,m=!0){return t.BASE.multiply(n.fromBytes(l)).toBytes(m)}function f(l){let{secretKey:m,publicKey:p,publicKeyUncompressed:w}=r,b=n._lengths;if(!$t(l))return;let k=X(l,void 0,"key").length,v=k===p||k===w,O=k===m||!!b?.includes(k);if(!(v&&O))return v}function u(l,m,p=!0){if(f(l)===!0)throw new Error("first arg must be private key");if(f(m)===!1)throw new Error("second arg must be public key");let w=n.fromBytes(l);return t.fromBytes(m).multiply(w).toBytes(p)}let d={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},h=js(a,c);return Object.freeze(d),Object.freeze(r),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:h,Point:t,utils:d,lengths:r})}function Zs(t,e,n={}){Mt(t);let o=e;kn(o),ot(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let r=Object.assign({},n),i=r.randomBytes===void 0?Dn:r.randomBytes,s=r.hmac===void 0?(I,x)=>Ks(o,I,x):r.hmac,{Fp:a,Fn:c}=t,{ORDER:f,BITS:u}=c,d=Fn(f),h=Wo(i,d),{keygen:l,getPublicKey:m,getSharedSecret:p,utils:w,lengths:b}=fu(t,r),k={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},v=f*zs+gt<a.ORDER;function O(I){let x=f>>gt;return I>x}function z(I,x){if(!c.isValidNot0(x))throw new Error(`invalid signature ${I}: out of range 1..Point.Fn.ORDER`);return x}function S(){if(!a.isOdd)throw new Error("Field doesn't support isOdd")}function U(I,x,H){return S(),(I===H?0:2)|Number(a.isOdd(x))}function F(){if(v)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function G(I,x){Qo(x);let H=b.signature,R=x==="compact"?H:x==="recovered"?H+1:void 0;return X(I,R)}class q{r;s;recovery;constructor(x,H,R){if(this.r=z("r",x),this.s=z("s",H),R!=null){if(F(),![0,1,2,3].includes(R))throw new Error("invalid recovery id");this.recovery=R}Object.freeze(this)}static fromBytes(x,H=k.format){G(x,H);let R;if(H==="der"){let{r:j,s:Z}=Yo.toSig(X(x));return new q(j,Z)}H==="recovered"&&(R=x[0],H="compact",x=x.subarray(1));let M=b.signature/2,P=x.subarray(0,M),K=x.subarray(M,M*2);return new q(c.fromBytes(P),c.fromBytes(K),R)}static fromHex(x,H){return this.fromBytes(Pn(x),H)}assertRecovery(){let{recovery:x}=this;if(x==null)throw new Error("invalid recovery id: must be present");return x}addRecoveryBit(x){return new q(this.r,this.s,x)}recoverPublicKey(x){let{r:H,s:R}=this,M=this.assertRecovery(),P=M===2||M===3?H+f:H;if(!a.isValid(P))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let K=a.toBytes(P),j=t.fromBytes(Ue(Gs((M&1)===0),K)),Z=c.inv(P),ae=N(X(x,void 0,"msgHash")),W=c.create(-ae*Z),te=c.create(R*Z),Ee=t.BASE.mulAddUnsafe(W,j,te);if(Ee.is0())throw new Error("invalid recovery: point at infinify");return Ee.assertValidity(),Ee}hasHighS(){return O(this.s)}toBytes(x=k.format){if(Qo(x),x==="der")return Pn(Yo.hexFromSig(this));let{r:H,s:R}=this,M=c.toBytes(H),P=c.toBytes(R);return x==="recovered"?(F(),Ue(Uint8Array.of(this.assertRecovery()),M,P)):Ue(M,P)}toHex(x){return No(this.toBytes(x))}}Object.freeze(q.prototype),Object.freeze(q);let le=r.bits2int===void 0?function(x){if(x.length>8192)throw new Error("input is too large");let H=Ce(x),R=x.length*8-u;return R>0?H>>BigInt(R):H}:r.bits2int,N=r.bits2int_modN===void 0?function(x){return c.create(le(x))}:r.bits2int_modN,se=Jt(u);function oe(I){return Fo("num < 2^"+u,I,je,se),c.toBytes(I)}function L(I,x){return X(I,void 0,"message"),x?X(o(I),void 0,"prehashed message"):I}function E(I,x,H){let{lowS:R,prehash:M,extraEntropy:P}=Xo(H,k);I=L(I,M);let K=N(I),j=c.fromBytes(x);if(!c.isValidNot0(j))throw new Error("invalid private key");let Z=[oe(j),oe(K)];if(P!=null&&P!==!1){let Ee=P===!0?i(b.secretKey):P;Z.push(X(Ee,void 0,"extraEntropy"))}let ae=Ue(...Z),W=K;function te(Ee){let Et=le(Ee);if(!c.isValidNot0(Et))return;let _t=t.BASE.multiply(Et).toAffine(),Ze=c.create(_t.x);if(Ze===je)return;let Be;if(h!==void 0){let jt=Ce(Vo(h(d),f)),hc=c.inv(c.mul(jt,Et)),lc=c.mul(jt,W),pc=c.mul(jt,j);Be=c.create(hc*c.create(lc+pc*Ze))}else{let jt=Rs(Et,f);Be=c.create(jt*c.create(W+Ze*j))}if(Be===je)return;let to=U(_t.x,_t.y,Ze),ii=Be;return R&&O(Be)&&(ii=c.neg(Be),to^=1),new q(Ze,ii,v?void 0:to)}return{seed:ae,k2sig:te}}function A(I,x,H={}){let{seed:R,k2sig:M}=E(I,x,H);return Bs(o.outputLen,c.BYTES,s)(R,M).toBytes(H.format)}function C(I,x,H,R={}){let{lowS:M,prehash:P,format:K}=Xo(R,k);if(H=X(H,void 0,"publicKey"),x=L(x,P),!$t(I)){let j=I instanceof q?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+j)}G(I,K);try{let j=q.fromBytes(I,K),Z=t.fromBytes(H);if(M&&j.hasHighS())return!1;let{r:ae,s:W}=j,te=N(x),Ee=c.inv(W),Et=c.create(te*Ee),_t=c.create(ae*Ee),Ze=t.BASE.mulAddUnsafe(Et,Z,_t);if(Ze.is0())return!1;let Be=Ze.toAffine();return!(c.create(Be.x)!==ae||K==="recovered"&&j.recovery!==U(Be.x,Be.y,ae))}catch{return!1}}function D(I,x,H={}){let{prehash:R}=Xo(H,k);return x=L(x,R),q.fromBytes(I,"recovered").recoverPublicKey(x).toBytes()}return Object.freeze({keygen:l,getPublicKey:m,getSharedSecret:p,utils:w,lengths:b,Point:t,sign:A,verify:C,recoverPublicKey:D,Signature:q,hash:o})}var uu={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")};var du=qs(uu),Ys=Zs(du,ys);var tr=globalThis.crypto,er=class{hasher;constructor(e){let n=e.toLowerCase().replace("-","");if(n==="sha256")this.hasher=_.create();else if(n==="sha512")this.hasher=An.create();else throw new Error(`createHash: unsupported algorithm ${e} in the browser verifier`)}update(e){return this.hasher.update(typeof e=="string"?new TextEncoder().encode(e):e),this}digest(e){let n=this.hasher.digest(),o=B.Buffer.from(n);return e===void 0?o:o.toString(e)}};function Kn(t){return new er(t)}function nr(t){let e=[];return{update(n){return e.push(n),this},verify(n,o){try{let r=n instanceof Uint8Array?n:n.key,i=r.subarray(r.length-65);if(i.length!==65||i[0]!==4)return!1;let s=0;for(let f of e)s+=f.length;let a=new Uint8Array(s),c=0;for(let f of e)a.set(f,c),c+=f.length;return Ys.verify(o,_(a),i,{format:"der",prehash:!1,lowS:!1})}catch{return!1}}}}y();function ge(t){let e=Xs(t);return new TextEncoder().encode(e)}function Xs(t){return JSON.stringify(or(t))}function or(t){if(t===null||typeof t!="object"){if(typeof t>"u")throw new TypeError("bitgraph-core/canonical: undefined values are not serializable to canonical JSON");if(typeof t=="function"||typeof t=="symbol")throw new TypeError(`bitgraph-core/canonical: ${typeof t} values are not serializable to canonical JSON`);if(typeof t=="bigint")throw new TypeError("bitgraph-core/canonical: BigInt values are not serializable to canonical JSON; convert to string (decimal) before canonicalizing");return t}if(Array.isArray(t))return t.map(or);let e={};for(let n of Object.keys(t).sort()){let o=t[n];typeof o>"u"||(e[n]=or(o))}return e}function Vn(t,e){if(t.length!==e.length)return!1;let n=0;for(let o=0;o<t.length;o++)n|=t[o]^e[o];return n===0}async function ir(t){let{proof:e,bytes:n,trustAnchors:o}=t,r=await Js(e,n,o);return r===null?{valid:!0}:xu(r)}async function it(t){let{proof:e,trustAnchors:n}=t,o=await Js(e,void 0,n);return o===null?{valid:!0,artifactBinding:"not-checked"}:{valid:!1,artifactBinding:"not-checked",reason:o}}async function Js(t,e,n){let o=lu(t);if(o!==null)return o;let r=e===void 0?void 0:_(e),i;try{i=Lt(t.artifact.digestB64)}catch{return"artifact.digestB64 is not valid base64"}if(r!==void 0&&!Vn(r,i))return"artifact digest mismatch: the provided bytes do not match the committed digest";let s;try{s=Lt(t.signer.publicKeyB64)}catch{return"signer.publicKeyB64 is not valid base64"}if(s.length!==32)return`signer.publicKeyB64 decodes to ${s.length} bytes; expected 32 (Ed25519)`;let a={version:t.version,artifact:t.artifact,commit:t.commit,publicKeyB64:t.signer.publicKeyB64,enforcement:t.environment.enforcement,measurement:t.environment.measurement};t.environment.attestation!==void 0&&(a.attestationFormat=t.environment.attestation.format),t.agency!==void 0&&(a.actor=t.agency.actor),t.policy!==void 0&&(a.policy=t.policy),t.attribution!==void 0&&(a.attribution=t.attribution);let c=ge(a),f;try{f=Lt(t.signer.signatureB64)}catch{return"signer.signatureB64 is not valid base64"}if(f.length!==64)return`signer.signatureB64 decodes to ${f.length} bytes; expected 64 (Ed25519)`;let u;try{u=await Ao(f,c,s)}catch(d){return`signature verification error: ${d instanceof Error?d.message:String(d)}`}if(!u)return"signature verification failed: signature does not match";if(t.agency!==void 0){let d=gu(t);if(d!==null)return d}if(t.slotAllocation!==void 0){let d=await bu(t);if(d!==null)return d}if(t.commit.epochLink!==void 0){let d=wu(t);if(d!==null)return d}if(n!==void 0){let d=pu(t,n);if(d!==null)return d}return null}var hu=new Set(["stub","hw-key","measured-tee"]);function lu(t){if(t===null||typeof t!="object")return"proof must be an object";let e=t;if(e.version!=="bitgraph/1")return`unsupported proof version: ${String(e.version)}`;if(!en(e.artifact))return"proof.artifact is missing or not an object";let n=e.artifact;if(n.hashAlg!=="sha256")return`unsupported hashAlg: ${String(n.hashAlg)}`;if(typeof n.digestB64!="string"||n.digestB64.length===0)return"proof.artifact.digestB64 must be a non-empty string";if(!en(e.commit))return"proof.commit is missing or not an object";let o=e.commit;if(typeof o.nonceB64!="string"||o.nonceB64.length===0)return"proof.commit.nonceB64 must be a non-empty string";if(o.counter!==void 0&&typeof o.counter!="string")return"proof.commit.counter must be a string when present";if(o.time!==void 0&&(typeof o.time!="number"||!Number.isFinite(o.time)||o.time<0))return"proof.commit.time must be a non-negative finite number when present";if(o.prevB64!==void 0&&typeof o.prevB64!="string")return"proof.commit.prevB64 must be a string when present";if(o.epochId!==void 0&&typeof o.epochId!="string")return"proof.commit.epochId must be a string when present";if(!en(e.signer))return"proof.signer is missing or not an object";let r=e.signer;if(typeof r.publicKeyB64!="string"||r.publicKeyB64.length===0)return"proof.signer.publicKeyB64 must be a non-empty string";if(typeof r.signatureB64!="string"||r.signatureB64.length===0)return"proof.signer.signatureB64 must be a non-empty string";if(!en(e.environment))return"proof.environment is missing or not an object";let i=e.environment;if(typeof i.enforcement!="string"||!hu.has(i.enforcement))return"proof.environment.enforcement must be one of: stub, hw-key, measured-tee";if(typeof i.measurement!="string"||i.measurement.length===0)return"proof.environment.measurement must be a non-empty string";if(i.attestation!==void 0){if(!en(i.attestation))return"proof.environment.attestation must be an object when present";let s=i.attestation;if(typeof s.format!="string"||s.format.length===0)return"proof.environment.attestation.format must be a non-empty string";if(typeof s.reportB64!="string"||s.reportB64.length===0)return"proof.environment.attestation.reportB64 must be a non-empty string"}return null}function pu(t,e){if(e.requireEnforcement!==void 0&&t.environment.enforcement!==e.requireEnforcement)return`enforcement tier "${t.environment.enforcement}" does not meet required tier "${e.requireEnforcement}"`;if(e.allowedMeasurements!==void 0&&e.allowedMeasurements.length>0&&!e.allowedMeasurements.includes(t.environment.measurement))return`measurement "${t.environment.measurement}" is not in the allowed set`;if(e.allowedPublicKeys!==void 0&&e.allowedPublicKeys.length>0&&!e.allowedPublicKeys.includes(t.signer.publicKeyB64))return"proof public key is not in the allowed set";if(e.requireAttestation===!0&&t.environment.attestation===void 0)return"policy requires attestation but proof has none";if(e.requireAttestationFormat!==void 0&&e.requireAttestationFormat.length>0){if(t.environment.attestation===void 0)return"policy requires attestation format but proof has no attestation";if(!e.requireAttestationFormat.includes(t.environment.attestation.format))return`attestation format "${t.environment.attestation.format}" is not in the required set`}if(e.minCounter!==void 0||e.maxCounter!==void 0){if(t.commit.counter===void 0)return"policy requires a counter but proof has none";let n;try{n=BigInt(t.commit.counter)}catch{return"could not parse proof counter value as integer"}if(e.minCounter!==void 0){let o;try{o=BigInt(e.minCounter)}catch{return"could not parse policy minCounter as integer"}if(n<o)return`counter ${t.commit.counter} is below minimum ${e.minCounter}`}if(e.maxCounter!==void 0){let o;try{o=BigInt(e.maxCounter)}catch{return"could not parse policy maxCounter as integer"}if(n>o)return`counter ${t.commit.counter} is above maximum ${e.maxCounter}`}}if(e.minTime!==void 0||e.maxTime!==void 0){if(t.commit.time===void 0)return"policy requires a time field but proof has none";if(e.minTime!==void 0&&t.commit.time<e.minTime)return`commit time ${t.commit.time} is before minimum ${e.minTime}`;if(e.maxTime!==void 0&&t.commit.time>e.maxTime)return`commit time ${t.commit.time} is after maximum ${e.maxTime}`}if(e.requireEpochId===!0&&(t.commit.epochId===void 0||t.commit.epochId.length===0))return"policy requires epochId but proof has none";if(e.requireActor===!0&&t.agency===void 0)return"policy requires actor (agency) but proof has none";if(e.allowedActorKeyIds!==void 0&&e.allowedActorKeyIds.length>0){if(t.agency===void 0)return"policy requires allowed actor key ID but proof has no agency";if(!e.allowedActorKeyIds.includes(t.agency.actor.keyId))return"actor key ID is not in the allowed set"}if(e.allowedActorProviders!==void 0&&e.allowedActorProviders.length>0){if(t.agency===void 0)return"policy requires allowed actor provider but proof has no agency";if(!e.allowedActorProviders.includes(t.agency.actor.provider))return`actor provider "${t.agency.actor.provider}" is not in the allowed set`}if(e.allowedOrigins!==void 0&&e.allowedOrigins.length>0){if(t.agency===void 0)return"policy requires an allowed origin but proof has no agency";let n=t.agency.authorization;if(!("format"in n)||n.format!=="webauthn")return"policy requires an allowed WebAuthn origin but the authorization is not WebAuthn";let o;try{o=JSON.parse(n.clientDataJSON).origin}catch{o=void 0}if(typeof o!="string"||!e.allowedOrigins.includes(o))return`WebAuthn origin "${o??"(none)"}" is not in the allowed set`}return e.requireSlot===!0&&t.slotAllocation===void 0?"policy requires slotAllocation (BitGraph causal slot) but proof has none":null}function mu(t,e){if(typeof t!="string"||t.length===0)return"agency: clientDataJSON missing origin field";let n;try{n=new URL(t).hostname.toLowerCase()}catch{return"agency: clientDataJSON origin is not a valid origin"}if(!n)return"agency: clientDataJSON origin has no host";let o=e.subarray(0,32).toString("hex"),r=n.split("."),i=[];for(let a=0;a<r.length;a++){let c=r.slice(a).join(".");if(a>0&&r.length-a<2)break;i.push(c)}return i.some(a=>Kn("sha256").update(a,"utf8").digest("hex")===o)?null:"agency: authenticatorData rpIdHash does not match the origin's domain"}function gu(t){let e=t.agency,{actor:n,authorization:o}=e,r="format"in o&&o.format==="webauthn";if(typeof n.keyId!="string"||n.keyId.length===0)return"agency.actor.keyId must be a non-empty string";if(typeof n.publicKeyB64!="string"||n.publicKeyB64.length===0)return"agency.actor.publicKeyB64 must be a non-empty string";if(n.algorithm!=="ES256")return`agency.actor.algorithm must be "ES256", got "${String(n.algorithm)}"`;if(typeof n.provider!="string"||n.provider.length===0)return"agency.actor.provider must be a non-empty string";if(o.purpose!=="bitgraph/commit-authorize/v1")return`agency.authorization.purpose must be "bitgraph/commit-authorize/v1", got "${String(o.purpose)}"`;if(typeof o.signatureB64!="string"||o.signatureB64.length===0)return"agency.authorization.signatureB64 must be a non-empty string";let i;try{i=B.Buffer.from(n.publicKeyB64,"base64")}catch{return"agency.actor.publicKeyB64 is not valid base64"}if(Kn("sha256").update(i).digest("hex")!==n.keyId)return"agency: actor.keyId does not match SHA-256 of public key";if(o.actorKeyId!==n.keyId)return"agency: authorization.actorKeyId does not match actor.keyId";if(o.artifactHash!==t.artifact.digestB64){let c=e.batchContext;if(!c||!Array.isArray(c.batchDigests)||!c.batchDigests.includes(t.artifact.digestB64)||c.batchDigests[0]!==o.artifactHash)return"agency: authorization.artifactHash does not match proof.artifact.digestB64"}let a;try{a=B.Buffer.from(o.signatureB64,"base64")}catch{return"agency.authorization.signatureB64 is not valid base64"}try{if(r){let c=o;if(typeof c.clientDataJSON!="string"||!c.clientDataJSON)return"agency: WebAuthn authorization missing clientDataJSON";if(typeof c.authenticatorDataB64!="string"||!c.authenticatorDataB64)return"agency: WebAuthn authorization missing authenticatorDataB64";let f;try{f=JSON.parse(c.clientDataJSON)}catch{return"agency: clientDataJSON is not valid JSON"}if(f.type!=="webauthn.get")return`agency: clientDataJSON.type must be "webauthn.get", got "${f.type}"`;if(!f.challenge)return"agency: clientDataJSON missing challenge field";let u=f.challenge.replace(/-/g,"+").replace(/_/g,"/");for(;u.length%4;)u+="=";if(u!==o.challenge)return"agency: clientDataJSON challenge does not match authorization.challenge";let d=B.Buffer.from(c.authenticatorDataB64,"base64");if(d.length<37)return"agency: authenticatorData too short";let h=d[32];if(!(h&1))return"agency: authenticatorData UP flag not set";if(!(h&4))return"agency: authenticatorData UV flag not set";let l=mu(f.origin,d);if(l!==null)return l;let m=Kn("sha256").update(B.Buffer.from(c.clientDataJSON,"utf8")).digest(),p=B.Buffer.concat([d,m]),w=nr("SHA256");if(w.update(p),!w.verify({key:i,format:"der",type:"spki"},a))return"agency: WebAuthn P-256 signature verification failed"}else{let c={purpose:o.purpose,actorKeyId:o.actorKeyId,artifactHash:o.artifactHash,challenge:o.challenge,timestamp:o.timestamp};"protocolVersion"in o&&o.protocolVersion!==void 0&&(c.protocolVersion=o.protocolVersion);let f=B.Buffer.from(JSON.stringify(c,Object.keys(c).sort()),"utf8"),u=nr("SHA256");if(u.update(f),!u.verify({key:i,format:"der",type:"spki"},a))return"agency: P-256 signature verification failed"}}catch(c){return`agency: P-256 signature verification error: ${c instanceof Error?c.message:String(c)}`}return null}async function bu(t){let e=t.slotAllocation;if(e.version!=="bitgraph/slot/1")return`slotAllocation.version must be "bitgraph/slot/1", got "${String(e.version)}"`;if(typeof e.nonceB64!="string"||e.nonceB64.length===0)return"slotAllocation.nonceB64 must be a non-empty string";if(typeof e.counter!="string"||e.counter.length===0)return"slotAllocation.counter must be a non-empty string";if(e.time!==void 0&&(typeof e.time!="number"||!Number.isFinite(e.time)||e.time<0))return"slotAllocation.time must be a non-negative finite number when present";if(typeof e.epochId!="string"||e.epochId.length===0)return"slotAllocation.epochId must be a non-empty string";if(typeof e.publicKeyB64!="string"||e.publicKeyB64.length===0)return"slotAllocation.publicKeyB64 must be a non-empty string";if(typeof e.signatureB64!="string"||e.signatureB64.length===0)return"slotAllocation.signatureB64 must be a non-empty string";let n={version:e.version,nonceB64:e.nonceB64,counter:e.counter,...e.time!==void 0?{time:e.time}:{},epochId:e.epochId,publicKeyB64:e.publicKeyB64,...e.chainId?{chainId:e.chainId}:{}},o=ge(n),r,i;try{r=Lt(e.signatureB64),i=Lt(e.publicKeyB64)}catch{return"slotAllocation contains invalid base64"}if(r.length!==64)return`slotAllocation.signatureB64 decodes to ${r.length} bytes; expected 64 (Ed25519)`;if(i.length!==32)return`slotAllocation.publicKeyB64 decodes to ${i.length} bytes; expected 32 (Ed25519)`;let s;try{s=await Ao(r,o,i)}catch(d){return`slotAllocation signature verification error: ${d instanceof Error?d.message:String(d)}`}if(!s)return"slotAllocation signature verification failed";let a=new Set(["digestB64","artifact","hashAlg","signatureB64"]),c=Object.keys(n);for(let d of c)if(a.has(d))return`slotAllocation body contains forbidden field '${d}' \u2014 causal independence violated`;if(typeof t.commit.slotHashB64!="string"||t.commit.slotHashB64.length===0)return"commit.slotHashB64 must be present when slotAllocation is present";let f=_(o),u;try{u=Lt(t.commit.slotHashB64)}catch{return"commit.slotHashB64 is not valid base64"}if(!Vn(f,u))return"commit.slotHashB64 does not match SHA-256 of canonical slot body \u2014 slot binding broken";if(e.nonceB64!==t.commit.nonceB64)return"slotAllocation.nonceB64 does not match commit.nonceB64";if(typeof t.commit.slotCounter!="string"||t.commit.slotCounter.length===0)return"commit.slotCounter must be present when slotAllocation is present";if(t.commit.slotCounter!==e.counter)return"commit.slotCounter does not match slotAllocation.counter";if(t.commit.counter===void 0)return"commit.counter must be present for slot ordering verification";try{let d=BigInt(e.counter),h=BigInt(t.commit.counter);if(d>=h)return`slotAllocation.counter (${e.counter}) must be less than commit.counter (${t.commit.counter})`}catch{return"could not parse slot or commit counter as integer"}return e.publicKeyB64!==t.signer.publicKeyB64?"slotAllocation.publicKeyB64 does not match signer.publicKeyB64 \u2014 different enclave":t.commit.epochId!==void 0&&e.epochId!==t.commit.epochId?"slotAllocation.epochId does not match commit.epochId \u2014 different lifecycle":null}var rr=new Map;function yu(t){let e=`${t.prevEpochId}|${t.prevCounter}|${t.prevProofHashB64}`,n=_(new TextEncoder().encode(e));return B.Buffer.from(n).toString("base64")}function wu(t){let e=t.commit.epochLink;if(typeof e.prevEpochId!="string"||e.prevEpochId.length===0)return"epochLink.prevEpochId must be a non-empty string";if(typeof e.prevPublicKeyB64!="string"||e.prevPublicKeyB64.length===0)return"epochLink.prevPublicKeyB64 must be a non-empty string";if(typeof e.prevCounter!="string"||e.prevCounter.length===0)return"epochLink.prevCounter must be a non-empty string";if(typeof e.prevProofHashB64!="string"||e.prevProofHashB64.length===0)return"epochLink.prevProofHashB64 must be a non-empty string";if(typeof e.toEpochId!="string"||e.toEpochId.length===0)return"epochLink.toEpochId must be a non-empty string";if(typeof e.toPublicKeyB64!="string"||e.toPublicKeyB64.length===0)return"epochLink.toPublicKeyB64 must be a non-empty string";try{BigInt(e.prevCounter)}catch{return"epochLink.prevCounter is not a valid decimal string"}if(t.commit.epochId!==void 0&&e.toEpochId!==t.commit.epochId)return`epochLink.toEpochId "${e.toEpochId}" does not match proof commit.epochId "${t.commit.epochId}" \u2014 successor binding broken`;if(e.toPublicKeyB64!==t.signer.publicKeyB64)return"epochLink.toPublicKeyB64 does not match proof signer.publicKeyB64 \u2014 successor binding broken";if(e.prevEpochId===e.toEpochId)return"epochLink.prevEpochId equals toEpochId \u2014 epoch link must cross epoch boundary";if(e.prevPublicKeyB64===e.toPublicKeyB64)return"epochLink.prevPublicKeyB64 equals toPublicKeyB64 \u2014 epochs must have different keys";let n=yu(e),o=rr.get(n);if(o!==void 0){if(o!==e.toEpochId)return`FORK DETECTED: predecessor (epoch=${e.prevEpochId.slice(0,12)}..., counter=${e.prevCounter}) already consumed by epoch ${o.slice(0,12)}..., but this proof claims consumption by epoch ${e.toEpochId.slice(0,12)}... \u2014 single-successor invariant violated`}else rr.set(n,e.toEpochId);return null}function Ke(){rr.clear()}function xu(t){return{valid:!1,reason:t}}function en(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Lt(t){let e=B.Buffer.from(t,"base64");if(e.toString("base64")!==t)throw new Error(`invalid base64 string: "${t}"`);return new Uint8Array(e)}y();function zn(t){let e=t,n=e.signer,o=e.environment,r={version:e.version,artifact:e.artifact,commit:e.commit,publicKeyB64:n?.publicKeyB64,enforcement:o?.enforcement,measurement:o?.measurement};e.attribution&&(r.attribution=e.attribution),o?.attestation&&(r.attestationFormat=o.attestation.format);let i=ge(r),s=_(i);return ar(s)}var Qs=["proofHash","ethereum"];function sr(t){let e=t,n=e;if(Qs.some(r=>Object.prototype.hasOwnProperty.call(e,r))){n={};for(let r of Object.keys(e))Qs.includes(r)||(n[r]=e[r])}let o=ge(n);return ar(_(o))}function ar(t){if(typeof B.Buffer<"u")return B.Buffer.from(t).toString("base64");let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function ea(t){let e=t,n=e.signer,o=e.environment,r={version:e.version,artifact:e.artifact,commit:e.commit,publicKeyB64:n?.publicKeyB64,enforcement:o?.enforcement,measurement:o?.measurement};o?.attestation!==void 0&&(r.attestationFormat=o.attestation.format);let i=e.agency;return i!==void 0&&(r.actor=i.actor),e.policy!==void 0&&(r.policy=e.policy),e.attribution!==void 0&&(r.attribution=e.attribution),r}function cr(t){return ar(_(ge(ea(t))))}y();var Ve="bitgraph-fuse/1",oa=(()=>{let t=new TextEncoder().encode(Ve),e=new Uint8Array(t.length+1);return e.set(t,0),e[t.length]=0,e})(),ra=Ve,fr="BGFUSE01",qn=48,dr="bitgraph-fuse/manifest.json",hr="bitgraph-fuse/original",Ot="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",tn={};for(let t=0;t<Ot.length;t++)tn[Ot[t]]=t;function ze(t){let e="";for(let n=0;n<t.length;n+=3){let o=t[n],r=n+1<t.length?t[n+1]:0,i=n+2<t.length?t[n+2]:0;e+=Ot[o>>2]+Ot[(o&3)<<4|r>>4],e+=n+1<t.length?Ot[(r&15)<<2|i>>6]:"=",e+=n+2<t.length?Ot[i&63]:"="}return e}function Ft(t){if(typeof t!="string"||t.length%4!==0||!/^[A-Za-z0-9+/]*={0,2}$/.test(t))return null;let e=t.endsWith("==")?2:t.endsWith("=")?1:0,n=new Uint8Array(t.length/4*3-e),o=0;for(let r=0;r<t.length;r+=4){let i=tn[t[r]]<<18|tn[t[r+1]]<<12|(t[r+2]==="="?0:tn[t[r+2]])<<6|(t[r+3]==="="?0:tn[t[r+3]]);n[o++]=i>>16&255,o<n.length&&(n[o++]=i>>8&255),o<n.length&&(n[o++]=i&255)}return ze(n)!==t?null:n}function Re(t){let e="";for(let n of t)e+=(n<16?"0":"")+n.toString(16);return e}function lr(t){if(typeof t!="string"||t.length%2!==0||!/^[0-9a-f]*$/.test(t))return null;let e=new Uint8Array(t.length/2);for(let n=0;n<e.length;n++)e[n]=parseInt(t.slice(n*2,n*2+2),16);return e}function $e(t,e){if(t.length!==e.length)return!1;let n=0;for(let o=0;o<t.length;o++)n|=t[o]^e[o];return n===0}function pr(...t){let e=0;for(let r of t)e+=r.length;let n=new Uint8Array(e),o=0;for(let r of t)n.set(r,o),o+=r.length;return n}var be=t=>new TextEncoder().encode(t);function ia(t){return{version:t.version,nonceB64:t.nonceB64,counter:t.counter,...t.time!==void 0?{time:t.time}:{},epochId:t.epochId,publicKeyB64:t.publicKeyB64,...t.chainId?{chainId:t.chainId}:{}}}function sa(t){return _(ge(ia(t)))}function aa(t){let e=Ft(t.nonceB64);if(e===null||e.length!==32)throw new TypeError("slot.nonceB64 must decode to exactly 32 bytes");return pr(oa,sa(t),e)}function nn(t){return _(aa(t))}function Gn(t,e){if(t.length!==32)throw new TypeError("commitment must be 32 bytes");if(e!==void 0&&e.length!==32)throw new TypeError("originDigest must be 32 bytes");let n={type:Ve,...e!==void 0?{origin:{algorithm:"sha256",digest:Re(e)}}:{},slotCommitment:{algorithm:"sha256",digest:Re(t)}};return ge(n)}function st(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)&&Object.getPrototypeOf(t)===Object.prototype}function bt(t){if(!st(t)||Object.keys(t).length!==2||t.algorithm!=="sha256"||typeof t.digest!="string")return null;let n=lr(t.digest);return n!==null&&n.length===32?n:null}function mr(t){let e;try{e=new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch{return null}let n;try{n=JSON.parse(e)}catch{return null}if(!st(n))return null;let o=Object.keys(n).sort(),r=o.length===2?["slotCommitment","type"]:o.length===3?["origin","slotCommitment","type"]:null;if(r===null||o.join(",")!==r.join(",")||n.type!==Ve)return null;let i=bt(n.slotCommitment);if(i===null)return null;let s;if("origin"in n){let a=bt(n.origin);if(a===null)return null;s=a}return $e(Gn(i,s),t)?s!==void 0?{commitment:i,originDigest:s}:{commitment:i}:null}var ye=512,Eu=8589934591;function Bu(t,e){let n=t.toString(8).padStart(e-1,"0")+"\0";if(n.length!==e)throw new RangeError("field overflow");return be(n)}function ta(t,e){if(e>Eu)throw new RangeError("container/1 entries are limited to 8 GiB");let n=new Uint8Array(ye),o=be(t);if(o.length>100)throw new RangeError("ustar name too long");n.set(o,0),n.set(be("0000644\0"),100),n.set(be("0000000\0"),108),n.set(be("0000000\0"),116),n.set(Bu(e,12),124),n.set(be("00000000000\0"),136),n.set(be(" "),148),n[156]=48,n.set(be("ustar\0"),257),n.set(be("00"),263);let r=0;for(let i of n)r+=i;return n.set(be(r.toString(8).padStart(6,"0")+"\0 "),148),n}function ur(t){return(ye-t%ye)%ye}function na(t,e){return pr(ta(dr,e.length),e,new Uint8Array(ur(e.length)),ta(hr,t.length),t,new Uint8Array(ur(t.length)),new Uint8Array(ye*2))}function vu(t){let e=[],n=0;for(;n+ye<=t.length;){let o=t.subarray(n,n+ye);if(o.every(f=>f===0)){let f=t.subarray(n);return f.length!==ye*2||!f.every(u=>u===0)?null:e}let r=o.indexOf(0,0),i=new TextDecoder().decode(o.subarray(0,r<0||r>100?100:r)),s=new TextDecoder().decode(o.subarray(124,135));if(!/^[0-7]{11}$/.test(s))return null;let a=parseInt(s,8);if(n+ye+a>t.length)return null;let c=t.subarray(n+ye,n+ye+a);e.push({name:i,data:c,headerBytes:o}),n+=ye+a+ur(a)}return null}var Au={id:"trailer/1",form:"A",byteExact:!0,build({original:t,commitment:e}){if(t===void 0)throw new TypeError("trailer/1 requires the original bytes");if(e.length!==32)throw new TypeError("commitment must be 32 bytes");return pr(t,be(fr),new Uint8Array(8),e)},locate(t){if(t.length<qn)return null;let e=t.subarray(t.length-qn);return!$e(e.subarray(0,8),be(fr))||!e.subarray(8,16).every(n=>n===0)?null:{commitment:new Uint8Array(e.subarray(16,48)),originalBytes:t.subarray(0,t.length-qn)}}},Iu={id:"container/1",form:"B",byteExact:!0,build({original:t,originDigest:e,commitment:n}){if(t===void 0)throw new TypeError("container/1 requires the original bytes");let o=e??_(t);return na(t,Gn(n,o))},locate(t){let e=vu(t);if(e===null||e.length!==2)return null;let[n,o]=e;if(n.name!==dr||o.name!==hr)return null;let r=mr(n.data);if(r===null||r.originDigest===void 0)return null;let i=na(o.data,n.data);return $e(i,t)?{commitment:r.commitment,originDigest:r.originDigest,originalBytes:o.data}:null}},ku={id:"produced/1",form:"C",byteExact:!1,build({original:t,originDigest:e,commitment:n}){if(t!==void 0)throw new TypeError("produced/1 takes no original; pass originDigest for a source reference");return Gn(n,e)},locate(t){let e=mr(t);return e===null?null:e.originDigest!==void 0?{commitment:e.commitment,originDigest:e.originDigest}:{commitment:e.commitment}}},Ut=Object.freeze([Au,Iu,ku]),yt="set/1";var ca=/^[a-z0-9][a-z0-9-]*\/[1-9][0-9]*$/;function fa(t,e){if(t.length!==32)throw new TypeError("commitment must be 32 bytes");if(e.length===0)throw new TypeError("a set lists at least one member");let n=[],o=new Set;for(let i of e){if(i.artifact.length!==32)throw new TypeError("member artifact digest must be 32 bytes");if(i.origin.length!==32)throw new TypeError("member origin digest must be 32 bytes");if(!ca.test(i.placement))throw new TypeError(`member placement "${i.placement}" is not a placement id`);if(i.placement===yt)throw new TypeError("a set cannot list a set as a member");let s=Re(i.artifact);if(o.has(s))throw new TypeError(`duplicate member artifact digest ${s}`);o.add(s),n.push({artifact:{algorithm:"sha256",digest:s},origin:{algorithm:"sha256",digest:Re(i.origin)},placement:i.placement})}n.sort((i,s)=>i.artifact.digest<s.artifact.digest?-1:1);let r={members:n,placement:yt,slotCommitment:{algorithm:"sha256",digest:Re(t)},type:Ve};return ge(r)}function gr(t){let e;try{e=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode(t)}catch{return null}let n;try{n=JSON.parse(e)}catch{return null}if(!st(n)||Object.keys(n).sort().join(",")!=="members,placement,slotCommitment,type"||n.type!==Ve||n.placement!==yt)return null;let o=bt(n.slotCommitment);if(o===null)return null;let r=n.members;if(!Array.isArray(r)||r.length===0)return null;let i=[];for(let a of r){if(!st(a)||Object.keys(a).sort().join(",")!=="artifact,origin,placement")return null;let c=bt(a.artifact),f=bt(a.origin),u=a.placement;if(c===null||f===null||typeof u!="string"||!ca.test(u)||u===yt)return null;i.push({artifact:c,origin:f,placement:u})}let s;try{s=fa(o,i)}catch{return null}return $e(s,t)?{commitment:o,members:i}:null}var Su={id:yt,form:"C",byteExact:!1,build(){throw new TypeError("set/1 is built with buildSetManifest(commitment, members)")},locate(t){let e=gr(t);return e===null?null:{commitment:e.commitment}}};function on(t){return[...Ut,Su].find(e=>e.id===t)}function wt(t){let e=t.attribution;if(e===void 0||e.name!==ra)return null;let n=typeof e.title=="string"&&e.title.length>0,o={placement:n?e.title:null,placementSource:n?"attribution":null,source:"attribution"};if(typeof e.message=="string"&&e.message.length>0){let r=Ft(e.message);r!==null&&r.length===32&&(o.originDigest=r,o.originSource="attribution")}return o}function br(t,e){if(t===null)return e;if(e===null)return t;let n={...t};return n.placement===null&&e.placement!==null&&(n.placement=e.placement,n.placementSource="manifest"),n.originDigest===void 0&&e.originDigest!==void 0&&(n.originDigest=e.originDigest,n.originSource="manifest"),n}function yr(t){let e=typeof t=="string"?(()=>{try{return JSON.parse(t)}catch{return null}})():t;if(!st(e)||e.type!==Ve)return null;let n=e.manifest;if(!st(n)||n.placement!==void 0&&typeof n.placement!="string"||bt(n.artifact)===null||n.origin!==void 0&&bt(n.origin)===null||n.fusedFile!==null&&typeof n.fusedFile!="string")return null;let r=e.proof;if(!st(r)||r.version!=="bitgraph/1")return null;let i={type:Ve,manifest:{placement:typeof n.placement=="string"?n.placement:"",...n.origin!==void 0?{origin:n.origin}:{},artifact:n.artifact,fusedFile:n.fusedFile},proof:r};if(e.fusePayload!==void 0){if(!st(e.fusePayload))return null;i.fusePayload=e.fusePayload}return i}function wr(t){let e=t.manifest.placement.length>0,n={placement:e?t.manifest.placement:null,placementSource:e?"manifest":null,source:"manifest"};if(t.manifest.origin!==void 0){let o=lr(t.manifest.origin.digest);o!==null&&o.length===32&&(n.originDigest=o,n.originSource="manifest")}return n}y();function ua(t){let e=t.commit;if(typeof e.counter!="string"||typeof e.slotCounter!="string"||typeof e.epochId!="string")return null;let n;try{n=(BigInt(e.counter)-BigInt(e.slotCounter)).toString()}catch{return null}return{slotCounter:e.slotCounter,commitCounter:e.counter,epochId:e.epochId,chainId:typeof e.chainId=="string"?e.chainId:null,positions:n}}function da(t){return`The exact fused bytes could not feasibly have been finalized before their signed slot allocation at position ${t.slotCounter}, and were committed no later than position ${t.commitCounter}.`}function xr(t,e,n){if(e===null)return[];let o=[];return t==="FUSED_FROM_ORIGIN"?o.push(`The supplied original rebuilds the committed fused artifact byte for byte, so these exact original bytes existed no later than commit position ${e.commitCounter}.`):t==="FUSED_DIRECT"&&n&&o.push("The fused bytes carry an origin digest that matches the signed marker; the original itself was not supplied and was not checked."),(t==="FUSED_DIRECT"||t==="FUSED_FROM_ORIGIN")&&o.push(da(e)),t==="RECORDED"&&o.push(`These exact bytes existed no later than commit position ${e.commitCounter}.`),o}async function Er(t){let{proof:e,bytes:n}=t,o=t.frame===void 0||t.frame===null?null:yr(t.frame)??null,r=_(n),i=ze(r),s=e?.artifact?.digestB64??"",a=(w,b,k)=>({category:w,proof:b.proof??{valid:!0},marker:b.marker??null,placement:b.placement??null,fileDigestB64:i,artifactDigestB64:s,originDigestB64:b.originDigestB64??null,slotCommitmentB64:b.slotCommitmentB64??null,span:b.span??null,policy:b.policy??{spanExceeded:!1,maxPositions:null},statements:b.statements??[],reason:k}),c=await it(t.trustAnchors!==void 0?{proof:e,trustAnchors:t.trustAnchors}:{proof:e});if(!c.valid){let w=c.reason??"proof failed verification";return a("INVALID_UNDERLYING_PROOF",{proof:{valid:!1,reason:w}},w)}let f=br(wt(e),o!==null?wr(o):null),u=f?.originDigest,d=u!==void 0?ze(u):null,h=ua(e),l=t.maxPositions===void 0?null:BigInt(t.maxPositions),m={spanExceeded:l!==null&&h!==null&&BigInt(h.positions)>l,maxPositions:l===null?null:l.toString()},p={proof:{valid:!0},marker:f,originDigestB64:d,span:h,policy:m};if(i===s){if(f===null)return a("RECORDED",{...p,statements:xr("RECORDED",h,!1)},null);let w=e.slotAllocation;if(w===void 0)return a("INVALID_SLOT_COMMITMENT",p,"the proof carries no slot record, so no commitment can be recomputed");let b;try{b=nn(w)}catch(S){return a("INVALID_SLOT_COMMITMENT",p,`commitment could not be recomputed: ${S instanceof Error?S.message:String(S)}`)}let k=ze(b),v=f.placement===null?void 0:on(f.placement),O=v===void 0?null:v.locate(n);if(f.placement===null){for(let S of Ut){let U=S.locate(n);if(U!==null){v=S,O=U;break}}if(v===void 0)return a("INVALID_SLOT_COMMITMENT",{...p,slotCommitmentB64:k},"no registered placement finds a commitment in the fused bytes")}else if(v===void 0)return a("UNDETERMINED_PLACEMENT",{...p,slotCommitmentB64:k},`placement "${f.placement}" is not registered; the commitment cannot be located`);if(O===null)return a("INVALID_SLOT_COMMITMENT",{...p,slotCommitmentB64:k,placement:v.id},`no ${v.id} commitment found in the fused bytes`);if(!$e(O.commitment,b))return a("INVALID_SLOT_COMMITMENT",{...p,slotCommitmentB64:k,placement:v.id},"the commitment in the fused bytes does not match the proof's slot record");let z=!1;if(u!==void 0){let S=O.originDigest??(O.originalBytes!==void 0?_(O.originalBytes):void 0);if(S!==void 0){if(!$e(S,u))return a("INVALID_ORIGIN_ATTRIBUTION",{...p,slotCommitmentB64:k,placement:v.id},f.originSource==="attribution"?"the origin digest in the signed attribution does not match the origin inside the fused bytes":"the origin digest in the manifest does not match the origin inside the fused bytes");z=!0}}return a("FUSED_DIRECT",{...p,slotCommitmentB64:k,placement:v.id,statements:xr("FUSED_DIRECT",h,z)},null)}if(u!==void 0&&$e(r,u)){let w=e.slotAllocation;if(w===void 0)return a("INVALID_SLOT_COMMITMENT",p,"the proof carries no slot record, so the fused bytes cannot be rebuilt");let b;try{b=nn(w)}catch(S){return a("INVALID_SLOT_COMMITMENT",p,`commitment could not be recomputed: ${S instanceof Error?S.message:String(S)}`)}let k=ze(b),v=f!==null&&f.placement!==null?on(f.placement):void 0;if(f!==null&&f.placement!==null&&v===void 0)return a("UNDETERMINED_PLACEMENT",{...p,slotCommitmentB64:k},`placement "${f.placement}" is not registered; the fused bytes cannot be rebuilt`);let O=v!==void 0?[v]:Ut.filter(S=>S.byteExact),z=e.artifact.digestB64;for(let S of O){if(!S.byteExact)continue;let U;try{U=S.build({original:n,originDigest:u,commitment:b})}catch{continue}if(ze(_(U))===z)return a("FUSED_FROM_ORIGIN",{...p,slotCommitmentB64:k,placement:S.id,statements:xr("FUSED_FROM_ORIGIN",h,!0)},null)}return a("RECONSTRUCTION_MISMATCH",{...p,slotCommitmentB64:k,placement:v?.id??null},v!==void 0?`rebuilding ${v.id} from this file and the proof's slot record does not reproduce the committed artifact digest`:"no registered byte-exact placement rebuilds the committed artifact digest from this file")}return a("NO_MATCH",p,"this file matches neither the committed artifact digest nor the origin digest; the proof proves nothing about it")}y();y();async function*la(t,e){let n=new vr(t,e?.maxTotalBytes),o=e?.maxEntryCount??Number.POSITIVE_INFINITY,r=e?.maxMetadataEntryBytes??Number.POSITIVE_INFINITY,i=null,s=null,a=null,c=0,f=(u,d)=>{if(u>r)throw new Error(`tar: ${d} metadata entry of ${u} bytes exceeds the ${r}-byte cap`)};for(;;){let u=await n.readExact(512);if(u===null||Pu(u))return;if(++c>o)throw new Error(`tar: archive exceeds the maximum of ${o} entries`);let d=Ru(u),h=d.typeflag;if(h==="x"||h==="g"){f(d.size,"PAX");let v=await ha(n,d.size);await n.skip(Wn(d.size));let O=Du(v);h==="x"?i=O:s=Nu(s,O);continue}if(h==="L"){f(d.size,"GNU long-name");let v=await ha(n,d.size);await n.skip(Wn(d.size)),a=xt(Mu(v));continue}if(h==="K"){await n.skip(d.size+Wn(d.size));continue}let l=d.name;s!==null&&s.has("path")&&(l=s.get("path")),a!==null&&(l=a),i!==null&&i.has("path")&&(l=i.get("path"));let m=d.size,p=i?.get("size")??s?.get("size");if(p!==void 0){let v=Number(p);if(!Number.isSafeInteger(v)||v<0)throw new Error("tar: invalid PAX size value");m=v}i=null,a=null;let w=h==="0"||h==="\0",b={remaining:m},k=Cu(n,b);yield{path:l,size:m,kind:w?"file":"other",typeflag:h,body:k},b.remaining>0&&(await n.skip(b.remaining),b.remaining=0),await n.skip(Wn(m))}}async function*Cu(t,e){for(;e.remaining>0;){let n=await t.readSome(e.remaining);if(n===null)throw new Error("tar: truncated archive (unexpected end of stream inside entry body)");e.remaining-=n.length,yield n}}async function ha(t,e){if(e===0)return new Uint8Array(0);let n=await t.readExact(e);if(n===null)throw new Error("tar: truncated archive (unexpected end of stream)");return n}function Ru(t){$u(t);let e=t[156],n=e===0?"\0":String.fromCharCode(e),o=xt(Br(t,0,100));if(xt(Br(t,257,6))==="ustar"){let s=xt(Br(t,345,155));s.length>0&&(o=`${s}/${o}`)}let i=pa(t.subarray(124,136));return{name:o,size:i,typeflag:n}}function Br(t,e,n){let o=t.subarray(e,e+n),r=o.indexOf(0);return r===-1&&(r=o.length),o.subarray(0,r)}function pa(t){if(t.length>0&&(t[0]&128)!==0){let o=0n;for(let r=0;r<t.length;r++){let i=r===0?t[0]&127:t[r];o=o<<8n|BigInt(i)}if(o>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("tar: numeric field exceeds the supported range");return Number(o)}let e=xt(t).trim().replace(/\0+$/,"").trim();if(e.length===0)return 0;let n=Number.parseInt(e,8);if(!Number.isSafeInteger(n)||n<0)throw new Error(`tar: invalid octal numeric field: "${e}"`);return n}function $u(t){let e=pa(t.subarray(148,156)),n=0;for(let o=0;o<512;o++)n+=o>=148&&o<156?32:t[o];if(n!==e)throw new Error("tar: header checksum mismatch (corrupt or not a tar archive)")}function Pu(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return!1;return!0}function Du(t){let e=new Map,n=0;for(;n<t.length;){let o=n;for(;o<t.length&&t[o]!==32;)o++;if(o>=t.length)throw new Error("tar: malformed PAX record (no length delimiter)");let r=Number(xt(t.subarray(n,o)));if(!Number.isInteger(r)||r<=0||n+r>t.length)throw new Error("tar: malformed PAX record (bad length)");let i=t.subarray(o+1,n+r);if(i.length===0||i[i.length-1]!==10)throw new Error("tar: malformed PAX record (missing newline)");let s=xt(i.subarray(0,i.length-1)),a=s.indexOf("=");if(a===-1)throw new Error("tar: malformed PAX record (missing '=')");e.set(s.slice(0,a),s.slice(a+1)),n+=r}return e}function Nu(t,e){let n=new Map(t??[]);for(let[o,r]of e)n.set(o,r);return n}function xt(t){return new TextDecoder("utf-8").decode(t)}function Mu(t){let e=t.length;for(;e>0&&t[e-1]===0;)e--;return t.subarray(0,e)}var vr=class{iter;chunks=[];head=0;available=0;ended=!1;totalPulled=0;maxTotalBytes;constructor(e,n){this.iter=e[Symbol.asyncIterator](),this.maxTotalBytes=n??Number.POSITIVE_INFINITY}async fill(){if(this.ended)return!1;let e=await this.iter.next();if(e.done===!0)return this.ended=!0,!1;let n=e.value;if(n.length>0){if(this.totalPulled+=n.length,this.totalPulled>this.maxTotalBytes)throw new Error(`tar: archive exceeds the maximum decompressed size of ${this.maxTotalBytes} bytes`);this.chunks.push(n),this.available+=n.length}return!0}async readExact(e){for(;this.available<e;)if(!await this.fill()){if(this.available===0)return null;throw new Error("tar: truncated archive (unexpected end of stream)")}return this.take(e)}async readSome(e){for(;this.available===0;)if(!await this.fill())return null;let n=this.chunks[0],o=Math.min(e,n.length-this.head),r=n.subarray(this.head,this.head+o);return this.advance(o,n),r}async skip(e){let n=e;for(;n>0;){let o=await this.readSome(n);if(o===null)throw new Error("tar: truncated archive (unexpected end of stream)");n-=o.length}}take(e){let n=new Uint8Array(e),o=0;for(;o<e;){let r=this.chunks[0],i=Math.min(e-o,r.length-this.head);n.set(r.subarray(this.head,this.head+i),o),o+=i,this.advance(i,r)}return n}advance(e,n){this.head+=e,this.available-=e,this.head===n.length&&(this.chunks.shift(),this.head=0)}};function Wn(t){return(512-t%512)%512}y();var am=new Uint8Array([0]);function ma(t){let e=Array.from(t,o=>({pathBytes:Lu(o.path),entryDigest:o.entryDigest}));e.sort((o,r)=>Ou(o.pathBytes,r.pathBytes));let n=_.create();for(let o of e)n.update(o.entryDigest);return B.Buffer.from(n.digest()).toString("base64")}function Lu(t){if(t.includes("\0"))throw new TypeError("bitgraph-audit: bundle entry paths must not contain NUL bytes");return new TextEncoder().encode(t)}function Ou(t,e){let n=Math.min(t.length,e.length);for(let o=0;o<n;o++){let r=t[o]-e[o];if(r!==0)return r}return t.length-e.length}var ga=8*1024*1024,xa={maxTotalBytes:2*1024*1024*1024,maxEntryCount:1e6,maxMetadataEntryBytes:8*1024*1024},ba=new Uint8Array([0]),ya="manifest.json",Ar="bitgraph-bundle/1",Fu="bitgraph-anchor-witness/1";var Ea=new WeakMap;async function Ir(t,e){let n=[],o=0,r=0,i=[],s=new Map,a=Array.from(t).sort((f,u)=>f.path<u.path?-1:f.path>u.path?1:0);for(let f of a){r++;let u=Aa(f.path);if(u.unsafe){o++,n.push({code:"unsafe-path",path:f.path,message:`entry skipped: ${u.reason}`});continue}let d=await Ku(u.path,void 0,void 0,Ba(f.open()));i.push(Vu(u.path,d)),s.set(u.path,f)}let c=_u({bundlePath:e?.label??"",container:"memory",scanned:i,strippedRootPrefix:void 0,findings:n,entriesScanned:r,skippedUnsafePaths:o});return Ea.set(c,s),c}async function*Ba(t){let e=await Promise.resolve(t);if(e instanceof Uint8Array){yield e;return}for await(let n of t)yield n}async function Uu(t){let e=[],n=0;for await(let o of Ba(t.open()))e.push(o),n+=o.length;return Tr(e,n)}function _u(t){let{bundlePath:e,container:n,scanned:o,strippedRootPrefix:r,findings:i,entriesScanned:s,skippedUnsafePaths:a}=t,c=new Map;for(let S of o){let U=S.rawPath,F=S.entryDigestFull;r!==void 0&&(U=S.rawPath.slice(r.length+1),F=S.entryDigestStripped),c.has(U)&&i.push({code:"duplicate-path",path:U,message:"multiple archive entries normalized to the same path; the last entry wins"}),c.set(U,{path:U,sha256Hex:S.sha256Hex,byteLength:S.byteLength,entryDigest:F,...S.json!==void 0?{json:S.json}:{}})}let f=Array.from(c.values()),u=ma(f.filter(S=>S.path!==ya).map(S=>({path:S.path,entryDigest:S.entryDigest}))),d=[],h=new Map,l=[],m=[],p=new Map,w,b=0,k=0,v=0;for(let S of f){if(S.path===ya){w=Yu(S,u,i);continue}let F=qu(S.json)??S.json;if(F!==void 0&&Ia(F)){let G=F.version;if(G==="bitgraph/1"){b++;let q=Gu(S,F,h,d,i);q==="exact-duplicate"&&k++,q==="semantic-duplicate"&&v++;continue}l.push({code:"unsupported-version",path:S.path,version:G,fileSha256Hex:S.sha256Hex}),i.push({code:"unsupported-version",path:S.path,message:`proof-shaped file rejected: version "${G}" is not "bitgraph/1"`,details:{version:G}}),wa(S,p);continue}if(F!==void 0&&F.version===Fu){m.push({path:S.path,fileSha256Hex:S.sha256Hex,witness:F});continue}wa(S,p)}for(let S of d){let U=Zu(S.proof.artifact);if(U===null)continue;let F=p.get(U);F!==void 0&&F.matchedProofHashes.push(S.proofHash)}let O=Array.from(p.values()),z={observed:d.length,proofFiles:b,exactDuplicates:k,semanticDuplicates:v,unsupportedVersion:l.length,artifacts:O.length,witnesses:m.length,skippedUnsafePaths:a};return{bundlePath:e,container:n,...r!==void 0?{strippedRootPrefix:r}:{},entriesScanned:s,proofs:d,unsupportedVersions:l,artifacts:O,witnesses:m,...w!==void 0?{manifest:w}:{},computedContentsHashB64:u,findings:i,counts:z}}async function*kr(t){yield*va(t,t.artifacts.filter(e=>e.matchedProofHashes.length>0))}async function*Sr(t,e){let n=new Set(e);n.size!==0&&(yield*va(t,t.artifacts.filter(o=>n.has(o.sha256Hex))))}async function*va(t,e){if(e.length===0)return;if(t.container==="memory"){let s=Ea.get(t);if(s===void 0)return;for(let a of e)for(let c of a.paths){let f=s.get(c);if(f===void 0)continue;let u;try{u=await Uu(f)}catch{continue}if(Zn(_(u))===a.sha256Hex){yield{sha256Hex:a.sha256Hex,path:c,bytes:u};break}}return}if(t.container==="directory"){for(let s of e)for(let a of s.paths){let c;try{c=new Uint8Array(await rs(is(t.bundlePath,...a.split("/"))))}catch{continue}if(Zn(_(c))===s.sha256Hex){yield{sha256Hex:s.sha256Hex,path:a,bytes:c};break}}return}let n=new Map;for(let s of e)for(let a of s.paths)n.set(a,s);let o=new Set,{stream:r,close:i}=ju(t.bundlePath,t.container);try{for await(let s of la(r,xa)){if(o.size===e.length)break;if(s.kind!=="file")continue;let a=Aa(s.path);if(a.unsafe)continue;let c=a.path;if(t.strippedRootPrefix!==void 0){if(!c.startsWith(`${t.strippedRootPrefix}/`))continue;c=c.slice(t.strippedRootPrefix.length+1)}let f=n.get(c);if(f===void 0||o.has(f.sha256Hex))continue;let u=[],d=0;for await(let l of s.body)u.push(l.slice()),d+=l.length;let h=Tr(u,d);Zn(_(h))===f.sha256Hex&&(o.add(f.sha256Hex),yield{sha256Hex:f.sha256Hex,path:c,bytes:h})}}finally{i()}}function ju(t,e){let n=os(t);if(e==="tar-gz"){let o=ss();return n.pipe(o),n.on("error",r=>o.destroy(r)),{stream:o,close:()=>{o.destroy(),n.destroy()}}}return{stream:n,close:()=>n.destroy()}}async function Ku(t,e,n,o){let r=new TextEncoder,i=_.create(),s=_.create();s.update(r.encode(t)),s.update(ba);let a=e===void 0?void 0:_.create();a!==void 0&&(a.update(r.encode(e)),a.update(ba));let c=n===void 0||n<=ga,f=[],u=0;for await(let d of o)i.update(d),s.update(d),a?.update(d),u+=d.length,c&&(u>ga?(f.length=0,c=!1):f.push(d.slice()));return{sha256Hex:Zn(i.digest()),byteLength:u,entryDigestFull:s.digest(),...a!==void 0?{entryDigestStripped:a.digest()}:{},...c?{buffered:Tr(f,u)}:{}}}function Vu(t,e){let n=e.buffered===void 0?void 0:zu(e.buffered);return{rawPath:t,sha256Hex:e.sha256Hex,byteLength:e.byteLength,entryDigestFull:e.entryDigestFull,...e.entryDigestStripped!==void 0?{entryDigestStripped:e.entryDigestStripped}:{},...n!==void 0?{json:n}:{}}}function zu(t){let e=t;e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191&&(e=e.subarray(3));let n;try{n=new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{return}let o;try{o=JSON.parse(n)}catch{return}if(!(o===null||typeof o!="object"||Array.isArray(o)))return o}function Aa(t){if(t.includes("\0"))return{path:t,unsafe:!0,reason:"path contains a NUL byte"};let e=t.startsWith("/"),n=t.split("/").filter(r=>r!==""&&r!=="."),o=n.join("/");return e?{path:o,unsafe:!0,reason:"absolute path"}:n.some(r=>r==="..")?{path:o,unsafe:!0,reason:"path escapes the bundle root"}:o===""?{path:o,unsafe:!0,reason:"empty path"}:{path:o,unsafe:!1}}function re(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function qu(t){if(!re(t)||t.type!=="bitgraph-fuse/1")return;let e=t.proof;return Ia(e)?e:void 0}function Ia(t){return re(t)?typeof t.version=="string"&&re(t.artifact)&&re(t.commit)&&re(t.signer):!1}function Gu(t,e,n,o,r){let i=zn(e),s={path:t.path,fileSha256Hex:t.sha256Hex,byteLength:t.byteLength},a=Wu(e,i);a==="mismatch"&&r.push({code:"proofhash-mismatch",path:t.path,message:"embedded proofHash does not match the computed canonical proof hash",details:{embedded:e.proofHash,computed:i}});let c=n.get(i);if(c!==void 0){let w=c.sources.some(b=>b.fileSha256Hex===s.fileSha256Hex);return c.sources.push(s),a==="mismatch"&&(c.embeddedProofHash="mismatch"),r.push({code:w?"exact-duplicate":"semantic-duplicate",path:t.path,message:w?"byte-identical copy of an already observed proof":"different byte encoding of an already observed proof (same canonical identity)",details:{proofHash:i,firstObservedAt:c.sources[0].path}}),w?"exact-duplicate":"semantic-duplicate"}let f=re(e.commit)?e.commit:{},u=re(e.signer)?e.signer:{},d=re(e.environment)?e.environment:{},h=he(f.counter),l=he(f.epochId),m=he(f.chainId),p={proofHash:i,chainHash:sr(e),proof:e,sources:[s],version:"bitgraph/1",...h!==void 0?{counter:h}:{},...he(f.slotCounter)!==void 0?{slotCounter:he(f.slotCounter)}:{},...he(f.prevB64)!==void 0?{prevB64:he(f.prevB64)}:{},...l!==void 0?{epochId:l}:{},chainId:m!==void 0&&m.length>0?m:"global",...he(u.publicKeyB64)!==void 0?{publicKeyB64:he(u.publicKeyB64)}:{},...he(d.measurement)!==void 0?{measurement:he(d.measurement)}:{},...he(d.enforcement)!==void 0?{enforcement:he(d.enforcement)}:{},hasSlotAllocation:re(e.slotAllocation),hasAttestation:re(d.attestation),hasAgency:re(e.agency),hasEpochLink:re(f.epochLink),embeddedProofHash:a,chainless:h===void 0&&l===void 0};return n.set(i,p),o.push(p),"new"}function Wu(t,e){let n=t.proofHash;return n===void 0?"absent":typeof n=="string"&&n===e?"match":"mismatch"}function he(t){return typeof t=="string"?t:void 0}function wa(t,e){let n=e.get(t.sha256Hex);if(n!==void 0){n.paths.push(t.path);return}e.set(t.sha256Hex,{sha256Hex:t.sha256Hex,sha256B64:B.Buffer.from(t.sha256Hex,"hex").toString("base64"),byteLength:t.byteLength,paths:[t.path],matchedProofHashes:[]})}function Zu(t){if(!re(t))return null;let e=t.digestB64;if(typeof e!="string"||e.length===0)return null;let n=B.Buffer.from(e,"base64");return n.toString("base64")!==e||n.length!==32?null:n.toString("hex")}function Yu(t,e,n){if(t.json===void 0)return n.push({code:"manifest-unparseable",path:t.path,message:"root manifest.json did not parse as a single JSON object; proceeding as if no manifest were present"}),{path:t.path,parsed:!1,recognized:!1,problems:[]};let o=t.json,r=o.version;if(r!==Ar)return n.push({code:"manifest-unrecognized-version",path:t.path,message:`manifest version ${JSON.stringify(r)} is not "${Ar}"; the manifest was not interpreted`,...typeof r=="string"?{details:{version:r}}:{}}),{path:t.path,parsed:!0,...typeof r=="string"?{version:r}:{},recognized:!1,problems:[]};let i=Xu(o);for(let c of i)n.push({code:"manifest-field-invalid",path:t.path,message:c});let s={path:t.path,parsed:!0,version:Ar,recognized:!0,manifest:o,problems:i},a=o.contentsHashB64;if(typeof a=="string"&&a.length>0){let c=a===e;s.contentsHash={declaredB64:a,computedB64:e,match:c},c||n.push({code:"manifest-contents-hash-mismatch",path:t.path,message:"manifest contentsHashB64 does not match the computed contents hash; the bundle held is not byte-for-byte the bundle the manifest describes. Advisory: this does not fail any proof.",details:{declared:a,computed:e}})}return s}function Xu(t){let e=[],n=o=>Array.isArray(o)&&o.every(r=>typeof r=="string");if(t.epochIds!==void 0&&!n(t.epochIds)&&e.push("manifest.epochIds must be an array of strings when present"),t.chainIds!==void 0&&!n(t.chainIds)&&e.push("manifest.chainIds must be an array of strings when present"),t.proofCount!==void 0&&(typeof t.proofCount!="number"||!Number.isInteger(t.proofCount)||t.proofCount<0)&&e.push("manifest.proofCount must be a non-negative integer when present"),t.counterRanges!==void 0&&(Array.isArray(t.counterRanges)&&t.counterRanges.every(r=>re(r)&&typeof r.epochId=="string"&&typeof r.chainId=="string"&&typeof r.min=="string"&&typeof r.max=="string")||e.push("manifest.counterRanges must be an array of { epochId, chainId, min, max } string fields when present")),t.generatedAt!==void 0&&typeof t.generatedAt!="string"&&e.push("manifest.generatedAt must be a string when present"),t.contentsHashB64!==void 0){let o=t.contentsHashB64,r=typeof o=="string"&&o.length>0;if(r){let i=B.Buffer.from(o,"base64");r=i.toString("base64")===o&&i.length===32}r||e.push("manifest.contentsHashB64 must be standard base64 of 32 bytes when present")}return t.artifactsIncluded!==void 0&&typeof t.artifactsIncluded!="boolean"&&e.push("manifest.artifactsIncluded must be a boolean when present"),t.openEpochs!==void 0&&(Array.isArray(t.openEpochs)&&t.openEpochs.every(r=>re(r)&&typeof r.epochId=="string"&&typeof r.counterAtSnapshot=="string")||e.push("manifest.openEpochs must be an array of { epochId, counterAtSnapshot } string fields when present")),e}function Zn(t){return B.Buffer.from(t).toString("hex")}function Tr(t,e){let n=new Uint8Array(e),o=0;for(let r of t)n.set(r,o),o+=r.length;return n}y();async function Hr(t,e){Ke();let n=e?.trustAnchors,o=new Map(t.proofs.map(f=>[f.proofHash,f])),r=new Map;for(let f of t.artifacts){if(f.matchedProofHashes.length===0)continue;let u=f.matchedProofHashes.map(d=>o.get(d)).filter(d=>d!==void 0);r.set(f.sha256Hex,u)}for await(let f of kr(t)){let u=r.get(f.sha256Hex)??[];for(let d of u){if(d.verification!==void 0)continue;let h=await ir({proof:d.proof,bytes:f.bytes,...n!==void 0?{trustAnchors:n}:{}}),l={tier:"full",status:h.valid?"verified":"failed",...h.reason!==void 0?{reason:h.reason}:{},artifactPath:f.path};d.verification=l}}for(let f of t.proofs){if(f.verification!==void 0)continue;let u=await it({proof:f.proof,...n!==void 0?{trustAnchors:n}:{}}),d={tier:"integrity",status:u.valid?"artifact-unavailable":"failed",...u.reason!==void 0?{reason:u.reason}:{}};f.verification=d}let i=0,s=0,a=0,c=0;for(let f of t.proofs){let u=f.verification?.status;u==="verified"?i++:u==="failed"?s++:u==="artifact-unavailable"&&a++,f.chainless&&c++}return{total:t.proofs.length,verified:i,failed:s,artifactUnavailable:a,chainless:c}}y();y();var ka=new WeakMap;async function qe(t){let e=t.verification?.status;if(e==="verified"||e==="artifact-unavailable")return!0;let n=ka.get(t);if(n!==void 0)return n;Ke();let o=!1;try{o=(await it({proof:t.proof})).valid}catch{o=!1}return Ke(),ka.set(t,o),o}function Y(t){if(!(t===void 0||t.length===0||!/^[0-9]+$/.test(t)))return BigInt(t)}function Pe(t,e){let n=Y(t.counter),o=Y(e.counter);return n!==void 0&&o!==void 0&&n!==o?n<o?-1:1:n!==void 0&&o===void 0?-1:n===void 0&&o!==void 0?1:t.proofHash<e.proofHash?-1:t.proofHash>e.proofHash?1:0}function ue(t,e,n){let o=t.get(e);o===void 0?t.set(e,[n]):o.push(n)}async function Rr(t){let e=[],n=[],o=new Map;for(let f of t.proofs){if(f.chainless){e.push(f.proofHash);continue}if(f.publicKeyB64===void 0){n.push(f.proofHash);continue}let u={publicKeyB64:f.publicKeyB64,...f.epochId!==void 0?{epochId:f.epochId}:{},chainId:f.chainId},d=JSON.stringify([u.publicKeyB64,u.epochId??null,u.chainId]),h=o.get(d);h===void 0?o.set(d,{key:u,members:[f]}):h.members.push(f)}let r=[...o.values()].sort((f,u)=>Ju(f.key,u.key)),i=[],s=new Set,a=new Map;for(let f of r){let u=Qu(f.key,f.members,s);i.push(u);for(let d of u.memberProofHashes)a.set(d,f.key)}let c=await nd(t,i,s,a);return{partitions:i,unchainedProofHashes:e,unpartitionedProofHashes:n,epochRelationships:c}}function Ju(t,e){if(t.chainId!==e.chainId)return t.chainId<e.chainId?-1:1;let n=t.epochId??"",o=e.epochId??"";return n!==o?n<o?-1:1:t.publicKeyB64!==e.publicKeyB64?t.publicKeyB64<e.publicKeyB64?-1:1:0}function Qu(t,e,n){let o=new Map(e.map(h=>[h.chainHash,h])),r=new Map,i=new Set,s=new Map;for(let h of e)s.set(h.proofHash,h.proofHash);let a=h=>{let l=h;for(;s.get(l)!==l;)l=s.get(l);let m=h;for(;m!==l;){let p=s.get(m);s.set(m,l),m=p}return l},c=(h,l)=>{let m=a(h),p=a(l);m!==p&&s.set(m,p)};for(let h of e){if(h.prevB64===void 0)continue;let l=o.get(h.prevB64);l===void 0||l.proofHash===h.proofHash||(i.add(h.proofHash),ue(r,l.proofHash,h),n.add(l.proofHash),c(l.proofHash,h.proofHash))}let f=new Map;for(let h of e)ue(f,a(h.proofHash),h);let u=[];for(let h of f.values())u.push(ed(h,r,i));u.sort(td);let d=[...e].sort(Pe).map(h=>h.proofHash);return{key:t,memberProofHashes:d,components:u}}function ed(t,e,n){let o=[...t].sort(Pe),r=o.filter(h=>h.prevB64===void 0),i=o.filter(h=>h.prevB64!==void 0&&!n.has(h.proofHash)),s=o.filter(h=>(e.get(h.proofHash)??[]).length===0),a=new Set,c=[],f=h=>{let l=[h];for(;l.length>0;){let m=l.pop();if(a.has(m))continue;a.add(m),c.push(m);let p=[...e.get(m)??[]].sort(Pe);for(let w=p.length-1;w>=0;w--)l.push(p[w].proofHash)}};for(let h of[...r,...i])f(h.proofHash);for(let h of o)a.has(h.proofHash)||f(h.proofHash);let u,d;for(let h of t)for(let l of[h.counter,h.slotCounter]){let m=Y(l);m!==void 0&&((u===void 0||m<u)&&(u=m),(d===void 0||m>d)&&(d=m))}return{memberProofHashes:c,genesisProofHashes:r.map(h=>h.proofHash),brokenLinkProofHashes:i.map(h=>h.proofHash),terminalProofHashes:s.map(h=>h.proofHash),hasCounterEvidence:u!==void 0,...u!==void 0&&d!==void 0?{positionRange:{min:String(u),max:String(d)}}:{}}}function td(t,e){let n=t.positionRange?.min,o=e.positionRange?.min;if(n!==void 0&&o!==void 0&&n!==o)return BigInt(n)<BigInt(o)?-1:1;if(n!==void 0&&o===void 0)return-1;if(n===void 0&&o!==void 0)return 1;let r=t.memberProofHashes[0]??"",i=e.memberProofHashes[0]??"";return r<i?-1:r>i?1:0}async function nd(t,e,n,o){let r=new Map;for(let h of e){let l=h.key.epochId;if(l===void 0)continue;let m=r.get(l);m===void 0&&(m={chainIds:new Set,publicKeys:new Set,proofCount:0},r.set(l,m)),m.chainIds.add(h.key.chainId),m.publicKeys.add(h.key.publicKeyB64),m.proofCount+=h.memberProofHashes.length}let i=new Map(t.proofs.map(h=>[h.chainHash,h])),s=[];for(let h of t.proofs){if(!h.hasEpochLink)continue;let l=od(h);l!==null&&s.push(await rd(l,h,i,r,n,o))}let a=sd(s),c=new Set,f=new Map,u=new Map;for(let h of s)h.hardEdge&&(c.add(h.fromEpochId),c.add(h.toEpochId),Cr(f,h.toEpochId,h.fromEpochId),Cr(u,h.fromEpochId,h.toEpochId));return{epochs:[...r.entries()].sort(([h],[l])=>h<l?-1:h>l?1:0).map(([h,l])=>({epochId:h,chainIds:[...l.chainIds].sort(),publicKeysB64:[...l.publicKeys].sort(),proofCount:l.proofCount,ordering:c.has(h)?"linked":"observed-but-unordered",linkedPredecessorEpochIds:[...f.get(h)??[]].sort(),linkedSuccessorEpochIds:[...u.get(h)??[]].sort()})),edges:s,orderedPairs:a}}function od(t){let e=t.proof.commit;if(e===null||typeof e!="object")return null;let n=e.epochLink;if(n===null||typeof n!="object"||Array.isArray(n))return null;let o=n,r=["prevEpochId","prevPublicKeyB64","prevCounter","prevProofHashB64","toEpochId","toPublicKeyB64"],i={};for(let s of r){let a=o[s];if(typeof a!="string"||a.length===0)return null;i[s]=a}return i}async function rd(t,e,n,o,r,i){let s=await qe(e),a=n.get(t.prevProofHashB64);if(a===void 0){let h=o.has(t.prevEpochId);return{fromEpochId:t.prevEpochId,toEpochId:t.toEpochId,viaProofHash:e.proofHash,link:t,resolution:h?"terminal-missing":"dangling",viaProofValid:s,hardEdge:!1}}let c=[];a.epochId!==t.prevEpochId&&c.push(`the referenced proof's epochId (${a.epochId??"absent"}) does not match epochLink.prevEpochId (${t.prevEpochId})`),a.publicKeyB64!==t.prevPublicKeyB64&&c.push("the referenced proof's signer key does not match epochLink.prevPublicKeyB64"),id(a.counter,t.prevCounter)||c.push(`the referenced proof's counter (${a.counter??"absent"}) does not match epochLink.prevCounter (${t.prevCounter})`);let f=await qe(a),u=c.length===0,d=i.has(a.proofHash);return{fromEpochId:t.prevEpochId,toEpochId:t.toEpochId,viaProofHash:e.proofHash,link:t,resolution:"matched",predecessorProofHash:a.proofHash,metadataConsistent:u,...u?{}:{inconsistencies:c},...d?{referencedProofIsTerminal:!r.has(a.proofHash)}:{},viaProofValid:s,predecessorValid:f,hardEdge:u&&s&&f}}function id(t,e){if(t===void 0)return!1;if(t===e)return!0;let n=Y(t),o=Y(e);return n!==void 0&&o!==void 0&&n===o}function sd(t){let e=new Map,n=new Set;for(let i of t)i.hardEdge&&(Cr(e,i.fromEpochId,i.toEpochId),n.add(i.fromEpochId),n.add(i.toEpochId));let o=new Set;for(let i of n){let s=new Set,a=[...e.get(i)??[]];for(;a.length>0;){let c=a.pop();if(!s.has(c)){s.add(c);for(let f of e.get(c)??[])a.push(f)}}for(let c of s)c!==i&&o.add(`${i}\0${c}`)}let r=[];for(let i of o){let[s,a]=i.split("\0");o.has(`${a}\0${s}`)||r.push({beforeEpochId:s,afterEpochId:a})}return r.sort((i,s)=>i.beforeEpochId!==s.beforeEpochId?i.beforeEpochId<s.beforeEpochId?-1:1:i.afterEpochId<s.afterEpochId?-1:i.afterEpochId>s.afterEpochId?1:0),r}function Cr(t,e,n){let o=t.get(e);o===void 0?t.set(e,new Set([n])):o.add(n)}y();var ad=1e4;async function $r(t,e){let n=[],o=[],r=[],i=new Map(t.proofs.map(c=>[c.proofHash,c])),s=new Map(t.proofs.map(c=>[c.chainHash,c])),a=new Map;for(let c of e.partitions)for(let f of c.memberProofHashes)a.set(f,c.key);for(let c of e.partitions){let f=c.memberProofHashes.map(u=>i.get(u));cd(c,f,n),await Sa(c,f,"counter",n,o),await Sa(c,f,"slot",n,o),await fd(c,f,n,o),await ud(c,f,s,n,o),dd(c,f,s,a,n,r),await ld(c,f,n,o),pd(c,f,n)}return await md(e.epochRelationships.edges,i,n,o),{anomalies:n,divergences:o,boundaryEntryPoints:r}}function cd(t,e,n){let o=new Set;for(let d of e){let h=Y(d.counter);h!==void 0&&o.add(h);let l=Y(d.slotCounter);l!==void 0&&o.add(l)}if(o.size<2)return;let r=[...o].sort((d,h)=>d<h?-1:d>h?1:0),i=[],s=[],a=0n;for(let d=1;d<r.length;d++){let h=r[d-1]+1n,l=r[d]-1n;if(!(h>l)){i.push({start:String(h),end:String(l)}),a+=l-h+1n;for(let m=h;m<=l&&s.length<ad;m++)s.push(String(m))}}if(i.length===0)return;let c={count:String(a),ranges:i,positions:s,truncated:a>BigInt(s.length)},f=String(r[0]),u=String(r[r.length-1]);n.push({code:"unexplained-counter-positions",partition:t.key,proofHashes:[],message:`${a} counter position${a===1n?"":"s"} within the observed range [${f}, ${u}] of this partition ${a===1n?"is":"are"} neither a commit position nor a referenced slot position in the supplied bundle. Such ${a===1n?"a position":"positions"} may mean a proof is absent from the bundle, or a slot that was allocated but never committed (a routine, benign occurrence); this offline audit cannot distinguish the two. It does not, by itself, establish that the authority failed to create or withheld any proof.`,details:c})}async function Sa(t,e,n,o,r){let i=new Map;for(let s of e){let a=n==="counter"?s.counter:s.slotCounter;if(a===void 0)continue;let c=Y(a);ue(i,c!==void 0?String(c):`raw:${a}`,s)}for(let[s,a]of Pr(i)){if(a.length<2)continue;let{parties:c,context:f}=await Yn(a);if(c.length<2)continue;let u=s.startsWith("raw:")?s.slice(4):s,d=n==="counter"?"counter-collision":"slot-collision";o.push({code:d,partition:t.key,proofHashes:a.map(h=>h.proofHash),message:n==="counter"?`${c.length} distinct valid proofs claim commit counter ${u} in one partition. The audit does not choose between them; all parties are preserved for adjudication.`:`${c.length} distinct valid proofs reference slot counter ${u} in one partition. A slot position is consumed exactly once; all parties are preserved for adjudication.`,details:{position:u,validParties:c.map(h=>h.proofHash),invalidObserved:f.map(h=>h.proofHash)}}),r.push({kind:d,partition:t.key,contested:n==="counter"?{counter:u}:{slotCounter:u},parties:c.map(De),invalidContext:f.map(De),explanation:n==="counter"?`Two or more independently valid proof objects claim commit counter ${u} in the same signer, epoch, and chain partition. A commit counter position can be consumed only once, so at most one of these can belong to the authoritative sequence. The audit tool does not choose between them; every party and its predecessor relationship is preserved for adjudication.`:`Two or more independently valid proof objects reference slot counter ${u} in the same signer, epoch, and chain partition. A slot position is allocated once and consumed by one commit, so at most one of these can belong to the authoritative sequence. The audit tool does not choose between them.`})}}async function fd(t,e,n,o){let r=new Map,i=new Map;for(let a of e){let c=Y(a.counter);c!==void 0&&ue(r,String(c),a);let f=Y(a.slotCounter);f!==void 0&&ue(i,String(f),a)}let s=[...r.keys()].filter(a=>i.has(a)).sort((a,c)=>BigInt(a)<BigInt(c)?-1:BigInt(a)>BigInt(c)?1:0);for(let a of s){let c=r.get(a),f=i.get(a),u=[];for(let b of c)await qe(b)&&u.push(b);let d=[];for(let b of f)await qe(b)&&d.push(b);if(!u.some(b=>d.some(k=>k.proofHash!==b.proofHash)))continue;let l=new Map;for(let b of[...u,...d])l.set(b.proofHash,b);let m=[...l.values()],p=new Map;for(let b of[...c,...f])p.set(b.proofHash,b);let w=[...p.values()].filter(b=>!l.has(b.proofHash));n.push({code:"cross-kind-position-reuse",partition:t.key,proofHashes:[...p.keys()],message:`Counter position ${a} is committed by one proof and reserved as a slot by a different proof in the same partition. A single causal position is consumed once, as a slot or as a commit, never both across distinct proofs. The audit does not choose between them; all parties are preserved for adjudication.`,details:{position:a,commitParties:u.map(b=>b.proofHash),slotParties:d.map(b=>b.proofHash),validParties:m.map(b=>b.proofHash),invalidObserved:w.map(b=>b.proofHash)}}),o.push({kind:"cross-kind-position-reuse",partition:t.key,contested:{position:a},parties:m.map(De),invalidContext:w.map(De),explanation:`Two or more independently valid proof objects allocate counter position ${a} in the same signer, epoch, and chain partition through different roles: at least one commits at it and at least one reserves it as a slot. Each position in a chain is consumed exactly once, so at most one of these allocations can belong to the authoritative sequence. This pattern only arises through enclave malfunction, replay, or compromise. The audit tool does not choose between them; every party is preserved for adjudication.`})}}async function ud(t,e,n,o,r){let i=new Map;for(let s of e)s.prevB64!==void 0&&ue(i,s.prevB64,s);for(let[s,a]of Pr(i)){if(a.length<2)continue;let{parties:c,context:f}=await Yn(a);if(c.length<2)continue;let u=n.has(s);o.push({code:"predecessor-reuse",partition:t.key,proofHashes:a.map(d=>d.proofHash),message:`${c.length} distinct valid proofs claim the same predecessor hash: a detectable fork. All branches are preserved; the audit does not choose between them.`,details:{prevB64:s,predecessorObserved:u,validParties:c.map(d=>d.proofHash),invalidObserved:f.map(d=>d.proofHash)}}),r.push({kind:"predecessor-reuse",partition:t.key,contested:{prevB64:s},parties:c.map(De),invalidContext:f.map(De),explanation:`Two or more independently valid proof objects name the same predecessor proof in their prevB64 hash link. Each proof has exactly one successor in an intact chain, so this is a fork: the history diverges into multiple branches at that predecessor${u?", which is itself observed in the bundle":", which is absent from the bundle"}. All branches are shown; the audit tool does not select one.`})}}function dd(t,e,n,o,r,i){let s=new Set(e.map(c=>c.chainHash)),a;for(let c of e){let f=Y(c.counter);f!==void 0&&(a===void 0||f<a)&&(a=f)}for(let c of[...e].sort(Pe)){if(c.prevB64===void 0||s.has(c.prevB64))continue;if(!hd(c.prevB64)){r.push({code:"chain-break-malformed",partition:t.key,proofHashes:[c.proofHash],message:"commit.prevB64 is not standard base64 of 32 bytes, so it can never match a canonical proof hash. The predecessor link is unusable as reconstruction evidence.",details:{prevB64:c.prevB64}});continue}let f=n.get(c.prevB64);if(f!==void 0){let h=o.get(f.proofHash);r.push({code:"chain-break-cross-partition",partition:t.key,proofHashes:[c.proofHash,f.proofHash],message:"commit.prevB64 resolves to an observed proof outside this proof's own signer, epoch, and chain partition. prevB64 never bridges partitions (each epoch and chain keeps its own hash chain), so this link does not join the two.",details:{prevB64:c.prevB64,predecessorProofHash:f.proofHash,predecessorPartition:h!==void 0?{publicKeyB64:h.publicKeyB64,...h.epochId!==void 0?{epochId:h.epochId}:{},chainId:h.chainId}:"unchained-or-unpartitioned"}});continue}let u=Y(c.counter);if(u===void 0||a===void 0||u<=a){i.push({partition:t.key,proofHash:c.proofHash,prevB64:c.prevB64});continue}r.push({code:"chain-break-missing",partition:t.key,proofHashes:[c.proofHash],message:"commit.prevB64 references a predecessor proof that is absent from the supplied bundle, and a lower-positioned proof IS present, so this is an interior break (a hole), not the excerpt's starting boundary. The chain cannot be reconstructed across this link from the supplied evidence; this does not, by itself, establish that the predecessor never existed.",details:{prevB64:c.prevB64}})}}function hd(t){if(t.length===0)return!1;let e=B.Buffer.from(t,"base64");return e.length===32&&e.toString("base64")===t}async function ld(t,e,n,o){let r=[...e.filter(a=>a.prevB64===void 0)].sort(Pe);if(r.length<2)return;let{parties:i,context:s}=await Yn(r);n.push({code:"multiple-genesis",partition:t.key,proofHashes:r.map(a=>a.proofHash),message:`${r.length} proofs in one partition carry no prevB64 link. An epoch has exactly one first proof, so at most one of these can be the genesis of this partition's chain.`,details:{validParties:i.map(a=>a.proofHash),invalidObserved:s.map(a=>a.proofHash)}}),!(i.length<2)&&o.push({kind:"multiple-genesis",partition:t.key,contested:{...t.key.epochId!==void 0?{epochId:t.key.epochId}:{},chainId:t.key.chainId},parties:i.map(De),invalidContext:s.map(De),explanation:"Two or more independently valid proof objects in the same signer, epoch, and chain partition carry no predecessor link, each presenting itself as the first proof of the chain. An epoch has exactly one first proof, so at most one of these can be the genesis. The audit tool does not choose between them."})}function pd(t,e,n){for(let o of[...e].sort(Pe)){let r=Y(o.slotCounter),i=Y(o.counter);r===void 0||i===void 0||r<i||n.push({code:"slot-order-violation",partition:t.key,proofHashes:[o.proofHash],message:"commit.slotCounter is not strictly less than commit.counter. The slot must be allocated before the commit that consumes it, so this proof's declared positions contradict the nonce-first construction order.",details:{slotCounter:o.slotCounter,counter:o.counter}})}}async function md(t,e,n,o){for(let s of t)s.resolution==="terminal-missing"?n.push({code:"epochlink-terminal-missing",proofHashes:[s.viaProofHash],message:"commit.epochLink references a prior epoch that is observed in the bundle, but the referenced terminal proof is absent from the bundle. The lineage claim cannot be confirmed from the supplied evidence; this does not, by itself, establish that the terminal never existed.",details:{link:{...s.link}}}):s.resolution==="dangling"?n.push({code:"epochlink-dangling",proofHashes:[s.viaProofHash],message:"commit.epochLink references a prior epoch and terminal proof, neither of which is observed in the bundle. The lineage claim dangles into unobserved history; it cannot be confirmed from the supplied evidence.",details:{link:{...s.link}}}):s.metadataConsistent===!1&&n.push({code:"epochlink-mismatch",proofHashes:[s.viaProofHash,...s.predecessorProofHash!==void 0?[s.predecessorProofHash]:[]],message:"commit.epochLink's prevProofHashB64 matches an observed proof, but the link's declared epoch, signer key, or counter disagrees with that proof. The hash reference and the declared metadata cannot both be right.",details:{link:{...s.link},inconsistencies:s.inconsistencies??[]}});let r=new Map;for(let s of t)ue(r,`${s.link.prevEpochId}|${s.link.prevCounter}|${s.link.prevProofHashB64}`,s);for(let[,s]of Pr(r)){let a=new Set(s.map(h=>h.link.toEpochId));if(a.size<2)continue;let c=s.map(h=>e.get(h.viaProofHash)),{parties:f,context:u}=await Yn(c),d=s[0].link;n.push({code:"epochlink-fork",proofHashes:s.map(h=>h.viaProofHash),message:`The same predecessor terminal (epoch ${d.prevEpochId}, counter ${d.prevCounter}) is consumed by genesis proofs of ${a.size} distinct successor epochs. A predecessor may be consumed by at most one successor epoch, so this is a detectable fork at the epoch boundary. All branches are preserved.`,details:{prevEpochId:d.prevEpochId,prevCounter:d.prevCounter,prevProofHashB64:d.prevProofHashB64,successorEpochIds:[...a].sort(),validParties:f.map(h=>h.proofHash),invalidObserved:u.map(h=>h.proofHash)}}),!(f.length<2)&&o.push({kind:"epochlink-fork",contested:{prevEpochId:d.prevEpochId,prevCounter:d.prevCounter,prevProofHashB64:d.prevProofHashB64},parties:f.map(De),invalidContext:u.map(De),explanation:"Two or more independently valid epoch-genesis proofs consume the same terminal proof of a prior epoch through their epochLink. The single-successor rule allows a terminal to be consumed by exactly one successor epoch, so at most one of these lineages can be the authoritative continuation. Note that whichever party verified second in this run carries a fork-detection failure from the canonical verifier; that ordering is an artifact of verification order, not evidence of which branch is authoritative. The audit tool does not choose between them."})}let i=new Map;for(let s of t){if(s.resolution!=="matched")continue;let a=i.get(s.fromEpochId);a===void 0?i.set(s.fromEpochId,new Set([s.toEpochId])):a.add(s.toEpochId)}for(let s of gd(i)){let a=t.filter(c=>c.resolution==="matched"&&s.includes(c.fromEpochId)&&s.includes(c.toEpochId)).map(c=>c.viaProofHash);n.push({code:"epochlink-cycle",proofHashes:a,message:`Epoch lineage links form a cycle among ${s.length} epochs. Each link claims its successor epoch came after its predecessor, so a cycle means these ordering claims contradict each other; no ordering is asserted for the epochs involved.`,details:{epochIds:s}})}}function gd(t){let e=new Map,n=new Set,o=[...t.keys()].sort();for(let r of o){if(n.has(r))continue;let i=[],s=new Set,a=new Map,c=[r];for(;c.length>0;){let f=c[c.length-1];s.has(f)||(s.add(f),i.push(f),a.set(f,[...t.get(f)??[]].sort()));let d=a.get(f).shift();if(d===void 0){c.pop(),s.delete(f),i.pop(),n.add(f);continue}if(s.has(d)){let h=i.indexOf(d),l=i.slice(h),m=bd(l);e.set(m.join("|"),m);continue}n.has(d)||c.push(d)}}return[...e.values()].sort((r,i)=>{let s=r.join("|"),a=i.join("|");return s<a?-1:s>a?1:0})}function bd(t){let e=0;for(let n=1;n<t.length;n++)t[n]<t[e]&&(e=n);return[...t.slice(e),...t.slice(0,e)]}async function Yn(t){let e=[],n=[];for(let o of t)await qe(o)?e.push(o):n.push(o);return{parties:e,context:n}}function De(t){let e=t.verification;return{proofHash:t.proofHash,sourcePaths:t.sources.map(n=>n.path),...e!==void 0?{verificationTier:e.tier,verificationStatus:e.status,...e.reason!==void 0?{verificationReason:e.reason}:{}}:{},...t.counter!==void 0?{counter:t.counter}:{},...t.slotCounter!==void 0?{slotCounter:t.slotCounter}:{},...t.prevB64!==void 0?{prevB64:t.prevB64}:{},...t.publicKeyB64!==void 0?{publicKeyB64:t.publicKeyB64}:{},...t.epochId!==void 0?{epochId:t.epochId}:{},chainId:t.chainId,...t.measurement!==void 0?{measurement:t.measurement}:{}}}function Pr(t){return[...t.entries()].sort(([e],[n])=>{let o=/^[0-9]+$/.test(e)?BigInt(e):void 0,r=/^[0-9]+$/.test(n)?BigInt(n):void 0;return o!==void 0&&r!==void 0&&o!==r?o<r?-1:1:o!==void 0&&r===void 0?-1:o===void 0&&r!==void 0?1:e<n?-1:e>n?1:0})}y();function Dr(t){let e=new Map;for(let a of t.proofs){let c=JSON.stringify([a.measurement??null,a.publicKeyB64??null,a.epochId??null,a.chainId,a.hasAttestation]),f=e.get(c);if(f!==void 0){f.proofHashes.push(a.proofHash);continue}e.set(c,{...a.measurement!==void 0?{measurement:a.measurement}:{},...a.publicKeyB64!==void 0?{publicKeyB64:a.publicKeyB64}:{},...a.epochId!==void 0?{epochId:a.epochId}:{},chainId:a.chainId,attestationPresent:a.hasAttestation,proofHashes:[a.proofHash]})}let n=[...e.values()].sort(yd),o=new Map;for(let a of t.proofs)a.epochId!==void 0&&ue(o,a.epochId,a);let r=[];for(let[a,c]of[...o.entries()].sort(([f],[u])=>f<u?-1:f>u?1:0)){let f=new Set,u=new Set;for(let d of c)d.publicKeyB64!==void 0&&f.add(d.publicKeyB64),d.measurement!==void 0&&u.add(d.measurement);f.size>=2&&r.push({code:"mid-epoch-signer-change",proofHashes:c.map(d=>d.proofHash),message:`${f.size} distinct signer keys appear within epoch ${a}. A single enclave boot generates exactly one keypair per epoch, so multiple keys under one epochId cannot come from one healthy authority lifecycle. All key groups are preserved for adjudication.`,details:{epochId:a,publicKeysB64:[...f].sort()}}),u.size>=2&&r.push({code:"mid-epoch-measurement-change",proofHashes:c.map(d=>d.proofHash),message:`${u.size} distinct declared measurements appear within epoch ${a}. A single enclave boot has exactly one measurement, so multiple declared measurements under one epochId cannot come from one healthy authority lifecycle. Declared measurements are self-reported; attestation validation is reported separately.`,details:{epochId:a,measurements:[...u].sort()}})}let i=new Map;for(let a of t.proofs){if(a.publicKeyB64===void 0||a.epochId===void 0)continue;let c=i.get(a.publicKeyB64);c===void 0?i.set(a.publicKeyB64,new Set([a.epochId])):c.add(a.epochId)}let s=[...i.entries()].filter(([,a])=>a.size>=2).map(([a,c])=>({publicKeyB64:a,epochIds:[...c].sort()})).sort((a,c)=>a.publicKeyB64<c.publicKeyB64?-1:a.publicKeyB64>c.publicKeyB64?1:0);return{groups:n,anomalies:r,sharedSignersAcrossEpochs:s}}function yd(t,e){if(t.chainId!==e.chainId)return t.chainId<e.chainId?-1:1;let n=t.epochId??"",o=e.epochId??"";if(n!==o)return n<o?-1:1;let r=t.publicKeyB64??"",i=e.publicKeyB64??"";if(r!==i)return r<i?-1:1;let s=t.measurement??"",a=e.measurement??"";return s!==a?s<a?-1:1:t.attestationPresent!==e.attestationPresent?t.attestationPresent?-1:1:0}y();var wd="Ethereum Anchor",Ta="ethereum-anchor",xd=/^https:\/\/etherscan\.io\/block\/([0-9]+)$/;function Lr(t){let e=[],n=[],o=[];for(let r of t.proofs){let i=Nr(r,"name"),s=Ed(r);if(!(i===wd)){s===Ta&&(n.push(r.proofHash),o.push({code:"anchor-metadata-only-claim",...Mr(r),message:"unsigned metadata.type claims ethereum-anchor, but the signed attribution does not identify this proof as an anchor. Metadata is advisory and unsigned; the proof is not treated as an anchor.",details:{proofHash:r.proofHash}}));continue}let c=s===Ta?"agrees":s===void 0?"absent":"disagrees";c==="disagrees"&&o.push({code:"anchor-metadata-disagreement",...Mr(r),message:`signed attribution identifies an Ethereum anchor, but unsigned metadata.type is ${JSON.stringify(s)}. The signed field governs; the disagreement is recorded.`,details:{proofHash:r.proofHash,metadataType:s}});let f=Nr(r,"message"),u=Nr(r,"title"),d=u!==void 0?xd.exec(u)?.[1]??void 0:void 0;d===void 0&&o.push({code:"anchor-title-unparseable",...Mr(r),message:u===void 0?"anchor proof carries no signed attribution.title; the signed block number is absent":"anchor attribution.title does not parse as an Etherscan block URL; the signed block number is treated as absent",details:{proofHash:r.proofHash,...u!==void 0?{title:u}:{}}});let h=r.verification;e.push({proofHash:r.proofHash,...r.epochId!==void 0?{epochId:r.epochId}:{},chainId:r.chainId,...r.counter!==void 0?{counter:r.counter}:{},...r.slotCounter!==void 0?{slotCounter:r.slotCounter}:{},...f!==void 0?{blockHash:f}:{},...d!==void 0?{blockNumber:d}:{},metadataCorroboration:c,...h!==void 0?{verificationTier:h.tier,verificationStatus:h.status,...h.reason!==void 0?{verificationReason:h.reason}:{}}:{}})}return{anchors:e,metadataOnlyProofHashes:n,findings:o}}function Nr(t,e){let n=t.proof.attribution;if(n===null||typeof n!="object"||Array.isArray(n))return;let o=n[e];return typeof o=="string"?o:void 0}function Ed(t){let e=t.proof.metadata;if(e===null||typeof e!="object"||Array.isArray(e))return;let n=e.type;return typeof n=="string"?n:void 0}function Mr(t){let e=t.sources[0]?.path;return e!==void 0?{path:e}:{}}y();y();var Bd=BigInt(0),rn=BigInt(1),vd=BigInt(2),Ad=BigInt(7),Id=BigInt(256),kd=BigInt(113),Ra=[],$a=[],Pa=[];for(let t=0,e=rn,n=1,o=0;t<24;t++){[n,o]=[o,(2*n+3*o)%5],Ra.push(2*(5*o+n)),$a.push((t+1)*(t+2)/2%64);let r=Bd;for(let i=0;i<7;i++)e=(e<<rn^(e>>Ad)*kd)%Id,e&vd&&(r^=rn<<(rn<<BigInt(i))-rn);Pa.push(r)}var Da=Bn(Pa,!0),Sd=Da[0],Td=Da[1],Ha=(t,e,n)=>n>32?Gi(t,e,n):zi(t,e,n),Ca=(t,e,n)=>n>32?Wi(t,e,n):qi(t,e,n);function Hd(t,e=24){let n=new Uint32Array(10);for(let o=24-e;o<24;o++){for(let s=0;s<10;s++)n[s]=t[s]^t[s+10]^t[s+20]^t[s+30]^t[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,c=(s+2)%10,f=n[c],u=n[c+1],d=Ha(f,u,1)^n[a],h=Ca(f,u,1)^n[a+1];for(let l=0;l<50;l+=10)t[s+l]^=d,t[s+l+1]^=h}let r=t[2],i=t[3];for(let s=0;s<24;s++){let a=$a[s],c=Ha(r,i,a),f=Ca(r,i,a),u=Ra[s];r=t[u],i=t[u+1],t[u]=c,t[u+1]=f}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)n[a]=t[s+a];for(let a=0;a<10;a++)t[s+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=Sd[o],t[1]^=Td[o]}ke(n)}var Or=class t extends Ht{constructor(e,n,o,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=n,this.outputLen=o,this.enableXOF=r,this.rounds=i,Io(o),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=_i(this.state)}clone(){return this._cloneInto()}keccak(){ko(this.state32),Hd(this.state32,this.rounds),ko(this.state32),this.posOut=0,this.pos=0}update(e){Ct(this),e=zt(e),ht(e);let{blockLen:n,state:o}=this,r=e.length;for(let i=0;i<r;){let s=Math.min(n-this.pos,r-i);for(let a=0;a<s;a++)o[this.pos++]^=e[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:n,pos:o,blockLen:r}=this;e[o]^=n,(n&128)!==0&&o===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){Ct(this,!1),ht(e),this.finish();let n=this.state,{blockLen:o}=this;for(let r=0,i=e.length;r<i;){this.posOut>=o&&this.keccak();let s=Math.min(o-this.posOut,i-r);e.set(n.subarray(this.posOut,this.posOut+s),r),this.posOut+=s,r+=s}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Io(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(wn(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,ke(this.state)}_cloneInto(e){let{blockLen:n,suffix:o,outputLen:r,rounds:i,enableXOF:s}=this;return e||(e=new t(n,o,r,s,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=o,e.outputLen=r,e.enableXOF=s,e.destroyed=this.destroyed,e}},Cd=(t,e,n)=>qt(()=>new Or(e,t,n));var Na=Cd(1,136,256/8);y();function Oa(t){if(t.length===0)throw new Error("RLP: empty input");let{item:e,next:n}=Fa(t,0);if(n!==t.length)throw new Error(`RLP: ${t.length-n} trailing byte(s) after the top-level item`);if(!Array.isArray(e))throw new Error("RLP: top-level item is not a list");return e}function Fa(t,e){let n=Ua(t,e);if(n<128)return{item:t.subarray(e,e+1),next:e+1};if(n<=183){let a=n-128,c=Xn(t,e+1,a);return{item:t.subarray(e+1,c),next:c}}if(n<=191){let a=n-183,c=La(t,e+1,a),f=e+1+a,u=Xn(t,f,c);return{item:t.subarray(f,u),next:u}}if(n<=247){let a=n-192,c=Xn(t,e+1,a);return{item:Ma(t,e+1,c),next:c}}let o=n-247,r=La(t,e+1,o),i=e+1+o,s=Xn(t,i,r);return{item:Ma(t,i,s),next:s}}function Ma(t,e,n){let o=[],r=e;for(;r<n;){let i=Fa(t,r);if(i.next>n)throw new Error("RLP: list item overruns its list payload");o.push(i.item),r=i.next}return o}function La(t,e,n){if(n<1||n>8)throw new Error(`RLP: invalid length-of-length ${n}`);let o=0;for(let r=0;r<n;r++)o=o*256+Ua(t,e+r);if(o>t.length)throw new Error("RLP: declared length exceeds the input size");return o}function Xn(t,e,n){let o=e+n;if(o>t.length)throw new Error("RLP: item is truncated");return o}function Ua(t,e){let n=t[e];if(n===void 0)throw new Error("RLP: unexpected end of input");return n}function Fr(t){let e=0n;for(let n of t)e=e<<8n|BigInt(n);return e}function _a(t){if(!t.startsWith("0x"))return null;let e=t.slice(2);if(e.length%2!==0||!/^[0-9a-fA-F]*$/.test(e))return null;let n=new Uint8Array(e.length/2);for(let o=0;o<n.length;o++)n[o]=Number.parseInt(e.slice(o*2,o*2+2),16);return n}function ja(t){return`0x${B.Buffer.from(t).toString("hex")}`}var Ka=8,Va=11,Rd=/^0x[0-9a-fA-F]{64}$/,$d=/^https:\/\/etherscan\.io\/block\/([0-9]+)$/;async function _r(t,e){let n=[],o=[],r=new Map(t.proofs.map(i=>[i.proofHash,i]));for(let i of t.witnesses){let s=Pd(i);if(s.failure!==void 0){let u={witnessPath:i.path,verified:!1,reason:s.failure.reason,detail:s.failure.detail};n.push(u),o.push(Ur(u));continue}let a=s.computedHash,c=s.claimedHash.toLowerCase(),f=e.anchors.filter(u=>{let d=u.blockHash?.toLowerCase();return d!==void 0&&(d===a||d===c)});if(f.length===0){let u={witnessPath:i.path,verified:!1,reason:"witness-unmatched",detail:"neither the locally recomputed block hash nor the claimed blockHash matches any observed anchor's signed attribution.message",computedBlockHash:a};n.push(u),o.push(Ur(u));continue}for(let u of f){let d=r.get(u.proofHash),h=d!==void 0&&await qe(d),l=Dd(s,i.path,u.proofHash,d,h);n.push(l),l.verified||o.push(Ur(l))}}return{outcomes:n,findings:o}}function Pd(t){let e=t.witness,n=e.headerRlpHex;if(typeof n!="string")return Jn("headerRlpHex is missing or not a string");let o=e.blockNumber;if(typeof o!="number"||!Number.isInteger(o)||o<0)return Jn("blockNumber is missing or not a non-negative integer");let r=e.blockHash;if(typeof r!="string"||!Rd.test(r))return Jn("blockHash is missing or not 0x followed by 64 hex characters");let i=_a(n);if(i===null)return Jn("headerRlpHex is not 0x-prefixed even-length hex");let s;try{s=Oa(i)}catch(c){return{failure:{reason:"witness-rlp-invalid",detail:c instanceof Error?c.message:String(c)}}}return{computedHash:ja(Na(i)),items:s,claimedHash:r,claimedNumber:BigInt(o)}}function Jn(t){return{failure:{reason:"witness-malformed",detail:t}}}function Dd(t,e,n,o,r){let i=t.computedHash,s={witnessPath:e,anchorProofHash:n,computedBlockHash:i},a=(b,k,v)=>({...s,verified:!1,reason:b,detail:k,...v?.blockNumber!==void 0?{blockNumber:v.blockNumber}:{}});if(o===void 0||!r)return a("witness-anchor-invalid","the candidate anchor proof is not cryptographically valid; the witness confers nothing");let c=Nd(o);if(c===void 0||c.toLowerCase()!==i)return a("witness-hash-mismatch",c===void 0?"the anchor carries no signed attribution.message to compare against":"the locally recomputed block hash does not equal the anchor's signed attribution.message");let f=Od(Ld(o));if(f===null)return a("witness-digest-mismatch","the anchor's artifact.digestB64 does not strictly decode as base64 of 32 bytes");let u=_(new TextEncoder().encode(c));if(!Fd(u,f))return a("witness-digest-mismatch","SHA-256 of the exact signed attribution.message string does not equal the anchor's artifact digest");let d=t.items,h=d[Ka];if(h===void 0||!(h instanceof Uint8Array))return a("witness-header-shape",`header RLP item ${Ka} (block number) is missing or not a byte string`);let l=Fr(h);if(l!==t.claimedNumber)return a("witness-block-number-mismatch",`the witness claims blockNumber ${t.claimedNumber}, but the header's number field is ${l}`,{blockNumber:String(l)});let m=Md(o);if(m!==void 0){let b=$d.exec(m)?.[1];if(b!==void 0&&BigInt(b)!==l)return a("witness-block-number-mismatch",`the anchor's signed Etherscan URL names block ${b}, but the header's number field is ${l}`,{blockNumber:String(l)})}if(t.claimedHash.toLowerCase()!==i)return a("witness-claimed-hash-mismatch","the witness's claimed blockHash does not equal the locally recomputed block hash",{blockNumber:String(l)});let p=d[Va];if(p===void 0||!(p instanceof Uint8Array))return a("witness-header-shape",`header RLP item ${Va} (timestamp) is missing or not a byte string`,{blockNumber:String(l)});let w=Fr(p);return w>BigInt(Number.MAX_SAFE_INTEGER)?a("witness-header-shape","header timestamp does not fit a safe integer",{blockNumber:String(l)}):{...s,verified:!0,blockNumber:String(l),timestamp:Number(w)}}function Nd(t){return za(t,"message")}function Md(t){return za(t,"title")}function za(t,e){let n=t.proof.attribution;if(n===null||typeof n!="object"||Array.isArray(n))return;let o=n[e];return typeof o=="string"?o:void 0}function Ld(t){let e=t.proof.artifact;if(e===null||typeof e!="object"||Array.isArray(e))return;let n=e.digestB64;return typeof n=="string"?n:void 0}function Od(t){if(t===void 0||t.length===0)return null;let e=B.Buffer.from(t,"base64");return e.length!==32||e.toString("base64")!==t?null:new Uint8Array(e)}function Fd(t,e){if(t.length!==e.length)return!1;let n=0;for(let o=0;o<t.length;o++)n|=t[o]^e[o];return n===0}function Ur(t){return{code:t.reason,path:t.witnessPath,message:`anchor witness rejected: ${t.detail??"verification failed"}. The witness confers nothing; the anchor proof's own standing is unchanged.`,details:{...t.anchorProofHash!==void 0?{anchorProofHash:t.anchorProofHash}:{},...t.computedBlockHash!==void 0?{computedBlockHash:t.computedBlockHash}:{}}}}y();function jr(t,e,n,o){let r=new Map(t.proofs.map(u=>[u.proofHash,u])),i=new Map;for(let u of o.outcomes)!u.verified||u.anchorProofHash===void 0||i.has(u.anchorProofHash)||i.set(u.anchorProofHash,{anchorProofHash:u.anchorProofHash,timestamp:u.timestamp,blockHash:u.computedBlockHash,...u.blockNumber!==void 0?{blockNumber:u.blockNumber}:{}});let s=[...i.keys()].sort(),a=n.anchors.map(u=>u.proofHash).filter(u=>!i.has(u)).sort(),c=[];for(let u of e.partitions)c.push(...Ud(u,r,i));let f=qd(e,c);return{segments:c,anchorOrderedPairs:f,verifiedAnchorProofHashes:s,unverifiedAnchorProofHashes:a}}function Ud(t,e,n){let o=t.memberProofHashes.map(h=>e.get(h)),r=new Map(o.map(h=>[h.chainHash,h])),i=o.filter(h=>n.has(h.proofHash)),s=new Map;for(let h of o){if(h.prevB64===void 0)continue;let l=r.get(h.prevB64);l===void 0||l.proofHash===h.proofHash||ue(s,l.proofHash,h)}let a=new Map,c=new Map;for(let h of i)a.set(h.proofHash,jd(h,s)),c.set(h.proofHash,Kd(h,r));let f=o.map(h=>{let l=new Map,m=new Map,p=Y(h.counter);for(let w of i){let b=w.proofHash,k=Y(w.counter);h.proofHash===b||a.get(b).has(h.proofHash)?l.set(b,"chain-link"):p!==void 0&&k!==void 0&&p>k&&(l.has(b)||l.set(b,"counter-order")),c.get(b).has(h.proofHash)?m.set(b,"chain-link"):h.proofHash!==b&&p!==void 0&&k!==void 0&&p<k&&(m.has(b)||m.set(b,"counter-order"))}return{member:h,lower:qa("not-before",l,n),upper:qa("not-after",m,n)}}),u=new Map;for(let h of f)ue(u,_d(h),h);let d=[];for(let h of u.values()){let l=h.map(v=>v.member).sort(Pe),m=h[0],p=m.lower,w=m.upper,b=p.length>0&&w.length>0?"lower-bounded-with-following-anchor":p.length>0?"lower-bounded":w.length>0?"upper-bounded":"ordered-but-unanchored",k=Vd(l);d.push({partition:t.key,memberProofHashes:l.map(v=>v.proofHash),...k!==void 0?{positionRange:k}:{},status:b,lowerBounds:p,upperBounds:w})}return d.sort(zd),d}function qa(t,e,n){if(e.size===0)return[];let o=[...e.entries()].map(([c,f])=>({anchorHash:c,evidenceKind:f,info:n.get(c)})),r=(c,f)=>f===void 0?!0:c.info.timestamp!==f.info.timestamp?t==="not-before"?c.info.timestamp>f.info.timestamp:c.info.timestamp<f.info.timestamp:c.evidenceKind!==f.evidenceKind?c.evidenceKind==="chain-link":c.anchorHash<f.anchorHash,i,s;for(let c of o)r(c,i)&&(i=c),c.evidenceKind==="chain-link"&&r(c,s)&&(s=c);let a=[Ga(t,i)];return s!==void 0&&(i.anchorHash!==s.anchorHash||i.evidenceKind!=="chain-link")&&a.push(Ga(t,s)),a}function Ga(t,e){let{info:n,evidenceKind:o}=e,r=new Date(n.timestamp*1e3).toISOString(),i=n.blockNumber!==void 0?`Ethereum block ${n.blockNumber}`:"an Ethereum block",s=o==="chain-link"?"Evidence: a verified hash-link path connects these proofs and the anchor.":"Evidence: commit-counter ordering within the partition only, which relies on the authority's counter discipline rather than verifiable hash links (weaker).",a=t==="not-before"?`These proofs were committed no earlier than ${r} (unix ${n.timestamp}), the timestamp of ${i}: the block hash was unpredictable before that time and the anchor commit consumed it. Reading this as a wall-clock floor additionally assumes the anchored header is a genuine, publicly published Ethereum block: this offline audit checks the header's structure and hash binding, not proof-of-work, consensus, or chain membership, so it cannot confirm the block is real. ${s}`:`These proofs existed before the anchor commit that consumed the hash of ${i} (block timestamp ${r}, unix ${n.timestamp}). The block timestamp proves the anchor commit came at or after it, not how promptly; reading it as a wall-clock ceiling additionally assumes the anchor consumed a recently published block. ${s}`;return{kind:t,anchorProofHash:e.anchorHash,...n.blockNumber!==void 0?{blockNumber:n.blockNumber}:{},blockHash:n.blockHash,timestamp:n.timestamp,evidence:o,weaker:o==="counter-order",basis:t==="not-before"?"block-hash-unpredictability":"causal-precedence",boundClass:t==="not-before"?"evidence":"assumption",claim:t==="not-before"?a:"NOT a proof-carried upper bound. "+a}}function _d(t){let e=n=>n.map(o=>`${o.anchorProofHash}:${o.evidence}`).join(",");return`${e(t.lower)}|${e(t.upper)}`}function jd(t,e){let n=new Set,o=[...e.get(t.proofHash)??[]];for(;o.length>0;){let r=o.pop();if(!n.has(r.proofHash)){n.add(r.proofHash);for(let i of e.get(r.proofHash)??[])o.push(i)}}return n}function Kd(t,e){let n=new Set,o=t;for(;o!==void 0&&o.prevB64!==void 0;){let r=e.get(o.prevB64);if(r===void 0||n.has(r.proofHash)||r.proofHash===t.proofHash)break;n.add(r.proofHash),o=r}return n}function Vd(t){let e,n;for(let o of t)for(let r of[o.counter,o.slotCounter]){let i=Y(r);i!==void 0&&((e===void 0||i<e)&&(e=i),(n===void 0||i>n)&&(n=i))}return e!==void 0&&n!==void 0?{min:String(e),max:String(n)}:void 0}function zd(t,e){let n=t.positionRange?.min,o=e.positionRange?.min;if(n!==void 0&&o!==void 0&&n!==o)return BigInt(n)<BigInt(o)?-1:1;if(n!==void 0&&o===void 0)return-1;if(n===void 0&&o!==void 0)return 1;let r=t.memberProofHashes[0]??"",i=e.memberProofHashes[0]??"";return r<i?-1:r>i?1:0}function Wa(t){return t?" The representative bound rests on commit-counter ordering rather than a verified hash-link path, which relies on the authority's counter discipline (weaker evidence).":""}function qd(t,e){let n=new Map;for(let i of t.epochRelationships.epochs)n.set(i.epochId,{totalProofCount:i.proofCount,lowerCovered:new Set,upperCovered:new Set});for(let i of e){let s=i.partition.epochId;if(s===void 0)continue;let a=n.get(s);if(a!==void 0){for(let c of i.lowerBounds){for(let f of i.memberProofHashes)a.lowerCovered.add(f);(a.lowerMin===void 0||c.timestamp<a.lowerMin.timestamp||c.timestamp===a.lowerMin.timestamp&&a.lowerMin.weaker&&!c.weaker)&&(a.lowerMin={timestamp:c.timestamp,anchorProofHash:c.anchorProofHash,blockHash:c.blockHash,...c.blockNumber!==void 0?{blockNumber:c.blockNumber}:{},evidence:c.evidence,weaker:c.weaker})}for(let c of i.upperBounds){for(let f of i.memberProofHashes)a.upperCovered.add(f);(a.upperMax===void 0||c.timestamp>a.upperMax.timestamp||c.timestamp===a.upperMax.timestamp&&a.upperMax.weaker&&!c.weaker)&&(a.upperMax={timestamp:c.timestamp,anchorProofHash:c.anchorProofHash,blockHash:c.blockHash,...c.blockNumber!==void 0?{blockNumber:c.blockNumber}:{},evidence:c.evidence,weaker:c.weaker})}}}for(let i of t.epochRelationships.epochs){let s=n.get(i.epochId),a=[];s.lowerMin!==void 0&&a.push({kind:"not-before",anchorProofHash:s.lowerMin.anchorProofHash,...s.lowerMin.blockNumber!==void 0?{blockNumber:s.lowerMin.blockNumber}:{},blockHash:s.lowerMin.blockHash,witnessTimestamp:s.lowerMin.timestamp,coverage:"members-after-anchor",coveredProofCount:s.lowerCovered.size,totalProofCount:s.totalProofCount,basis:"block-hash-unpredictability",evidence:s.lowerMin.evidence,weaker:s.lowerMin.weaker,claim:`${s.lowerCovered.size} of ${s.totalProofCount} observed proofs of this epoch were committed no earlier than unix ${s.lowerMin.timestamp}, grounded in block-hash unpredictability through verified anchor witnesses. This additionally assumes the anchored header is a genuine, publicly published Ethereum block, which this offline audit cannot confirm.`+Wa(s.lowerMin.weaker)+" The remaining proofs sit causally before the covering anchors and carry no lower bound from this evidence."}),s.upperMax!==void 0&&a.push({kind:"not-after",anchorProofHash:s.upperMax.anchorProofHash,...s.upperMax.blockNumber!==void 0?{blockNumber:s.upperMax.blockNumber}:{},blockHash:s.upperMax.blockHash,witnessTimestamp:s.upperMax.timestamp,coverage:"members-before-anchor",coveredProofCount:s.upperCovered.size,totalProofCount:s.totalProofCount,basis:"causal-precedence",evidence:s.upperMax.evidence,weaker:s.upperMax.weaker,claim:`${s.upperCovered.size} of ${s.totalProofCount} observed proofs of this epoch existed before an anchor commit that consumed a block published at unix ${s.upperMax.timestamp}. Reading that timestamp as a wall-clock ceiling additionally assumes the anchor consumed a recently published block; the causal precedence itself is verified.`+Wa(s.upperMax.weaker)+" Proofs after the covering anchors are not covered."}),a.length>0&&(i.anchorBounds=a)}let o=[],r=t.epochRelationships.epochs;for(let i of r){let s=n.get(i.epochId);if(s.upperMax!==void 0)for(let a of r){if(a.epochId===i.epochId)continue;let c=n.get(a.epochId);if(c.lowerMin===void 0||s.upperMax.timestamp>=c.lowerMin.timestamp)continue;let f=s.upperMax.evidence,u=c.lowerMin.evidence,d=s.upperMax.weaker||c.lowerMin.weaker;o.push({beforeEpochId:i.epochId,afterEpochId:a.epochId,upperAnchorProofHash:s.upperMax.anchorProofHash,upperBoundTimestamp:s.upperMax.timestamp,lowerAnchorProofHash:c.lowerMin.anchorProofHash,lowerBoundTimestamp:c.lowerMin.timestamp,basis:"anchor-bounds",assumptionDependent:!0,upperEvidence:f,lowerEvidence:u,weaker:d,beforeCoveredProofCount:s.upperCovered.size,beforeTotalProofCount:s.totalProofCount,afterCoveredProofCount:c.lowerCovered.size,afterTotalProofCount:c.totalProofCount,note:`The anchor-covered portion of epoch ${i.epochId} (${s.upperCovered.size} of ${s.totalProofCount} proofs) precedes the anchor-covered portion of epoch ${a.epochId} (${c.lowerCovered.size} of ${c.totalProofCount} proofs): the first is bounded not-after unix ${s.upperMax.timestamp} and the second not-before unix ${c.lowerMin.timestamp}. One-sided evidence about the covered portions only; the not-after side rests on the anchor-freshness assumption documented on its bound.`+(d?" At least one side rests on commit-counter ordering rather than a verified hash-link path (weaker evidence), which relies on the authority's counter discipline.":"")+" This is ordering evidence, never divergence."})}}return o.sort((i,s)=>i.beforeEpochId!==s.beforeEpochId?i.beforeEpochId<s.beforeEpochId?-1:1:i.afterEpochId<s.afterEpochId?-1:i.afterEpochId>s.afterEpochId?1:0),o}y();y();var Za=`-----BEGIN CERTIFICATE-----
|
|
139
|
+
"use strict";(()=>{var Bc=Object.create;var ui=Object.defineProperty;var vc=Object.getOwnPropertyDescriptor;var Ac=Object.getOwnPropertyNames;var Ic=Object.getPrototypeOf,kc=Object.prototype.hasOwnProperty;var Sc=(t,e)=>()=>(t&&(e=t(t=0)),e);var dr=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Tc=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ac(e))!kc.call(t,o)&&o!==n&&ui(t,o,{get:()=>e[o],enumerable:!(r=vc(e,o))||r.enumerable});return t};var Hc=(t,e,n)=>(n=t!=null?Bc(Ic(t)):{},Tc(e||!t||!t.__esModule?ui(n,"default",{value:t,enumerable:!0}):n,t));var li=dr(bn=>{"use strict";y();bn.byteLength=Rc;bn.toByteArray=Pc;bn.fromByteArray=Nc;var ke=[],be=[],Cc=typeof Uint8Array<"u"?Uint8Array:Array,hr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(pt=0,di=hr.length;pt<di;++pt)ke[pt]=hr[pt],be[hr.charCodeAt(pt)]=pt;var pt,di;be[45]=62;be[95]=63;function hi(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");n===-1&&(n=e);var r=n===e?0:4-n%4;return[n,r]}function Rc(t){var e=hi(t),n=e[0],r=e[1];return(n+r)*3/4-r}function $c(t,e,n){return(e+n)*3/4-n}function Pc(t){var e,n=hi(t),r=n[0],o=n[1],i=new Cc($c(t,r,o)),s=0,a=o>0?r-4:r,c;for(c=0;c<a;c+=4)e=be[t.charCodeAt(c)]<<18|be[t.charCodeAt(c+1)]<<12|be[t.charCodeAt(c+2)]<<6|be[t.charCodeAt(c+3)],i[s++]=e>>16&255,i[s++]=e>>8&255,i[s++]=e&255;return o===2&&(e=be[t.charCodeAt(c)]<<2|be[t.charCodeAt(c+1)]>>4,i[s++]=e&255),o===1&&(e=be[t.charCodeAt(c)]<<10|be[t.charCodeAt(c+1)]<<4|be[t.charCodeAt(c+2)]>>2,i[s++]=e>>8&255,i[s++]=e&255),i}function Mc(t){return ke[t>>18&63]+ke[t>>12&63]+ke[t>>6&63]+ke[t&63]}function Dc(t,e,n){for(var r,o=[],i=e;i<n;i+=3)r=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),o.push(Mc(r));return o.join("")}function Nc(t){for(var e,n=t.length,r=n%3,o=[],i=16383,s=0,a=n-r;s<a;s+=i)o.push(Dc(t,s,s+i>a?a:s+i));return r===1?(e=t[n-1],o.push(ke[e>>2]+ke[e<<4&63]+"==")):r===2&&(e=(t[n-2]<<8)+t[n-1],o.push(ke[e>>10]+ke[e>>4&63]+ke[e<<2&63]+"=")),o.join("")}});var pi=dr(lr=>{y();lr.read=function(t,e,n,r,o){var i,s,a=o*8-r-1,c=(1<<a)-1,f=c>>1,u=-7,d=n?o-1:0,h=n?-1:1,l=t[e+d];for(d+=h,i=l&(1<<-u)-1,l>>=-u,u+=a;u>0;i=i*256+t[e+d],d+=h,u-=8);for(s=i&(1<<-u)-1,i>>=-u,u+=r;u>0;s=s*256+t[e+d],d+=h,u-=8);if(i===0)i=1-f;else{if(i===c)return s?NaN:(l?-1:1)*(1/0);s=s+Math.pow(2,r),i=i-f}return(l?-1:1)*s*Math.pow(2,i-r)};lr.write=function(t,e,n,r,o,i){var s,a,c,f=i*8-o-1,u=(1<<f)-1,d=u>>1,h=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,l=r?0:i-1,m=r?1:-1,p=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+d>=1?e+=h/c:e+=h*Math.pow(2,1-d),e*c>=2&&(s++,c/=2),s+d>=u?(a=0,s=u):s+d>=1?(a=(e*c-1)*Math.pow(2,o),s=s+d):(a=e*Math.pow(2,d-1)*Math.pow(2,o),s=0));o>=8;t[n+l]=a&255,l+=m,a/=256,o-=8);for(s=s<<o|a,f+=o;f>0;t[n+l]=s&255,l+=m,s/=256,f-=8);t[n+l-m]|=p*128}});var Ri=dr($t=>{"use strict";y();var pr=li(),Ct=pi(),mi=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;$t.Buffer=g;$t.SlowBuffer=jc;$t.INSPECT_MAX_BYTES=50;var yn=2147483647;$t.kMaxLength=yn;g.TYPED_ARRAY_SUPPORT=Lc();!g.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 Lc(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(g.prototype,"parent",{enumerable:!0,get:function(){if(g.isBuffer(this))return this.buffer}});Object.defineProperty(g.prototype,"offset",{enumerable:!0,get:function(){if(g.isBuffer(this))return this.byteOffset}});function Ne(t){if(t>yn)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,g.prototype),e}function g(t,e,n){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return yr(t)}return wi(t,e,n)}g.poolSize=8192;function wi(t,e,n){if(typeof t=="string")return Fc(t,e);if(ArrayBuffer.isView(t))return _c(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Se(t,ArrayBuffer)||t&&Se(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Se(t,SharedArrayBuffer)||t&&Se(t.buffer,SharedArrayBuffer)))return gr(t,e,n);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let r=t.valueOf&&t.valueOf();if(r!=null&&r!==t)return g.from(r,e,n);let o=Uc(t);if(o)return o;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return g.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}g.from=function(t,e,n){return wi(t,e,n)};Object.setPrototypeOf(g.prototype,Uint8Array.prototype);Object.setPrototypeOf(g,Uint8Array);function xi(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function Oc(t,e,n){return xi(t),t<=0?Ne(t):e!==void 0?typeof n=="string"?Ne(t).fill(e,n):Ne(t).fill(e):Ne(t)}g.alloc=function(t,e,n){return Oc(t,e,n)};function yr(t){return xi(t),Ne(t<0?0:wr(t)|0)}g.allocUnsafe=function(t){return yr(t)};g.allocUnsafeSlow=function(t){return yr(t)};function Fc(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!g.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let n=Ei(t,e)|0,r=Ne(n),o=r.write(t,e);return o!==n&&(r=r.slice(0,o)),r}function mr(t){let e=t.length<0?0:wr(t.length)|0,n=Ne(e);for(let r=0;r<e;r+=1)n[r]=t[r]&255;return n}function _c(t){if(Se(t,Uint8Array)){let e=new Uint8Array(t);return gr(e.buffer,e.byteOffset,e.byteLength)}return mr(t)}function gr(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let r;return e===void 0&&n===void 0?r=new Uint8Array(t):n===void 0?r=new Uint8Array(t,e):r=new Uint8Array(t,e,n),Object.setPrototypeOf(r,g.prototype),r}function Uc(t){if(g.isBuffer(t)){let e=wr(t.length)|0,n=Ne(e);return n.length===0||t.copy(n,0,0,e),n}if(t.length!==void 0)return typeof t.length!="number"||Er(t.length)?Ne(0):mr(t);if(t.type==="Buffer"&&Array.isArray(t.data))return mr(t.data)}function wr(t){if(t>=yn)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+yn.toString(16)+" bytes");return t|0}function jc(t){return+t!=t&&(t=0),g.alloc(+t)}g.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==g.prototype};g.compare=function(e,n){if(Se(e,Uint8Array)&&(e=g.from(e,e.offset,e.byteLength)),Se(n,Uint8Array)&&(n=g.from(n,n.offset,n.byteLength)),!g.isBuffer(e)||!g.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===n)return 0;let r=e.length,o=n.length;for(let i=0,s=Math.min(r,o);i<s;++i)if(e[i]!==n[i]){r=e[i],o=n[i];break}return r<o?-1:o<r?1:0};g.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}};g.concat=function(e,n){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return g.alloc(0);let r;if(n===void 0)for(n=0,r=0;r<e.length;++r)n+=e[r].length;let o=g.allocUnsafe(n),i=0;for(r=0;r<e.length;++r){let s=e[r];if(Se(s,Uint8Array))i+s.length>o.length?(g.isBuffer(s)||(s=g.from(s)),s.copy(o,i)):Uint8Array.prototype.set.call(o,s,i);else if(g.isBuffer(s))s.copy(o,i);else throw new TypeError('"list" argument must be an Array of Buffers');i+=s.length}return o};function Ei(t,e){if(g.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Se(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let n=t.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let o=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return br(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return Ci(t).length;default:if(o)return r?-1:br(t).length;e=(""+e).toLowerCase(),o=!0}}g.byteLength=Ei;function Kc(t,e,n){let r=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,e>>>=0,n<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return Qc(this,e,n);case"utf8":case"utf-8":return vi(this,e,n);case"ascii":return Xc(this,e,n);case"latin1":case"binary":return Jc(this,e,n);case"base64":return Zc(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ef(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}g.prototype._isBuffer=!0;function mt(t,e,n){let r=t[e];t[e]=t[n],t[n]=r}g.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let n=0;n<e;n+=2)mt(this,n,n+1);return this};g.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let n=0;n<e;n+=4)mt(this,n,n+3),mt(this,n+1,n+2);return this};g.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let n=0;n<e;n+=8)mt(this,n,n+7),mt(this,n+1,n+6),mt(this,n+2,n+5),mt(this,n+3,n+4);return this};g.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?vi(this,0,e):Kc.apply(this,arguments)};g.prototype.toLocaleString=g.prototype.toString;g.prototype.equals=function(e){if(!g.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:g.compare(this,e)===0};g.prototype.inspect=function(){let e="",n=$t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(e+=" ... "),"<Buffer "+e+">"};mi&&(g.prototype[mi]=g.prototype.inspect);g.prototype.compare=function(e,n,r,o,i){if(Se(e,Uint8Array)&&(e=g.from(e,e.offset,e.byteLength)),!g.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(n===void 0&&(n=0),r===void 0&&(r=e?e.length:0),o===void 0&&(o=0),i===void 0&&(i=this.length),n<0||r>e.length||o<0||i>this.length)throw new RangeError("out of range index");if(o>=i&&n>=r)return 0;if(o>=i)return-1;if(n>=r)return 1;if(n>>>=0,r>>>=0,o>>>=0,i>>>=0,this===e)return 0;let s=i-o,a=r-n,c=Math.min(s,a),f=this.slice(o,i),u=e.slice(n,r);for(let d=0;d<c;++d)if(f[d]!==u[d]){s=f[d],a=u[d];break}return s<a?-1:a<s?1:0};function Bi(t,e,n,r,o){if(t.length===0)return-1;if(typeof n=="string"?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Er(n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0)if(o)n=0;else return-1;if(typeof e=="string"&&(e=g.from(e,r)),g.isBuffer(e))return e.length===0?-1:gi(t,e,n,r,o);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):gi(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function gi(t,e,n,r,o){let i=1,s=t.length,a=e.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(t.length<2||e.length<2)return-1;i=2,s/=2,a/=2,n/=2}function c(u,d){return i===1?u[d]:u.readUInt16BE(d*i)}let f;if(o){let u=-1;for(f=n;f<s;f++)if(c(t,f)===c(e,u===-1?0:f-u)){if(u===-1&&(u=f),f-u+1===a)return u*i}else u!==-1&&(f-=f-u),u=-1}else for(n+a>s&&(n=s-a),f=n;f>=0;f--){let u=!0;for(let d=0;d<a;d++)if(c(t,f+d)!==c(e,d)){u=!1;break}if(u)return f}return-1}g.prototype.includes=function(e,n,r){return this.indexOf(e,n,r)!==-1};g.prototype.indexOf=function(e,n,r){return Bi(this,e,n,r,!0)};g.prototype.lastIndexOf=function(e,n,r){return Bi(this,e,n,r,!1)};function Vc(t,e,n,r){n=Number(n)||0;let o=t.length-n;r?(r=Number(r),r>o&&(r=o)):r=o;let i=e.length;r>i/2&&(r=i/2);let s;for(s=0;s<r;++s){let a=parseInt(e.substr(s*2,2),16);if(Er(a))return s;t[n+s]=a}return s}function zc(t,e,n,r){return wn(br(e,t.length-n),t,n,r)}function qc(t,e,n,r){return wn(of(e),t,n,r)}function Gc(t,e,n,r){return wn(Ci(e),t,n,r)}function Wc(t,e,n,r){return wn(sf(e,t.length-n),t,n,r)}g.prototype.write=function(e,n,r,o){if(n===void 0)o="utf8",r=this.length,n=0;else if(r===void 0&&typeof n=="string")o=n,r=this.length,n=0;else if(isFinite(n))n=n>>>0,isFinite(r)?(r=r>>>0,o===void 0&&(o="utf8")):(o=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let i=this.length-n;if((r===void 0||r>i)&&(r=i),e.length>0&&(r<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let s=!1;for(;;)switch(o){case"hex":return Vc(this,e,n,r);case"utf8":case"utf-8":return zc(this,e,n,r);case"ascii":case"latin1":case"binary":return qc(this,e,n,r);case"base64":return Gc(this,e,n,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Wc(this,e,n,r);default:if(s)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),s=!0}};g.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Zc(t,e,n){return e===0&&n===t.length?pr.fromByteArray(t):pr.fromByteArray(t.slice(e,n))}function vi(t,e,n){n=Math.min(t.length,n);let r=[],o=e;for(;o<n;){let i=t[o],s=null,a=i>239?4:i>223?3:i>191?2:1;if(o+a<=n){let c,f,u,d;switch(a){case 1:i<128&&(s=i);break;case 2:c=t[o+1],(c&192)===128&&(d=(i&31)<<6|c&63,d>127&&(s=d));break;case 3:c=t[o+1],f=t[o+2],(c&192)===128&&(f&192)===128&&(d=(i&15)<<12|(c&63)<<6|f&63,d>2047&&(d<55296||d>57343)&&(s=d));break;case 4:c=t[o+1],f=t[o+2],u=t[o+3],(c&192)===128&&(f&192)===128&&(u&192)===128&&(d=(i&15)<<18|(c&63)<<12|(f&63)<<6|u&63,d>65535&&d<1114112&&(s=d))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),o+=a}return Yc(r)}var bi=4096;function Yc(t){let e=t.length;if(e<=bi)return String.fromCharCode.apply(String,t);let n="",r=0;for(;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=bi));return n}function Xc(t,e,n){let r="";n=Math.min(t.length,n);for(let o=e;o<n;++o)r+=String.fromCharCode(t[o]&127);return r}function Jc(t,e,n){let r="";n=Math.min(t.length,n);for(let o=e;o<n;++o)r+=String.fromCharCode(t[o]);return r}function Qc(t,e,n){let r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);let o="";for(let i=e;i<n;++i)o+=af[t[i]];return o}function ef(t,e,n){let r=t.slice(e,n),o="";for(let i=0;i<r.length-1;i+=2)o+=String.fromCharCode(r[i]+r[i+1]*256);return o}g.prototype.slice=function(e,n){let r=this.length;e=~~e,n=n===void 0?r:~~n,e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),n<0?(n+=r,n<0&&(n=0)):n>r&&(n=r),n<e&&(n=e);let o=this.subarray(e,n);return Object.setPrototypeOf(o,g.prototype),o};function J(t,e,n){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}g.prototype.readUintLE=g.prototype.readUIntLE=function(e,n,r){e=e>>>0,n=n>>>0,r||J(e,n,this.length);let o=this[e],i=1,s=0;for(;++s<n&&(i*=256);)o+=this[e+s]*i;return o};g.prototype.readUintBE=g.prototype.readUIntBE=function(e,n,r){e=e>>>0,n=n>>>0,r||J(e,n,this.length);let o=this[e+--n],i=1;for(;n>0&&(i*=256);)o+=this[e+--n]*i;return o};g.prototype.readUint8=g.prototype.readUInt8=function(e,n){return e=e>>>0,n||J(e,1,this.length),this[e]};g.prototype.readUint16LE=g.prototype.readUInt16LE=function(e,n){return e=e>>>0,n||J(e,2,this.length),this[e]|this[e+1]<<8};g.prototype.readUint16BE=g.prototype.readUInt16BE=function(e,n){return e=e>>>0,n||J(e,2,this.length),this[e]<<8|this[e+1]};g.prototype.readUint32LE=g.prototype.readUInt32LE=function(e,n){return e=e>>>0,n||J(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};g.prototype.readUint32BE=g.prototype.readUInt32BE=function(e,n){return e=e>>>0,n||J(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};g.prototype.readBigUInt64LE=et(function(e){e=e>>>0,Rt(e,"offset");let n=this[e],r=this[e+7];(n===void 0||r===void 0)&&Yt(e,this.length-8);let o=n+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*2**8+this[++e]*2**16+r*2**24;return BigInt(o)+(BigInt(i)<<BigInt(32))});g.prototype.readBigUInt64BE=et(function(e){e=e>>>0,Rt(e,"offset");let n=this[e],r=this[e+7];(n===void 0||r===void 0)&&Yt(e,this.length-8);let o=n*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+r;return(BigInt(o)<<BigInt(32))+BigInt(i)});g.prototype.readIntLE=function(e,n,r){e=e>>>0,n=n>>>0,r||J(e,n,this.length);let o=this[e],i=1,s=0;for(;++s<n&&(i*=256);)o+=this[e+s]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*n)),o};g.prototype.readIntBE=function(e,n,r){e=e>>>0,n=n>>>0,r||J(e,n,this.length);let o=n,i=1,s=this[e+--o];for(;o>0&&(i*=256);)s+=this[e+--o]*i;return i*=128,s>=i&&(s-=Math.pow(2,8*n)),s};g.prototype.readInt8=function(e,n){return e=e>>>0,n||J(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};g.prototype.readInt16LE=function(e,n){e=e>>>0,n||J(e,2,this.length);let r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};g.prototype.readInt16BE=function(e,n){e=e>>>0,n||J(e,2,this.length);let r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};g.prototype.readInt32LE=function(e,n){return e=e>>>0,n||J(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};g.prototype.readInt32BE=function(e,n){return e=e>>>0,n||J(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};g.prototype.readBigInt64LE=et(function(e){e=e>>>0,Rt(e,"offset");let n=this[e],r=this[e+7];(n===void 0||r===void 0)&&Yt(e,this.length-8);let o=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(r<<24);return(BigInt(o)<<BigInt(32))+BigInt(n+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});g.prototype.readBigInt64BE=et(function(e){e=e>>>0,Rt(e,"offset");let n=this[e],r=this[e+7];(n===void 0||r===void 0)&&Yt(e,this.length-8);let o=(n<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(o)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+r)});g.prototype.readFloatLE=function(e,n){return e=e>>>0,n||J(e,4,this.length),Ct.read(this,e,!0,23,4)};g.prototype.readFloatBE=function(e,n){return e=e>>>0,n||J(e,4,this.length),Ct.read(this,e,!1,23,4)};g.prototype.readDoubleLE=function(e,n){return e=e>>>0,n||J(e,8,this.length),Ct.read(this,e,!0,52,8)};g.prototype.readDoubleBE=function(e,n){return e=e>>>0,n||J(e,8,this.length),Ct.read(this,e,!1,52,8)};function fe(t,e,n,r,o,i){if(!g.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}g.prototype.writeUintLE=g.prototype.writeUIntLE=function(e,n,r,o){if(e=+e,n=n>>>0,r=r>>>0,!o){let a=Math.pow(2,8*r)-1;fe(this,e,n,r,a,0)}let i=1,s=0;for(this[n]=e&255;++s<r&&(i*=256);)this[n+s]=e/i&255;return n+r};g.prototype.writeUintBE=g.prototype.writeUIntBE=function(e,n,r,o){if(e=+e,n=n>>>0,r=r>>>0,!o){let a=Math.pow(2,8*r)-1;fe(this,e,n,r,a,0)}let i=r-1,s=1;for(this[n+i]=e&255;--i>=0&&(s*=256);)this[n+i]=e/s&255;return n+r};g.prototype.writeUint8=g.prototype.writeUInt8=function(e,n,r){return e=+e,n=n>>>0,r||fe(this,e,n,1,255,0),this[n]=e&255,n+1};g.prototype.writeUint16LE=g.prototype.writeUInt16LE=function(e,n,r){return e=+e,n=n>>>0,r||fe(this,e,n,2,65535,0),this[n]=e&255,this[n+1]=e>>>8,n+2};g.prototype.writeUint16BE=g.prototype.writeUInt16BE=function(e,n,r){return e=+e,n=n>>>0,r||fe(this,e,n,2,65535,0),this[n]=e>>>8,this[n+1]=e&255,n+2};g.prototype.writeUint32LE=g.prototype.writeUInt32LE=function(e,n,r){return e=+e,n=n>>>0,r||fe(this,e,n,4,4294967295,0),this[n+3]=e>>>24,this[n+2]=e>>>16,this[n+1]=e>>>8,this[n]=e&255,n+4};g.prototype.writeUint32BE=g.prototype.writeUInt32BE=function(e,n,r){return e=+e,n=n>>>0,r||fe(this,e,n,4,4294967295,0),this[n]=e>>>24,this[n+1]=e>>>16,this[n+2]=e>>>8,this[n+3]=e&255,n+4};function Ai(t,e,n,r,o){Hi(e,r,o,t,n,7);let i=Number(e&BigInt(4294967295));t[n++]=i,i=i>>8,t[n++]=i,i=i>>8,t[n++]=i,i=i>>8,t[n++]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s=s>>8,t[n++]=s,s=s>>8,t[n++]=s,s=s>>8,t[n++]=s,n}function Ii(t,e,n,r,o){Hi(e,r,o,t,n,7);let i=Number(e&BigInt(4294967295));t[n+7]=i,i=i>>8,t[n+6]=i,i=i>>8,t[n+5]=i,i=i>>8,t[n+4]=i;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s=s>>8,t[n+2]=s,s=s>>8,t[n+1]=s,s=s>>8,t[n]=s,n+8}g.prototype.writeBigUInt64LE=et(function(e,n=0){return Ai(this,e,n,BigInt(0),BigInt("0xffffffffffffffff"))});g.prototype.writeBigUInt64BE=et(function(e,n=0){return Ii(this,e,n,BigInt(0),BigInt("0xffffffffffffffff"))});g.prototype.writeIntLE=function(e,n,r,o){if(e=+e,n=n>>>0,!o){let c=Math.pow(2,8*r-1);fe(this,e,n,r,c-1,-c)}let i=0,s=1,a=0;for(this[n]=e&255;++i<r&&(s*=256);)e<0&&a===0&&this[n+i-1]!==0&&(a=1),this[n+i]=(e/s>>0)-a&255;return n+r};g.prototype.writeIntBE=function(e,n,r,o){if(e=+e,n=n>>>0,!o){let c=Math.pow(2,8*r-1);fe(this,e,n,r,c-1,-c)}let i=r-1,s=1,a=0;for(this[n+i]=e&255;--i>=0&&(s*=256);)e<0&&a===0&&this[n+i+1]!==0&&(a=1),this[n+i]=(e/s>>0)-a&255;return n+r};g.prototype.writeInt8=function(e,n,r){return e=+e,n=n>>>0,r||fe(this,e,n,1,127,-128),e<0&&(e=255+e+1),this[n]=e&255,n+1};g.prototype.writeInt16LE=function(e,n,r){return e=+e,n=n>>>0,r||fe(this,e,n,2,32767,-32768),this[n]=e&255,this[n+1]=e>>>8,n+2};g.prototype.writeInt16BE=function(e,n,r){return e=+e,n=n>>>0,r||fe(this,e,n,2,32767,-32768),this[n]=e>>>8,this[n+1]=e&255,n+2};g.prototype.writeInt32LE=function(e,n,r){return e=+e,n=n>>>0,r||fe(this,e,n,4,2147483647,-2147483648),this[n]=e&255,this[n+1]=e>>>8,this[n+2]=e>>>16,this[n+3]=e>>>24,n+4};g.prototype.writeInt32BE=function(e,n,r){return e=+e,n=n>>>0,r||fe(this,e,n,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[n]=e>>>24,this[n+1]=e>>>16,this[n+2]=e>>>8,this[n+3]=e&255,n+4};g.prototype.writeBigInt64LE=et(function(e,n=0){return Ai(this,e,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});g.prototype.writeBigInt64BE=et(function(e,n=0){return Ii(this,e,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ki(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Si(t,e,n,r,o){return e=+e,n=n>>>0,o||ki(t,e,n,4,34028234663852886e22,-34028234663852886e22),Ct.write(t,e,n,r,23,4),n+4}g.prototype.writeFloatLE=function(e,n,r){return Si(this,e,n,!0,r)};g.prototype.writeFloatBE=function(e,n,r){return Si(this,e,n,!1,r)};function Ti(t,e,n,r,o){return e=+e,n=n>>>0,o||ki(t,e,n,8,17976931348623157e292,-17976931348623157e292),Ct.write(t,e,n,r,52,8),n+8}g.prototype.writeDoubleLE=function(e,n,r){return Ti(this,e,n,!0,r)};g.prototype.writeDoubleBE=function(e,n,r){return Ti(this,e,n,!1,r)};g.prototype.copy=function(e,n,r,o){if(!g.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),!o&&o!==0&&(o=this.length),n>=e.length&&(n=e.length),n||(n=0),o>0&&o<r&&(o=r),o===r||e.length===0||this.length===0)return 0;if(n<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-n<o-r&&(o=e.length-n+r);let i=o-r;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(n,r,o):Uint8Array.prototype.set.call(e,this.subarray(r,o),n),i};g.prototype.fill=function(e,n,r,o){if(typeof e=="string"){if(typeof n=="string"?(o=n,n=0,r=this.length):typeof r=="string"&&(o=r,r=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!g.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(e.length===1){let s=e.charCodeAt(0);(o==="utf8"&&s<128||o==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(n<0||this.length<n||this.length<r)throw new RangeError("Out of range index");if(r<=n)return this;n=n>>>0,r=r===void 0?this.length:r>>>0,e||(e=0);let i;if(typeof e=="number")for(i=n;i<r;++i)this[i]=e;else{let s=g.isBuffer(e)?e:g.from(e,o),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-n;++i)this[i+n]=s[i%a]}return this};var Ht={};function xr(t,e,n){Ht[t]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(o){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:o,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}xr("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);xr("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);xr("ERR_OUT_OF_RANGE",function(t,e,n){let r=`The value of "${t}" is out of range.`,o=n;return Number.isInteger(n)&&Math.abs(n)>2**32?o=yi(String(n)):typeof n=="bigint"&&(o=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(o=yi(o)),o+="n"),r+=` It must be ${e}. Received ${o}`,r},RangeError);function yi(t){let e="",n=t.length,r=t[0]==="-"?1:0;for(;n>=r+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function tf(t,e,n){Rt(e,"offset"),(t[e]===void 0||t[e+n]===void 0)&&Yt(e,t.length-(n+1))}function Hi(t,e,n,r,o,i){if(t>n||t<e){let s=typeof e=="bigint"?"n":"",a;throw i>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(i+1)*8}${s}`:a=`>= -(2${s} ** ${(i+1)*8-1}${s}) and < 2 ** ${(i+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${n}${s}`,new Ht.ERR_OUT_OF_RANGE("value",a,t)}tf(r,o,i)}function Rt(t,e){if(typeof t!="number")throw new Ht.ERR_INVALID_ARG_TYPE(e,"number",t)}function Yt(t,e,n){throw Math.floor(t)!==t?(Rt(t,n),new Ht.ERR_OUT_OF_RANGE(n||"offset","an integer",t)):e<0?new Ht.ERR_BUFFER_OUT_OF_BOUNDS:new Ht.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}var nf=/[^+/0-9A-Za-z-_]/g;function rf(t){if(t=t.split("=")[0],t=t.trim().replace(nf,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function br(t,e){e=e||1/0;let n,r=t.length,o=null,i=[];for(let s=0;s<r;++s){if(n=t.charCodeAt(s),n>55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}else if(s+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=(o-55296<<10|n-56320)+65536}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,n&63|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return i}function of(t){let e=[];for(let n=0;n<t.length;++n)e.push(t.charCodeAt(n)&255);return e}function sf(t,e){let n,r,o,i=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)n=t.charCodeAt(s),r=n>>8,o=n%256,i.push(o),i.push(r);return i}function Ci(t){return pr.toByteArray(rf(t))}function wn(t,e,n,r){let o;for(o=0;o<r&&!(o+n>=e.length||o>=t.length);++o)e[o+n]=t[o];return o}function Se(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Er(t){return t!==t}var af=(function(){let t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){let r=n*16;for(let o=0;o<16;++o)e[r+o]=t[n]+t[o]}return e})();function et(t){return typeof BigInt>"u"?cf:t}function cf(){throw new Error("BigInt not supported")}});var B,y=Sc(()=>{"use strict";B=Hc(Ri(),1);globalThis.Buffer=B.Buffer});y();y();var ff={p:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,n:0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,h:8n,a:0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,d:0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,Gx:0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,Gy:0x6666666666666666666666666666666666666666666666666666666666666658n},{p:ne,n:xn,Gx:$i,Gy:Pi,a:Br,d:vr}=ff,uf=8n,Xt=32,Ar=64,ye=(t="")=>{throw new Error(t)},df=t=>typeof t=="bigint",Fi=t=>typeof t=="string",hf=t=>t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array",Mt=(t,e)=>!hf(t)||typeof e=="number"&&e>0&&t.length!==e?ye("Uint8Array expected"):t,An=t=>new Uint8Array(t),Tr=t=>Uint8Array.from(t),_i=(t,e)=>t.toString(16).padStart(e,"0"),Hr=t=>Array.from(Mt(t)).map(e=>_i(e,2)).join(""),Le={_0:48,_9:57,A:65,F:70,a:97,f:102},Mi=t=>{if(t>=Le._0&&t<=Le._9)return t-Le._0;if(t>=Le.A&&t<=Le.F)return t-(Le.A-10);if(t>=Le.a&&t<=Le.f)return t-(Le.a-10)},Cr=t=>{let e="hex invalid";if(!Fi(t))return ye(e);let n=t.length,r=n/2;if(n%2)return ye(e);let o=An(r);for(let i=0,s=0;i<r;i++,s+=2){let a=Mi(t.charCodeAt(s)),c=Mi(t.charCodeAt(s+1));if(a===void 0||c===void 0)return ye(e);o[i]=a*16+c}return o},En=(t,e)=>Mt(Fi(t)?Cr(t):Tr(Mt(t)),e),Ui=()=>globalThis?.crypto,lf=()=>Ui()?.subtle??ye("crypto.subtle must be defined"),Ir=(...t)=>{let e=An(t.reduce((r,o)=>r+Mt(o).length,0)),n=0;return t.forEach(r=>{e.set(r,n),n+=r.length}),e},pf=(t=Xt)=>Ui().getRandomValues(An(t)),Bn=BigInt,gt=(t,e,n,r="bad number: out of range")=>df(t)&&e<=t&&t<n?t:ye(r),T=(t,e=ne)=>{let n=t%e;return n>=0n?n:e+n},mf=t=>T(t,xn),ji=(t,e)=>{(t===0n||e<=0n)&&ye("no inverse n="+t+" mod="+e);let n=T(t,e),r=e,o=0n,i=1n,s=1n,a=0n;for(;n!==0n;){let c=r/n,f=r%n,u=o-s*c,d=i-a*c;r=n,n=f,o=s,i=a,s=u,a=d}return r===1n?T(o,e):ye("no inverse")};var Di=t=>t instanceof Oe?t:ye("Point expected"),kr=2n**256n,Oe=class t{static BASE;static ZERO;ex;ey;ez;et;constructor(e,n,r,o){let i=kr;this.ex=gt(e,0n,i),this.ey=gt(n,0n,i),this.ez=gt(r,1n,i),this.et=gt(o,0n,i),Object.freeze(this)}static fromAffine(e){return new t(e.x,e.y,1n,T(e.x*e.y))}static fromBytes(e,n=!1){let r=vr,o=Tr(Mt(e,Xt)),i=e[31];o[31]=i&-129;let s=Rr(o);gt(s,0n,n?kr:ne);let c=T(s*s),f=T(c-1n),u=T(r*c+1n),{isValid:d,value:h}=yf(f,u);d||ye("bad point: y not sqrt");let l=(h&1n)===1n,m=(i&128)!==0;return!n&&h===0n&&m&&ye("bad point: x==0, isLastByteOdd"),m!==l&&(h=T(-h)),new t(h,s,1n,T(h*s))}assertValidity(){let e=Br,n=vr,r=this;if(r.is0())throw new Error("bad point: ZERO");let{ex:o,ey:i,ez:s,et:a}=r,c=T(o*o),f=T(i*i),u=T(s*s),d=T(u*u),h=T(c*e),l=T(u*T(h+f)),m=T(d+T(n*T(c*f)));if(l!==m)throw new Error("bad point: equation left != right (1)");let p=T(o*i),w=T(s*a);if(p!==w)throw new Error("bad point: equation left != right (2)");return this}equals(e){let{ex:n,ey:r,ez:o}=this,{ex:i,ey:s,ez:a}=Di(e),c=T(n*a),f=T(i*o),u=T(r*a),d=T(s*o);return c===f&&u===d}is0(){return this.equals(Pt)}negate(){return new t(T(-this.ex),this.ey,this.ez,T(-this.et))}double(){let{ex:e,ey:n,ez:r}=this,o=Br,i=T(e*e),s=T(n*n),a=T(2n*T(r*r)),c=T(o*i),f=e+n,u=T(T(f*f)-i-s),d=c+s,h=d-a,l=c-s,m=T(u*h),p=T(d*l),w=T(u*l),b=T(h*d);return new t(m,p,b,w)}add(e){let{ex:n,ey:r,ez:o,et:i}=this,{ex:s,ey:a,ez:c,et:f}=Di(e),u=Br,d=vr,h=T(n*s),l=T(r*a),m=T(i*d*f),p=T(o*c),w=T((n+r)*(s+a)-h-l),b=T(p-m),k=T(p+m),v=T(l-u*h),O=T(w*b),z=T(k*v),S=T(w*v),_=T(b*k);return new t(O,z,_,S)}multiply(e,n=!0){if(!n&&(e===0n||this.is0()))return Pt;if(gt(e,1n,xn),e===1n)return this;if(this.equals(Dt))return If(e).p;let r=Pt,o=Dt;for(let i=this;e>0n;i=i.double(),e>>=1n)e&1n?r=r.add(i):n&&(o=o.add(i));return r}toAffine(){let{ex:e,ey:n,ez:r}=this;if(this.equals(Pt))return{x:0n,y:1n};let o=ji(r,ne);return T(r*o)!==1n&&ye("invalid inverse"),{x:T(e*o),y:T(n*o)}}toBytes(){let{x:e,y:n}=this.assertValidity().toAffine(),r=gf(n);return r[31]|=e&1n?128:0,r}toHex(){return Hr(this.toBytes())}clearCofactor(){return this.multiply(Bn(uf),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.multiply(xn/2n,!1).double();return xn%2n&&(e=e.add(this)),e.is0()}static fromHex(e,n){return t.fromBytes(En(e),n)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}toRawBytes(){return this.toBytes()}},Dt=new Oe($i,Pi,1n,T($i*Pi)),Pt=new Oe(0n,1n,1n,0n);Oe.BASE=Dt;Oe.ZERO=Pt;var gf=t=>Cr(_i(gt(t,0n,kr),Ar)).reverse(),Rr=t=>Bn("0x"+Hr(Tr(Mt(t)).reverse())),Te=(t,e)=>{let n=t;for(;e-- >0n;)n*=n,n%=ne;return n},bf=t=>{let n=t*t%ne*t%ne,r=Te(n,2n)*n%ne,o=Te(r,1n)*t%ne,i=Te(o,5n)*o%ne,s=Te(i,10n)*i%ne,a=Te(s,20n)*s%ne,c=Te(a,40n)*a%ne,f=Te(c,80n)*c%ne,u=Te(f,80n)*c%ne,d=Te(u,10n)*i%ne;return{pow_p_5_8:Te(d,2n)*t%ne,b2:n}},Ni=0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n,yf=(t,e)=>{let n=T(e*e*e),r=T(n*n*e),o=bf(t*r).pow_p_5_8,i=T(t*n*o),s=T(e*i*i),a=i,c=T(i*Ni),f=s===t,u=s===T(-t),d=s===T(-t*Ni);return f&&(i=a),(u||d)&&(i=c),(T(i)&1n)===1n&&(i=T(-i)),{isValid:f||u,value:i}},wf=t=>mf(Rr(t)),xf=(...t)=>In.sha512Async(...t);var Ef=t=>xf(t.hashable).then(t.finish);var Ki={zip215:!0},Bf=(t,e,n,r=Ki)=>{t=En(t,Ar),e=En(e),n=En(n,Xt);let{zip215:o}=r,i,s,a,c,f=Uint8Array.of();try{i=Oe.fromHex(n,o),s=Oe.fromHex(t.slice(0,Xt),o),a=Rr(t.slice(Xt,Ar)),c=Dt.multiply(a,!1),f=Ir(s.toBytes(),i.toBytes(),e)}catch{}return{hashable:f,finish:d=>{if(c==null||!o&&i.isSmallOrder())return!1;let h=wf(d);return s.add(i.multiply(h,!1)).add(c.negate()).clearCofactor().is0()}}},$r=async(t,e,n,r=Ki)=>Ef(Bf(t,e,n,r));var In={sha512Async:async(...t)=>{let e=lf(),n=Ir(...t);return An(await e.digest("SHA-512",n.buffer))},sha512Sync:void 0,bytesToHex:Hr,hexToBytes:Cr,concatBytes:Ir,mod:T,invert:ji,randomBytes:pf};var vn=8,vf=256,Vi=Math.ceil(vf/vn)+1,Sr=2**(vn-1),Af=()=>{let t=[],e=Dt,n=e;for(let r=0;r<Vi;r++){n=e,t.push(n);for(let o=1;o<Sr;o++)n=n.add(e),t.push(n);e=n.double()}return t},Li,Oi=(t,e)=>{let n=e.negate();return t?n:e},If=t=>{let e=Li||(Li=Af()),n=Pt,r=Dt,o=2**vn,i=o,s=Bn(o-1),a=Bn(vn);for(let c=0;c<Vi;c++){let f=Number(t&s);t>>=a,f>Sr&&(f-=i,t+=1n);let u=c*Sr,d=u,h=u+Math.abs(f)-1,l=c%2!==0,m=f<0;f===0?r=r.add(Oi(l,e[d])):n=n.add(Oi(m,e[h]))}return{p:n,f:r}};y();y();y();function Sf(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Pr(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function bt(t,...e){if(!Sf(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Lt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function kn(t,e){bt(t);let n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function zi(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function He(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Sn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Be(t,e){return t<<32-e|t>>>e}var Tf=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Hf(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Cf(t){for(let e=0;e<t.length;e++)t[e]=Hf(t[e]);return t}var Mr=Tf?t=>t:Cf;function Rf(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Jt(t){return typeof t=="string"&&(t=Rf(t)),bt(t),t}var Nt=class{};function Qt(t){let e=r=>t().update(Jt(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function $f(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);let o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),a=Number(n&i),c=r?4:0,f=r?0:4;t.setUint32(e+c,s,r),t.setUint32(e+f,a,r)}function qi(t,e,n){return t&e^~t&n}function Gi(t,e,n){return t&e^t&n^e&n}var en=class extends Nt{constructor(e,n,r,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Sn(this.buffer)}update(e){Lt(this),e=Jt(e),bt(e);let{view:n,buffer:r,blockLen:o}=this,i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Sn(e);for(;o<=i-s;s+=o)this.process(c,s);continue}r.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Lt(this),kn(e,this),this.finished=!0;let{buffer:n,view:r,blockLen:o,isLE:i}=this,{pos:s}=this;n[s++]=128,He(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(r,0),s=0);for(let d=s;d<o;d++)n[d]=0;$f(r,o-8,BigInt(this.length*8),i),this.process(r,0);let a=Sn(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<f;d++)a.setUint32(4*d,u[d],i)}digest(){let{buffer:e,outputLen:n}=this;this.digestInto(e);let r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:n,buffer:r,length:o,finished:i,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=i,e.length=o,e.pos=a,o%n&&e.buffer.set(r),e}clone(){return this._cloneInto()}},Fe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var Q=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);y();var Tn=BigInt(4294967295),Wi=BigInt(32);function Pf(t,e=!1){return e?{h:Number(t&Tn),l:Number(t>>Wi&Tn)}:{h:Number(t>>Wi&Tn)|0,l:Number(t&Tn)|0}}function Hn(t,e=!1){let n=t.length,r=new Uint32Array(n),o=new Uint32Array(n);for(let i=0;i<n;i++){let{h:s,l:a}=Pf(t[i],e);[r[i],o[i]]=[s,a]}return[r,o]}var Dr=(t,e,n)=>t>>>n,Nr=(t,e,n)=>t<<32-n|e>>>n,yt=(t,e,n)=>t>>>n|e<<32-n,wt=(t,e,n)=>t<<32-n|e>>>n,tn=(t,e,n)=>t<<64-n|e>>>n-32,nn=(t,e,n)=>t>>>n-32|e<<64-n;var Zi=(t,e,n)=>t<<n|e>>>32-n,Yi=(t,e,n)=>e<<n|t>>>32-n,Xi=(t,e,n)=>e<<n-32|t>>>64-n,Ji=(t,e,n)=>t<<n-32|e>>>64-n;function Ce(t,e,n,r){let o=(e>>>0)+(r>>>0);return{h:t+n+(o/2**32|0)|0,l:o|0}}var Qi=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),es=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,ts=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),ns=(t,e,n,r,o)=>e+n+r+o+(t/2**32|0)|0,rs=(t,e,n,r,o)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(o>>>0),os=(t,e,n,r,o,i)=>e+n+r+o+i+(t/2**32|0)|0;var Df=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]),tt=new Uint32Array(64),Cn=class extends en{constructor(e=32){super(64,e,8,!1),this.A=Fe[0]|0,this.B=Fe[1]|0,this.C=Fe[2]|0,this.D=Fe[3]|0,this.E=Fe[4]|0,this.F=Fe[5]|0,this.G=Fe[6]|0,this.H=Fe[7]|0}get(){let{A:e,B:n,C:r,D:o,E:i,F:s,G:a,H:c}=this;return[e,n,r,o,i,s,a,c]}set(e,n,r,o,i,s,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,n){for(let d=0;d<16;d++,n+=4)tt[d]=e.getUint32(n,!1);for(let d=16;d<64;d++){let h=tt[d-15],l=tt[d-2],m=Be(h,7)^Be(h,18)^h>>>3,p=Be(l,17)^Be(l,19)^l>>>10;tt[d]=p+tt[d-7]+m+tt[d-16]|0}let{A:r,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let d=0;d<64;d++){let h=Be(a,6)^Be(a,11)^Be(a,25),l=u+h+qi(a,c,f)+Df[d]+tt[d]|0,p=(Be(r,2)^Be(r,13)^Be(r,22))+Gi(r,o,i)|0;u=f,f=c,c=a,a=s+l|0,s=i,i=o,o=r,r=l+p|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(r,o,i,s,a,c,f,u)}roundClean(){He(tt)}destroy(){this.set(0,0,0,0,0,0,0,0),He(this.buffer)}};var is=Hn(["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"].map(t=>BigInt(t))),Nf=is[0],Lf=is[1],nt=new Uint32Array(80),rt=new Uint32Array(80),Lr=class extends en{constructor(e=64){super(128,e,16,!1),this.Ah=Q[0]|0,this.Al=Q[1]|0,this.Bh=Q[2]|0,this.Bl=Q[3]|0,this.Ch=Q[4]|0,this.Cl=Q[5]|0,this.Dh=Q[6]|0,this.Dl=Q[7]|0,this.Eh=Q[8]|0,this.El=Q[9]|0,this.Fh=Q[10]|0,this.Fl=Q[11]|0,this.Gh=Q[12]|0,this.Gl=Q[13]|0,this.Hh=Q[14]|0,this.Hl=Q[15]|0}get(){let{Ah:e,Al:n,Bh:r,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:d,Fl:h,Gh:l,Gl:m,Hh:p,Hl:w}=this;return[e,n,r,o,i,s,a,c,f,u,d,h,l,m,p,w]}set(e,n,r,o,i,s,a,c,f,u,d,h,l,m,p,w){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=d|0,this.Fl=h|0,this.Gh=l|0,this.Gl=m|0,this.Hh=p|0,this.Hl=w|0}process(e,n){for(let v=0;v<16;v++,n+=4)nt[v]=e.getUint32(n),rt[v]=e.getUint32(n+=4);for(let v=16;v<80;v++){let O=nt[v-15]|0,z=rt[v-15]|0,S=yt(O,z,1)^yt(O,z,8)^Dr(O,z,7),_=wt(O,z,1)^wt(O,z,8)^Nr(O,z,7),F=nt[v-2]|0,G=rt[v-2]|0,q=yt(F,G,19)^tn(F,G,61)^Dr(F,G,6),ge=wt(F,G,19)^nn(F,G,61)^Nr(F,G,6),D=ts(_,ge,rt[v-7],rt[v-16]),ae=ns(D,S,q,nt[v-7],nt[v-16]);nt[v]=ae|0,rt[v]=D|0}let{Ah:r,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:d,El:h,Fh:l,Fl:m,Gh:p,Gl:w,Hh:b,Hl:k}=this;for(let v=0;v<80;v++){let O=yt(d,h,14)^yt(d,h,18)^tn(d,h,41),z=wt(d,h,14)^wt(d,h,18)^nn(d,h,41),S=d&l^~d&p,_=h&m^~h&w,F=rs(k,z,_,Lf[v],rt[v]),G=os(F,b,O,S,Nf[v],nt[v]),q=F|0,ge=yt(r,o,28)^tn(r,o,34)^tn(r,o,39),D=wt(r,o,28)^nn(r,o,34)^nn(r,o,39),ae=r&i^r&a^i&a,re=o&s^o&c^s&c;b=p|0,k=w|0,p=l|0,w=m|0,l=d|0,m=h|0,{h:d,l:h}=Ce(f|0,u|0,G|0,q|0),f=a|0,u=c|0,a=i|0,c=s|0,i=r|0,s=o|0;let L=Qi(q,D,re);r=es(L,G,ge,ae),o=L|0}({h:r,l:o}=Ce(this.Ah|0,this.Al|0,r|0,o|0)),{h:i,l:s}=Ce(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=Ce(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=Ce(this.Dh|0,this.Dl|0,f|0,u|0),{h:d,l:h}=Ce(this.Eh|0,this.El|0,d|0,h|0),{h:l,l:m}=Ce(this.Fh|0,this.Fl|0,l|0,m|0),{h:p,l:w}=Ce(this.Gh|0,this.Gl|0,p|0,w|0),{h:b,l:k}=Ce(this.Hh|0,this.Hl|0,b|0,k|0),this.set(r,o,i,s,a,c,f,u,d,h,l,m,p,w,b,k)}roundClean(){He(nt,rt)}destroy(){He(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var ss=Qt(()=>new Cn);var Rn=Qt(()=>new Lr);y();y();y();function ue(t){return()=>{throw new Error(`${t} is not available in the browser verifier`)}}var as=ue("fs.createReadStream"),Al=ue("fs.readFileSync"),Il=ue("fs.existsSync"),kl=ue("fs.writeFileSync"),Of=ue("fs.open"),Ff=ue("fs.readdir"),cs=ue("fs.readFile"),_f=ue("fs.stat"),Sl=ue("fs.mkdir"),Tl=ue("fs.writeFile"),fs=ue("path.join"),Hl=ue("path.basename"),us=ue("zlib.createGunzip"),Uf=ue("zlib.gzipSync");y();var U=ss;y();y();y();y();y();y();y();var jf=t=>t/2**32|0,Kf=t=>t>>>0;function ds(t,e,n,r){let o=jf(n),i=Kf(n);t.setUint32(e,r?i:o,r),t.setUint32(e+4,r?o:i,r)}y();function $n(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}var Or=t=>t?`"${t}" `:"";function _e(t,e=""){if(typeof t!="number")throw new TypeError(Or(e)+"expected number, got "+typeof t);if(!Number.isSafeInteger(t)||t<0)throw new RangeError(Or(e)+"expected integer >= 0, got "+t);return t}function Re(t,e,n=""){if($n(t)&&(e===void 0||t.length===e))return t;e!==void 0&&_e(e,"length");let r=$n(t),o=e!==void 0?` of length ${e}`:"",i=r?`length=${t.length}`:`type=${typeof t}`,s=Or(n)+"expected Uint8Array"+o+", got "+i;throw r?new RangeError(s):new TypeError(s)}function Pn(t){if(typeof t!="function"||typeof t.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(_e(t.outputLen),_e(t.blockLen),t.outputLen<1||t.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}var hs=(t,e)=>{if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError((e==="object"?"":`"${e}" `)+"expected object, got type="+typeof t)};function Ot(t,e=!0){if(t.destroyed)throw new Error("hash was destroyed");if(e&&t.finished)throw new Error("digest() was already called")}function Mn(t,e){Re(t,void 0,"output");let n=e.outputLen;if(!(t.length>=n))throw new RangeError('"output" expected length >= '+n)}function rn(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Dn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function ve(t,e){return t<<32-e|t>>>e}var ps=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Vf=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Nn(t){if(Re(t),ps)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=Vf[t[n]];return e}function ls(t){return t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0}function Fr(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);if(ps)try{return Uint8Array.fromHex(t)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let e=t.length,n=e/2;if(e%2)throw new RangeError("hex string expected, got unpadded hex of length "+e);let r=new Uint8Array(n);for(let o=0,i=0;o<n;o++,i+=2){let s=ls(t.charCodeAt(i)),a=ls(t.charCodeAt(i+1));if(s===void 0||a===void 0){let c=t[i]+t[i+1];throw new RangeError('hex string expected, got non-hex character "'+c+'" at index '+i)}r[o]=s*16+a}return r}function ms(...t){let e=0;for(let r=0;r<t.length;r++){let o=t[r];Re(o),e+=o.length}let n=new Uint8Array(e);for(let r=0,o=0;r<t.length;r++){let i=t[r];n.set(i,o),o+=i.length}return n}function zf(t,e,n="opts"){return hs(t,"defaults"),e!==void 0&&hs(e,n),Object.assign(t,e)}function gs(t,e={}){if(typeof t!="function")throw new TypeError('"hashCons" expected function, got type='+typeof t);e=zf({},e,"info");let n=(o,i)=>t(i).update(o).digest(),r=t(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=o=>t(o),Object.assign(n,e),Object.freeze(n)}function bs(t=32){_e(t,"bytesLength");let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(t>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${t}`);return e.getRandomValues(new Uint8Array(t))}var ys=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function ws(t,e,n){return t&e^~t&n}function xs(t,e,n){return t&e^t&n^e&n}var Ln=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,n,r,o){this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Dn(this.buffer)}update(e){Ot(this),Re(e);let{view:n,buffer:r,blockLen:o}=this,i=e.length,s=!1;for(let a=0;a<i;){let c=Math.min(o-this.pos,i-a);if(c===o){let f=Dn(e);for(;o<=i-a;a+=o)this.process(f,a);s=!0;continue}r.set(a===0&&c===i?e:e.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===o&&(this.process(n,0),this.pos=0,s=!0)}return this.length+=e.length,s&&this.roundClean(),this}digestInto(e){Ot(this),Mn(e,this),this.finished=!0;let{buffer:n,view:r,blockLen:o,isLE:i}=this,{pos:s}=this;n[s++]=128,n.fill(0,s),this.padOffset>o-s&&(this.process(r,0),n.fill(0)),ds(r,o-8,this.length*8,i),this.process(r,0),this.roundClean();let a=e===n?r:Dn(e),c=this.outputLen,f=c/4,u=this.get();if(c%4||f>u.length)throw new Error("invalid outputLen");for(let d=0;d<f;d++)a.setUint32(4*d,u[d],i)}digest(){let{buffer:e,outputLen:n}=this;this.digestInto(e);let r=e.slice(0,n);return this.destroy(),r}_cloneIntoMeta(e){let{buffer:n,length:r,finished:o,destroyed:i,pos:s}=this;return e.destroyed=i,e.finished=o,e.length=r,e.pos=s,s&&e.buffer.set(n),e}clone(){return this._cloneInto()}},Es=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var qf=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]),ot=new Uint32Array(64),_r=class extends Ln{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(e,n){super(64,e,8,!1),this.A=n[0]|0,this.B=n[1]|0,this.C=n[2]|0,this.D=n[3]|0,this.E=n[4]|0,this.F=n[5]|0,this.G=n[6]|0,this.H=n[7]|0}get(){let{A:e,B:n,C:r,D:o,E:i,F:s,G:a,H:c}=this;return[e,n,r,o,i,s,a,c]}set(e,n,r,o,i,s,a,c){this.A=e|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,n){for(let d=0;d<16;d++,n+=4)ot[d]=e.getUint32(n,!1);for(let d=16;d<64;d++){let h=ot[d-15],l=ot[d-2],m=ve(h,7)^ve(h,18)^h>>>3,p=ve(l,17)^ve(l,19)^l>>>10;ot[d]=p+ot[d-7]+m+ot[d-16]|0}let{A:r,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let d=0;d<64;d++){let h=ve(a,6)^ve(a,11)^ve(a,25),l=u+h+ws(a,c,f)+qf[d]+ot[d]|0,p=(ve(r,2)^ve(r,13)^ve(r,22))+xs(r,o,i)|0;u=f,f=c,c=a,a=s+l|0,s=i,i=o,o=r,r=l+p|0}r=r+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(r,o,i,s,a,c,f,u)}roundClean(){rn(ot)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),rn(this.buffer)}},Ur=class extends _r{constructor(){super(32,Es)}};var Bs=gs(()=>new Ur,ys(1));y();function Fn(t,e,n=()=>{}){if(!Array.isArray(t))throw new TypeError(`"${e}" expected array, got type=${typeof t}`);for(let r=0;r<t.length;r++)n(t[r],`${e}[${r}]`);return t}var X=(t,e,n)=>Re(t,e,n),jr=_e;function As(t,e=""){if(typeof t!="string"){let n=e&&`"${e}" `;throw new TypeError(n+"expected string, got type="+typeof t)}return t}function it(t,e="object"){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError(e==="object"?"expected valid options object":`"${e}" expected object, got type=${typeof t}`);return t}function xt(t,e){if(typeof t!="function")throw new TypeError(`"${e}" is invalid: expected function, got ${typeof t}`);return t}var Kr=Nn,Ue=(...t)=>ms(...t),_n=t=>Fr(t),Ft=$n,Un=t=>bs(t),On=BigInt(0),vs=BigInt(1),Gf=t=>t?`"${t}" `:"";function $e(t,e=""){if(typeof t!="boolean")throw new TypeError(Gf(e)+"expected boolean, got type="+typeof t);return t}function jn(t){if(typeof t=="bigint"){if(!st(t))throw new RangeError("positive bigint expected, got "+t)}else jr(t);return t}function _t(t,e=""){if(typeof t!="number"){let n=e&&`"${e}" `;throw new TypeError(n+"expected number, got type="+typeof t)}if(!Number.isSafeInteger(t)){let n=e&&`"${e}" `;throw new RangeError(n+"expected safe integer, got "+t)}}function on(t){let e=jn(t).toString(16);return e.length&1?"0"+e:e}function Is(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);return t===""?On:BigInt("0x"+t)}function Pe(t){return Is(Nn(t))}function Vr(t){return Is(Nn(Wf(Re(t)).reverse()))}function Kn(t,e){if(_e(e),e===0)throw new Error("zero output length is invalid");t=jn(t);let n=e*2,r=t.toString(16);if(r.length>n)throw new RangeError("number is too large");return Fr(r.padStart(n,"0"))}function zr(t,e){return Kn(t,e).reverse()}function Wf(t){return Uint8Array.from(X(t))}function st(t){return typeof t=="bigint"&&On<=t}function qr(t,e,n){return st(t)&&st(e)&&st(n)&&e<=t&&t<n}function Gr(t,e,n,r){if(!qr(e,n,r))throw new RangeError("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}function Ut(t){if(t<On)throw new Error("expected non-negative bigint, got "+t);return t===On?0:t.toString(2).length}var sn=t=>(_t(t,"n"),(vs<<BigInt(t))-vs);function ks(t,e,n){if(_e(t,"hashLen"),_e(e,"qByteLen"),typeof n!="function")throw new TypeError("hmacFn must be a function");let r=w=>new Uint8Array(w),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=r(t),f=r(t),u=0,d=()=>{c.fill(1),f.fill(0),u=0},h=(...w)=>n(f,Ue(c,...w)),l=(w=o)=>{f=h(i,w),c=h(),w.length!==0&&(f=h(s,w),c=h())},m=()=>{if(u++>=a)throw new Error("drbg: tried max amount of iterations");let w=0,b=[];for(;w<e;){c=h();let k=c.slice();b.push(k),w+=c.length}return Ue(...b)};return(w,b)=>{d(),l(w);let k;for(;(k=b(m()))===void 0;)l();return d(),k}}function at(t,e={},n={},r="object"){it(t,r),it(e,"fields"),it(n,"optFields");function o(s,a,c){let f=r==="object"?`param "${String(s)}"`:`"${r}.${String(s)}"`,u=t[s];if(!Object.hasOwn(t,s)&&(c?u!==void 0:a!=="function"))throw new TypeError(`${f} is invalid: expected own property`);if(c&&u===void 0)return;let d=typeof u;if(d!==a||u===null)throw new TypeError(`${f} is invalid: expected ${a}, got ${d}`)}let i=(s,a)=>Object.entries(s).forEach(([c,f])=>o(c,f,a));i(e,!1),i(n,!0)}y();y();var ee=BigInt(0),V=BigInt(1),ct=BigInt(2),Cs=BigInt(3),Wr=BigInt(4),Rs=BigInt(5),Zf=BigInt(7),$s=BigInt(8),Yf=BigInt(9),Xf=BigInt(15),Ps=BigInt(16),Jf=BigInt("0x10000000000000000");function he(t,e){if(e<=ee)throw new Error("mod: expected positive modulus, got "+e);let n=t%e;return n>=ee?n:e+n}function Ms(t,e,n){if(n<=V)throw new Error("pow: expected modulus > 1, got "+n);if(typeof e!="bigint")throw new TypeError("invalid exponent: expected bigint, got "+typeof e);if(e<ee)throw new Error("invalid exponent, negatives unsupported");if(e===ee)return V;if(e===V)return t;let r=t%n;if(r<ee&&(r+=n),e<Jf){let a=V;for(;e>ee;)e&V&&(a=a*r%n),r=r*r%n,e>>=V;return a}let o=[];for(;e>ee;)o.push(Number(e&Xf)),e>>=Wr;let i=new Array(16);i[0]=V,i[1]=r;for(let a=2;a<16;a++)i[a]=i[a-1]*r%n;let s=i[o[o.length-1]];for(let a=o.length-2;a>=0;a--){s=s*s%n,s=s*s%n,s=s*s%n,s=s*s%n;let c=o[a];c!==0&&(s=s*i[c]%n)}return s}function Ss(t,e){if(t===ee)throw new Error("invert: expected non-zero number");if(e<=V)throw new Error("invert: expected modulus > 1, got "+e);let n=he(t,e),r=e,o=ee,i=V;for(;n!==ee;){let a=r/n,c=r-n*a,f=o-i*a;r=n,n=c,o=i,i=f}if(r!==V)throw new Error("invert: does not exist");return he(o,e)}function Ds(t,e){if(e<=V)throw new Error("invertCt: expected prime modulus > 1, got "+e);let n=he(t,e);if(n===ee)throw new Error("invertCt: expected non-zero number");let r=Ms(n,e-ct,e);if(he(n*r,e)!==V)throw new Error("invertCt: does not exist");return r}function Zr(t,e,n){let r=t;if(!r.eql(r.sqr(e),n))throw new Error("Cannot find square root")}function Yr(t,e){if((t&V)===ee)throw new Error(e+": expected odd modulus, got "+t)}function Ns(t,e){let n=t,r=(n.ORDER+V)/Wr,o=n.pow(e,r);return Zr(n,o,e),o}function Qf(t,e){let n=t,r=(n.ORDER-Rs)/$s,o=n.mul(e,ct),i=n.pow(o,r),s=n.mul(e,i),a=n.mul(n.mul(s,ct),i),c=n.mul(s,n.sub(a,n.ONE));return Zr(n,c,e),c}function eu(t){let e=zn(t),n=Ls(t),r=n(e,e.neg(e.ONE)),o=n(e,r),i=n(e,e.neg(r)),s=(t+Zf)/Ps;return((a,c)=>{let f=a,u=f.pow(c,s),d=f.mul(u,r),h=f.mul(u,o),l=f.mul(u,i),m=f.eql(f.sqr(d),c),p=f.eql(f.sqr(h),c);u=f.cmov(u,d,m),d=f.cmov(l,h,p);let w=f.eql(f.sqr(d),c),b=f.cmov(u,d,w);return Zr(f,b,c),b})}function Ls(t){if(t<Cs)throw new Error("sqrt is not defined for small field");Yr(t,"tonelliShanks");let e=t-V,n=0;for(;e%ct===ee;)e/=ct,n++;let r=ct,o=zn(t);for(;Ts(o,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return Ns;let i=o.pow(r,e),s=(e+V)/ct;return function(c,f){let u=c;if(u.is0(f))return f;if(Ts(u,f)!==1)throw new Error("Cannot find square root");let d=n,h=u.mul(u.ONE,i),l=u.pow(f,e),m=u.pow(f,s);for(;!u.eql(l,u.ONE);){if(u.is0(l))throw new Error("Cannot find square root: probably non-prime P");let p=1,w=u.sqr(l);for(;!u.eql(w,u.ONE);)if(p++,w=u.sqr(w),p===d)throw new Error("Cannot find square root");let b=V<<BigInt(d-p-1),k=u.pow(h,b);d=p,h=u.sqr(k),l=u.mul(l,h),m=u.mul(m,k)}return m}}function tu(t){return Yr(t,"Fp.sqrt"),t%Wr===Cs?Ns:t%$s===Rs?Qf:t%Ps===Yf?eu(t):Ls(t)}var nu=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function jt(t){if(it(t,"field"),typeof t.ORDER!="bigint")throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof t.ORDER);_t(t.BYTES,"BYTES"),_t(t.BITS,"BITS");for(let e of nu)xt(t[e],"field."+e);if(t.BYTES<1||t.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(t.ORDER<=V)throw new Error("invalid field: expected ORDER > 1, got "+t.ORDER);return t}function Xr(t,e,n=!1){jt(t),Fn(e,"nums"),$e(n,"passZero");let r=t,o=new Array(e.length).fill(n?r.ZERO:void 0),i=e.reduce((a,c,f)=>r.is0(c)?a:(o[f]=a,r.mul(a,c)),r.ONE),s=r.inv(i);return e.reduceRight((a,c,f)=>r.is0(c)?a:(o[f]=r.mul(a,o[f]),r.mul(a,c)),s),o}function Ts(t,e){jt(t);let n=t;Yr(n.ORDER,"FpLegendre");let r=(n.ORDER-V)/ct,o=n.pow(e,r),i=n.eql(o,n.ONE),s=n.eql(o,n.ZERO),a=n.eql(o,n.neg(n.ONE));if(!i&&!s&&!a)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function ru(t,e){if(e!==void 0&&jr(e),t<=ee)throw new Error("invalid n length: expected positive n, got "+t);if(e!==void 0&&e<1)throw new Error("invalid n length: expected positive bit length, got "+e);let n=Ut(t);if(e!==void 0&&e<n)throw new Error(`invalid n length: expected nBitLength (${e}) >= bitLen(n) (${n})`);let r=e!==void 0?e:n,o=Math.ceil(r/8);return{nBitLength:r,nByteLength:o}}var Hs=new WeakMap,Vn=class{ORDER;BITS;BYTES;isLE;ZERO=ee;ONE=V;_lengths;_mod;constructor(e,n={}){if(e<=V)throw new Error("invalid field: expected ORDER > 1, got "+e);let r;this.isLE=!1,n!=null&&typeof n=="object"&&(typeof n.BITS=="number"&&(r=n.BITS),typeof n.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:n.sqrt,enumerable:!0}),typeof n.isLE=="boolean"&&(this.isLE=n.isLE),n.allowedLengths&&(this._lengths=Object.freeze(n.allowedLengths.slice())),typeof n.modFromBytes=="boolean"&&(this._mod=n.modFromBytes));let{nBitLength:o,nByteLength:i}=ru(e,r);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=i,Object.freeze(this)}create(e){return he(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof e);return ee<=e&&e<this.ORDER}is0(e){return e===ee}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&V)===V}neg(e){return he(-e,this.ORDER)}eql(e,n){return e===n}sqr(e){return he(e*e,this.ORDER)}add(e,n){return he(e+n,this.ORDER)}sub(e,n){return he(e-n,this.ORDER)}mul(e,n){return he(e*n,this.ORDER)}pow(e,n){return Ms(e,n,this.ORDER)}div(e,n){return he(e*Ss(n,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,n){return e+n}subN(e,n){return e-n}mulN(e,n){return e*n}inv(e){return Ss(e,this.ORDER)}sqrt(e){let n=Hs.get(this);return n||Hs.set(this,n=tu(this.ORDER)),n(this,e)}toBytes(e){return this.isLE?zr(e,this.BYTES):Kn(e,this.BYTES)}fromBytes(e,n=!1){X(e);let{_lengths:r,BYTES:o,isLE:i,ORDER:s,_mod:a}=this;if(r){if(e.length<1||!r.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+r+" bytes, got "+e.length);let f=new Uint8Array(o);f.set(e,i?0:f.length-e.length),e=f}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let c=i?Vr(e):Pe(e);if(a&&(c=he(c,s)),!n&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(e){return Xr(this,e,!0)}cmov(e,n,r){return $e(r,"condition"),r?n:e}};function zn(t,e={}){return Object.freeze(Vn.prototype),new Vn(t,e)}function Os(t){if(typeof t!="bigint")throw new Error("field order must be bigint");if(t<=V)throw new Error("field order must be greater than 1");let e=Ut(t-V);return Math.ceil(e/8)}function qn(t){let e=Os(t);return e+Math.ceil(e/2)}function Jr(t,e,n=!1){X(t);let r=t.length,o=Os(e),i=Math.max(qn(e),16);if(r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);let s=n?Vr(t):Pe(t),a=he(s,e-V)+V;return n?zr(a,o):Kn(a,o)}var to=BigInt(0),an=BigInt(1),ou=BigInt(4),Qr=16,Fs=128,iu=5,_s=2**31;function Kt(t){let e=t;if(typeof e!="function")throw new TypeError('"Point" expected constructor, got type='+typeof t);xt(e.fromAffine,"Point.fromAffine"),xt(e.fromBytes,"Point.fromBytes"),xt(e.fromHex,"Point.fromHex"),it(e.BASE,"Point.BASE"),it(e.ZERO,"Point.ZERO"),jt(e.Fp),jt(e.Fn)}function js(t,e){Kt(t),Ks(e,t);let n=Xr(t.Fp,e.map(r=>r.Z));return e.map((r,o)=>t.fromAffine(r.toAffine(n[o])))}function su(t,e,n=1){if(!Number.isSafeInteger(t)||t<n||t>e)throw new Error("invalid window size, expected ["+n+".."+e+"], got W="+t)}function au(t,e){let n=t*(4*e+128);if(n>_s)throw new Error("invalid window size: table would need ~"+Math.ceil(n/2**20)+" MiB, max "+_s/2**20+" MiB")}function no(t,e){if(t!==void 0){xt(t,"randomBytes");try{let n=t(e);if(!Ft(n)||n.length!==e)return}catch{return}return t}}function Ks(t,e){Fn(t,"points"),t.forEach((n,r)=>{if(!(n instanceof e))throw new Error("invalid point at index "+r)})}function cu(t,e,n){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((r,o)=>{if(!(n===void 0?e.isValid(r):st(r)&&r<n))throw new Error("invalid scalar at index "+o)})}var Vs=new WeakMap;function eo(t){return Vs.get(t)||1}function fu(t,e){let n=t.double(),r=[t];for(let o=1;o<e;o++)r.push(r[o-1].add(n));return r}function uu(t,e){let n=2**e,r=n/2,o=BigInt(n-1),i=[];for(;t>to;){let s=0;t&an&&(s=Number(t&o),s>=r&&(s-=n),t-=BigInt(s)),i.push(s),t>>=an}return i}function du(t,e,n){let r=2**e,o=r/2,i=BigInt(r-1),s=BigInt(e),a=[];for(let c=0;c<n;c++){let f=Number(t&i);t>>=s,f>o&&(f-=r,t+=an),a.push(f)}if(t!==to)throw new Error("invalid wnaf");return a}function hu(t,e,n){let r=0;for(let i of n)r=Math.max(r,i.length);let o=t;for(let i=r-1;i>=0;i--){i!==r-1&&(o=o.double());for(let s=0;s<n.length;s++){let a=n[s][i];if(a){let c=e[s][Math.abs(a)-1>>1];o=o.add(a<0?c.negate():c)}}}return o}var Gn=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(e,n){Kt(e),this.randomBytes=no(n,Qr),this.Point=e,this.BASE=e.BASE,this.ZERO=e.ZERO,this.bits=e.Fn.BITS}buildWnafTable(e,n,r){let o=Math.ceil(r/n)+1,i=2**(n-1),s=[],a=e;for(let c=0;c<o;c++){let f=a;for(let u=0;u<i;u++)s.push(f),f=f.add(a);a=s[s.length-1].double()}return{W:n,bits:r,windows:o,comp:s}}wnafCachedCT(e,n){let{W:r,windows:o,comp:i}=e,s=2**(r-1),a=du(n,r,o),c=this.ZERO,f=this.BASE;for(let u=0;u<o;u++){let d=a[u],h=u*s,l=Math.abs(d)-1,m=i[h];for(let w=1;w<s;w++)m=w===l?i[h+w]:m;let p=m.negate();d===0?f=f.add(i[h]):c=c.add(d<0?p:m)}return{p:c,f}}getWnafPrecomputes(e,n,r,o){let i=this.wnafPrecomputes.get(n),s=i?.find(a=>a.W===e&&a.bits===r);return s||(s=this.buildWnafTable(n,e,r),typeof o=="function"&&(s={...s,comp:o(s.comp)}),i||(i=[],this.wnafPrecomputes.set(n,i)),i.push(s)),s}assertPoint(e){if(!(e instanceof this.Point))throw new TypeError('"point" expected Point instance, got type='+typeof e)}validateMulInput(e,n){if(this.assertPoint(e),!qr(n,an,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(e,n,r,o){let i=eo(e);return i===1?this.fixedWindowCT(e,n,r):this.wnafCachedCT(this.getWnafPrecomputes(i,e,r,o),n)}mulCT(e,n,r){return this.validateMulInput(e,n),this.runCT(e,n,this.bits,r)}mulCTBlinded(e,n,r){if(this.validateMulInput(e,n),this.randomBytes===void 0)throw new Error("randomBytes is required for scalar blinding");let o=this.Point.Fn.BITS+Fs,i=this.randomBytes(Qr);if(!Ft(i)||i.length!==Qr)throw new Error("randomBytes returned invalid byte array");i[0]=i[0]&63|128;let s=n+Pe(i)*this.Point.Fn.ORDER;return this.runCT(e,s,o,r)}fixedWindowCT(e,n,r){let o=iu,i=1<<o,s=sn(o),a=new Array(i);a[0]=this.ZERO;for(let u=1;u<i;u++)a[u]=a[u-1].add(e);let c=Math.ceil(r/o),f=this.ZERO;for(let u=c-1;u>=0;u--){if(u!==c-1)for(let l=0;l<o;l++)f=f.double();let d=Number(n>>BigInt(u*o)&s),h=a[0];for(let l=1;l<i;l++)h=l===d?a[l]:h;f=f.add(h)}return{p:f,f}}shouldBlind(e,n){return this.randomBytes===void 0?!1:n===an?!0:e!==this.BASE?!1:(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(e,n,r,o){return this.shouldBlind(e,r)?this.mulCTBlinded(e,n,o):this.mulCT(e,n,o)}mulUnsafe(e,n,r){if(this.assertPoint(e),!st(n))throw new Error("invalid scalar");let o=eo(e);if(o===1||n>=this.Point.Fn.ORDER)return Wn(this.Point,[e],[n],!0);let i=this.getWnafPrecomputes(o,e,this.bits,r);return this.wnafCachedCT(i,n).p}setWindowSize(e,n){this.assertPoint(e),su(n,this.bits);let r=Math.ceil((this.bits+Fs)/n)+1;au(r*2**(n-1),this.Point.Fp.BYTES),Vs.set(e,n),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return eo(e)!==1}};function Wn(t,e,n,r=!1){if(Kt(t),Ks(e,t),$e(r,"allowOversized"),cu(n,t.Fn,r?t.Fn.ORDER**ou:void 0),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=e.map(s=>fu(s,4)),i=n.map(s=>uu(s,4));return hu(t.ZERO,o,i)}function Us(t,e,n){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return jt(e),e}else return zn(t,{isLE:n})}function zs(t,e,n={},r){if(t!=="weierstrass"&&t!=="edwards")throw new Error('expected curve type "weierstrass" or "edwards"');if(r===void 0&&(r=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);at(n);for(let c of["p","n","h"]){let f=e[c];if(!(st(f)&&f!==to))throw new Error(`CURVE.${c} must be positive bigint`)}let o=Us(e.p,n.Fp,r),i=Us(e.n,n.Fn,r),a=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:i}}function qs(t,e){return function(r){let o=t(r);return{secretKey:o,publicKey:e(o)}}}y();y();var Zn=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,n){if(Pn(e),Re(n,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,o=new Uint8Array(r);o.set(n.length>r?e.create().update(n).digest():n);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),rn(o)}update(e){return Ot(this),this.iHash.update(e),this}digestInto(e){Ot(this),Mn(e,this),this.finished=!0;let n=e.subarray(0,this.outputLen);this.iHash.digestInto(n),this.oHash.update(n),this.oHash.digestInto(n),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:n,iHash:r,finished:o,destroyed:i,blockLen:s,outputLen:a,canXOF:c}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.canXOF=c,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Gs=(()=>{let t=((e,n,r)=>new Zn(e,n).update(r).digest());return t.create=(e,n)=>new Zn(e,n),t})();y();var lu=BigInt(0),ro=class extends Error{constructor(e=""){super(e)}},je={Err:ro,_tlv:{encode:(t,e)=>{let{Err:n}=je;if(_t(t,"tag"),t<0||t>255)throw new n("tlv.encode: wrong tag");if(As(e,"data"),e.length&1)throw new n("tlv.encode: unpadded data");let r=e.length/2,o=on(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");let i=r>127?on(o.length/2|128):"";return on(t)+i+o+e},decode(t,e){let{Err:n}=je;e=X(e,void 0,"DER data");let r=0;if(t<0||t>255)throw new n("tlv.decode: wrong tag");if(e.length<2||e[r++]!==t)throw new n("tlv.decode: wrong tlv");let o=e[r++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new n("tlv.decode(long): indefinite length not supported");if(c>4)throw new n("tlv.decode(long): byte length is too big");let f=e.subarray(r,r+c);if(f.length!==c)throw new n("tlv.decode: length bytes not complete");if(f[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(let u of f)s=s<<8|u;if(r+=c,s<128)throw new n("tlv.decode(long): not minimal encoding")}let a=e.subarray(r,r+s);if(a.length!==s)throw new n("tlv.decode: wrong value length");return{v:a,l:e.subarray(r+s)}}},_int:{encode(t){let{Err:e}=je;if(jn(t),t<lu)throw new e("integer: negative integers are not allowed");let n=on(t);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return n},decode(t){let{Err:e}=je;if(t.length<1)throw new e("invalid signature integer: empty");if(t[0]&128)throw new e("invalid signature integer: negative");if(t.length>1&&t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Pe(t)}},toSig(t){let{Err:e,_int:n,_tlv:r}=je,o=X(t,void 0,"signature"),{v:i,l:s}=r.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=r.decode(2,i),{v:f,l:u}=r.decode(2,c);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(f)}},hexFromSig(t){let{_tlv:e,_int:n}=je;at(t,{r:"bigint",s:"bigint"},{},"sig");let r=e.encode(2,n.encode(t.r)),o=e.encode(2,n.encode(t.s)),i=r+o;return e.encode(48,i)}},oo=(Object.freeze(je._tlv),Object.freeze(je._int),Object.freeze(je));var Ws=(t,e)=>(t+(t>=0?e:-e)/Zs)/e;function pu(t,e,n){Gr("scalar",t,Ke,n);let[[r,o],[i,s]]=e,a=Ws(s*t,n),c=Ws(-o*t,n),f=t-a*r-c*i,u=-a*o-c*s,d=f<Ke,h=u<Ke;d&&(f=-f),h&&(u=-u);let l=sn(Math.ceil(Ut(n)/2))+Et;if(f<Ke||f>=l||u<Ke||u>=l)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:d,k1:f,k2neg:h,k2:u}}function ao(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function io(t,e){at(t);let n={};for(let r of Object.keys(e))n[r]=t[r]===void 0?e[r]:t[r];return $e(n.lowS,"lowS"),$e(n.prehash,"prehash"),n.format!==void 0&&ao(n.format),n}var Ke=BigInt(0),Et=BigInt(1),Zs=BigInt(2),so=BigInt(3),mu=BigInt(4);function Ys(t,e={}){let n=zs("weierstrass",t,e),r=n.Fp,o=n.Fn,i=n.CURVE,{h:s,n:a}=i;at(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});let{endo:c,allowInfinityPoint:f}=e,u=e.randomBytes===void 0?Un:e.randomBytes;if(c&&(!r.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let d=Js(r,o);function h(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l(L,E,A){if(f&&E.is0())return Uint8Array.of(0);let{x:C,y:M}=E.toAffine(),I=r.toBytes(C);if($e(A,"isCompressed"),A){h();let x=!r.isOdd(M);return Ue(Xs(x),I)}else return Ue(Uint8Array.of(4),I,r.toBytes(M))}function m(L){X(L,void 0,"Point");let{publicKey:E,publicKeyUncompressed:A}=d,C=L.length,M=L[0],I=L.subarray(1);if(f&&C===1&&M===0)return{x:r.ZERO,y:r.ZERO};if(C===E&&(M===2||M===3)){let x=r.fromBytes(I);if(!r.isValid(x))throw new Error("bad point: is not on curve, wrong x");let H=v(x),R;try{R=r.sqrt(H)}catch(K){let j=K instanceof Error?": "+K.message:"";throw new Error("bad point: is not on curve, sqrt error"+j)}h();let N=r.isOdd(R);return(M&1)===1!==N&&(R=r.neg(R)),{x,y:R}}else if(C===A&&M===4){let x=r.BYTES,H=r.fromBytes(I.subarray(0,x)),R=r.fromBytes(I.subarray(x,x*2));if(!O(H,R))throw new Error("bad point: is not on curve");return{x:H,y:R}}else throw new Error(`bad point: got length ${C}, expected compressed=${E} or uncompressed=${A}`)}let p=e.toBytes===void 0?l:e.toBytes,w=e.fromBytes===void 0?m:e.fromBytes,b=r.mul(i.b,so),k=r.is0(i.a)?L=>r.ZERO:L=>r.mul(i.a,L);function v(L){let E=r.sqr(L),A=r.mul(E,L);return r.add(r.add(A,r.mul(L,i.a)),i.b)}function O(L,E){let A=r.sqr(E),C=v(L);return r.eql(A,C)}if(!O(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let z=r.mul(r.pow(i.a,so),mu),S=r.mul(r.sqr(i.b),BigInt(27));if(r.is0(r.add(z,S)))throw new Error("bad curve params: a or b");function _(L,E,A=!1){if(!r.isValid(E)||A&&r.is0(E))throw new Error(`bad point coordinate ${L}`);return E}function F(L){if(!(L instanceof D))throw new Error("Weierstrass Point expected")}function G(L){if(!c||!c.basises)throw new Error("no endo");return pu(L,c.basises,o.ORDER)}function q(L,E,A,C){if(!o.isValid(C))throw new RangeError("invalid scalar: out of range");if(c){let{k1neg:M,k1:I,k2neg:x,k2:H}=G(C),R=new D(r.mul(A.X,c.beta),A.Y,A.Z);L.push(M?A.negate():A,x?R.negate():R),E.push(I,H)}else L.push(A),E.push(C)}let ge=new WeakSet;class D{static BASE=new D(i.Gx,i.Gy,r.ONE);static ZERO=new D(r.ZERO,r.ONE,r.ZERO);static Fp=r;static Fn=o;X;Y;Z;constructor(E,A,C){this.X=_("x",E),this.Y=_("y",A,!0),this.Z=_("z",C),Object.freeze(this)}static CURVE(){return i}static fromAffine(E){let{x:A,y:C}=E||{};if(!E||!r.isValid(A)||!r.isValid(C))throw new Error("invalid affine point");if(E instanceof D)throw new Error("projective point not allowed");return r.is0(A)&&r.is0(C)?D.ZERO:new D(A,C,r.ONE)}static fromBytes(E){let A=D.fromAffine(w(X(E,void 0,"point")));return A.assertValidity(),A}static fromHex(E){return D.fromBytes(_n(E))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(E=6,A=!0){return re.setWindowSize(this,E),A||this.multiply(so),this}assertValidity(){let E=this;if(E.is0()){if(e.allowInfinityPoint&&r.is0(E.X)&&r.eql(E.Y,r.ONE)&&r.is0(E.Z))return;throw new Error("bad point: ZERO")}if(ge.has(E))return;let{x:A,y:C}=E.toAffine();if(!r.isValid(A)||!r.isValid(C))throw new Error("bad point: x or y not field elements");if(!O(A,C))throw new Error("bad point: equation left != right");if(!E.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");ge.add(E)}hasEvenY(){let{y:E}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(E)}equals(E){F(E);let{X:A,Y:C,Z:M}=this,{X:I,Y:x,Z:H}=E,R=r.eql(r.mul(A,H),r.mul(I,M)),N=r.eql(r.mul(C,H),r.mul(x,M));return R&&N}negate(){return new D(this.X,r.neg(this.Y),this.Z)}double(){let{X:E,Y:A,Z:C}=this,M=r.ZERO,I=r.ZERO,x=r.ZERO,H=r.mul(E,E),R=r.mul(A,A),N=r.mul(C,C),P=r.mul(E,A);return P=r.add(P,P),x=r.mul(E,C),x=r.add(x,x),M=k(x),I=r.mul(b,N),I=r.add(M,I),M=r.sub(R,I),I=r.add(R,I),I=r.mul(M,I),M=r.mul(P,M),x=r.mul(b,x),N=k(N),P=r.sub(H,N),P=k(P),P=r.add(P,x),x=r.add(H,H),H=r.add(x,H),H=r.add(H,N),H=r.mul(H,P),I=r.add(I,H),N=r.mul(A,C),N=r.add(N,N),H=r.mul(N,P),M=r.sub(M,H),x=r.mul(N,R),x=r.add(x,x),x=r.add(x,x),new D(M,I,x)}add(E){F(E);let{X:A,Y:C,Z:M}=this,{X:I,Y:x,Z:H}=E,R=r.ZERO,N=r.ZERO,P=r.ZERO,K=r.mul(A,I),j=r.mul(C,x),Z=r.mul(M,H),ce=r.add(A,C),W=r.add(I,x);ce=r.mul(ce,W),W=r.add(K,j),ce=r.sub(ce,W),W=r.add(A,M);let te=r.add(I,H);return W=r.mul(W,te),te=r.add(K,Z),W=r.sub(W,te),te=r.add(C,M),R=r.add(x,H),te=r.mul(te,R),R=r.add(j,Z),te=r.sub(te,R),P=k(W),R=r.mul(b,Z),P=r.add(R,P),R=r.sub(j,P),P=r.add(j,P),N=r.mul(R,P),j=r.add(K,K),j=r.add(j,K),Z=k(Z),W=r.mul(b,W),j=r.add(j,Z),Z=r.sub(K,Z),Z=k(Z),W=r.add(W,Z),K=r.mul(j,W),N=r.add(N,K),K=r.mul(te,W),R=r.mul(ce,R),R=r.sub(R,K),K=r.mul(ce,j),P=r.mul(te,P),P=r.add(P,K),new D(R,N,P)}subtract(E){return F(E),this.add(E.negate())}is0(){return this.equals(D.ZERO)}multiply(E){if(!o.isValidNot0(E))throw new RangeError("invalid scalar: out of range");let{p:A,f:C}=re.mulSecret(this,E,s,ae);return ae([A,C])[0]}multiplyUnsafe(E){let A=this,C=E;if(!o.isValid(C))throw new RangeError("invalid scalar: out of range");if(C===Ke||A.is0())return D.ZERO;if(C===Et)return A;if(re.hasWindowSize(this))return re.mulUnsafe(A,C,ae);let M=[],I=[];return q(M,I,A,C),Wn(D,M,I)}mulAddUnsafe(E,A,C){F(A);let M=[],I=[];return q(M,I,this,E),q(M,I,A,C),Wn(D,M,I)}toAffine(E){let A=this,C=E;if(C!=null&&!r.isValid(C))throw new RangeError('"invertedZ" expected valid field element');let{X:M,Y:I,Z:x}=A;if(r.eql(x,r.ONE))return{x:M,y:I};let H=A.is0();C==null&&(C=H?r.ONE:r.inv(x));let R=r.mul(M,C),N=r.mul(I,C),P=r.mul(x,C);if(H)return{x:r.ZERO,y:r.ZERO};if(!r.eql(P,r.ONE))throw new Error("invZ was invalid");return{x:R,y:N}}isTorsionFree(){let{isTorsionFree:E}=e;return s===Et?!0:E?E(D,this):re.mulUnsafe(this,a).is0()}clearCofactor(){let{clearCofactor:E}=e;return s===Et?this:E?E(D,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===Et?this.is0():this.clearCofactor().is0()}toBytes(E=!0){return $e(E,"isCompressed"),this.assertValidity(),p(D,this,E)}toHex(E=!0){return Kr(this.toBytes(E))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let ae=L=>js(D,L),re=new Gn(D,u);return re.bits>=6&&D.BASE.precompute(6),Object.freeze(D.prototype),Object.freeze(D),D}function Xs(t){return Uint8Array.of(t?2:3)}function Js(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function gu(t,e={}){Kt(t);let{Fn:n}=t,r=e.randomBytes===void 0?Un:e.randomBytes,o=Object.assign(Js(t.Fp,n),{seed:Math.max(qn(n.ORDER),16)});function i(l){try{let m=n.fromBytes(l);return n.isValidNot0(m)}catch{return!1}}function s(l,m){let{publicKey:p,publicKeyUncompressed:w}=o;try{let b=l.length;return m===!0&&b!==p||m===!1&&b!==w?!1:!!t.fromBytes(l)}catch{return!1}}function a(l){return l=l===void 0?r(o.seed):l,Jr(X(l,o.seed,"seed"),n.ORDER)}function c(l,m=!0){return t.BASE.multiply(n.fromBytes(l)).toBytes(m)}function f(l){let{secretKey:m,publicKey:p,publicKeyUncompressed:w}=o,b=n._lengths;if(!Ft(l))return;let k=X(l,void 0,"key").length,v=k===p||k===w,O=k===m||!!b?.includes(k);if(!(v&&O))return v}function u(l,m,p=!0){if(f(l)===!0)throw new Error("first arg must be private key");if(f(m)===!1)throw new Error("second arg must be public key");let w=n.fromBytes(l);return t.fromBytes(m).multiply(w).toBytes(p)}let d={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},h=qs(a,c);return Object.freeze(d),Object.freeze(o),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:h,Point:t,utils:d,lengths:o})}function Qs(t,e,n={}){Kt(t);let r=e;Pn(r),at(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let o=Object.assign({},n),i=o.randomBytes===void 0?Un:o.randomBytes,s=o.hmac===void 0?(I,x)=>Gs(r,I,x):o.hmac,{Fp:a,Fn:c}=t,{ORDER:f,BITS:u}=c,d=qn(f),h=no(i,d),{keygen:l,getPublicKey:m,getSharedSecret:p,utils:w,lengths:b}=gu(t,o),k={prehash:!0,lowS:typeof o.lowS=="boolean"?o.lowS:!0,format:"compact",extraEntropy:!1},v=f*Zs+Et<a.ORDER;function O(I){let x=f>>Et;return I>x}function z(I,x){if(!c.isValidNot0(x))throw new Error(`invalid signature ${I}: out of range 1..Point.Fn.ORDER`);return x}function S(){if(!a.isOdd)throw new Error("Field doesn't support isOdd")}function _(I,x,H){return S(),(I===H?0:2)|Number(a.isOdd(x))}function F(){if(v)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function G(I,x){ao(x);let H=b.signature,R=x==="compact"?H:x==="recovered"?H+1:void 0;return X(I,R)}class q{r;s;recovery;constructor(x,H,R){if(this.r=z("r",x),this.s=z("s",H),R!=null){if(F(),![0,1,2,3].includes(R))throw new Error("invalid recovery id");this.recovery=R}Object.freeze(this)}static fromBytes(x,H=k.format){G(x,H);let R;if(H==="der"){let{r:j,s:Z}=oo.toSig(X(x));return new q(j,Z)}H==="recovered"&&(R=x[0],H="compact",x=x.subarray(1));let N=b.signature/2,P=x.subarray(0,N),K=x.subarray(N,N*2);return new q(c.fromBytes(P),c.fromBytes(K),R)}static fromHex(x,H){return this.fromBytes(_n(x),H)}assertRecovery(){let{recovery:x}=this;if(x==null)throw new Error("invalid recovery id: must be present");return x}addRecoveryBit(x){return new q(this.r,this.s,x)}recoverPublicKey(x){let{r:H,s:R}=this,N=this.assertRecovery(),P=N===2||N===3?H+f:H;if(!a.isValid(P))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let K=a.toBytes(P),j=t.fromBytes(Ue(Xs((N&1)===0),K)),Z=c.inv(P),ce=D(X(x,void 0,"msgHash")),W=c.create(-ce*Z),te=c.create(R*Z),Ae=t.BASE.mulAddUnsafe(W,j,te);if(Ae.is0())throw new Error("invalid recovery: point at infinify");return Ae.assertValidity(),Ae}hasHighS(){return O(this.s)}toBytes(x=k.format){if(ao(x),x==="der")return _n(oo.hexFromSig(this));let{r:H,s:R}=this,N=c.toBytes(H),P=c.toBytes(R);return x==="recovered"?(F(),Ue(Uint8Array.of(this.assertRecovery()),N,P)):Ue(N,P)}toHex(x){return Kr(this.toBytes(x))}}Object.freeze(q.prototype),Object.freeze(q);let ge=o.bits2int===void 0?function(x){if(x.length>8192)throw new Error("input is too large");let H=Pe(x),R=x.length*8-u;return R>0?H>>BigInt(R):H}:o.bits2int,D=o.bits2int_modN===void 0?function(x){return c.create(ge(x))}:o.bits2int_modN,ae=sn(u);function re(I){return Gr("num < 2^"+u,I,Ke,ae),c.toBytes(I)}function L(I,x){return X(I,void 0,"message"),x?X(r(I),void 0,"prehashed message"):I}function E(I,x,H){let{lowS:R,prehash:N,extraEntropy:P}=io(H,k);I=L(I,N);let K=D(I),j=c.fromBytes(x);if(!c.isValidNot0(j))throw new Error("invalid private key");let Z=[re(j),re(K)];if(P!=null&&P!==!1){let Ae=P===!0?i(b.secretKey):P;Z.push(X(Ae,void 0,"extraEntropy"))}let ce=Ue(...Z),W=K;function te(Ae){let Tt=ge(Ae);if(!c.isValidNot0(Tt))return;let Wt=t.BASE.multiply(Tt).toAffine(),Qe=c.create(Wt.x);if(Qe===Ke)return;let Ie;if(h!==void 0){let Zt=Pe(Jr(h(d),f)),wc=c.inv(c.mul(Zt,Tt)),xc=c.mul(Zt,W),Ec=c.mul(Zt,j);Ie=c.create(wc*c.create(xc+Ec*Qe))}else{let Zt=Ds(Tt,f);Ie=c.create(Zt*c.create(W+Qe*j))}if(Ie===Ke)return;let ur=_(Wt.x,Wt.y,Qe),fi=Ie;return R&&O(Ie)&&(fi=c.neg(Ie),ur^=1),new q(Qe,fi,v?void 0:ur)}return{seed:ce,k2sig:te}}function A(I,x,H={}){let{seed:R,k2sig:N}=E(I,x,H);return ks(r.outputLen,c.BYTES,s)(R,N).toBytes(H.format)}function C(I,x,H,R={}){let{lowS:N,prehash:P,format:K}=io(R,k);if(H=X(H,void 0,"publicKey"),x=L(x,P),!Ft(I)){let j=I instanceof q?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+j)}G(I,K);try{let j=q.fromBytes(I,K),Z=t.fromBytes(H);if(N&&j.hasHighS())return!1;let{r:ce,s:W}=j,te=D(x),Ae=c.inv(W),Tt=c.create(te*Ae),Wt=c.create(ce*Ae),Qe=t.BASE.mulAddUnsafe(Tt,Z,Wt);if(Qe.is0())return!1;let Ie=Qe.toAffine();return!(c.create(Ie.x)!==ce||K==="recovered"&&j.recovery!==_(Ie.x,Ie.y,ce))}catch{return!1}}function M(I,x,H={}){let{prehash:R}=io(H,k);return x=L(x,R),q.fromBytes(I,"recovered").recoverPublicKey(x).toBytes()}return Object.freeze({keygen:l,getPublicKey:m,getSharedSecret:p,utils:w,lengths:b,Point:t,sign:A,verify:C,recoverPublicKey:M,Signature:q,hash:r})}var bu={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")};var yu=Ys(bu),ea=Qs(yu,Bs);var fo=globalThis.crypto,co=class{hasher;constructor(e){let n=e.toLowerCase().replace("-","");if(n==="sha256")this.hasher=U.create();else if(n==="sha512")this.hasher=Rn.create();else throw new Error(`createHash: unsupported algorithm ${e} in the browser verifier`)}update(e){return this.hasher.update(typeof e=="string"?new TextEncoder().encode(e):e),this}digest(e){let n=this.hasher.digest(),r=B.Buffer.from(n);return e===void 0?r:r.toString(e)}};function Yn(t){return new co(t)}function uo(t){let e=[];return{update(n){return e.push(n),this},verify(n,r){try{let o=n instanceof Uint8Array?n:n.key,i=o.subarray(o.length-65);if(i.length!==65||i[0]!==4)return!1;let s=0;for(let f of e)s+=f.length;let a=new Uint8Array(s),c=0;for(let f of e)a.set(f,c),c+=f.length;return ea.verify(r,U(a),i,{format:"der",prehash:!1,lowS:!1})}catch{return!1}}}}y();function le(t){let e=ta(t);return new TextEncoder().encode(e)}function ta(t){return JSON.stringify(ho(t))}function ho(t){if(t===null||typeof t!="object"){if(typeof t>"u")throw new TypeError("bitgraph-core/canonical: undefined values are not serializable to canonical JSON");if(typeof t=="function"||typeof t=="symbol")throw new TypeError(`bitgraph-core/canonical: ${typeof t} values are not serializable to canonical JSON`);if(typeof t=="bigint")throw new TypeError("bitgraph-core/canonical: BigInt values are not serializable to canonical JSON; convert to string (decimal) before canonicalizing");return t}if(Array.isArray(t))return t.map(ho);let e={};for(let n of Object.keys(t).sort()){let r=t[n];typeof r>"u"||(e[n]=ho(r))}return e}function Xn(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0}async function po(t){let{proof:e,bytes:n,trustAnchors:r}=t,o=await na(e,n,r);return o===null?{valid:!0}:Su(o)}async function ft(t){let{proof:e,trustAnchors:n}=t,r=await na(e,void 0,n);return r===null?{valid:!0,artifactBinding:"not-checked"}:{valid:!1,artifactBinding:"not-checked",reason:r}}async function na(t,e,n){let r=xu(t);if(r!==null)return r;let o=e===void 0?void 0:U(e),i;try{i=Vt(t.artifact.digestB64)}catch{return"artifact.digestB64 is not valid base64"}if(o!==void 0&&!Xn(o,i))return"artifact digest mismatch: the provided bytes do not match the committed digest";let s;try{s=Vt(t.signer.publicKeyB64)}catch{return"signer.publicKeyB64 is not valid base64"}if(s.length!==32)return`signer.publicKeyB64 decodes to ${s.length} bytes; expected 32 (Ed25519)`;let a={version:t.version,artifact:t.artifact,commit:t.commit,publicKeyB64:t.signer.publicKeyB64,enforcement:t.environment.enforcement,measurement:t.environment.measurement};t.environment.attestation!==void 0&&(a.attestationFormat=t.environment.attestation.format),t.agency!==void 0&&(a.actor=t.agency.actor),t.policy!==void 0&&(a.policy=t.policy),t.attribution!==void 0&&(a.attribution=t.attribution);let c=le(a),f;try{f=Vt(t.signer.signatureB64)}catch{return"signer.signatureB64 is not valid base64"}if(f.length!==64)return`signer.signatureB64 decodes to ${f.length} bytes; expected 64 (Ed25519)`;let u;try{u=await $r(f,c,s)}catch(d){return`signature verification error: ${d instanceof Error?d.message:String(d)}`}if(!u)return"signature verification failed: signature does not match";if(t.agency!==void 0){let d=vu(t);if(d!==null)return d}if(t.slotAllocation!==void 0){let d=await Au(t);if(d!==null)return d}if(t.commit.epochLink!==void 0){let d=ku(t);if(d!==null)return d}if(n!==void 0){let d=Eu(t,n);if(d!==null)return d}return null}var wu=new Set(["stub","hw-key","measured-tee"]);function xu(t){if(t===null||typeof t!="object")return"proof must be an object";let e=t;if(e.version!=="bitgraph/1")return`unsupported proof version: ${String(e.version)}`;if(!cn(e.artifact))return"proof.artifact is missing or not an object";let n=e.artifact;if(n.hashAlg!=="sha256")return`unsupported hashAlg: ${String(n.hashAlg)}`;if(typeof n.digestB64!="string"||n.digestB64.length===0)return"proof.artifact.digestB64 must be a non-empty string";if(!cn(e.commit))return"proof.commit is missing or not an object";let r=e.commit;if(typeof r.nonceB64!="string"||r.nonceB64.length===0)return"proof.commit.nonceB64 must be a non-empty string";if(r.counter!==void 0&&typeof r.counter!="string")return"proof.commit.counter must be a string when present";if(r.time!==void 0&&(typeof r.time!="number"||!Number.isFinite(r.time)||r.time<0))return"proof.commit.time must be a non-negative finite number when present";if(r.prevB64!==void 0&&typeof r.prevB64!="string")return"proof.commit.prevB64 must be a string when present";if(r.epochId!==void 0&&typeof r.epochId!="string")return"proof.commit.epochId must be a string when present";if(!cn(e.signer))return"proof.signer is missing or not an object";let o=e.signer;if(typeof o.publicKeyB64!="string"||o.publicKeyB64.length===0)return"proof.signer.publicKeyB64 must be a non-empty string";if(typeof o.signatureB64!="string"||o.signatureB64.length===0)return"proof.signer.signatureB64 must be a non-empty string";if(!cn(e.environment))return"proof.environment is missing or not an object";let i=e.environment;if(typeof i.enforcement!="string"||!wu.has(i.enforcement))return"proof.environment.enforcement must be one of: stub, hw-key, measured-tee";if(typeof i.measurement!="string"||i.measurement.length===0)return"proof.environment.measurement must be a non-empty string";if(i.attestation!==void 0){if(!cn(i.attestation))return"proof.environment.attestation must be an object when present";let s=i.attestation;if(typeof s.format!="string"||s.format.length===0)return"proof.environment.attestation.format must be a non-empty string";if(typeof s.reportB64!="string"||s.reportB64.length===0)return"proof.environment.attestation.reportB64 must be a non-empty string"}return null}function Eu(t,e){if(e.requireEnforcement!==void 0&&t.environment.enforcement!==e.requireEnforcement)return`enforcement tier "${t.environment.enforcement}" does not meet required tier "${e.requireEnforcement}"`;if(e.allowedMeasurements!==void 0&&e.allowedMeasurements.length>0&&!e.allowedMeasurements.includes(t.environment.measurement))return`measurement "${t.environment.measurement}" is not in the allowed set`;if(e.allowedPublicKeys!==void 0&&e.allowedPublicKeys.length>0&&!e.allowedPublicKeys.includes(t.signer.publicKeyB64))return"proof public key is not in the allowed set";if(e.requireAttestation===!0&&t.environment.attestation===void 0)return"policy requires attestation but proof has none";if(e.requireAttestationFormat!==void 0&&e.requireAttestationFormat.length>0){if(t.environment.attestation===void 0)return"policy requires attestation format but proof has no attestation";if(!e.requireAttestationFormat.includes(t.environment.attestation.format))return`attestation format "${t.environment.attestation.format}" is not in the required set`}if(e.minCounter!==void 0||e.maxCounter!==void 0){if(t.commit.counter===void 0)return"policy requires a counter but proof has none";let n;try{n=BigInt(t.commit.counter)}catch{return"could not parse proof counter value as integer"}if(e.minCounter!==void 0){let r;try{r=BigInt(e.minCounter)}catch{return"could not parse policy minCounter as integer"}if(n<r)return`counter ${t.commit.counter} is below minimum ${e.minCounter}`}if(e.maxCounter!==void 0){let r;try{r=BigInt(e.maxCounter)}catch{return"could not parse policy maxCounter as integer"}if(n>r)return`counter ${t.commit.counter} is above maximum ${e.maxCounter}`}}if(e.minTime!==void 0||e.maxTime!==void 0){if(t.commit.time===void 0)return"policy requires a time field but proof has none";if(e.minTime!==void 0&&t.commit.time<e.minTime)return`commit time ${t.commit.time} is before minimum ${e.minTime}`;if(e.maxTime!==void 0&&t.commit.time>e.maxTime)return`commit time ${t.commit.time} is after maximum ${e.maxTime}`}if(e.requireEpochId===!0&&(t.commit.epochId===void 0||t.commit.epochId.length===0))return"policy requires epochId but proof has none";if(e.requireActor===!0&&t.agency===void 0)return"policy requires actor (agency) but proof has none";if(e.allowedActorKeyIds!==void 0&&e.allowedActorKeyIds.length>0){if(t.agency===void 0)return"policy requires allowed actor key ID but proof has no agency";if(!e.allowedActorKeyIds.includes(t.agency.actor.keyId))return"actor key ID is not in the allowed set"}if(e.allowedActorProviders!==void 0&&e.allowedActorProviders.length>0){if(t.agency===void 0)return"policy requires allowed actor provider but proof has no agency";if(!e.allowedActorProviders.includes(t.agency.actor.provider))return`actor provider "${t.agency.actor.provider}" is not in the allowed set`}if(e.allowedOrigins!==void 0&&e.allowedOrigins.length>0){if(t.agency===void 0)return"policy requires an allowed origin but proof has no agency";let n=t.agency.authorization;if(!("format"in n)||n.format!=="webauthn")return"policy requires an allowed WebAuthn origin but the authorization is not WebAuthn";let r;try{r=JSON.parse(n.clientDataJSON).origin}catch{r=void 0}if(typeof r!="string"||!e.allowedOrigins.includes(r))return`WebAuthn origin "${r??"(none)"}" is not in the allowed set`}return e.requireSlot===!0&&t.slotAllocation===void 0?"policy requires slotAllocation (BitGraph causal slot) but proof has none":null}function Bu(t,e){if(typeof t!="string"||t.length===0)return"agency: clientDataJSON missing origin field";let n;try{n=new URL(t).hostname.toLowerCase()}catch{return"agency: clientDataJSON origin is not a valid origin"}if(!n)return"agency: clientDataJSON origin has no host";let r=e.subarray(0,32).toString("hex"),o=n.split("."),i=[];for(let a=0;a<o.length;a++){let c=o.slice(a).join(".");if(a>0&&o.length-a<2)break;i.push(c)}return i.some(a=>Yn("sha256").update(a,"utf8").digest("hex")===r)?null:"agency: authenticatorData rpIdHash does not match the origin's domain"}function vu(t){let e=t.agency,{actor:n,authorization:r}=e,o="format"in r&&r.format==="webauthn";if(typeof n.keyId!="string"||n.keyId.length===0)return"agency.actor.keyId must be a non-empty string";if(typeof n.publicKeyB64!="string"||n.publicKeyB64.length===0)return"agency.actor.publicKeyB64 must be a non-empty string";if(n.algorithm!=="ES256")return`agency.actor.algorithm must be "ES256", got "${String(n.algorithm)}"`;if(typeof n.provider!="string"||n.provider.length===0)return"agency.actor.provider must be a non-empty string";if(r.purpose!=="bitgraph/commit-authorize/v1")return`agency.authorization.purpose must be "bitgraph/commit-authorize/v1", got "${String(r.purpose)}"`;if(typeof r.signatureB64!="string"||r.signatureB64.length===0)return"agency.authorization.signatureB64 must be a non-empty string";let i;try{i=B.Buffer.from(n.publicKeyB64,"base64")}catch{return"agency.actor.publicKeyB64 is not valid base64"}if(Yn("sha256").update(i).digest("hex")!==n.keyId)return"agency: actor.keyId does not match SHA-256 of public key";if(r.actorKeyId!==n.keyId)return"agency: authorization.actorKeyId does not match actor.keyId";if(r.artifactHash!==t.artifact.digestB64){let c=e.batchContext;if(!c||!Array.isArray(c.batchDigests)||!c.batchDigests.includes(t.artifact.digestB64)||c.batchDigests[0]!==r.artifactHash)return"agency: authorization.artifactHash does not match proof.artifact.digestB64"}let a;try{a=B.Buffer.from(r.signatureB64,"base64")}catch{return"agency.authorization.signatureB64 is not valid base64"}try{if(o){let c=r;if(typeof c.clientDataJSON!="string"||!c.clientDataJSON)return"agency: WebAuthn authorization missing clientDataJSON";if(typeof c.authenticatorDataB64!="string"||!c.authenticatorDataB64)return"agency: WebAuthn authorization missing authenticatorDataB64";let f;try{f=JSON.parse(c.clientDataJSON)}catch{return"agency: clientDataJSON is not valid JSON"}if(f.type!=="webauthn.get")return`agency: clientDataJSON.type must be "webauthn.get", got "${f.type}"`;if(!f.challenge)return"agency: clientDataJSON missing challenge field";let u=f.challenge.replace(/-/g,"+").replace(/_/g,"/");for(;u.length%4;)u+="=";if(u!==r.challenge)return"agency: clientDataJSON challenge does not match authorization.challenge";let d=B.Buffer.from(c.authenticatorDataB64,"base64");if(d.length<37)return"agency: authenticatorData too short";let h=d[32];if(!(h&1))return"agency: authenticatorData UP flag not set";if(!(h&4))return"agency: authenticatorData UV flag not set";let l=Bu(f.origin,d);if(l!==null)return l;let m=Yn("sha256").update(B.Buffer.from(c.clientDataJSON,"utf8")).digest(),p=B.Buffer.concat([d,m]),w=uo("SHA256");if(w.update(p),!w.verify({key:i,format:"der",type:"spki"},a))return"agency: WebAuthn P-256 signature verification failed"}else{let c={purpose:r.purpose,actorKeyId:r.actorKeyId,artifactHash:r.artifactHash,challenge:r.challenge,timestamp:r.timestamp};"protocolVersion"in r&&r.protocolVersion!==void 0&&(c.protocolVersion=r.protocolVersion);let f=B.Buffer.from(JSON.stringify(c,Object.keys(c).sort()),"utf8"),u=uo("SHA256");if(u.update(f),!u.verify({key:i,format:"der",type:"spki"},a))return"agency: P-256 signature verification failed"}}catch(c){return`agency: P-256 signature verification error: ${c instanceof Error?c.message:String(c)}`}return null}async function Au(t){let e=t.slotAllocation;if(e.version!=="bitgraph/slot/1")return`slotAllocation.version must be "bitgraph/slot/1", got "${String(e.version)}"`;if(typeof e.nonceB64!="string"||e.nonceB64.length===0)return"slotAllocation.nonceB64 must be a non-empty string";if(typeof e.counter!="string"||e.counter.length===0)return"slotAllocation.counter must be a non-empty string";if(e.time!==void 0&&(typeof e.time!="number"||!Number.isFinite(e.time)||e.time<0))return"slotAllocation.time must be a non-negative finite number when present";if(typeof e.epochId!="string"||e.epochId.length===0)return"slotAllocation.epochId must be a non-empty string";if(typeof e.publicKeyB64!="string"||e.publicKeyB64.length===0)return"slotAllocation.publicKeyB64 must be a non-empty string";if(typeof e.signatureB64!="string"||e.signatureB64.length===0)return"slotAllocation.signatureB64 must be a non-empty string";let n={version:e.version,nonceB64:e.nonceB64,counter:e.counter,...e.time!==void 0?{time:e.time}:{},epochId:e.epochId,publicKeyB64:e.publicKeyB64,...e.chainId?{chainId:e.chainId}:{}},r=le(n),o,i;try{o=Vt(e.signatureB64),i=Vt(e.publicKeyB64)}catch{return"slotAllocation contains invalid base64"}if(o.length!==64)return`slotAllocation.signatureB64 decodes to ${o.length} bytes; expected 64 (Ed25519)`;if(i.length!==32)return`slotAllocation.publicKeyB64 decodes to ${i.length} bytes; expected 32 (Ed25519)`;let s;try{s=await $r(o,r,i)}catch(d){return`slotAllocation signature verification error: ${d instanceof Error?d.message:String(d)}`}if(!s)return"slotAllocation signature verification failed";let a=new Set(["digestB64","artifact","hashAlg","signatureB64"]),c=Object.keys(n);for(let d of c)if(a.has(d))return`slotAllocation body contains forbidden field '${d}' \u2014 causal independence violated`;if(typeof t.commit.slotHashB64!="string"||t.commit.slotHashB64.length===0)return"commit.slotHashB64 must be present when slotAllocation is present";let f=U(r),u;try{u=Vt(t.commit.slotHashB64)}catch{return"commit.slotHashB64 is not valid base64"}if(!Xn(f,u))return"commit.slotHashB64 does not match SHA-256 of canonical slot body \u2014 slot binding broken";if(e.nonceB64!==t.commit.nonceB64)return"slotAllocation.nonceB64 does not match commit.nonceB64";if(typeof t.commit.slotCounter!="string"||t.commit.slotCounter.length===0)return"commit.slotCounter must be present when slotAllocation is present";if(t.commit.slotCounter!==e.counter)return"commit.slotCounter does not match slotAllocation.counter";if(t.commit.counter===void 0)return"commit.counter must be present for slot ordering verification";try{let d=BigInt(e.counter),h=BigInt(t.commit.counter);if(d>=h)return`slotAllocation.counter (${e.counter}) must be less than commit.counter (${t.commit.counter})`}catch{return"could not parse slot or commit counter as integer"}return e.publicKeyB64!==t.signer.publicKeyB64?"slotAllocation.publicKeyB64 does not match signer.publicKeyB64 \u2014 different enclave":t.commit.epochId!==void 0&&e.epochId!==t.commit.epochId?"slotAllocation.epochId does not match commit.epochId \u2014 different lifecycle":null}var lo=new Map;function Iu(t){let e=`${t.prevEpochId}|${t.prevCounter}|${t.prevProofHashB64}`,n=U(new TextEncoder().encode(e));return B.Buffer.from(n).toString("base64")}function ku(t){let e=t.commit.epochLink;if(typeof e.prevEpochId!="string"||e.prevEpochId.length===0)return"epochLink.prevEpochId must be a non-empty string";if(typeof e.prevPublicKeyB64!="string"||e.prevPublicKeyB64.length===0)return"epochLink.prevPublicKeyB64 must be a non-empty string";if(typeof e.prevCounter!="string"||e.prevCounter.length===0)return"epochLink.prevCounter must be a non-empty string";if(typeof e.prevProofHashB64!="string"||e.prevProofHashB64.length===0)return"epochLink.prevProofHashB64 must be a non-empty string";if(typeof e.toEpochId!="string"||e.toEpochId.length===0)return"epochLink.toEpochId must be a non-empty string";if(typeof e.toPublicKeyB64!="string"||e.toPublicKeyB64.length===0)return"epochLink.toPublicKeyB64 must be a non-empty string";try{BigInt(e.prevCounter)}catch{return"epochLink.prevCounter is not a valid decimal string"}if(t.commit.epochId!==void 0&&e.toEpochId!==t.commit.epochId)return`epochLink.toEpochId "${e.toEpochId}" does not match proof commit.epochId "${t.commit.epochId}" \u2014 successor binding broken`;if(e.toPublicKeyB64!==t.signer.publicKeyB64)return"epochLink.toPublicKeyB64 does not match proof signer.publicKeyB64 \u2014 successor binding broken";if(e.prevEpochId===e.toEpochId)return"epochLink.prevEpochId equals toEpochId \u2014 epoch link must cross epoch boundary";if(e.prevPublicKeyB64===e.toPublicKeyB64)return"epochLink.prevPublicKeyB64 equals toPublicKeyB64 \u2014 epochs must have different keys";let n=Iu(e),r=lo.get(n);if(r!==void 0){if(r!==e.toEpochId)return`FORK DETECTED: predecessor (epoch=${e.prevEpochId.slice(0,12)}..., counter=${e.prevCounter}) already consumed by epoch ${r.slice(0,12)}..., but this proof claims consumption by epoch ${e.toEpochId.slice(0,12)}... \u2014 single-successor invariant violated`}else lo.set(n,e.toEpochId);return null}function Ve(){lo.clear()}function Su(t){return{valid:!1,reason:t}}function cn(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Vt(t){let e=B.Buffer.from(t,"base64");if(e.toString("base64")!==t)throw new Error(`invalid base64 string: "${t}"`);return new Uint8Array(e)}y();function Jn(t){let e=t,n=e.signer,r=e.environment,o={version:e.version,artifact:e.artifact,commit:e.commit,publicKeyB64:n?.publicKeyB64,enforcement:r?.enforcement,measurement:r?.measurement};e.attribution&&(o.attribution=e.attribution),r?.attestation&&(o.attestationFormat=r.attestation.format);let i=le(o),s=U(i);return go(s)}var ra=["proofHash","ethereum"];function mo(t){let e=t,n=e;if(ra.some(o=>Object.prototype.hasOwnProperty.call(e,o))){n={};for(let o of Object.keys(e))ra.includes(o)||(n[o]=e[o])}let r=le(n);return go(U(r))}function go(t){if(typeof B.Buffer<"u")return B.Buffer.from(t).toString("base64");let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function oa(t){let e=t,n=e.signer,r=e.environment,o={version:e.version,artifact:e.artifact,commit:e.commit,publicKeyB64:n?.publicKeyB64,enforcement:r?.enforcement,measurement:r?.measurement};r?.attestation!==void 0&&(o.attestationFormat=r.attestation.format);let i=e.agency;return i!==void 0&&(o.actor=i.actor),e.policy!==void 0&&(o.policy=e.policy),e.attribution!==void 0&&(o.attribution=e.attribution),o}function bo(t){return go(U(le(oa(t))))}y();y();var zp=new Uint8Array([0]),qp=new Uint8Array([1]);var xe="bitgraph-fuse/1",aa=(()=>{let t=new TextEncoder().encode(xe),e=new Uint8Array(t.length+1);return e.set(t,0),e[t.length]=0,e})(),ca=xe,Qn="BGFUSE01",er=48,Bt="bitgraph-fuse/manifest.json",ut="bitgraph-fuse/original",zt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fn={};for(let t=0;t<zt.length;t++)fn[zt[t]]=t;function Ze(t){let e="";for(let n=0;n<t.length;n+=3){let r=t[n],o=n+1<t.length?t[n+1]:0,i=n+2<t.length?t[n+2]:0;e+=zt[r>>2]+zt[(r&3)<<4|o>>4],e+=n+1<t.length?zt[(o&15)<<2|i>>6]:"=",e+=n+2<t.length?zt[i&63]:"="}return e}function qt(t){if(typeof t!="string"||t.length%4!==0||!/^[A-Za-z0-9+/]*={0,2}$/.test(t))return null;let e=t.endsWith("==")?2:t.endsWith("=")?1:0,n=new Uint8Array(t.length/4*3-e),r=0;for(let o=0;o<t.length;o+=4){let i=fn[t[o]]<<18|fn[t[o+1]]<<12|(t[o+2]==="="?0:fn[t[o+2]])<<6|(t[o+3]==="="?0:fn[t[o+3]]);n[r++]=i>>16&255,r<n.length&&(n[r++]=i>>8&255),r<n.length&&(n[r++]=i&255)}return Ze(n)!==t?null:n}function we(t){let e="";for(let n of t)e+=(n<16?"0":"")+n.toString(16);return e}function yo(t){if(typeof t!="string"||t.length%2!==0||!/^[0-9a-f]*$/.test(t))return null;let e=new Uint8Array(t.length/2);for(let n=0;n<e.length;n++)e[n]=parseInt(t.slice(n*2,n*2+2),16);return e}function Ee(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0}function dt(...t){let e=0;for(let o of t)e+=o.length;let n=new Uint8Array(e),r=0;for(let o of t)n.set(o,r),r+=o.length;return n}var pe=t=>new TextEncoder().encode(t);function fa(t){return{version:t.version,nonceB64:t.nonceB64,counter:t.counter,...t.time!==void 0?{time:t.time}:{},epochId:t.epochId,publicKeyB64:t.publicKeyB64,...t.chainId?{chainId:t.chainId}:{}}}function ua(t){return U(le(fa(t)))}function da(t){let e=qt(t.nonceB64);if(e===null||e.length!==32)throw new TypeError("slot.nonceB64 must decode to exactly 32 bytes");return dt(aa,ua(t),e)}function un(t){return U(da(t))}function vt(t,e){if(t.length!==32)throw new TypeError("commitment must be 32 bytes");if(e!==void 0&&e.length!==32)throw new TypeError("originDigest must be 32 bytes");let n={type:xe,...e!==void 0?{origin:{algorithm:"sha256",digest:we(e)}}:{},slotCommitment:{algorithm:"sha256",digest:we(t)}};return le(n)}function ze(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)&&Object.getPrototypeOf(t)===Object.prototype}function qe(t){if(!ze(t)||Object.keys(t).length!==2||t.algorithm!=="sha256"||typeof t.digest!="string")return null;let n=yo(t.digest);return n!==null&&n.length===32?n:null}function nr(t){let e;try{e=new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch{return null}let n;try{n=JSON.parse(e)}catch{return null}if(!ze(n))return null;let r=Object.keys(n).sort(),o=r.length===2?["slotCommitment","type"]:r.length===3?["origin","slotCommitment","type"]:null;if(o===null||r.join(",")!==o.join(",")||n.type!==xe)return null;let i=qe(n.slotCommitment);if(i===null)return null;let s;if("origin"in n){let a=qe(n.origin);if(a===null)return null;s=a}return Ee(vt(i,s),t)?s!==void 0?{commitment:i,originDigest:s}:{commitment:i}:null}var oe=512,Ru=8589934591;function $u(t,e){let n=t.toString(8).padStart(e-1,"0")+"\0";if(n.length!==e)throw new RangeError("field overflow");return pe(n)}function Ge(t,e){if(e>Ru)throw new RangeError("container entries are limited to 8 GiB");let n=new Uint8Array(oe),r=pe(t);if(r.length>100)throw new RangeError("ustar name too long");n.set(r,0),n.set(pe("0000644\0"),100),n.set(pe("0000000\0"),108),n.set(pe("0000000\0"),116),n.set($u(e,12),124),n.set(pe("00000000000\0"),136),n.set(pe(" "),148),n[156]=48,n.set(pe("ustar\0"),257),n.set(pe("00"),263);let o=0;for(let i of n)o+=i;return n.set(pe(o.toString(8).padStart(6,"0")+"\0 "),148),n}function We(t){return(oe-t%oe)%oe}function ia(t,e){return dt(Ge(Bt,e.length),e,new Uint8Array(We(e.length)),Ge(ut,t.length),t,new Uint8Array(We(t.length)),new Uint8Array(oe*2))}function ha(t){let e=[],n=0;for(;n+oe<=t.length;){let r=t.subarray(n,n+oe);if(r.every(f=>f===0)){let f=t.subarray(n);return f.length!==oe*2||!f.every(u=>u===0)?null:e}let o=r.indexOf(0,0),i=new TextDecoder().decode(r.subarray(0,o<0||o>100?100:o)),s=new TextDecoder().decode(r.subarray(124,135));if(!/^[0-7]{11}$/.test(s))return null;let a=parseInt(s,8);if(n+oe+a>t.length)return null;let c=t.subarray(n+oe,n+oe+a);e.push({name:i,data:c,headerBytes:r}),n+=oe+a+We(a)}return null}var Pu={id:"trailer/1",form:"A",byteExact:!0,build({original:t,commitment:e}){if(t===void 0)throw new TypeError("trailer/1 requires the original bytes");if(e.length!==32)throw new TypeError("commitment must be 32 bytes");return dt(t,pe(Qn),new Uint8Array(8),e)},locate(t){if(t.length<er)return null;let e=t.subarray(t.length-er);return!Ee(e.subarray(0,8),pe(Qn))||!e.subarray(8,16).every(n=>n===0)?null:{commitment:new Uint8Array(e.subarray(16,48)),originalBytes:t.subarray(0,t.length-er)}},frame({commitment:t}){if(t.length!==32)throw new TypeError("commitment must be 32 bytes");return{prefix:new Uint8Array(0),suffix:dt(pe(Qn),new Uint8Array(8),t)}},scanPrefix(){return new Uint8Array(0)}},Mu={id:"container/1",form:"B",byteExact:!0,build({original:t,originDigest:e,commitment:n}){if(t===void 0)throw new TypeError("container/1 requires the original bytes");let r=e??U(t);return ia(t,vt(n,r))},locate(t){let e=ha(t);if(e===null||e.length!==2)return null;let[n,r]=e;if(n.name!==Bt||r.name!==ut)return null;let o=nr(n.data);if(o===null||o.originDigest===void 0)return null;let i=ia(r.data,n.data);return Ee(i,t)?{commitment:o.commitment,originDigest:o.originDigest,originalBytes:r.data}:null},frame({originalSize:t,originDigest:e,commitment:n}){let r=vt(n,e);return{prefix:dt(Ge(Bt,r.length),r,new Uint8Array(We(r.length)),Ge(ut,t)),suffix:dt(new Uint8Array(We(t)),new Uint8Array(oe*2))}},scanPrefix(){return null}};function sa(t,e){return dt(Ge(ut,t.length),t,new Uint8Array(We(t.length)),Ge(Bt,e.length),e,new Uint8Array(We(e.length)),new Uint8Array(oe*2))}var Du={id:"container/2",form:"B",byteExact:!0,build({original:t,originDigest:e,commitment:n}){if(t===void 0)throw new TypeError("container/2 requires the original bytes");let r=e??U(t);return sa(t,vt(n,r))},locate(t){let e=ha(t);if(e===null||e.length!==2)return null;let[n,r]=e;if(n.name!==ut||r.name!==Bt)return null;let o=nr(r.data);if(o===null||o.originDigest===void 0)return null;let i=sa(n.data,r.data);return Ee(i,t)?{commitment:o.commitment,originDigest:o.originDigest,originalBytes:n.data}:null},frame({originalSize:t,originDigest:e,commitment:n}){let r=vt(n,e);return{prefix:Ge(ut,t),suffix:dt(new Uint8Array(We(t)),Ge(Bt,r.length),r,new Uint8Array(We(r.length)),new Uint8Array(oe*2))}},scanPrefix(t){return Ge(ut,t)}},Nu={id:"produced/1",form:"C",byteExact:!1,build({original:t,originDigest:e,commitment:n}){if(t!==void 0)throw new TypeError("produced/1 takes no original; pass originDigest for a source reference");return vt(n,e)},locate(t){let e=nr(t);return e===null?null:e.originDigest!==void 0?{commitment:e.commitment,originDigest:e.originDigest}:{commitment:e.commitment}}},Gt=Object.freeze([Pu,Mu,Du,Nu]),At="set/1";var la=/^[a-z0-9][a-z0-9-]*\/[1-9][0-9]*$/;function pa(t,e){if(t.length!==32)throw new TypeError("commitment must be 32 bytes");if(e.length===0)throw new TypeError("a set lists at least one member");let n=[],r=new Set;for(let i of e){if(i.artifact.length!==32)throw new TypeError("member artifact digest must be 32 bytes");if(i.origin.length!==32)throw new TypeError("member origin digest must be 32 bytes");if(!la.test(i.placement))throw new TypeError(`member placement "${i.placement}" is not a placement id`);if(i.placement===At||i.placement===It)throw new TypeError("a set cannot list a set as a member");let s=we(i.artifact);if(r.has(s))throw new TypeError(`duplicate member artifact digest ${s}`);r.add(s),n.push({artifact:{algorithm:"sha256",digest:s},origin:{algorithm:"sha256",digest:we(i.origin)},placement:i.placement})}n.sort((i,s)=>i.artifact.digest<s.artifact.digest?-1:1);let o={members:n,placement:At,slotCommitment:{algorithm:"sha256",digest:we(t)},type:xe};return le(o)}function wo(t){let e;try{e=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode(t)}catch{return null}let n;try{n=JSON.parse(e)}catch{return null}if(!ze(n)||Object.keys(n).sort().join(",")!=="members,placement,slotCommitment,type"||n.type!==xe||n.placement!==At)return null;let r=qe(n.slotCommitment);if(r===null)return null;let o=n.members;if(!Array.isArray(o)||o.length===0)return null;let i=[];for(let a of o){if(!ze(a)||Object.keys(a).sort().join(",")!=="artifact,origin,placement")return null;let c=qe(a.artifact),f=qe(a.origin),u=a.placement;if(c===null||f===null||typeof u!="string"||!la.test(u)||u===At||u===It)return null;i.push({artifact:c,origin:f,placement:u})}let s;try{s=pa(r,i)}catch{return null}return Ee(s,t)?{commitment:r,members:i}:null}var Lu={id:At,form:"C",byteExact:!1,build(){throw new TypeError("set/1 is built with buildSetManifest(commitment, members)")},locate(t){let e=wo(t);return e===null?null:{commitment:e.commitment}}},It="set/2",ma=`${xe}/member`,tr=1e6;function ga(t,e,n){if(t.length!==32)throw new TypeError("commitment must be 32 bytes");if(n.length!==32)throw new TypeError("root must be 32 bytes");if(!Number.isInteger(e)||e<1||e>tr)throw new TypeError(`count must be an integer from 1 to ${tr}`);let r={count:e,placement:It,root:{algorithm:"sha256",digest:we(n)},slotCommitment:{algorithm:"sha256",digest:we(t)},type:xe};return le(r)}function xo(t){let e;try{e=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode(t)}catch{return null}let n;try{n=JSON.parse(e)}catch{return null}if(!ze(n)||Object.keys(n).sort().join(",")!=="count,placement,root,slotCommitment,type"||n.type!==xe||n.placement!==It)return null;let r=n.count;if(typeof r!="number"||!Number.isInteger(r)||r<1||r>tr)return null;let o=qe(n.slotCommitment),i=qe(n.root);if(o===null||i===null)return null;let s;try{s=ga(o,r,i)}catch{return null}return Ee(s,t)?{commitment:o,count:r,root:i}:null}var Ou={id:It,form:"C",byteExact:!1,build(){throw new TypeError("set/2 is built with buildSetRoot(commitment, count, root)")},locate(t){let e=xo(t);return e===null?null:{commitment:e.commitment}}};function dn(t){return[...Gt,Lu,Ou].find(e=>e.id===t)}function kt(t){let e=t.attribution;if(e===void 0||e.name!==ca)return null;let n=typeof e.title=="string"&&e.title.length>0,r={placement:n?e.title:null,placementSource:n?"attribution":null,source:"attribution"};if(typeof e.message=="string"&&e.message.length>0){let o=qt(e.message);o!==null&&o.length===32&&(r.originDigest=o,r.originSource="attribution")}return r}function Eo(t,e){if(t===null)return e;if(e===null)return t;let n={...t};return n.placement===null&&e.placement!==null&&(n.placement=e.placement,n.placementSource="manifest"),n.originDigest===void 0&&e.originDigest!==void 0&&(n.originDigest=e.originDigest,n.originSource="manifest"),n}function Bo(t){let e=typeof t=="string"?(()=>{try{return JSON.parse(t)}catch{return null}})():t;if(!ze(e)||e.type!==xe)return null;let n=e.manifest;if(!ze(n)||n.placement!==void 0&&typeof n.placement!="string"||qe(n.artifact)===null||n.origin!==void 0&&qe(n.origin)===null||n.fusedFile!==null&&typeof n.fusedFile!="string")return null;let o=e.proof;if(!ze(o)||o.version!=="bitgraph/1")return null;let i={type:xe,manifest:{placement:typeof n.placement=="string"?n.placement:"",...n.origin!==void 0?{origin:n.origin}:{},artifact:n.artifact,fusedFile:n.fusedFile},proof:o};if(e.fusePayload!==void 0){if(!ze(e.fusePayload))return null;i.fusePayload=e.fusePayload}return i}function vo(t){let e=t.manifest.placement.length>0,n={placement:e?t.manifest.placement:null,placementSource:e?"manifest":null,source:"manifest"};if(t.manifest.origin!==void 0){let r=yo(t.manifest.origin.digest);r!==null&&r.length===32&&(n.originDigest=r,n.originSource="manifest")}return n}y();function ba(t){let e=t.commit;if(typeof e.counter!="string"||typeof e.slotCounter!="string"||typeof e.epochId!="string")return null;let n;try{n=(BigInt(e.counter)-BigInt(e.slotCounter)).toString()}catch{return null}return{slotCounter:e.slotCounter,commitCounter:e.counter,epochId:e.epochId,chainId:typeof e.chainId=="string"?e.chainId:null,positions:n}}function ya(t){return`The exact fused bytes could not feasibly have been finalized before their signed slot allocation at position ${t.slotCounter}, and were committed no later than position ${t.commitCounter}.`}function Ao(t,e,n){if(e===null)return[];let r=[];return t==="FUSED_FROM_ORIGIN"?r.push(`The supplied original rebuilds the committed fused artifact byte for byte, so these exact original bytes existed no later than commit position ${e.commitCounter}.`):t==="FUSED_DIRECT"&&n&&r.push("The fused bytes carry an origin digest that matches the signed marker; the original itself was not supplied and was not checked."),(t==="FUSED_DIRECT"||t==="FUSED_FROM_ORIGIN")&&r.push(ya(e)),t==="RECORDED"&&r.push(`These exact bytes existed no later than commit position ${e.commitCounter}.`),r}async function Io(t){let{proof:e,bytes:n}=t,r=t.frame===void 0||t.frame===null?null:Bo(t.frame)??null,o=U(n),i=Ze(o),s=e?.artifact?.digestB64??"",a=(w,b,k)=>({category:w,proof:b.proof??{valid:!0},marker:b.marker??null,placement:b.placement??null,fileDigestB64:i,artifactDigestB64:s,originDigestB64:b.originDigestB64??null,slotCommitmentB64:b.slotCommitmentB64??null,span:b.span??null,policy:b.policy??{spanExceeded:!1,maxPositions:null},statements:b.statements??[],reason:k}),c=await ft(t.trustAnchors!==void 0?{proof:e,trustAnchors:t.trustAnchors}:{proof:e});if(!c.valid){let w=c.reason??"proof failed verification";return a("INVALID_UNDERLYING_PROOF",{proof:{valid:!1,reason:w}},w)}let f=Eo(kt(e),r!==null?vo(r):null),u=f?.originDigest,d=u!==void 0?Ze(u):null,h=ba(e),l=t.maxPositions===void 0?null:BigInt(t.maxPositions),m={spanExceeded:l!==null&&h!==null&&BigInt(h.positions)>l,maxPositions:l===null?null:l.toString()},p={proof:{valid:!0},marker:f,originDigestB64:d,span:h,policy:m};if(i===s){if(f===null)return a("RECORDED",{...p,statements:Ao("RECORDED",h,!1)},null);let w=e.slotAllocation;if(w===void 0)return a("INVALID_SLOT_COMMITMENT",p,"the proof carries no slot record, so no commitment can be recomputed");let b;try{b=un(w)}catch(S){return a("INVALID_SLOT_COMMITMENT",p,`commitment could not be recomputed: ${S instanceof Error?S.message:String(S)}`)}let k=Ze(b),v=f.placement===null?void 0:dn(f.placement),O=v===void 0?null:v.locate(n);if(f.placement===null){for(let S of Gt){let _=S.locate(n);if(_!==null){v=S,O=_;break}}if(v===void 0)return a("INVALID_SLOT_COMMITMENT",{...p,slotCommitmentB64:k},"no registered placement finds a commitment in the fused bytes")}else if(v===void 0)return a("UNDETERMINED_PLACEMENT",{...p,slotCommitmentB64:k},`placement "${f.placement}" is not registered; the commitment cannot be located`);if(O===null)return a("INVALID_SLOT_COMMITMENT",{...p,slotCommitmentB64:k,placement:v.id},`no ${v.id} commitment found in the fused bytes`);if(!Ee(O.commitment,b))return a("INVALID_SLOT_COMMITMENT",{...p,slotCommitmentB64:k,placement:v.id},"the commitment in the fused bytes does not match the proof's slot record");let z=!1;if(u!==void 0){let S=O.originDigest??(O.originalBytes!==void 0?U(O.originalBytes):void 0);if(S!==void 0){if(!Ee(S,u))return a("INVALID_ORIGIN_ATTRIBUTION",{...p,slotCommitmentB64:k,placement:v.id},f.originSource==="attribution"?"the origin digest in the signed attribution does not match the origin inside the fused bytes":"the origin digest in the manifest does not match the origin inside the fused bytes");z=!0}}return a("FUSED_DIRECT",{...p,slotCommitmentB64:k,placement:v.id,statements:Ao("FUSED_DIRECT",h,z)},null)}if(u!==void 0&&Ee(o,u)){let w=e.slotAllocation;if(w===void 0)return a("INVALID_SLOT_COMMITMENT",p,"the proof carries no slot record, so the fused bytes cannot be rebuilt");let b;try{b=un(w)}catch(S){return a("INVALID_SLOT_COMMITMENT",p,`commitment could not be recomputed: ${S instanceof Error?S.message:String(S)}`)}let k=Ze(b),v=f!==null&&f.placement!==null?dn(f.placement):void 0;if(f!==null&&f.placement!==null&&v===void 0)return a("UNDETERMINED_PLACEMENT",{...p,slotCommitmentB64:k},`placement "${f.placement}" is not registered; the fused bytes cannot be rebuilt`);let O=v!==void 0?[v]:Gt.filter(S=>S.byteExact),z=e.artifact.digestB64;for(let S of O){if(!S.byteExact)continue;let _;try{_=S.build({original:n,originDigest:u,commitment:b})}catch{continue}if(Ze(U(_))===z)return a("FUSED_FROM_ORIGIN",{...p,slotCommitmentB64:k,placement:S.id,statements:Ao("FUSED_FROM_ORIGIN",h,!0)},null)}return a("RECONSTRUCTION_MISMATCH",{...p,slotCommitmentB64:k,placement:v?.id??null},v!==void 0?`rebuilding ${v.id} from this file and the proof's slot record does not reproduce the committed artifact digest`:"no registered byte-exact placement rebuilds the committed artifact digest from this file")}return a("NO_MATCH",p,"this file matches neither the committed artifact digest nor the origin digest; the proof proves nothing about it")}y();y();async function*xa(t,e){let n=new So(t,e?.maxTotalBytes),r=e?.maxEntryCount??Number.POSITIVE_INFINITY,o=e?.maxMetadataEntryBytes??Number.POSITIVE_INFINITY,i=null,s=null,a=null,c=0,f=(u,d)=>{if(u>o)throw new Error(`tar: ${d} metadata entry of ${u} bytes exceeds the ${o}-byte cap`)};for(;;){let u=await n.readExact(512);if(u===null||qu(u))return;if(++c>r)throw new Error(`tar: archive exceeds the maximum of ${r} entries`);let d=Vu(u),h=d.typeflag;if(h==="x"||h==="g"){f(d.size,"PAX");let v=await wa(n,d.size);await n.skip(rr(d.size));let O=Gu(v);h==="x"?i=O:s=Wu(s,O);continue}if(h==="L"){f(d.size,"GNU long-name");let v=await wa(n,d.size);await n.skip(rr(d.size)),a=St(Zu(v));continue}if(h==="K"){await n.skip(d.size+rr(d.size));continue}let l=d.name;s!==null&&s.has("path")&&(l=s.get("path")),a!==null&&(l=a),i!==null&&i.has("path")&&(l=i.get("path"));let m=d.size,p=i?.get("size")??s?.get("size");if(p!==void 0){let v=Number(p);if(!Number.isSafeInteger(v)||v<0)throw new Error("tar: invalid PAX size value");m=v}i=null,a=null;let w=h==="0"||h==="\0",b={remaining:m},k=Ku(n,b);yield{path:l,size:m,kind:w?"file":"other",typeflag:h,body:k},b.remaining>0&&(await n.skip(b.remaining),b.remaining=0),await n.skip(rr(m))}}async function*Ku(t,e){for(;e.remaining>0;){let n=await t.readSome(e.remaining);if(n===null)throw new Error("tar: truncated archive (unexpected end of stream inside entry body)");e.remaining-=n.length,yield n}}async function wa(t,e){if(e===0)return new Uint8Array(0);let n=await t.readExact(e);if(n===null)throw new Error("tar: truncated archive (unexpected end of stream)");return n}function Vu(t){zu(t);let e=t[156],n=e===0?"\0":String.fromCharCode(e),r=St(ko(t,0,100));if(St(ko(t,257,6))==="ustar"){let s=St(ko(t,345,155));s.length>0&&(r=`${s}/${r}`)}let i=Ea(t.subarray(124,136));return{name:r,size:i,typeflag:n}}function ko(t,e,n){let r=t.subarray(e,e+n),o=r.indexOf(0);return o===-1&&(o=r.length),r.subarray(0,o)}function Ea(t){if(t.length>0&&(t[0]&128)!==0){let r=0n;for(let o=0;o<t.length;o++){let i=o===0?t[0]&127:t[o];r=r<<8n|BigInt(i)}if(r>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("tar: numeric field exceeds the supported range");return Number(r)}let e=St(t).trim().replace(/\0+$/,"").trim();if(e.length===0)return 0;let n=Number.parseInt(e,8);if(!Number.isSafeInteger(n)||n<0)throw new Error(`tar: invalid octal numeric field: "${e}"`);return n}function zu(t){let e=Ea(t.subarray(148,156)),n=0;for(let r=0;r<512;r++)n+=r>=148&&r<156?32:t[r];if(n!==e)throw new Error("tar: header checksum mismatch (corrupt or not a tar archive)")}function qu(t){for(let e=0;e<t.length;e++)if(t[e]!==0)return!1;return!0}function Gu(t){let e=new Map,n=0;for(;n<t.length;){let r=n;for(;r<t.length&&t[r]!==32;)r++;if(r>=t.length)throw new Error("tar: malformed PAX record (no length delimiter)");let o=Number(St(t.subarray(n,r)));if(!Number.isInteger(o)||o<=0||n+o>t.length)throw new Error("tar: malformed PAX record (bad length)");let i=t.subarray(r+1,n+o);if(i.length===0||i[i.length-1]!==10)throw new Error("tar: malformed PAX record (missing newline)");let s=St(i.subarray(0,i.length-1)),a=s.indexOf("=");if(a===-1)throw new Error("tar: malformed PAX record (missing '=')");e.set(s.slice(0,a),s.slice(a+1)),n+=o}return e}function Wu(t,e){let n=new Map(t??[]);for(let[r,o]of e)n.set(r,o);return n}function St(t){return new TextDecoder("utf-8").decode(t)}function Zu(t){let e=t.length;for(;e>0&&t[e-1]===0;)e--;return t.subarray(0,e)}var So=class{iter;chunks=[];head=0;available=0;ended=!1;totalPulled=0;maxTotalBytes;constructor(e,n){this.iter=e[Symbol.asyncIterator](),this.maxTotalBytes=n??Number.POSITIVE_INFINITY}async fill(){if(this.ended)return!1;let e=await this.iter.next();if(e.done===!0)return this.ended=!0,!1;let n=e.value;if(n.length>0){if(this.totalPulled+=n.length,this.totalPulled>this.maxTotalBytes)throw new Error(`tar: archive exceeds the maximum decompressed size of ${this.maxTotalBytes} bytes`);this.chunks.push(n),this.available+=n.length}return!0}async readExact(e){for(;this.available<e;)if(!await this.fill()){if(this.available===0)return null;throw new Error("tar: truncated archive (unexpected end of stream)")}return this.take(e)}async readSome(e){for(;this.available===0;)if(!await this.fill())return null;let n=this.chunks[0],r=Math.min(e,n.length-this.head),o=n.subarray(this.head,this.head+r);return this.advance(r,n),o}async skip(e){let n=e;for(;n>0;){let r=await this.readSome(n);if(r===null)throw new Error("tar: truncated archive (unexpected end of stream)");n-=r.length}}take(e){let n=new Uint8Array(e),r=0;for(;r<e;){let o=this.chunks[0],i=Math.min(e-r,o.length-this.head);n.set(o.subarray(this.head,this.head+i),r),r+=i,this.advance(i,o)}return n}advance(e,n){this.head+=e,this.available-=e,this.head===n.length&&(this.chunks.shift(),this.head=0)}};function rr(t){return(512-t%512)%512}y();var Nm=new Uint8Array([0]);function Ba(t){let e=Array.from(t,r=>({pathBytes:Yu(r.path),entryDigest:r.entryDigest}));e.sort((r,o)=>Xu(r.pathBytes,o.pathBytes));let n=U.create();for(let r of e)n.update(r.entryDigest);return B.Buffer.from(n.digest()).toString("base64")}function Yu(t){if(t.includes("\0"))throw new TypeError("bitgraph-audit: bundle entry paths must not contain NUL bytes");return new TextEncoder().encode(t)}function Xu(t,e){let n=Math.min(t.length,e.length);for(let r=0;r<n;r++){let o=t[r]-e[r];if(o!==0)return o}return t.length-e.length}var va=8*1024*1024,Sa={maxTotalBytes:2*1024*1024*1024,maxEntryCount:1e6,maxMetadataEntryBytes:8*1024*1024},Aa=new Uint8Array([0]),Ia="manifest.json",To="bitgraph-bundle/1",Ju="bitgraph-anchor-witness/1";var Ta=new WeakMap;async function Ho(t,e){let n=[],r=0,o=0,i=[],s=new Map,a=Array.from(t).sort((f,u)=>f.path<u.path?-1:f.path>u.path?1:0);for(let f of a){o++;let u=Ra(f.path);if(u.unsafe){r++,n.push({code:"unsafe-path",path:f.path,message:`entry skipped: ${u.reason}`});continue}let d=await nd(u.path,void 0,void 0,Ha(f.open()));i.push(rd(u.path,d)),s.set(u.path,f)}let c=ed({bundlePath:e?.label??"",container:"memory",scanned:i,strippedRootPrefix:void 0,findings:n,entriesScanned:o,skippedUnsafePaths:r});return Ta.set(c,s),c}async function*Ha(t){let e=await Promise.resolve(t);if(e instanceof Uint8Array){yield e;return}for await(let n of t)yield n}async function Qu(t){let e=[],n=0;for await(let r of Ha(t.open()))e.push(r),n+=r.length;return $o(e,n)}function ed(t){let{bundlePath:e,container:n,scanned:r,strippedRootPrefix:o,findings:i,entriesScanned:s,skippedUnsafePaths:a}=t,c=new Map;for(let S of r){let _=S.rawPath,F=S.entryDigestFull;o!==void 0&&(_=S.rawPath.slice(o.length+1),F=S.entryDigestStripped),c.has(_)&&i.push({code:"duplicate-path",path:_,message:"multiple archive entries normalized to the same path; the last entry wins"}),c.set(_,{path:_,sha256Hex:S.sha256Hex,byteLength:S.byteLength,entryDigest:F,...S.json!==void 0?{json:S.json}:{}})}let f=Array.from(c.values()),u=Ba(f.filter(S=>S.path!==Ia).map(S=>({path:S.path,entryDigest:S.entryDigest}))),d=[],h=new Map,l=[],m=[],p=new Map,w,b=0,k=0,v=0;for(let S of f){if(S.path===Ia){w=fd(S,u,i);continue}let F=id(S.json)??S.json;if(F!==void 0&&$a(F)){let G=F.version;if(G==="bitgraph/1"){b++;let q=sd(S,F,h,d,i);q==="exact-duplicate"&&k++,q==="semantic-duplicate"&&v++;continue}l.push({code:"unsupported-version",path:S.path,version:G,fileSha256Hex:S.sha256Hex}),i.push({code:"unsupported-version",path:S.path,message:`proof-shaped file rejected: version "${G}" is not "bitgraph/1"`,details:{version:G}}),ka(S,p);continue}if(F!==void 0&&F.version===Ju){m.push({path:S.path,fileSha256Hex:S.sha256Hex,witness:F});continue}ka(S,p)}for(let S of d){let _=cd(S.proof.artifact);if(_===null)continue;let F=p.get(_);F!==void 0&&F.matchedProofHashes.push(S.proofHash)}let O=Array.from(p.values()),z={observed:d.length,proofFiles:b,exactDuplicates:k,semanticDuplicates:v,unsupportedVersion:l.length,artifacts:O.length,witnesses:m.length,skippedUnsafePaths:a};return{bundlePath:e,container:n,...o!==void 0?{strippedRootPrefix:o}:{},entriesScanned:s,proofs:d,unsupportedVersions:l,artifacts:O,witnesses:m,...w!==void 0?{manifest:w}:{},computedContentsHashB64:u,findings:i,counts:z}}async function*Co(t){yield*Ca(t,t.artifacts.filter(e=>e.matchedProofHashes.length>0))}async function*Ro(t,e){let n=new Set(e);n.size!==0&&(yield*Ca(t,t.artifacts.filter(r=>n.has(r.sha256Hex))))}async function*Ca(t,e){if(e.length===0)return;if(t.container==="memory"){let s=Ta.get(t);if(s===void 0)return;for(let a of e)for(let c of a.paths){let f=s.get(c);if(f===void 0)continue;let u;try{u=await Qu(f)}catch{continue}if(or(U(u))===a.sha256Hex){yield{sha256Hex:a.sha256Hex,path:c,bytes:u};break}}return}if(t.container==="directory"){for(let s of e)for(let a of s.paths){let c;try{c=new Uint8Array(await cs(fs(t.bundlePath,...a.split("/"))))}catch{continue}if(or(U(c))===s.sha256Hex){yield{sha256Hex:s.sha256Hex,path:a,bytes:c};break}}return}let n=new Map;for(let s of e)for(let a of s.paths)n.set(a,s);let r=new Set,{stream:o,close:i}=td(t.bundlePath,t.container);try{for await(let s of xa(o,Sa)){if(r.size===e.length)break;if(s.kind!=="file")continue;let a=Ra(s.path);if(a.unsafe)continue;let c=a.path;if(t.strippedRootPrefix!==void 0){if(!c.startsWith(`${t.strippedRootPrefix}/`))continue;c=c.slice(t.strippedRootPrefix.length+1)}let f=n.get(c);if(f===void 0||r.has(f.sha256Hex))continue;let u=[],d=0;for await(let l of s.body)u.push(l.slice()),d+=l.length;let h=$o(u,d);or(U(h))===f.sha256Hex&&(r.add(f.sha256Hex),yield{sha256Hex:f.sha256Hex,path:c,bytes:h})}}finally{i()}}function td(t,e){let n=as(t);if(e==="tar-gz"){let r=us();return n.pipe(r),n.on("error",o=>r.destroy(o)),{stream:r,close:()=>{r.destroy(),n.destroy()}}}return{stream:n,close:()=>n.destroy()}}async function nd(t,e,n,r){let o=new TextEncoder,i=U.create(),s=U.create();s.update(o.encode(t)),s.update(Aa);let a=e===void 0?void 0:U.create();a!==void 0&&(a.update(o.encode(e)),a.update(Aa));let c=n===void 0||n<=va,f=[],u=0;for await(let d of r)i.update(d),s.update(d),a?.update(d),u+=d.length,c&&(u>va?(f.length=0,c=!1):f.push(d.slice()));return{sha256Hex:or(i.digest()),byteLength:u,entryDigestFull:s.digest(),...a!==void 0?{entryDigestStripped:a.digest()}:{},...c?{buffered:$o(f,u)}:{}}}function rd(t,e){let n=e.buffered===void 0?void 0:od(e.buffered);return{rawPath:t,sha256Hex:e.sha256Hex,byteLength:e.byteLength,entryDigestFull:e.entryDigestFull,...e.entryDigestStripped!==void 0?{entryDigestStripped:e.entryDigestStripped}:{},...n!==void 0?{json:n}:{}}}function od(t){let e=t;e.length>=3&&e[0]===239&&e[1]===187&&e[2]===191&&(e=e.subarray(3));let n;try{n=new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{return}let r;try{r=JSON.parse(n)}catch{return}if(!(r===null||typeof r!="object"||Array.isArray(r)))return r}function Ra(t){if(t.includes("\0"))return{path:t,unsafe:!0,reason:"path contains a NUL byte"};let e=t.startsWith("/"),n=t.split("/").filter(o=>o!==""&&o!=="."),r=n.join("/");return e?{path:r,unsafe:!0,reason:"absolute path"}:n.some(o=>o==="..")?{path:r,unsafe:!0,reason:"path escapes the bundle root"}:r===""?{path:r,unsafe:!0,reason:"empty path"}:{path:r,unsafe:!1}}function ie(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function id(t){if(!ie(t)||t.type!=="bitgraph-fuse/1")return;let e=t.proof;return $a(e)?e:void 0}function $a(t){return ie(t)?typeof t.version=="string"&&ie(t.artifact)&&ie(t.commit)&&ie(t.signer):!1}function sd(t,e,n,r,o){let i=Jn(e),s={path:t.path,fileSha256Hex:t.sha256Hex,byteLength:t.byteLength},a=ad(e,i);a==="mismatch"&&o.push({code:"proofhash-mismatch",path:t.path,message:"embedded proofHash does not match the computed canonical proof hash",details:{embedded:e.proofHash,computed:i}});let c=n.get(i);if(c!==void 0){let w=c.sources.some(b=>b.fileSha256Hex===s.fileSha256Hex);return c.sources.push(s),a==="mismatch"&&(c.embeddedProofHash="mismatch"),o.push({code:w?"exact-duplicate":"semantic-duplicate",path:t.path,message:w?"byte-identical copy of an already observed proof":"different byte encoding of an already observed proof (same canonical identity)",details:{proofHash:i,firstObservedAt:c.sources[0].path}}),w?"exact-duplicate":"semantic-duplicate"}let f=ie(e.commit)?e.commit:{},u=ie(e.signer)?e.signer:{},d=ie(e.environment)?e.environment:{},h=me(f.counter),l=me(f.epochId),m=me(f.chainId),p={proofHash:i,chainHash:mo(e),proof:e,sources:[s],version:"bitgraph/1",...h!==void 0?{counter:h}:{},...me(f.slotCounter)!==void 0?{slotCounter:me(f.slotCounter)}:{},...me(f.prevB64)!==void 0?{prevB64:me(f.prevB64)}:{},...l!==void 0?{epochId:l}:{},chainId:m!==void 0&&m.length>0?m:"global",...me(u.publicKeyB64)!==void 0?{publicKeyB64:me(u.publicKeyB64)}:{},...me(d.measurement)!==void 0?{measurement:me(d.measurement)}:{},...me(d.enforcement)!==void 0?{enforcement:me(d.enforcement)}:{},hasSlotAllocation:ie(e.slotAllocation),hasAttestation:ie(d.attestation),hasAgency:ie(e.agency),hasEpochLink:ie(f.epochLink),embeddedProofHash:a,chainless:h===void 0&&l===void 0};return n.set(i,p),r.push(p),"new"}function ad(t,e){let n=t.proofHash;return n===void 0?"absent":typeof n=="string"&&n===e?"match":"mismatch"}function me(t){return typeof t=="string"?t:void 0}function ka(t,e){let n=e.get(t.sha256Hex);if(n!==void 0){n.paths.push(t.path);return}e.set(t.sha256Hex,{sha256Hex:t.sha256Hex,sha256B64:B.Buffer.from(t.sha256Hex,"hex").toString("base64"),byteLength:t.byteLength,paths:[t.path],matchedProofHashes:[]})}function cd(t){if(!ie(t))return null;let e=t.digestB64;if(typeof e!="string"||e.length===0)return null;let n=B.Buffer.from(e,"base64");return n.toString("base64")!==e||n.length!==32?null:n.toString("hex")}function fd(t,e,n){if(t.json===void 0)return n.push({code:"manifest-unparseable",path:t.path,message:"root manifest.json did not parse as a single JSON object; proceeding as if no manifest were present"}),{path:t.path,parsed:!1,recognized:!1,problems:[]};let r=t.json,o=r.version;if(o!==To)return n.push({code:"manifest-unrecognized-version",path:t.path,message:`manifest version ${JSON.stringify(o)} is not "${To}"; the manifest was not interpreted`,...typeof o=="string"?{details:{version:o}}:{}}),{path:t.path,parsed:!0,...typeof o=="string"?{version:o}:{},recognized:!1,problems:[]};let i=ud(r);for(let c of i)n.push({code:"manifest-field-invalid",path:t.path,message:c});let s={path:t.path,parsed:!0,version:To,recognized:!0,manifest:r,problems:i},a=r.contentsHashB64;if(typeof a=="string"&&a.length>0){let c=a===e;s.contentsHash={declaredB64:a,computedB64:e,match:c},c||n.push({code:"manifest-contents-hash-mismatch",path:t.path,message:"manifest contentsHashB64 does not match the computed contents hash; the bundle held is not byte-for-byte the bundle the manifest describes. Advisory: this does not fail any proof.",details:{declared:a,computed:e}})}return s}function ud(t){let e=[],n=r=>Array.isArray(r)&&r.every(o=>typeof o=="string");if(t.epochIds!==void 0&&!n(t.epochIds)&&e.push("manifest.epochIds must be an array of strings when present"),t.chainIds!==void 0&&!n(t.chainIds)&&e.push("manifest.chainIds must be an array of strings when present"),t.proofCount!==void 0&&(typeof t.proofCount!="number"||!Number.isInteger(t.proofCount)||t.proofCount<0)&&e.push("manifest.proofCount must be a non-negative integer when present"),t.counterRanges!==void 0&&(Array.isArray(t.counterRanges)&&t.counterRanges.every(o=>ie(o)&&typeof o.epochId=="string"&&typeof o.chainId=="string"&&typeof o.min=="string"&&typeof o.max=="string")||e.push("manifest.counterRanges must be an array of { epochId, chainId, min, max } string fields when present")),t.generatedAt!==void 0&&typeof t.generatedAt!="string"&&e.push("manifest.generatedAt must be a string when present"),t.contentsHashB64!==void 0){let r=t.contentsHashB64,o=typeof r=="string"&&r.length>0;if(o){let i=B.Buffer.from(r,"base64");o=i.toString("base64")===r&&i.length===32}o||e.push("manifest.contentsHashB64 must be standard base64 of 32 bytes when present")}return t.artifactsIncluded!==void 0&&typeof t.artifactsIncluded!="boolean"&&e.push("manifest.artifactsIncluded must be a boolean when present"),t.openEpochs!==void 0&&(Array.isArray(t.openEpochs)&&t.openEpochs.every(o=>ie(o)&&typeof o.epochId=="string"&&typeof o.counterAtSnapshot=="string")||e.push("manifest.openEpochs must be an array of { epochId, counterAtSnapshot } string fields when present")),e}function or(t){return B.Buffer.from(t).toString("hex")}function $o(t,e){let n=new Uint8Array(e),r=0;for(let o of t)n.set(o,r),r+=o.length;return n}y();async function Po(t,e){Ve();let n=e?.trustAnchors,r=new Map(t.proofs.map(f=>[f.proofHash,f])),o=new Map;for(let f of t.artifacts){if(f.matchedProofHashes.length===0)continue;let u=f.matchedProofHashes.map(d=>r.get(d)).filter(d=>d!==void 0);o.set(f.sha256Hex,u)}for await(let f of Co(t)){let u=o.get(f.sha256Hex)??[];for(let d of u){if(d.verification!==void 0)continue;let h=await po({proof:d.proof,bytes:f.bytes,...n!==void 0?{trustAnchors:n}:{}}),l={tier:"full",status:h.valid?"verified":"failed",...h.reason!==void 0?{reason:h.reason}:{},artifactPath:f.path};d.verification=l}}for(let f of t.proofs){if(f.verification!==void 0)continue;let u=await ft({proof:f.proof,...n!==void 0?{trustAnchors:n}:{}}),d={tier:"integrity",status:u.valid?"artifact-unavailable":"failed",...u.reason!==void 0?{reason:u.reason}:{}};f.verification=d}let i=0,s=0,a=0,c=0;for(let f of t.proofs){let u=f.verification?.status;u==="verified"?i++:u==="failed"?s++:u==="artifact-unavailable"&&a++,f.chainless&&c++}return{total:t.proofs.length,verified:i,failed:s,artifactUnavailable:a,chainless:c}}y();y();var Pa=new WeakMap;async function Ye(t){let e=t.verification?.status;if(e==="verified"||e==="artifact-unavailable")return!0;let n=Pa.get(t);if(n!==void 0)return n;Ve();let r=!1;try{r=(await ft({proof:t.proof})).valid}catch{r=!1}return Ve(),Pa.set(t,r),r}function Y(t){if(!(t===void 0||t.length===0||!/^[0-9]+$/.test(t)))return BigInt(t)}function Me(t,e){let n=Y(t.counter),r=Y(e.counter);return n!==void 0&&r!==void 0&&n!==r?n<r?-1:1:n!==void 0&&r===void 0?-1:n===void 0&&r!==void 0?1:t.proofHash<e.proofHash?-1:t.proofHash>e.proofHash?1:0}function de(t,e,n){let r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}async function Do(t){let e=[],n=[],r=new Map;for(let f of t.proofs){if(f.chainless){e.push(f.proofHash);continue}if(f.publicKeyB64===void 0){n.push(f.proofHash);continue}let u={publicKeyB64:f.publicKeyB64,...f.epochId!==void 0?{epochId:f.epochId}:{},chainId:f.chainId},d=JSON.stringify([u.publicKeyB64,u.epochId??null,u.chainId]),h=r.get(d);h===void 0?r.set(d,{key:u,members:[f]}):h.members.push(f)}let o=[...r.values()].sort((f,u)=>dd(f.key,u.key)),i=[],s=new Set,a=new Map;for(let f of o){let u=hd(f.key,f.members,s);i.push(u);for(let d of u.memberProofHashes)a.set(d,f.key)}let c=await md(t,i,s,a);return{partitions:i,unchainedProofHashes:e,unpartitionedProofHashes:n,epochRelationships:c}}function dd(t,e){if(t.chainId!==e.chainId)return t.chainId<e.chainId?-1:1;let n=t.epochId??"",r=e.epochId??"";return n!==r?n<r?-1:1:t.publicKeyB64!==e.publicKeyB64?t.publicKeyB64<e.publicKeyB64?-1:1:0}function hd(t,e,n){let r=new Map(e.map(h=>[h.chainHash,h])),o=new Map,i=new Set,s=new Map;for(let h of e)s.set(h.proofHash,h.proofHash);let a=h=>{let l=h;for(;s.get(l)!==l;)l=s.get(l);let m=h;for(;m!==l;){let p=s.get(m);s.set(m,l),m=p}return l},c=(h,l)=>{let m=a(h),p=a(l);m!==p&&s.set(m,p)};for(let h of e){if(h.prevB64===void 0)continue;let l=r.get(h.prevB64);l===void 0||l.proofHash===h.proofHash||(i.add(h.proofHash),de(o,l.proofHash,h),n.add(l.proofHash),c(l.proofHash,h.proofHash))}let f=new Map;for(let h of e)de(f,a(h.proofHash),h);let u=[];for(let h of f.values())u.push(ld(h,o,i));u.sort(pd);let d=[...e].sort(Me).map(h=>h.proofHash);return{key:t,memberProofHashes:d,components:u}}function ld(t,e,n){let r=[...t].sort(Me),o=r.filter(h=>h.prevB64===void 0),i=r.filter(h=>h.prevB64!==void 0&&!n.has(h.proofHash)),s=r.filter(h=>(e.get(h.proofHash)??[]).length===0),a=new Set,c=[],f=h=>{let l=[h];for(;l.length>0;){let m=l.pop();if(a.has(m))continue;a.add(m),c.push(m);let p=[...e.get(m)??[]].sort(Me);for(let w=p.length-1;w>=0;w--)l.push(p[w].proofHash)}};for(let h of[...o,...i])f(h.proofHash);for(let h of r)a.has(h.proofHash)||f(h.proofHash);let u,d;for(let h of t)for(let l of[h.counter,h.slotCounter]){let m=Y(l);m!==void 0&&((u===void 0||m<u)&&(u=m),(d===void 0||m>d)&&(d=m))}return{memberProofHashes:c,genesisProofHashes:o.map(h=>h.proofHash),brokenLinkProofHashes:i.map(h=>h.proofHash),terminalProofHashes:s.map(h=>h.proofHash),hasCounterEvidence:u!==void 0,...u!==void 0&&d!==void 0?{positionRange:{min:String(u),max:String(d)}}:{}}}function pd(t,e){let n=t.positionRange?.min,r=e.positionRange?.min;if(n!==void 0&&r!==void 0&&n!==r)return BigInt(n)<BigInt(r)?-1:1;if(n!==void 0&&r===void 0)return-1;if(n===void 0&&r!==void 0)return 1;let o=t.memberProofHashes[0]??"",i=e.memberProofHashes[0]??"";return o<i?-1:o>i?1:0}async function md(t,e,n,r){let o=new Map;for(let h of e){let l=h.key.epochId;if(l===void 0)continue;let m=o.get(l);m===void 0&&(m={chainIds:new Set,publicKeys:new Set,proofCount:0},o.set(l,m)),m.chainIds.add(h.key.chainId),m.publicKeys.add(h.key.publicKeyB64),m.proofCount+=h.memberProofHashes.length}let i=new Map(t.proofs.map(h=>[h.chainHash,h])),s=[];for(let h of t.proofs){if(!h.hasEpochLink)continue;let l=gd(h);l!==null&&s.push(await bd(l,h,i,o,n,r))}let a=wd(s),c=new Set,f=new Map,u=new Map;for(let h of s)h.hardEdge&&(c.add(h.fromEpochId),c.add(h.toEpochId),Mo(f,h.toEpochId,h.fromEpochId),Mo(u,h.fromEpochId,h.toEpochId));return{epochs:[...o.entries()].sort(([h],[l])=>h<l?-1:h>l?1:0).map(([h,l])=>({epochId:h,chainIds:[...l.chainIds].sort(),publicKeysB64:[...l.publicKeys].sort(),proofCount:l.proofCount,ordering:c.has(h)?"linked":"observed-but-unordered",linkedPredecessorEpochIds:[...f.get(h)??[]].sort(),linkedSuccessorEpochIds:[...u.get(h)??[]].sort()})),edges:s,orderedPairs:a}}function gd(t){let e=t.proof.commit;if(e===null||typeof e!="object")return null;let n=e.epochLink;if(n===null||typeof n!="object"||Array.isArray(n))return null;let r=n,o=["prevEpochId","prevPublicKeyB64","prevCounter","prevProofHashB64","toEpochId","toPublicKeyB64"],i={};for(let s of o){let a=r[s];if(typeof a!="string"||a.length===0)return null;i[s]=a}return i}async function bd(t,e,n,r,o,i){let s=await Ye(e),a=n.get(t.prevProofHashB64);if(a===void 0){let h=r.has(t.prevEpochId);return{fromEpochId:t.prevEpochId,toEpochId:t.toEpochId,viaProofHash:e.proofHash,link:t,resolution:h?"terminal-missing":"dangling",viaProofValid:s,hardEdge:!1}}let c=[];a.epochId!==t.prevEpochId&&c.push(`the referenced proof's epochId (${a.epochId??"absent"}) does not match epochLink.prevEpochId (${t.prevEpochId})`),a.publicKeyB64!==t.prevPublicKeyB64&&c.push("the referenced proof's signer key does not match epochLink.prevPublicKeyB64"),yd(a.counter,t.prevCounter)||c.push(`the referenced proof's counter (${a.counter??"absent"}) does not match epochLink.prevCounter (${t.prevCounter})`);let f=await Ye(a),u=c.length===0,d=i.has(a.proofHash);return{fromEpochId:t.prevEpochId,toEpochId:t.toEpochId,viaProofHash:e.proofHash,link:t,resolution:"matched",predecessorProofHash:a.proofHash,metadataConsistent:u,...u?{}:{inconsistencies:c},...d?{referencedProofIsTerminal:!o.has(a.proofHash)}:{},viaProofValid:s,predecessorValid:f,hardEdge:u&&s&&f}}function yd(t,e){if(t===void 0)return!1;if(t===e)return!0;let n=Y(t),r=Y(e);return n!==void 0&&r!==void 0&&n===r}function wd(t){let e=new Map,n=new Set;for(let i of t)i.hardEdge&&(Mo(e,i.fromEpochId,i.toEpochId),n.add(i.fromEpochId),n.add(i.toEpochId));let r=new Set;for(let i of n){let s=new Set,a=[...e.get(i)??[]];for(;a.length>0;){let c=a.pop();if(!s.has(c)){s.add(c);for(let f of e.get(c)??[])a.push(f)}}for(let c of s)c!==i&&r.add(`${i}\0${c}`)}let o=[];for(let i of r){let[s,a]=i.split("\0");r.has(`${a}\0${s}`)||o.push({beforeEpochId:s,afterEpochId:a})}return o.sort((i,s)=>i.beforeEpochId!==s.beforeEpochId?i.beforeEpochId<s.beforeEpochId?-1:1:i.afterEpochId<s.afterEpochId?-1:i.afterEpochId>s.afterEpochId?1:0),o}function Mo(t,e,n){let r=t.get(e);r===void 0?t.set(e,new Set([n])):r.add(n)}y();var xd=1e4;async function No(t,e){let n=[],r=[],o=[],i=new Map(t.proofs.map(c=>[c.proofHash,c])),s=new Map(t.proofs.map(c=>[c.chainHash,c])),a=new Map;for(let c of e.partitions)for(let f of c.memberProofHashes)a.set(f,c.key);for(let c of e.partitions){let f=c.memberProofHashes.map(u=>i.get(u));Ed(c,f,n),await Ma(c,f,"counter",n,r),await Ma(c,f,"slot",n,r),await Bd(c,f,n,r),await vd(c,f,s,n,r),Ad(c,f,s,a,n,o),await kd(c,f,n,r),Sd(c,f,n)}return await Td(e.epochRelationships.edges,i,n,r),{anomalies:n,divergences:r,boundaryEntryPoints:o}}function Ed(t,e,n){let r=new Set;for(let d of e){let h=Y(d.counter);h!==void 0&&r.add(h);let l=Y(d.slotCounter);l!==void 0&&r.add(l)}if(r.size<2)return;let o=[...r].sort((d,h)=>d<h?-1:d>h?1:0),i=[],s=[],a=0n;for(let d=1;d<o.length;d++){let h=o[d-1]+1n,l=o[d]-1n;if(!(h>l)){i.push({start:String(h),end:String(l)}),a+=l-h+1n;for(let m=h;m<=l&&s.length<xd;m++)s.push(String(m))}}if(i.length===0)return;let c={count:String(a),ranges:i,positions:s,truncated:a>BigInt(s.length)},f=String(o[0]),u=String(o[o.length-1]);n.push({code:"unexplained-counter-positions",partition:t.key,proofHashes:[],message:`${a} counter position${a===1n?"":"s"} within the observed range [${f}, ${u}] of this partition ${a===1n?"is":"are"} neither a commit position nor a referenced slot position in the supplied bundle. Such ${a===1n?"a position":"positions"} may mean a proof is absent from the bundle, or a slot that was allocated but never committed (a routine, benign occurrence); this offline audit cannot distinguish the two. It does not, by itself, establish that the authority failed to create or withheld any proof.`,details:c})}async function Ma(t,e,n,r,o){let i=new Map;for(let s of e){let a=n==="counter"?s.counter:s.slotCounter;if(a===void 0)continue;let c=Y(a);de(i,c!==void 0?String(c):`raw:${a}`,s)}for(let[s,a]of Lo(i)){if(a.length<2)continue;let{parties:c,context:f}=await ir(a);if(c.length<2)continue;let u=s.startsWith("raw:")?s.slice(4):s,d=n==="counter"?"counter-collision":"slot-collision";r.push({code:d,partition:t.key,proofHashes:a.map(h=>h.proofHash),message:n==="counter"?`${c.length} distinct valid proofs claim commit counter ${u} in one partition. The audit does not choose between them; all parties are preserved for adjudication.`:`${c.length} distinct valid proofs reference slot counter ${u} in one partition. A slot position is consumed exactly once; all parties are preserved for adjudication.`,details:{position:u,validParties:c.map(h=>h.proofHash),invalidObserved:f.map(h=>h.proofHash)}}),o.push({kind:d,partition:t.key,contested:n==="counter"?{counter:u}:{slotCounter:u},parties:c.map(De),invalidContext:f.map(De),explanation:n==="counter"?`Two or more independently valid proof objects claim commit counter ${u} in the same signer, epoch, and chain partition. A commit counter position can be consumed only once, so at most one of these can belong to the authoritative sequence. The audit tool does not choose between them; every party and its predecessor relationship is preserved for adjudication.`:`Two or more independently valid proof objects reference slot counter ${u} in the same signer, epoch, and chain partition. A slot position is allocated once and consumed by one commit, so at most one of these can belong to the authoritative sequence. The audit tool does not choose between them.`})}}async function Bd(t,e,n,r){let o=new Map,i=new Map;for(let a of e){let c=Y(a.counter);c!==void 0&&de(o,String(c),a);let f=Y(a.slotCounter);f!==void 0&&de(i,String(f),a)}let s=[...o.keys()].filter(a=>i.has(a)).sort((a,c)=>BigInt(a)<BigInt(c)?-1:BigInt(a)>BigInt(c)?1:0);for(let a of s){let c=o.get(a),f=i.get(a),u=[];for(let b of c)await Ye(b)&&u.push(b);let d=[];for(let b of f)await Ye(b)&&d.push(b);if(!u.some(b=>d.some(k=>k.proofHash!==b.proofHash)))continue;let l=new Map;for(let b of[...u,...d])l.set(b.proofHash,b);let m=[...l.values()],p=new Map;for(let b of[...c,...f])p.set(b.proofHash,b);let w=[...p.values()].filter(b=>!l.has(b.proofHash));n.push({code:"cross-kind-position-reuse",partition:t.key,proofHashes:[...p.keys()],message:`Counter position ${a} is committed by one proof and reserved as a slot by a different proof in the same partition. A single causal position is consumed once, as a slot or as a commit, never both across distinct proofs. The audit does not choose between them; all parties are preserved for adjudication.`,details:{position:a,commitParties:u.map(b=>b.proofHash),slotParties:d.map(b=>b.proofHash),validParties:m.map(b=>b.proofHash),invalidObserved:w.map(b=>b.proofHash)}}),r.push({kind:"cross-kind-position-reuse",partition:t.key,contested:{position:a},parties:m.map(De),invalidContext:w.map(De),explanation:`Two or more independently valid proof objects allocate counter position ${a} in the same signer, epoch, and chain partition through different roles: at least one commits at it and at least one reserves it as a slot. Each position in a chain is consumed exactly once, so at most one of these allocations can belong to the authoritative sequence. This pattern only arises through enclave malfunction, replay, or compromise. The audit tool does not choose between them; every party is preserved for adjudication.`})}}async function vd(t,e,n,r,o){let i=new Map;for(let s of e)s.prevB64!==void 0&&de(i,s.prevB64,s);for(let[s,a]of Lo(i)){if(a.length<2)continue;let{parties:c,context:f}=await ir(a);if(c.length<2)continue;let u=n.has(s);r.push({code:"predecessor-reuse",partition:t.key,proofHashes:a.map(d=>d.proofHash),message:`${c.length} distinct valid proofs claim the same predecessor hash: a detectable fork. All branches are preserved; the audit does not choose between them.`,details:{prevB64:s,predecessorObserved:u,validParties:c.map(d=>d.proofHash),invalidObserved:f.map(d=>d.proofHash)}}),o.push({kind:"predecessor-reuse",partition:t.key,contested:{prevB64:s},parties:c.map(De),invalidContext:f.map(De),explanation:`Two or more independently valid proof objects name the same predecessor proof in their prevB64 hash link. Each proof has exactly one successor in an intact chain, so this is a fork: the history diverges into multiple branches at that predecessor${u?", which is itself observed in the bundle":", which is absent from the bundle"}. All branches are shown; the audit tool does not select one.`})}}function Ad(t,e,n,r,o,i){let s=new Set(e.map(c=>c.chainHash)),a;for(let c of e){let f=Y(c.counter);f!==void 0&&(a===void 0||f<a)&&(a=f)}for(let c of[...e].sort(Me)){if(c.prevB64===void 0||s.has(c.prevB64))continue;if(!Id(c.prevB64)){o.push({code:"chain-break-malformed",partition:t.key,proofHashes:[c.proofHash],message:"commit.prevB64 is not standard base64 of 32 bytes, so it can never match a canonical proof hash. The predecessor link is unusable as reconstruction evidence.",details:{prevB64:c.prevB64}});continue}let f=n.get(c.prevB64);if(f!==void 0){let h=r.get(f.proofHash);o.push({code:"chain-break-cross-partition",partition:t.key,proofHashes:[c.proofHash,f.proofHash],message:"commit.prevB64 resolves to an observed proof outside this proof's own signer, epoch, and chain partition. prevB64 never bridges partitions (each epoch and chain keeps its own hash chain), so this link does not join the two.",details:{prevB64:c.prevB64,predecessorProofHash:f.proofHash,predecessorPartition:h!==void 0?{publicKeyB64:h.publicKeyB64,...h.epochId!==void 0?{epochId:h.epochId}:{},chainId:h.chainId}:"unchained-or-unpartitioned"}});continue}let u=Y(c.counter);if(u===void 0||a===void 0||u<=a){i.push({partition:t.key,proofHash:c.proofHash,prevB64:c.prevB64});continue}o.push({code:"chain-break-missing",partition:t.key,proofHashes:[c.proofHash],message:"commit.prevB64 references a predecessor proof that is absent from the supplied bundle, and a lower-positioned proof IS present, so this is an interior break (a hole), not the excerpt's starting boundary. The chain cannot be reconstructed across this link from the supplied evidence; this does not, by itself, establish that the predecessor never existed.",details:{prevB64:c.prevB64}})}}function Id(t){if(t.length===0)return!1;let e=B.Buffer.from(t,"base64");return e.length===32&&e.toString("base64")===t}async function kd(t,e,n,r){let o=[...e.filter(a=>a.prevB64===void 0)].sort(Me);if(o.length<2)return;let{parties:i,context:s}=await ir(o);n.push({code:"multiple-genesis",partition:t.key,proofHashes:o.map(a=>a.proofHash),message:`${o.length} proofs in one partition carry no prevB64 link. An epoch has exactly one first proof, so at most one of these can be the genesis of this partition's chain.`,details:{validParties:i.map(a=>a.proofHash),invalidObserved:s.map(a=>a.proofHash)}}),!(i.length<2)&&r.push({kind:"multiple-genesis",partition:t.key,contested:{...t.key.epochId!==void 0?{epochId:t.key.epochId}:{},chainId:t.key.chainId},parties:i.map(De),invalidContext:s.map(De),explanation:"Two or more independently valid proof objects in the same signer, epoch, and chain partition carry no predecessor link, each presenting itself as the first proof of the chain. An epoch has exactly one first proof, so at most one of these can be the genesis. The audit tool does not choose between them."})}function Sd(t,e,n){for(let r of[...e].sort(Me)){let o=Y(r.slotCounter),i=Y(r.counter);o===void 0||i===void 0||o<i||n.push({code:"slot-order-violation",partition:t.key,proofHashes:[r.proofHash],message:"commit.slotCounter is not strictly less than commit.counter. The slot must be allocated before the commit that consumes it, so this proof's declared positions contradict the nonce-first construction order.",details:{slotCounter:r.slotCounter,counter:r.counter}})}}async function Td(t,e,n,r){for(let s of t)s.resolution==="terminal-missing"?n.push({code:"epochlink-terminal-missing",proofHashes:[s.viaProofHash],message:"commit.epochLink references a prior epoch that is observed in the bundle, but the referenced terminal proof is absent from the bundle. The lineage claim cannot be confirmed from the supplied evidence; this does not, by itself, establish that the terminal never existed.",details:{link:{...s.link}}}):s.resolution==="dangling"?n.push({code:"epochlink-dangling",proofHashes:[s.viaProofHash],message:"commit.epochLink references a prior epoch and terminal proof, neither of which is observed in the bundle. The lineage claim dangles into unobserved history; it cannot be confirmed from the supplied evidence.",details:{link:{...s.link}}}):s.metadataConsistent===!1&&n.push({code:"epochlink-mismatch",proofHashes:[s.viaProofHash,...s.predecessorProofHash!==void 0?[s.predecessorProofHash]:[]],message:"commit.epochLink's prevProofHashB64 matches an observed proof, but the link's declared epoch, signer key, or counter disagrees with that proof. The hash reference and the declared metadata cannot both be right.",details:{link:{...s.link},inconsistencies:s.inconsistencies??[]}});let o=new Map;for(let s of t)de(o,`${s.link.prevEpochId}|${s.link.prevCounter}|${s.link.prevProofHashB64}`,s);for(let[,s]of Lo(o)){let a=new Set(s.map(h=>h.link.toEpochId));if(a.size<2)continue;let c=s.map(h=>e.get(h.viaProofHash)),{parties:f,context:u}=await ir(c),d=s[0].link;n.push({code:"epochlink-fork",proofHashes:s.map(h=>h.viaProofHash),message:`The same predecessor terminal (epoch ${d.prevEpochId}, counter ${d.prevCounter}) is consumed by genesis proofs of ${a.size} distinct successor epochs. A predecessor may be consumed by at most one successor epoch, so this is a detectable fork at the epoch boundary. All branches are preserved.`,details:{prevEpochId:d.prevEpochId,prevCounter:d.prevCounter,prevProofHashB64:d.prevProofHashB64,successorEpochIds:[...a].sort(),validParties:f.map(h=>h.proofHash),invalidObserved:u.map(h=>h.proofHash)}}),!(f.length<2)&&r.push({kind:"epochlink-fork",contested:{prevEpochId:d.prevEpochId,prevCounter:d.prevCounter,prevProofHashB64:d.prevProofHashB64},parties:f.map(De),invalidContext:u.map(De),explanation:"Two or more independently valid epoch-genesis proofs consume the same terminal proof of a prior epoch through their epochLink. The single-successor rule allows a terminal to be consumed by exactly one successor epoch, so at most one of these lineages can be the authoritative continuation. Note that whichever party verified second in this run carries a fork-detection failure from the canonical verifier; that ordering is an artifact of verification order, not evidence of which branch is authoritative. The audit tool does not choose between them."})}let i=new Map;for(let s of t){if(s.resolution!=="matched")continue;let a=i.get(s.fromEpochId);a===void 0?i.set(s.fromEpochId,new Set([s.toEpochId])):a.add(s.toEpochId)}for(let s of Hd(i)){let a=t.filter(c=>c.resolution==="matched"&&s.includes(c.fromEpochId)&&s.includes(c.toEpochId)).map(c=>c.viaProofHash);n.push({code:"epochlink-cycle",proofHashes:a,message:`Epoch lineage links form a cycle among ${s.length} epochs. Each link claims its successor epoch came after its predecessor, so a cycle means these ordering claims contradict each other; no ordering is asserted for the epochs involved.`,details:{epochIds:s}})}}function Hd(t){let e=new Map,n=new Set,r=[...t.keys()].sort();for(let o of r){if(n.has(o))continue;let i=[],s=new Set,a=new Map,c=[o];for(;c.length>0;){let f=c[c.length-1];s.has(f)||(s.add(f),i.push(f),a.set(f,[...t.get(f)??[]].sort()));let d=a.get(f).shift();if(d===void 0){c.pop(),s.delete(f),i.pop(),n.add(f);continue}if(s.has(d)){let h=i.indexOf(d),l=i.slice(h),m=Cd(l);e.set(m.join("|"),m);continue}n.has(d)||c.push(d)}}return[...e.values()].sort((o,i)=>{let s=o.join("|"),a=i.join("|");return s<a?-1:s>a?1:0})}function Cd(t){let e=0;for(let n=1;n<t.length;n++)t[n]<t[e]&&(e=n);return[...t.slice(e),...t.slice(0,e)]}async function ir(t){let e=[],n=[];for(let r of t)await Ye(r)?e.push(r):n.push(r);return{parties:e,context:n}}function De(t){let e=t.verification;return{proofHash:t.proofHash,sourcePaths:t.sources.map(n=>n.path),...e!==void 0?{verificationTier:e.tier,verificationStatus:e.status,...e.reason!==void 0?{verificationReason:e.reason}:{}}:{},...t.counter!==void 0?{counter:t.counter}:{},...t.slotCounter!==void 0?{slotCounter:t.slotCounter}:{},...t.prevB64!==void 0?{prevB64:t.prevB64}:{},...t.publicKeyB64!==void 0?{publicKeyB64:t.publicKeyB64}:{},...t.epochId!==void 0?{epochId:t.epochId}:{},chainId:t.chainId,...t.measurement!==void 0?{measurement:t.measurement}:{}}}function Lo(t){return[...t.entries()].sort(([e],[n])=>{let r=/^[0-9]+$/.test(e)?BigInt(e):void 0,o=/^[0-9]+$/.test(n)?BigInt(n):void 0;return r!==void 0&&o!==void 0&&r!==o?r<o?-1:1:r!==void 0&&o===void 0?-1:r===void 0&&o!==void 0?1:e<n?-1:e>n?1:0})}y();function Oo(t){let e=new Map;for(let a of t.proofs){let c=JSON.stringify([a.measurement??null,a.publicKeyB64??null,a.epochId??null,a.chainId,a.hasAttestation]),f=e.get(c);if(f!==void 0){f.proofHashes.push(a.proofHash);continue}e.set(c,{...a.measurement!==void 0?{measurement:a.measurement}:{},...a.publicKeyB64!==void 0?{publicKeyB64:a.publicKeyB64}:{},...a.epochId!==void 0?{epochId:a.epochId}:{},chainId:a.chainId,attestationPresent:a.hasAttestation,proofHashes:[a.proofHash]})}let n=[...e.values()].sort(Rd),r=new Map;for(let a of t.proofs)a.epochId!==void 0&&de(r,a.epochId,a);let o=[];for(let[a,c]of[...r.entries()].sort(([f],[u])=>f<u?-1:f>u?1:0)){let f=new Set,u=new Set;for(let d of c)d.publicKeyB64!==void 0&&f.add(d.publicKeyB64),d.measurement!==void 0&&u.add(d.measurement);f.size>=2&&o.push({code:"mid-epoch-signer-change",proofHashes:c.map(d=>d.proofHash),message:`${f.size} distinct signer keys appear within epoch ${a}. A single enclave boot generates exactly one keypair per epoch, so multiple keys under one epochId cannot come from one healthy authority lifecycle. All key groups are preserved for adjudication.`,details:{epochId:a,publicKeysB64:[...f].sort()}}),u.size>=2&&o.push({code:"mid-epoch-measurement-change",proofHashes:c.map(d=>d.proofHash),message:`${u.size} distinct declared measurements appear within epoch ${a}. A single enclave boot has exactly one measurement, so multiple declared measurements under one epochId cannot come from one healthy authority lifecycle. Declared measurements are self-reported; attestation validation is reported separately.`,details:{epochId:a,measurements:[...u].sort()}})}let i=new Map;for(let a of t.proofs){if(a.publicKeyB64===void 0||a.epochId===void 0)continue;let c=i.get(a.publicKeyB64);c===void 0?i.set(a.publicKeyB64,new Set([a.epochId])):c.add(a.epochId)}let s=[...i.entries()].filter(([,a])=>a.size>=2).map(([a,c])=>({publicKeyB64:a,epochIds:[...c].sort()})).sort((a,c)=>a.publicKeyB64<c.publicKeyB64?-1:a.publicKeyB64>c.publicKeyB64?1:0);return{groups:n,anomalies:o,sharedSignersAcrossEpochs:s}}function Rd(t,e){if(t.chainId!==e.chainId)return t.chainId<e.chainId?-1:1;let n=t.epochId??"",r=e.epochId??"";if(n!==r)return n<r?-1:1;let o=t.publicKeyB64??"",i=e.publicKeyB64??"";if(o!==i)return o<i?-1:1;let s=t.measurement??"",a=e.measurement??"";return s!==a?s<a?-1:1:t.attestationPresent!==e.attestationPresent?t.attestationPresent?-1:1:0}y();var $d="Ethereum Anchor",Da="ethereum-anchor",Pd=/^https:\/\/etherscan\.io\/block\/([0-9]+)$/;function Uo(t){let e=[],n=[],r=[];for(let o of t.proofs){let i=Fo(o,"name"),s=Md(o);if(!(i===$d)){s===Da&&(n.push(o.proofHash),r.push({code:"anchor-metadata-only-claim",..._o(o),message:"unsigned metadata.type claims ethereum-anchor, but the signed attribution does not identify this proof as an anchor. Metadata is advisory and unsigned; the proof is not treated as an anchor.",details:{proofHash:o.proofHash}}));continue}let c=s===Da?"agrees":s===void 0?"absent":"disagrees";c==="disagrees"&&r.push({code:"anchor-metadata-disagreement",..._o(o),message:`signed attribution identifies an Ethereum anchor, but unsigned metadata.type is ${JSON.stringify(s)}. The signed field governs; the disagreement is recorded.`,details:{proofHash:o.proofHash,metadataType:s}});let f=Fo(o,"message"),u=Fo(o,"title"),d=u!==void 0?Pd.exec(u)?.[1]??void 0:void 0;d===void 0&&r.push({code:"anchor-title-unparseable",..._o(o),message:u===void 0?"anchor proof carries no signed attribution.title; the signed block number is absent":"anchor attribution.title does not parse as an Etherscan block URL; the signed block number is treated as absent",details:{proofHash:o.proofHash,...u!==void 0?{title:u}:{}}});let h=o.verification;e.push({proofHash:o.proofHash,...o.epochId!==void 0?{epochId:o.epochId}:{},chainId:o.chainId,...o.counter!==void 0?{counter:o.counter}:{},...o.slotCounter!==void 0?{slotCounter:o.slotCounter}:{},...f!==void 0?{blockHash:f}:{},...d!==void 0?{blockNumber:d}:{},metadataCorroboration:c,...h!==void 0?{verificationTier:h.tier,verificationStatus:h.status,...h.reason!==void 0?{verificationReason:h.reason}:{}}:{}})}return{anchors:e,metadataOnlyProofHashes:n,findings:r}}function Fo(t,e){let n=t.proof.attribution;if(n===null||typeof n!="object"||Array.isArray(n))return;let r=n[e];return typeof r=="string"?r:void 0}function Md(t){let e=t.proof.metadata;if(e===null||typeof e!="object"||Array.isArray(e))return;let n=e.type;return typeof n=="string"?n:void 0}function _o(t){let e=t.sources[0]?.path;return e!==void 0?{path:e}:{}}y();y();var Dd=BigInt(0),hn=BigInt(1),Nd=BigInt(2),Ld=BigInt(7),Od=BigInt(256),Fd=BigInt(113),Oa=[],Fa=[],_a=[];for(let t=0,e=hn,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],Oa.push(2*(5*r+n)),Fa.push((t+1)*(t+2)/2%64);let o=Dd;for(let i=0;i<7;i++)e=(e<<hn^(e>>Ld)*Fd)%Od,e&Nd&&(o^=hn<<(hn<<BigInt(i))-hn);_a.push(o)}var Ua=Hn(_a,!0),_d=Ua[0],Ud=Ua[1],Na=(t,e,n)=>n>32?Xi(t,e,n):Zi(t,e,n),La=(t,e,n)=>n>32?Ji(t,e,n):Yi(t,e,n);function jd(t,e=24){let n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let s=0;s<10;s++)n[s]=t[s]^t[s+10]^t[s+20]^t[s+30]^t[s+40];for(let s=0;s<10;s+=2){let a=(s+8)%10,c=(s+2)%10,f=n[c],u=n[c+1],d=Na(f,u,1)^n[a],h=La(f,u,1)^n[a+1];for(let l=0;l<50;l+=10)t[s+l]^=d,t[s+l+1]^=h}let o=t[2],i=t[3];for(let s=0;s<24;s++){let a=Fa[s],c=Na(o,i,a),f=La(o,i,a),u=Oa[s];o=t[u],i=t[u+1],t[u]=c,t[u+1]=f}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)n[a]=t[s+a];for(let a=0;a<10;a++)t[s+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=_d[r],t[1]^=Ud[r]}He(n)}var jo=class t extends Nt{constructor(e,n,r,o=!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=n,this.outputLen=r,this.enableXOF=o,this.rounds=i,Pr(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=zi(this.state)}clone(){return this._cloneInto()}keccak(){Mr(this.state32),jd(this.state32,this.rounds),Mr(this.state32),this.posOut=0,this.pos=0}update(e){Lt(this),e=Jt(e),bt(e);let{blockLen:n,state:r}=this,o=e.length;for(let i=0;i<o;){let s=Math.min(n-this.pos,o-i);for(let a=0;a<s;a++)r[this.pos++]^=e[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:n,pos:r,blockLen:o}=this;e[r]^=n,(n&128)!==0&&r===o-1&&this.keccak(),e[o-1]^=128,this.keccak()}writeInto(e){Lt(this,!1),bt(e),this.finish();let n=this.state,{blockLen:r}=this;for(let o=0,i=e.length;o<i;){this.posOut>=r&&this.keccak();let s=Math.min(r-this.posOut,i-o);e.set(n.subarray(this.posOut,this.posOut+s),o),this.posOut+=s,o+=s}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Pr(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(kn(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,He(this.state)}_cloneInto(e){let{blockLen:n,suffix:r,outputLen:o,rounds:i,enableXOF:s}=this;return e||(e=new t(n,r,o,s,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=o,e.enableXOF=s,e.destroyed=this.destroyed,e}},Kd=(t,e,n)=>Qt(()=>new jo(e,t,n));var ja=Kd(1,136,256/8);y();function za(t){if(t.length===0)throw new Error("RLP: empty input");let{item:e,next:n}=qa(t,0);if(n!==t.length)throw new Error(`RLP: ${t.length-n} trailing byte(s) after the top-level item`);if(!Array.isArray(e))throw new Error("RLP: top-level item is not a list");return e}function qa(t,e){let n=Ga(t,e);if(n<128)return{item:t.subarray(e,e+1),next:e+1};if(n<=183){let a=n-128,c=sr(t,e+1,a);return{item:t.subarray(e+1,c),next:c}}if(n<=191){let a=n-183,c=Va(t,e+1,a),f=e+1+a,u=sr(t,f,c);return{item:t.subarray(f,u),next:u}}if(n<=247){let a=n-192,c=sr(t,e+1,a);return{item:Ka(t,e+1,c),next:c}}let r=n-247,o=Va(t,e+1,r),i=e+1+r,s=sr(t,i,o);return{item:Ka(t,i,s),next:s}}function Ka(t,e,n){let r=[],o=e;for(;o<n;){let i=qa(t,o);if(i.next>n)throw new Error("RLP: list item overruns its list payload");r.push(i.item),o=i.next}return r}function Va(t,e,n){if(n<1||n>8)throw new Error(`RLP: invalid length-of-length ${n}`);let r=0;for(let o=0;o<n;o++)r=r*256+Ga(t,e+o);if(r>t.length)throw new Error("RLP: declared length exceeds the input size");return r}function sr(t,e,n){let r=e+n;if(r>t.length)throw new Error("RLP: item is truncated");return r}function Ga(t,e){let n=t[e];if(n===void 0)throw new Error("RLP: unexpected end of input");return n}function Ko(t){let e=0n;for(let n of t)e=e<<8n|BigInt(n);return e}function Wa(t){if(!t.startsWith("0x"))return null;let e=t.slice(2);if(e.length%2!==0||!/^[0-9a-fA-F]*$/.test(e))return null;let n=new Uint8Array(e.length/2);for(let r=0;r<n.length;r++)n[r]=Number.parseInt(e.slice(r*2,r*2+2),16);return n}function Za(t){return`0x${B.Buffer.from(t).toString("hex")}`}var Ya=8,Xa=11,Vd=/^0x[0-9a-fA-F]{64}$/,zd=/^https:\/\/etherscan\.io\/block\/([0-9]+)$/;async function zo(t,e){let n=[],r=[],o=new Map(t.proofs.map(i=>[i.proofHash,i]));for(let i of t.witnesses){let s=qd(i);if(s.failure!==void 0){let u={witnessPath:i.path,verified:!1,reason:s.failure.reason,detail:s.failure.detail};n.push(u),r.push(Vo(u));continue}let a=s.computedHash,c=s.claimedHash.toLowerCase(),f=e.anchors.filter(u=>{let d=u.blockHash?.toLowerCase();return d!==void 0&&(d===a||d===c)});if(f.length===0){let u={witnessPath:i.path,verified:!1,reason:"witness-unmatched",detail:"neither the locally recomputed block hash nor the claimed blockHash matches any observed anchor's signed attribution.message",computedBlockHash:a};n.push(u),r.push(Vo(u));continue}for(let u of f){let d=o.get(u.proofHash),h=d!==void 0&&await Ye(d),l=Gd(s,i.path,u.proofHash,d,h);n.push(l),l.verified||r.push(Vo(l))}}return{outcomes:n,findings:r}}function qd(t){let e=t.witness,n=e.headerRlpHex;if(typeof n!="string")return ar("headerRlpHex is missing or not a string");let r=e.blockNumber;if(typeof r!="number"||!Number.isInteger(r)||r<0)return ar("blockNumber is missing or not a non-negative integer");let o=e.blockHash;if(typeof o!="string"||!Vd.test(o))return ar("blockHash is missing or not 0x followed by 64 hex characters");let i=Wa(n);if(i===null)return ar("headerRlpHex is not 0x-prefixed even-length hex");let s;try{s=za(i)}catch(c){return{failure:{reason:"witness-rlp-invalid",detail:c instanceof Error?c.message:String(c)}}}return{computedHash:Za(ja(i)),items:s,claimedHash:o,claimedNumber:BigInt(r)}}function ar(t){return{failure:{reason:"witness-malformed",detail:t}}}function Gd(t,e,n,r,o){let i=t.computedHash,s={witnessPath:e,anchorProofHash:n,computedBlockHash:i},a=(b,k,v)=>({...s,verified:!1,reason:b,detail:k,...v?.blockNumber!==void 0?{blockNumber:v.blockNumber}:{}});if(r===void 0||!o)return a("witness-anchor-invalid","the candidate anchor proof is not cryptographically valid; the witness confers nothing");let c=Wd(r);if(c===void 0||c.toLowerCase()!==i)return a("witness-hash-mismatch",c===void 0?"the anchor carries no signed attribution.message to compare against":"the locally recomputed block hash does not equal the anchor's signed attribution.message");let f=Xd(Yd(r));if(f===null)return a("witness-digest-mismatch","the anchor's artifact.digestB64 does not strictly decode as base64 of 32 bytes");let u=U(new TextEncoder().encode(c));if(!Jd(u,f))return a("witness-digest-mismatch","SHA-256 of the exact signed attribution.message string does not equal the anchor's artifact digest");let d=t.items,h=d[Ya];if(h===void 0||!(h instanceof Uint8Array))return a("witness-header-shape",`header RLP item ${Ya} (block number) is missing or not a byte string`);let l=Ko(h);if(l!==t.claimedNumber)return a("witness-block-number-mismatch",`the witness claims blockNumber ${t.claimedNumber}, but the header's number field is ${l}`,{blockNumber:String(l)});let m=Zd(r);if(m!==void 0){let b=zd.exec(m)?.[1];if(b!==void 0&&BigInt(b)!==l)return a("witness-block-number-mismatch",`the anchor's signed Etherscan URL names block ${b}, but the header's number field is ${l}`,{blockNumber:String(l)})}if(t.claimedHash.toLowerCase()!==i)return a("witness-claimed-hash-mismatch","the witness's claimed blockHash does not equal the locally recomputed block hash",{blockNumber:String(l)});let p=d[Xa];if(p===void 0||!(p instanceof Uint8Array))return a("witness-header-shape",`header RLP item ${Xa} (timestamp) is missing or not a byte string`,{blockNumber:String(l)});let w=Ko(p);return w>BigInt(Number.MAX_SAFE_INTEGER)?a("witness-header-shape","header timestamp does not fit a safe integer",{blockNumber:String(l)}):{...s,verified:!0,blockNumber:String(l),timestamp:Number(w)}}function Wd(t){return Ja(t,"message")}function Zd(t){return Ja(t,"title")}function Ja(t,e){let n=t.proof.attribution;if(n===null||typeof n!="object"||Array.isArray(n))return;let r=n[e];return typeof r=="string"?r:void 0}function Yd(t){let e=t.proof.artifact;if(e===null||typeof e!="object"||Array.isArray(e))return;let n=e.digestB64;return typeof n=="string"?n:void 0}function Xd(t){if(t===void 0||t.length===0)return null;let e=B.Buffer.from(t,"base64");return e.length!==32||e.toString("base64")!==t?null:new Uint8Array(e)}function Jd(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return n===0}function Vo(t){return{code:t.reason,path:t.witnessPath,message:`anchor witness rejected: ${t.detail??"verification failed"}. The witness confers nothing; the anchor proof's own standing is unchanged.`,details:{...t.anchorProofHash!==void 0?{anchorProofHash:t.anchorProofHash}:{},...t.computedBlockHash!==void 0?{computedBlockHash:t.computedBlockHash}:{}}}}y();function qo(t,e,n,r){let o=new Map(t.proofs.map(u=>[u.proofHash,u])),i=new Map;for(let u of r.outcomes)!u.verified||u.anchorProofHash===void 0||i.has(u.anchorProofHash)||i.set(u.anchorProofHash,{anchorProofHash:u.anchorProofHash,timestamp:u.timestamp,blockHash:u.computedBlockHash,...u.blockNumber!==void 0?{blockNumber:u.blockNumber}:{}});let s=[...i.keys()].sort(),a=n.anchors.map(u=>u.proofHash).filter(u=>!i.has(u)).sort(),c=[];for(let u of e.partitions)c.push(...Qd(u,o,i));let f=ih(e,c);return{segments:c,anchorOrderedPairs:f,verifiedAnchorProofHashes:s,unverifiedAnchorProofHashes:a}}function Qd(t,e,n){let r=t.memberProofHashes.map(h=>e.get(h)),o=new Map(r.map(h=>[h.chainHash,h])),i=r.filter(h=>n.has(h.proofHash)),s=new Map;for(let h of r){if(h.prevB64===void 0)continue;let l=o.get(h.prevB64);l===void 0||l.proofHash===h.proofHash||de(s,l.proofHash,h)}let a=new Map,c=new Map;for(let h of i)a.set(h.proofHash,th(h,s)),c.set(h.proofHash,nh(h,o));let f=r.map(h=>{let l=new Map,m=new Map,p=Y(h.counter);for(let w of i){let b=w.proofHash,k=Y(w.counter);h.proofHash===b||a.get(b).has(h.proofHash)?l.set(b,"chain-link"):p!==void 0&&k!==void 0&&p>k&&(l.has(b)||l.set(b,"counter-order")),c.get(b).has(h.proofHash)?m.set(b,"chain-link"):h.proofHash!==b&&p!==void 0&&k!==void 0&&p<k&&(m.has(b)||m.set(b,"counter-order"))}return{member:h,lower:Qa("not-before",l,n),upper:Qa("not-after",m,n)}}),u=new Map;for(let h of f)de(u,eh(h),h);let d=[];for(let h of u.values()){let l=h.map(v=>v.member).sort(Me),m=h[0],p=m.lower,w=m.upper,b=p.length>0&&w.length>0?"lower-bounded-with-following-anchor":p.length>0?"lower-bounded":w.length>0?"upper-bounded":"ordered-but-unanchored",k=rh(l);d.push({partition:t.key,memberProofHashes:l.map(v=>v.proofHash),...k!==void 0?{positionRange:k}:{},status:b,lowerBounds:p,upperBounds:w})}return d.sort(oh),d}function Qa(t,e,n){if(e.size===0)return[];let r=[...e.entries()].map(([c,f])=>({anchorHash:c,evidenceKind:f,info:n.get(c)})),o=(c,f)=>f===void 0?!0:c.info.timestamp!==f.info.timestamp?t==="not-before"?c.info.timestamp>f.info.timestamp:c.info.timestamp<f.info.timestamp:c.evidenceKind!==f.evidenceKind?c.evidenceKind==="chain-link":c.anchorHash<f.anchorHash,i,s;for(let c of r)o(c,i)&&(i=c),c.evidenceKind==="chain-link"&&o(c,s)&&(s=c);let a=[ec(t,i)];return s!==void 0&&(i.anchorHash!==s.anchorHash||i.evidenceKind!=="chain-link")&&a.push(ec(t,s)),a}function ec(t,e){let{info:n,evidenceKind:r}=e,o=new Date(n.timestamp*1e3).toISOString(),i=n.blockNumber!==void 0?`Ethereum block ${n.blockNumber}`:"an Ethereum block",s=r==="chain-link"?"Evidence: a verified hash-link path connects these proofs and the anchor.":"Evidence: commit-counter ordering within the partition only, which relies on the authority's counter discipline rather than verifiable hash links (weaker).",a=t==="not-before"?`These proofs were committed no earlier than ${o} (unix ${n.timestamp}), the timestamp of ${i}: the block hash was unpredictable before that time and the anchor commit consumed it. Reading this as a wall-clock floor additionally assumes the anchored header is a genuine, publicly published Ethereum block: this offline audit checks the header's structure and hash binding, not proof-of-work, consensus, or chain membership, so it cannot confirm the block is real. ${s}`:`These proofs existed before the anchor commit that consumed the hash of ${i} (block timestamp ${o}, unix ${n.timestamp}). The block timestamp proves the anchor commit came at or after it, not how promptly; reading it as a wall-clock ceiling additionally assumes the anchor consumed a recently published block. ${s}`;return{kind:t,anchorProofHash:e.anchorHash,...n.blockNumber!==void 0?{blockNumber:n.blockNumber}:{},blockHash:n.blockHash,timestamp:n.timestamp,evidence:r,weaker:r==="counter-order",basis:t==="not-before"?"block-hash-unpredictability":"causal-precedence",boundClass:t==="not-before"?"evidence":"assumption",claim:t==="not-before"?a:"NOT a proof-carried upper bound. "+a}}function eh(t){let e=n=>n.map(r=>`${r.anchorProofHash}:${r.evidence}`).join(",");return`${e(t.lower)}|${e(t.upper)}`}function th(t,e){let n=new Set,r=[...e.get(t.proofHash)??[]];for(;r.length>0;){let o=r.pop();if(!n.has(o.proofHash)){n.add(o.proofHash);for(let i of e.get(o.proofHash)??[])r.push(i)}}return n}function nh(t,e){let n=new Set,r=t;for(;r!==void 0&&r.prevB64!==void 0;){let o=e.get(r.prevB64);if(o===void 0||n.has(o.proofHash)||o.proofHash===t.proofHash)break;n.add(o.proofHash),r=o}return n}function rh(t){let e,n;for(let r of t)for(let o of[r.counter,r.slotCounter]){let i=Y(o);i!==void 0&&((e===void 0||i<e)&&(e=i),(n===void 0||i>n)&&(n=i))}return e!==void 0&&n!==void 0?{min:String(e),max:String(n)}:void 0}function oh(t,e){let n=t.positionRange?.min,r=e.positionRange?.min;if(n!==void 0&&r!==void 0&&n!==r)return BigInt(n)<BigInt(r)?-1:1;if(n!==void 0&&r===void 0)return-1;if(n===void 0&&r!==void 0)return 1;let o=t.memberProofHashes[0]??"",i=e.memberProofHashes[0]??"";return o<i?-1:o>i?1:0}function tc(t){return t?" The representative bound rests on commit-counter ordering rather than a verified hash-link path, which relies on the authority's counter discipline (weaker evidence).":""}function ih(t,e){let n=new Map;for(let i of t.epochRelationships.epochs)n.set(i.epochId,{totalProofCount:i.proofCount,lowerCovered:new Set,upperCovered:new Set});for(let i of e){let s=i.partition.epochId;if(s===void 0)continue;let a=n.get(s);if(a!==void 0){for(let c of i.lowerBounds){for(let f of i.memberProofHashes)a.lowerCovered.add(f);(a.lowerMin===void 0||c.timestamp<a.lowerMin.timestamp||c.timestamp===a.lowerMin.timestamp&&a.lowerMin.weaker&&!c.weaker)&&(a.lowerMin={timestamp:c.timestamp,anchorProofHash:c.anchorProofHash,blockHash:c.blockHash,...c.blockNumber!==void 0?{blockNumber:c.blockNumber}:{},evidence:c.evidence,weaker:c.weaker})}for(let c of i.upperBounds){for(let f of i.memberProofHashes)a.upperCovered.add(f);(a.upperMax===void 0||c.timestamp>a.upperMax.timestamp||c.timestamp===a.upperMax.timestamp&&a.upperMax.weaker&&!c.weaker)&&(a.upperMax={timestamp:c.timestamp,anchorProofHash:c.anchorProofHash,blockHash:c.blockHash,...c.blockNumber!==void 0?{blockNumber:c.blockNumber}:{},evidence:c.evidence,weaker:c.weaker})}}}for(let i of t.epochRelationships.epochs){let s=n.get(i.epochId),a=[];s.lowerMin!==void 0&&a.push({kind:"not-before",anchorProofHash:s.lowerMin.anchorProofHash,...s.lowerMin.blockNumber!==void 0?{blockNumber:s.lowerMin.blockNumber}:{},blockHash:s.lowerMin.blockHash,witnessTimestamp:s.lowerMin.timestamp,coverage:"members-after-anchor",coveredProofCount:s.lowerCovered.size,totalProofCount:s.totalProofCount,basis:"block-hash-unpredictability",evidence:s.lowerMin.evidence,weaker:s.lowerMin.weaker,claim:`${s.lowerCovered.size} of ${s.totalProofCount} observed proofs of this epoch were committed no earlier than unix ${s.lowerMin.timestamp}, grounded in block-hash unpredictability through verified anchor witnesses. This additionally assumes the anchored header is a genuine, publicly published Ethereum block, which this offline audit cannot confirm.`+tc(s.lowerMin.weaker)+" The remaining proofs sit causally before the covering anchors and carry no lower bound from this evidence."}),s.upperMax!==void 0&&a.push({kind:"not-after",anchorProofHash:s.upperMax.anchorProofHash,...s.upperMax.blockNumber!==void 0?{blockNumber:s.upperMax.blockNumber}:{},blockHash:s.upperMax.blockHash,witnessTimestamp:s.upperMax.timestamp,coverage:"members-before-anchor",coveredProofCount:s.upperCovered.size,totalProofCount:s.totalProofCount,basis:"causal-precedence",evidence:s.upperMax.evidence,weaker:s.upperMax.weaker,claim:`${s.upperCovered.size} of ${s.totalProofCount} observed proofs of this epoch existed before an anchor commit that consumed a block published at unix ${s.upperMax.timestamp}. Reading that timestamp as a wall-clock ceiling additionally assumes the anchor consumed a recently published block; the causal precedence itself is verified.`+tc(s.upperMax.weaker)+" Proofs after the covering anchors are not covered."}),a.length>0&&(i.anchorBounds=a)}let r=[],o=t.epochRelationships.epochs;for(let i of o){let s=n.get(i.epochId);if(s.upperMax!==void 0)for(let a of o){if(a.epochId===i.epochId)continue;let c=n.get(a.epochId);if(c.lowerMin===void 0||s.upperMax.timestamp>=c.lowerMin.timestamp)continue;let f=s.upperMax.evidence,u=c.lowerMin.evidence,d=s.upperMax.weaker||c.lowerMin.weaker;r.push({beforeEpochId:i.epochId,afterEpochId:a.epochId,upperAnchorProofHash:s.upperMax.anchorProofHash,upperBoundTimestamp:s.upperMax.timestamp,lowerAnchorProofHash:c.lowerMin.anchorProofHash,lowerBoundTimestamp:c.lowerMin.timestamp,basis:"anchor-bounds",assumptionDependent:!0,upperEvidence:f,lowerEvidence:u,weaker:d,beforeCoveredProofCount:s.upperCovered.size,beforeTotalProofCount:s.totalProofCount,afterCoveredProofCount:c.lowerCovered.size,afterTotalProofCount:c.totalProofCount,note:`The anchor-covered portion of epoch ${i.epochId} (${s.upperCovered.size} of ${s.totalProofCount} proofs) precedes the anchor-covered portion of epoch ${a.epochId} (${c.lowerCovered.size} of ${c.totalProofCount} proofs): the first is bounded not-after unix ${s.upperMax.timestamp} and the second not-before unix ${c.lowerMin.timestamp}. One-sided evidence about the covered portions only; the not-after side rests on the anchor-freshness assumption documented on its bound.`+(d?" At least one side rests on commit-counter ordering rather than a verified hash-link path (weaker evidence), which relies on the authority's counter discipline.":"")+" This is ordering evidence, never divergence."})}}return r.sort((i,s)=>i.beforeEpochId!==s.beforeEpochId?i.beforeEpochId<s.beforeEpochId?-1:1:i.afterEpochId<s.afterEpochId?-1:i.afterEpochId>s.afterEpochId?1:0),r}y();y();var nc=`-----BEGIN CERTIFICATE-----
|
|
140
140
|
MIICETCCAZagAwIBAgIRAPkxdWgbkK/hHUbMtOTn+FYwCgYIKoZIzj0EAwMwSTEL
|
|
141
141
|
MAkGA1UEBhMCVVMxDzANBgNVBAoMBkFtYXpvbjEMMAoGA1UECwwDQVdTMRswGQYD
|
|
142
142
|
VQQDDBJhd3Mubml0cm8tZW5jbGF2ZXMwHhcNMTkxMDI4MTMyODA1WhcNNDkxMDI4
|
|
@@ -149,10 +149,10 @@ R+eWw5b6cp3PmanfS5YwDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMDA2kAMGYC
|
|
|
149
149
|
MQCjfy+Rocm9Xue4YnwWmNJVA44fA0P5W2OpYow9OYCVRaEevL8uO1XYru5xtMPW
|
|
150
150
|
rfMCMQCi85sWBbJwKKXdS6BptQFuZbT73o/gBh1qUxl/nNr12UO8Yfwr6wPLb+6N
|
|
151
151
|
IwLz3/Y=
|
|
152
|
-
-----END CERTIFICATE-----`;function Gd(){return Za.replace(/-----BEGIN CERTIFICATE-----/,"").replace(/-----END CERTIFICATE-----/,"").replace(/\s+/g,"")}function Ya(){return new Uint8Array(B.Buffer.from(Gd(),"base64"))}async function Ja(t,e){let n=[],o={},r,i,s,a,c,f=()=>({documentValid:!1,checks:n,failure:[...n].reverse().find(u=>!u.pass)?.detail,...r!==void 0?{pcr0:r}:{},pcrs:o,...i!==void 0?{moduleId:i}:{},...s!==void 0?{timestamp:s}:{},...a!==void 0?{certChainLength:a}:{},...c!==void 0?{userDataB64:c}:{}});try{let u=Yd(t);if(u===null)return n.push({name:"CBOR Decode",pass:!1,detail:"reportB64 is not valid base64"}),f();let d=Ge(u,0).value;if(!Array.isArray(d)||d.length<4)return n.push({name:"CBOR Decode",pass:!1,detail:"Not a valid COSE_Sign1 array"}),f();n.push({name:"CBOR Decode",pass:!0,detail:"COSE_Sign1 envelope parsed"});let h=d[0],l=d[2],m=d[3];if(!(h instanceof Uint8Array)||!(l instanceof Uint8Array)||!(m instanceof Uint8Array))return n.push({name:"COSE Structure",pass:!1,detail:"Missing protected/payload/signature"}),f();let p=Ge(l,0).value;if(!p||typeof p!="object"||Array.isArray(p))return n.push({name:"Payload Decode",pass:!1,detail:"Could not decode attestation payload"}),f();o=nh(p),r=o[0],i=typeof p.module_id=="string"?p.module_id:void 0,s=typeof p.timestamp=="number"?p.timestamp:void 0;let w=p.user_data;c=w instanceof Uint8Array&&w.length>0?B.Buffer.from(w).toString("base64"):void 0;let b=p.cabundle,k=p.certificate;if(!(k instanceof Uint8Array))return n.push({name:"Leaf Certificate",pass:!1,detail:"No leaf certificate in attestation"}),f();a=(Array.isArray(b)?b.length:0)+1;let v=zr(k),O=Qd(h,l),z=await qr(m,O,v.publicKey);if(n.push({name:"ECDSA P-384 Signature",pass:z,detail:z?"Attestation signed by leaf certificate":"Signature verification failed against leaf certificate public key"}),!z)return f();if(!Array.isArray(b)||b.length===0||!b.every(A=>A instanceof Uint8Array))return n.push({name:"Certificate Chain",pass:!1,detail:"Empty cabundle"}),f();let S=[...b,k].map(zr),U=!0,F="";for(let A=1;A<S.length;A++){let C=S[A],D=S[A-1];if(!await qr(C.signature,C.tbsCertificate,D.publicKey)){U=!1,F=`Certificate ${A} signature invalid (parent: ${A-1})`;break}}if(n.push({name:"Certificate Chain",pass:U,detail:U?`${S.length} certificates, each signed by parent`:F}),!U)return f();let G=e?.trustedRootCaDer===void 0,q=zr(e?.trustedRootCaDer??Ya()),le=S[0],N=await qr(le.signature,le.tbsCertificate,q.publicKey);if(n.push({name:"AWS Nitro Root CA",pass:N,detail:N?G?"Chain anchored to AWS Nitro Root G1 (CN=aws.nitro-enclaves)":"Chain anchored to the supplied trust root (non-default trust material)":G?"Top of chain not signed by AWS Nitro Root CA":"Top of chain not signed by the supplied trust root"}),!N)return f();let se=!0,oe=`All ${S.length} certificate validity windows contain the document timestamp`;if(s===void 0)se=!1,oe="Attestation document carries no timestamp; certificate validity cannot be evaluated offline";else for(let A=0;A<S.length;A++){let C=S[A];if(s<C.notBeforeMs||s>C.notAfterMs){se=!1,oe=`Certificate ${A} validity window [${new Date(C.notBeforeMs).toISOString()}, ${new Date(C.notAfterMs).toISOString()}] does not contain the document timestamp ${new Date(s).toISOString()}`;break}}if(n.push({name:"Certificate Validity Window",pass:se,detail:oe}),!se)return f();let L;e?.expectedPcr0!==void 0&&(L=r===e.expectedPcr0,n.push({name:"PCR0 Match",pass:L,detail:L?"PCR0 inside attestation matches declared measurement":`PCR0 mismatch: expected ${e.expectedPcr0.slice(0,16)}..., got ${(r??"").slice(0,16)}...`}));let E;return e?.expectedUserDataB64!==void 0&&(E=c!==void 0&&c===e.expectedUserDataB64,n.push({name:"Bound to this proof",pass:E,detail:E?"Attestation user_data matches this proof's canonical hash":c!==void 0?"Attestation user_data does not match this proof":"Attestation carries no user_data to bind"})),{documentValid:!0,checks:n,...r!==void 0?{pcr0:r}:{},pcrs:o,...i!==void 0?{moduleId:i}:{},...s!==void 0?{timestamp:s}:{},certChainLength:a,...c!==void 0?{userDataB64:c}:{},...L!==void 0?{pcr0Matches:L}:{},...E!==void 0?{userDataMatches:E}:{}}}catch(u){return n.push({name:"Verification Error",pass:!1,detail:u instanceof Error?u.message:String(u)}),f()}}async function Gr(t,e,n){let o=[],r=[],i={proofsWithDeclaredMeasurement:0,proofsWithDocument:0,documentsValidated:0,documentsFailed:0,pcr0Matches:0,pcr0Mismatches:0,userDataBound:0,userDataUnbound:0};for(let s of t.proofs){let a=s.measurement!==void 0&&s.measurement.length>0?s.measurement:void 0;a!==void 0&&i.proofsWithDeclaredMeasurement++;let c=Zd(s),f={proofHash:s.proofHash,declaredMeasurementPresent:a!==void 0,...a!==void 0?{declaredMeasurement:a}:{},documentPresent:c!==void 0,...c?.format!==void 0?{attestationFormat:c.format}:{},documentValidated:!1,checks:[]};if(c!==void 0){i.proofsWithDocument++;let u=await Ja(c.reportB64,{...a!==void 0?{expectedPcr0:a}:{},expectedUserDataB64:cr(s.proof),...n?.trustedRootCaDer!==void 0?{trustedRootCaDer:n.trustedRootCaDer}:{}});f.documentValidated=u.documentValid,f.checks=u.checks,u.pcr0!==void 0&&(f.attestedPcr0=u.pcr0),f.pcrs=u.pcrs,u.moduleId!==void 0&&(f.moduleId=u.moduleId),u.timestamp!==void 0&&(f.timestamp=u.timestamp),u.certChainLength!==void 0&&(f.certChainLength=u.certChainLength),u.userDataB64!==void 0&&(f.userDataB64=u.userDataB64),u.documentValid?(i.documentsValidated++,u.pcr0Matches!==void 0&&(f.pcr0MatchesDeclared=u.pcr0Matches,u.pcr0Matches?i.pcr0Matches++:(i.pcr0Mismatches++,r.push({code:"attestation-measurement-mismatch",...Kr(s),message:"the validated attestation document's PCR0 does not equal the proof's declared environment.measurement. Declared and attested measurements are reported separately and disagree here.",details:{proofHash:s.proofHash,declared:a,...u.pcr0!==void 0?{attested:u.pcr0}:{}}}))),u.userDataMatches!==void 0&&(f.userDataBoundToProof=u.userDataMatches,u.userDataMatches?i.userDataBound++:(i.userDataUnbound++,r.push({code:"attestation-user-data-mismatch",...Kr(s),message:"the validated attestation document's user_data is not bound to this proof's canonical hash. A genuine attestation lifted from another proof would look exactly like this.",details:{proofHash:s.proofHash,...u.userDataB64!==void 0?{userDataB64:u.userDataB64}:{}}})))):(i.documentsFailed++,u.failure!==void 0&&(f.validationFailure=u.failure),r.push({code:"attestation-invalid",...Kr(s),message:`attestation document failed offline validation: ${u.failure??"unknown"}. Presence of a document is reported separately and proves nothing by itself.`,details:{proofHash:s.proofHash}}))}o.push(f)}return e!==void 0&&Wd(e,o),{records:o,findings:r,counts:i}}function Wd(t,e){let n=new Map(e.map(o=>[o.proofHash,o]));for(let o of t.groups){if(!o.attestationPresent)continue;let r=o.proofHashes.map(f=>n.get(f)).filter(f=>f!==void 0&&f.documentPresent);if(r.length===0)continue;let i=r.filter(f=>f.documentValidated),s=r.length-i.length,a=[...new Set(i.map(f=>f.attestedPcr0).filter(f=>f!==void 0))].sort(),c=a.length===1?a[0]:void 0;o.attested={status:s===0&&i.length>0?"validated":"validation-failed",...c!==void 0?{attestedMeasurement:c}:{},...c!==void 0&&o.measurement!==void 0?{matchesDeclared:c===o.measurement}:{},validatedProofCount:i.length,failedProofCount:s,...a.length>1?{attestedMeasurements:a}:{}}}}function Zd(t){let e=t.proof.environment;if(e===null||typeof e!="object"||Array.isArray(e))return;let n=e.attestation;if(n===null||typeof n!="object"||Array.isArray(n))return;let o=n.reportB64;if(typeof o!="string"||o.length===0)return;let r=n.format;return{reportB64:o,...typeof r=="string"?{format:r}:{}}}function Kr(t){let e=t.sources[0]?.path;return e!==void 0?{path:e}:{}}function Yd(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4!==0;)e+="=";let n=B.Buffer.from(e,"base64");return n.toString("base64")!==e?null:new Uint8Array(n)}function Wr(t){return t<24?new Uint8Array([t]):t<256?new Uint8Array([24,t]):t<65536?new Uint8Array([25,t>>8,t&255]):new Uint8Array([26,t>>>24&255,t>>>16&255,t>>>8&255,t&255])}function Vr(t){let e=Wr(t.length);e[0]=e[0]&31|64;let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}function Xd(t){let e=new TextEncoder().encode(t),n=Wr(e.length);n[0]=n[0]&31|96;let o=new Uint8Array(n.length+e.length);return o.set(n,0),o.set(e,n.length),o}function Jd(t){let e=Wr(t.length);e[0]=e[0]&31|128;let n=e.length+t.reduce((i,s)=>i+s.length,0),o=new Uint8Array(n),r=0;o.set(e,r),r+=e.length;for(let i of t)o.set(i,r),r+=i.length;return o}function Qd(t,e){return Jd([Xd("Signature1"),Vr(t),Vr(new Uint8Array(0)),Vr(e)])}function Ge(t,e=0){let n=t[e];if(n===void 0)throw new Error("CBOR: unexpected end of input");let o=n>>5,r=n&31;e++;let i=a=>{let c=t[a];if(c===void 0)throw new Error("CBOR: unexpected end of input");return c};function s(){if(r<24)return r;if(r===24){let a=i(e);return e+=1,a}if(r===25){let a=i(e)<<8|i(e+1);return e+=2,a}if(r===26){let a=(i(e)<<24|i(e+1)<<16|i(e+2)<<8|i(e+3))>>>0;return e+=4,a}if(r===27){let a=0;for(let c=0;c<8;c++)a=a*256+i(e+c);return e+=8,a}throw new Error(`Unsupported CBOR length info: ${r}`)}switch(o){case 0:return{value:s(),offset:e};case 1:return{value:-1-s(),offset:e};case 2:{let a=s();if(e+a>t.length)throw new Error("CBOR: byte string is truncated");return{value:t.slice(e,e+a),offset:e+a}}case 3:{let a=s();if(e+a>t.length)throw new Error("CBOR: text string is truncated");return{value:new TextDecoder().decode(t.slice(e,e+a)),offset:e+a}}case 4:{if(r===31){let f=[];for(;i(e)!==255;){let u=Ge(t,e);f.push(u.value),e=u.offset}return{value:f,offset:e+1}}let a=s(),c=[];for(let f=0;f<a;f++){let u=Ge(t,e);c.push(u.value),e=u.offset}return{value:c,offset:e}}case 5:{if(r===31){let f={};for(;i(e)!==255;){let u=Ge(t,e);e=u.offset;let d=Ge(t,e);e=d.offset,f[String(u.value)]=d.value}return{value:f,offset:e+1}}let a=s(),c={};for(let f=0;f<a;f++){let u=Ge(t,e);e=u.offset;let d=Ge(t,e);e=d.offset,c[String(u.value)]=d.value}return{value:c,offset:e}}case 6:return s(),Ge(t,e);case 7:{if(r===20)return{value:!1,offset:e};if(r===21)return{value:!0,offset:e};if(r===22)return{value:null,offset:e};if(r===23)return{value:void 0,offset:e};throw new Error(`Unsupported CBOR simple value: ${r}`)}default:throw new Error(`Unsupported CBOR major type: ${o}`)}}function zr(t){let n=sn(t,0).contentStart,o=ie(t,n),r=t.slice(n,o.end);n=o.end,n=ie(t,n).end;let s=ie(t,n),a=t.slice(s.contentStart+1,s.end),c=th(a,48),{publicKey:f,notBeforeMs:u,notAfterMs:d}=eh(r);return{tbsCertificate:r,signature:c,publicKey:f,notBeforeMs:u,notAfterMs:d}}function ie(t,e){let n=t[e];if(n===void 0)throw new Error("DER: unexpected end of input");let o=e+1,r=t[o++];if(r===void 0)throw new Error("DER: unexpected end of input");if(r&128){let s=r&127;r=0;for(let a=0;a<s;a++){let c=t[o++];if(c===void 0)throw new Error("DER: unexpected end of input");r=r*256+c}}let i=o+r;if(i>t.length)throw new Error("DER: element is truncated");return{tag:n,contentStart:o,contentEnd:i,end:i}}function sn(t,e){let n=ie(t,e);if(n.tag!==48)throw new Error(`Expected SEQUENCE at offset ${e}, got tag 0x${n.tag.toString(16)}`);return n}function eh(t){let n=sn(t,0).contentStart;t[n]===160&&(n=ie(t,n).end),n=ie(t,n).end,n=ie(t,n).end,n=ie(t,n).end;let o=sn(t,n),r=o.contentStart,i=ie(t,r);r=i.end;let s=ie(t,r),a=Xa(t,i),c=Xa(t,s);n=o.end,n=ie(t,n).end;let u=sn(t,n).contentStart;u=ie(t,u).end;let h=ie(t,u);return{publicKey:t.slice(h.contentStart+1,h.end),notBeforeMs:a,notAfterMs:c}}function Xa(t,e){let n=String.fromCharCode(...t.slice(e.contentStart,e.contentEnd)),o,r;if(e.tag===23){if(!/^\d{12}Z$/.test(n))throw new Error(`DER: malformed UTCTime "${n}"`);let u=Number.parseInt(n.slice(0,2),10);o=u<50?2e3+u:1900+u,r=n.slice(2)}else if(e.tag===24){if(!/^\d{14}Z$/.test(n))throw new Error(`DER: malformed GeneralizedTime "${n}"`);o=Number.parseInt(n.slice(0,4),10),r=n.slice(4)}else throw new Error(`DER: expected a Time value, got tag 0x${e.tag.toString(16)}`);let i=Number.parseInt(r.slice(0,2),10),s=Number.parseInt(r.slice(2,4),10),a=Number.parseInt(r.slice(4,6),10),c=Number.parseInt(r.slice(6,8),10),f=Number.parseInt(r.slice(8,10),10);return Date.UTC(o,i-1,s,a,c,f)}function th(t,e){let o=sn(t,0).contentStart,r=ie(t,o);if(r.tag!==2)throw new Error("Expected INTEGER for r");let i=t.slice(r.contentStart,r.end);o=r.end;let s=ie(t,o);if(s.tag!==2)throw new Error("Expected INTEGER for s");let a=t.slice(s.contentStart,s.end);if(i[0]===0&&i.length>e&&(i=i.slice(1)),a[0]===0&&a.length>e&&(a=a.slice(1)),i.length>e||a.length>e)throw new Error("ECDSA signature component longer than the curve coordinate size");let c=new Uint8Array(e*2);return c.set(i,e-i.length),c.set(a,e*2-a.length),c}async function qr(t,e,n){if(n.length!==97||n[0]!==4||t.length!==96)return!1;try{let o=await tr.subtle.importKey("raw",n,{name:"ECDSA",namedCurve:"P-384"},!1,["verify"]);return await tr.subtle.verify({name:"ECDSA",hash:"SHA-384"},o,t,e)}catch{return!1}}function nh(t){let e={},n=t.pcrs;if(!n||typeof n!="object")return e;for(let[o,r]of Object.entries(n))if(r instanceof Uint8Array){let i=B.Buffer.from(r).toString("hex");i.replace(/0/g,"").length>0&&(e[Number(o)]=i)}return e}y();var Qn="0.4.1";function Qa(){return Qn}async function Zr(t,e){let n=e?.startedAt??new Date().toISOString(),o=await Hr(t,e?.trustAnchors!==void 0?{trustAnchors:e.trustAnchors}:void 0),r=await Rr(t),i=await $r(t,r),s=Dr(t),a=Lr(t),c=await _r(t,a),f=jr(t,r,a,c),u=await Gr(t,s,e?.trustedRootCaDer!==void 0?{trustedRootCaDer:e.trustedRootCaDer}:void 0);return{runMetadata:{toolVersion:Qa(),startedAt:n,bundlePath:t.bundlePath,container:t.container},ingest:t,verification:o,reconstruction:r,anomalies:i,authorities:s,anchors:a,witnesses:c,temporal:f,attestations:u}}y();y();y();y();y();function eo(t){let e=!1;for(let n of t){if(n==="FALSE")return"FALSE";n==="UNDETERMINED"&&(e=!0)}return e?"UNDETERMINED":"TRUE"}y();y();var Yr="0.10.0";var ah=[{pcr0:"8530a6399399c4f23d89f5a1faa2e8bf2e09a5959f117070fca08148377f92c902c695fc926c17f67f35f110327dca92",label:"genesis",period:"2026-05-15 to 2026-06-27"},{pcr0:"bb9dd158703603ec222fe565495ceaa7edc08f665da5c1cddad91442ac2211731390267036d79deb720d13fb704f648a",label:"enclave v2 (reproducible)",period:"2026-06-27 to 2026-07-05"},{pcr0:"e2fccbae77ee40aac4830e84f195e05d69eb4547bbd961f4d3459feba10807140424aca42ad03810354982598c86b9cb",label:"enclave v4 (reproducible)",period:"2026-07-05 to 2026-07-29"},{pcr0:"6483cedffed74680ffb287507744a398b288c3fb943eb3f2e4fe889f8b60b3d575ad8942350360b69a1bd7bf713df27f",label:"enclave v5 (reproducible)",period:"2026-07-29 to 2026-09-05"},{pcr0:"cd8ba52d340fb1be78610b59953ded2ceca23be1cfcc7ab504a26b8fdcd7ba92090f49e28a32d008df046ec4212f77bf",label:"enclave v6 (reproducible)",period:"2026-09-05 onward"}],ch=new Set(["unexplained-counter-positions","chain-break-missing","epochlink-terminal-missing","epochlink-dangling"]);async function rc(t,e){let n=e,o=await Zr(t,{startedAt:""});if(n?.fuseEvidence===void 0){let r=await fh(t);n={...n,fuseEvidence:r.evidence,fuseOriginHexes:r.originHexes}}return uh(o,n)}async function fh(t){let e=new Map,n=new Set,o=[],r=new Set;for(let s of t.proofs){let a=wt(s.proof);if(a===null)continue;let c=Ft(s.proof.artifact.digestB64),f=c!==null?Re(c):null,u=a.originDigest!==void 0?Re(a.originDigest):null;o.push({proof:s,artifactHex:f,originHex:u}),f!==null&&r.add(f),u!==null&&r.add(u)}if(o.length===0)return{evidence:e,originHexes:n};let i=new Map;for await(let s of Sr(t,r))i.has(s.sha256Hex)||i.set(s.sha256Hex,s.bytes);Ke();try{for(let s of o){let a=s.artifactHex!==null?i.get(s.artifactHex):void 0,c=s.originHex!==null?i.get(s.originHex):void 0;c!==void 0&&s.originHex!==null&&n.add(s.originHex);let f=a??c;f!==void 0&&e.set(s.proof.proofHash,await Er({proof:s.proof.proof,bytes:f}))}}finally{Ke()}return{evidence:e,originHexes:n}}function uh(t,e){let n=e?.webCryptoAvailable??!0,o=new Map(t.anchors.anchors.map(p=>[p.proofHash,p])),r=new Map(t.attestations.records.map(p=>[p.proofHash,p])),i=new Map;for(let p of t.temporal.segments)for(let w of p.memberProofHashes)i.set(w,p);let s=new Map;for(let p of t.witnesses.outcomes){if(p.anchorProofHash===void 0)continue;let w=s.get(p.anchorProofHash)??[];w.push(p),s.set(p.anchorProofHash,w)}let a=new Map;for(let p of t.ingest.artifacts)for(let w of p.matchedProofHashes)!a.has(w)&&p.paths[0]!==void 0&&a.set(w,p.paths[0]);let c=[],f=[];for(let p of t.ingest.proofs){let w=o.get(p.proofHash);w!==void 0?f.push(xh(p,w,s.get(p.proofHash)??[])):c.push(dh(p,r.get(p.proofHash),i.get(p.proofHash),a.get(p.proofHash),n,e?.fuseEvidence,o))}ec(c),ec(f);let u=Eh(t),d=Bh(t,c,f,e?.fuseOriginHexes),h=vh(f.length>0),l=[...c.map(p=>p.result),...f.map(p=>p.result),...u.map(p=>p.result)],m=l.length===0?"UNDETERMINED":eo(l);return{check:"bitgraph-check/1",result:m,summary:Ah(m,c,f,u),recordings:c,anchors:f,contradictions:u,notes:d,notChecked:h,evaluator:{name:"bitgraph-player",version:Yr,audit:Qn},network:"none"}}function ec(t){let e=n=>[n.epochId??"",n.counter!==void 0&&/^[0-9]+$/.test(n.counter)?BigInt(n.counter):void 0];t.sort((n,o)=>{let[r,i]=e(n),[s,a]=e(o);return r!==s?r<s?-1:1:i===void 0||a===void 0?i===void 0?a===void 0?0:1:-1:i<a?-1:i>a?1:0})}function dh(t,e,n,o,r,i,s){let a=[],c=t.verification,f=t.proof.artifact.digestB64;c?.tier==="full"?a.push({name:"file",result:c.status==="verified"||c.status==="failed"?"TRUE":"UNDETERMINED",detail:c.status==="verified"||c.status==="failed"?`${o??"the matched file"} hashes to the recorded digest ${f}`:`no file in this bundle hashes to the recorded digest ${f}`}):a.push({name:"file",result:"UNDETERMINED",detail:`no file in this bundle hashes to the recorded digest ${f}; the recording cannot be bound to bytes in hand`}),c===void 0?a.push({name:"signature",result:"UNDETERMINED",detail:"the proof was not verified"}):c.status==="failed"?a.push({name:"signature",result:"FALSE",detail:`the proof does not verify: ${c.reason??"unspecified failure"}`}):a.push({name:"signature",result:"TRUE",detail:`Ed25519 signature and slot binding verify under signer key ${Qr(t.publicKeyB64)}`});let u=mh(e,r);a.push(u.line),a.push(gh(u.attestedPcr0,u.line.result));let d=wt(t.proof),h;if(d!==null){let m=hh(n,s,t.slotCounter,t.chainId),p=ph(d.placement,d.originDigest!==void 0?t.proof.attribution?.message??null:null,i?.get(t.proofHash),m,t);a.push(p.line),h=p.fused}let l=eo(a.map(m=>m.result));return{proofHash:t.proofHash,digestB64:f,...t.epochId!==void 0?{epochId:t.epochId}:{},chainId:t.chainId,...t.counter!==void 0?{counter:t.counter}:{},...t.slotCounter!==void 0?{slotCounter:t.slotCounter}:{},...t.publicKeyB64!==void 0?{publicKeyB64:t.publicKeyB64}:{},...o!==void 0&&c?.tier==="full"?{filePath:o}:{},lines:a,result:l,bounds:bh(n),...h!==void 0?{fused:h}:{}}}var Jr="bitgraph:main";function hh(t,e,n,o=Jr){if(o!==Jr||t===void 0||e===void 0||n===void 0||!/^[0-9]+$/.test(n))return null;let r=BigInt(n),i;for(let s of t.lowerBounds){if(s.kind!=="not-before")continue;let a=e.get(s.anchorProofHash);if(a===void 0||a.counter===void 0||!/^[0-9]+$/.test(a.counter)||BigInt(a.counter)>=r)continue;if(i===void 0){i=s;continue}let c=s.blockNumber!==void 0?BigInt(s.blockNumber):BigInt(s.timestamp),f=i.blockNumber!==void 0?BigInt(i.blockNumber):BigInt(i.timestamp);c>f&&(i=s)}return i===void 0?null:{...i.blockNumber!==void 0?{blockNumber:i.blockNumber}:{},blockHash:i.blockHash,timestamp:i.timestamp,anchorProofHash:i.anchorProofHash,evidence:"counter-order"}}var lh="floor undetermined: no anchor precedes this slot in its epoch";function tc(t){return`anchored block ${t.blockNumber!==void 0?`#${t.blockNumber}`:t.blockHash} (${new Date(t.timestamp*1e3).toISOString()})`}function ph(t,e,n,o,r){let i=r.slotCounter??"?",s=t!==null?` (placement ${t})`:" (placement undeclared)",a=o!==null?`assembled after ${tc(o)}, the last verified anchor preceding slot ${i} in this epoch`:r.chainId!==Jr?`floor undetermined: the slot is on chain "${r.chainId}", not the anchored chain`:lh,c=n?.span!==void 0&&n.span!==null?{slotCounter:n.span.slotCounter,commitCounter:n.span.commitCounter,positions:n.span.positions}:r.slotCounter!==void 0&&r.counter!==void 0?{slotCounter:r.slotCounter,commitCounter:r.counter,positions:(BigInt(r.counter)-BigInt(r.slotCounter)).toString()}:null,f=(n?.statements??[]).map(h=>o!==null?h.replace(`at position ${i},`,`at position ${i}, which followed ${tc(o)},`):h),u=(h,l)=>({category:h,placement:n?.placement??t,originDigestB64:n?.originDigestB64??e,evidence:l,statements:f,floor:o,floorDetail:a,span:c});if(n===void 0)return{line:{name:"fused",result:"UNDETERMINED",detail:`marked fused${s}, but neither the fused bytes nor ${e!==null?"the original":"an original"} is in this bundle, so the commitment to slot ${i} cannot be checked`},fused:u("NO_EVIDENCE",null)};let d=n.category==="FUSED_FROM_ORIGIN"||n.fileDigestB64!==n.artifactDigestB64&&n.category!=="NO_MATCH"?"original":"fused-bytes";switch(n.category){case"FUSED_DIRECT":return{line:{name:"fused",result:"TRUE",detail:`the fused bytes carry the commitment to slot ${i}${s}`},fused:u(n.category,"fused-bytes")};case"FUSED_FROM_ORIGIN":return{line:{name:"fused",result:"TRUE",detail:`the original rebuilds the committed fused bytes${s}; they carry the commitment to slot ${i}`},fused:u(n.category,"original")};case"INVALID_SLOT_COMMITMENT":return{line:{name:"fused",result:"FALSE",detail:`the fused bytes do not carry the commitment to this proof's slot ${i}: ${n.reason??""}`},fused:u(n.category,d)};case"INVALID_ORIGIN_ATTRIBUTION":return{line:{name:"fused",result:"FALSE",detail:`the declared origin contradicts the origin inside the fused bytes: ${n.reason??""}`},fused:u(n.category,d)};case"RECONSTRUCTION_MISMATCH":return{line:{name:"fused",result:"FALSE",detail:`the file matching the declared origin does not rebuild the committed fused bytes: ${n.reason??""}`},fused:u(n.category,"original")};case"UNDETERMINED_PLACEMENT":return{line:{name:"fused",result:"UNDETERMINED",detail:`${n.reason??"the placement is not registered"}; this verifier cannot check the commitment`},fused:u(n.category,d)};case"INVALID_UNDERLYING_PROOF":return{line:{name:"fused",result:"UNDETERMINED",detail:"not checked: the proof itself does not verify (see the signature line)"},fused:u(n.category,d)};default:return{line:{name:"fused",result:"UNDETERMINED",detail:`the commitment could not be checked: ${n.reason??n.category}`},fused:u(n.category,d)}}}function mh(t,e){return t===void 0||!t.documentPresent?{line:{name:"attestation",result:"UNDETERMINED",detail:"no attestation document in this proof"}}:e?t.documentValidated?t.userDataBoundToProof!==!0?{line:{name:"attestation",result:"FALSE",detail:"attestation document validates but its user_data is not this proof: the document belongs to some other proof"},attestedPcr0:t.attestedPcr0}:t.pcr0MatchesDeclared!==!0?{line:{name:"attestation",result:"FALSE",detail:`attestation validates and binds this proof, but its PCR0 ${an(t.attestedPcr0)} is not the measurement the signed body declares ${an(t.declaredMeasurement)}`},attestedPcr0:t.attestedPcr0}:{line:{name:"attestation",result:"TRUE",detail:`AWS Nitro attestation validates to the AWS root, binds this exact proof (user_data), and attests PCR0 ${an(t.attestedPcr0)}`},attestedPcr0:t.attestedPcr0}:{line:{name:"attestation",result:"FALSE",detail:`attestation document does not validate: ${t.validationFailure??"unspecified failure"}`}}:{line:{name:"attestation",result:"UNDETERMINED",detail:"attestation not checked: this environment cannot verify ECDSA P-384 (no WebCrypto); open the verifier from a file or https page, or run bitgraph-play check"}}}function gh(t,e){if(e!=="TRUE"||t===void 0)return{name:"enclave",result:"UNDETERMINED",detail:"enclave identity rests on a validated attestation, which this recording does not have here"};let n=ah.find(o=>o.pcr0===t.toLowerCase());return n===void 0?{name:"enclave",result:"UNDETERMINED",detail:`PCR0 ${an(t)} is not among the BitGraph enclave measurements this verifier knows (player ${Yr}); compare it against the measurements published at bitgraph.ing/docs/self-host-tee`}:{name:"enclave",result:"TRUE",detail:`PCR0 ${an(t)} is the published BitGraph ${n.label} measurement (${n.period})`}}function bh(t){if(t===void 0)return{status:"unanchored",detail:"no verified Ethereum anchor bounds this recording in this bundle"};let e=nc(t.lowerBounds,"not-before"),n=nc(t.upperBounds,"not-after"),o=e===void 0?void 0:oc(e),r=n===void 0?void 0:oc(n),i=o!==void 0&&r!==void 0?"lower-bounded-with-following-anchor":o!==void 0?"lower-bounded":r!==void 0?"upper-bounded":"unanchored",s=i==="unanchored"?"no verified Ethereum anchor bounds this recording in this bundle":`recorded ${yh(i,o,r)}`;return{status:i,...o!==void 0?{notBefore:o}:{},...r!==void 0?{notAfter:r}:{},detail:s}}function yh(t,e,n){switch(t){case"lower-bounded-with-following-anchor":return`after Ethereum block ${at(e)} (header verified in this bundle); precedes an anchor that consumed block ${at(n)} (header verified), an anchor-latency assumption rather than an upper bound on this recording`+Xr(e.weaker||n.weaker);case"lower-bounded":return`after Ethereum block ${at(e)} (header verified in this bundle); no verified upper bound here`+Xr(e.weaker);case"upper-bounded":return`before Ethereum block ${at(n)} (header verified in this bundle); no verified lower bound here`+Xr(n.weaker);default:return"with no verified Ethereum bound in this bundle"}}function nc(t,e){let n=t.filter(r=>r.kind===e);return n.length===0?void 0:[...n].sort((r,i)=>{let s=r.blockNumber!==void 0?BigInt(r.blockNumber):BigInt(r.timestamp),a=i.blockNumber!==void 0?BigInt(i.blockNumber):BigInt(i.timestamp);return s!==a?e==="not-before"?s>a?-1:1:s<a?-1:1:r.weaker!==i.weaker?r.weaker?1:-1:0})[0]}function oc(t){return{...t.blockNumber!==void 0?{blockNumber:t.blockNumber}:{},blockHash:t.blockHash,timestamp:t.timestamp,anchorProofHash:t.anchorProofHash,evidence:t.evidence,weaker:t.weaker}}function wh(t){switch(t.status){case"lower-bounded-with-following-anchor":return`after Ethereum block ${at(t.notBefore)}, then an anchor at block ${at(t.notAfter)}`;case"lower-bounded":return`after Ethereum block ${at(t.notBefore)}`;case"upper-bounded":return`before Ethereum block ${at(t.notAfter)}`;default:return"with no Ethereum bound in this bundle"}}function at(t){return t.blockNumber!==void 0?t.blockNumber:t.blockHash}function Xr(t){return t?"; ordered by counter position within the epoch, since the recordings between are not in this bundle":""}function xh(t,e,n){let o=[],r=t.verification;r===void 0?o.push({name:"signature",result:"UNDETERMINED",detail:"the anchor proof was not verified"}):r.status==="failed"?o.push({name:"signature",result:"FALSE",detail:`the anchor proof does not verify: ${r.reason??"unspecified failure"}`}):o.push({name:"signature",result:"TRUE",detail:`anchor proof verifies under signer key ${Qr(t.publicKeyB64)}`});let i;if(n.length>0){let s=n.find(a=>a.verified);if(s!==void 0)i=s.witnessPath,o.push({name:"witness",result:"TRUE",detail:`block header ${s.witnessPath} hashes (keccak-256) to the anchored block hash${e.blockNumber!==void 0?` of block ${e.blockNumber}`:""}`});else{let a=n[0];i=a.witnessPath,o.push({name:"witness",result:"FALSE",detail:`block header ${a.witnessPath} contradicts this anchor: ${a.detail??a.reason??"witness verification failed"}`})}}return{proofHash:t.proofHash,...t.epochId!==void 0?{epochId:t.epochId}:{},chainId:t.chainId,...t.counter!==void 0?{counter:t.counter}:{},...e.blockNumber!==void 0?{blockNumber:e.blockNumber}:{},...e.blockHash!==void 0?{blockHash:e.blockHash}:{},...i!==void 0?{witnessPath:i}:{},lines:o,result:eo(o.map(s=>s.result))}}function Eh(t){let e=[],n=new Set,o=r=>{n.has(r)||(n.add(r),e.push({name:"contradiction",result:"FALSE",detail:r}))};for(let r of t.anomalies.anomalies)ch.has(r.code)||o(`${r.code}: ${r.message}`);for(let r of t.anomalies.divergences)o(`${r.kind}: ${r.explanation}`);for(let r of t.authorities.anomalies)o(`${r.code}: ${r.message}`);for(let r of t.witnesses.findings)(r.code==="witness-unmatched"||r.code==="witness-malformed"||r.code==="witness-rlp-invalid")&&o(`${r.code}: ${r.message}`);for(let r of t.ingest.findings)r.code==="proofhash-mismatch"&&o(`${r.code}: ${r.message}${r.path!==void 0?` (${r.path})`:""}`);return e}function Bh(t,e,n,o){let r=[],i=0n,s=0;for(let d of t.anomalies.anomalies)if(d.code==="unexplained-counter-positions"){let h=d.details?.count;h!==void 0&&/^[0-9]+$/.test(h)&&(i+=BigInt(h))}else d.code==="chain-break-missing"&&(s+=d.proofHashes.length);i>0n&&r.push(`${i} causal position${i===1n?"":"s"} between the earliest and latest recording here ${i===1n?"is":"are"} not in this bundle: normal for an export, which is an excerpt of the chain; a full-epoch audit checks them`),s>0&&r.push(`${s} recording${s===1?"":"s"} link${s===1?"s":""} to a predecessor that is not in this bundle: normal for an export`);let a=t.ingest.artifacts.filter(d=>d.matchedProofHashes.length===0&&o?.has(d.sha256Hex)===!0);a.length>0&&r.push(`${a.length} file${a.length===1?"":"s"} in this bundle ${a.length===1?"is":"are"} the original of a fused recording: ${a.slice(0,5).map(d=>d.paths[0]??"(unnamed)").join(", ")}${a.length>5?", \u2026":""}. The original itself receives only the ceiling (it existed no later than the commit); the fused bytes receive the interval`);let c=t.ingest.artifacts.filter(d=>d.matchedProofHashes.length===0&&o?.has(d.sha256Hex)!==!0);if(c.length>0&&e.length>0){let d=c.slice(0,5).map(h=>`${h.paths[0]??"(unnamed)"} (sha256:${h.sha256Hex.slice(0,16)}\u2026)`).join(", ");r.push(`${c.length} file${c.length===1?"":"s"} in this bundle match${c.length===1?"es":""} no recording here: ${d}${c.length>5?", \u2026":""}. If ${c.length===1?"it":"one of them"} was meant to be a recorded file, its bytes differ from what was recorded`)}let f=n.filter(d=>d.witnessPath===void 0);f.length>0&&r.push(`${f.length} Ethereum anchor${f.length===1?"":"s"} in this bundle ha${f.length===1?"s":"ve"} no block-header witness file, so ${f.length===1?"its":"their"} block hash${f.length===1?" is":"es are"} not verified here and no bound is derived from ${f.length===1?"it":"them"}`);for(let d of t.ingest.unsupportedVersions)r.push(`${d.path} is proof-shaped but its version "${d.version}" is not bitgraph/1; it was not checked`);let u=t.ingest.counts;if((u.exactDuplicates>0||u.semanticDuplicates>0)&&r.push(`${u.exactDuplicates+u.semanticDuplicates} duplicate proof file${u.exactDuplicates+u.semanticDuplicates===1?"":"s"} collapsed to one recording each`),t.ingest.manifest!==void 0)for(let d of t.ingest.findings)typeof d.code=="string"&&d.code.startsWith("manifest-")&&r.push(`${d.code}: ${d.message}`);return e.length===0&&n.length===0&&r.push("no BitGraph proofs were found in this bundle"),r}function vh(t){let e=[];return t&&e.push("whether the anchored Ethereum blocks are canonical: their headers are recomputed here, but canonicality needs an Ethereum node or a block explorer"),e.push("whether the public ledger holds these exact recordings at these positions: this is an offline check; drop the file on bitgraph.ing to compare against the ledger"),e.push("whether an epoch key was later quarantined: that is published outside any bundle"),e}function Ah(t,e,n,o){if(e.length===0&&n.length===0)return"UNDETERMINED: no BitGraph proofs were found in this bundle.";let r=e.length,i=`${r} recording${r===1?"":"s"}`;if(t==="TRUE"){let a=e[0];return r===1&&a!==void 0?`TRUE: this file was recorded${a.counter!==void 0?` at position ${a.counter}${a.epochId!==void 0?` of epoch ${Qr(a.epochId)}`:""}`:""}, ${wh(a.bounds)}.`:`TRUE: ${i} verified: files match, signatures and attestations hold, enclave measurements published${n.length>0?", Ethereum bounds verified from block headers in the bundle":""}.`}if(t==="FALSE")return`FALSE: evidence in this bundle contradicts itself. ${[...e.flatMap(c=>c.lines.filter(f=>f.result==="FALSE").map(f=>`${f.name}: ${f.detail}`)),...n.flatMap(c=>c.lines.filter(f=>f.result==="FALSE").map(f=>`${f.name}: ${f.detail}`)),...o.map(c=>c.detail)][0]??""}`.trim();let s=[...e.flatMap(a=>a.lines.filter(c=>c.result==="UNDETERMINED").map(c=>c.detail)),...n.flatMap(a=>a.lines.filter(c=>c.result==="UNDETERMINED").map(c=>c.detail))];return`UNDETERMINED: nothing here contradicts the ${i}, but the evidence does not fully decide. ${s[0]??""}`.trim()}function Qr(t){return t===void 0?"(none)":t.length>12?`${t.slice(0,12)}\u2026`:t}function an(t){return t===void 0?"(none)":t.length>16?`${t.slice(0,16)}\u2026`:t}yn.sha512Async=async(...t)=>An(yn.concatBytes(...t));var uc=typeof globalThis.crypto<"u"&&globalThis.crypto.subtle!==void 0;function dc(t){return new Promise((e,n)=>{let o=[],r=()=>{t.readEntries(i=>{if(i.length===0){e(o);return}o.push(...i),r()},n)};r()})}function Ih(t){return new Promise((e,n)=>t.file(e,n))}async function oi(t,e,n){if(t.isFile){let o=await Ih(t);n.push({path:e+t.name,file:o});return}if(t.isDirectory){let o=t.createReader(),r=await dc(o);for(let i of r)i.name!==".DS_Store"&&await oi(i,`${e}${t.name}/`,n)}}async function kh(t){let n=Array.from(t.items??[]).map(r=>typeof r.webkitGetAsEntry=="function"?r.webkitGetAsEntry():null).filter(r=>r!==null);if(n.length===0)return Array.from(t.files??[]).map(r=>({path:r.name,file:r}));let o=[];if(n.length===1&&n[0]!==void 0&&n[0].isDirectory){let r=n[0];for(let i of await dc(r.createReader()))i.name!==".DS_Store"&&await oi(i,"",o)}else for(let r of n)await oi(r,"",o);return o.length===0?Array.from(t.files??[]).map(r=>({path:r.name,file:r})):o}function ic(t){let e=Array.from(t.files??[]),n=e.map(s=>s.webkitRelativePath||s.name),o=n.map(s=>s.indexOf("/")),r=n.length>0&&o.every(s=>s>0)?n[0].slice(0,o[0]):void 0,i=r!==void 0&&n.every(s=>s.startsWith(`${r}/`));return e.map((s,a)=>({path:i?n[a].slice(r.length+1):n[a],file:s})).filter(s=>!s.path.endsWith("/.DS_Store")&&s.path!==".DS_Store")}function Sh(t){return t.map(e=>({path:e.path,open:()=>e.file.arrayBuffer().then(n=>new Uint8Array(n))}))}function $(t,e={},n=[]){let o=document.createElement(t);for(let[r,i]of Object.entries(e))r==="class"?o.className=i:o.setAttribute(r,i);for(let r of n)o.append(typeof r=="string"?document.createTextNode(r):r);return o}function ri(t){return t==="TRUE"?null:$("span",{class:t==="FALSE"?"mark false":"mark undet"},[t])}function fn(t,e,n={}){let o=$("div",{class:"field-head"},[$("span",{class:"field-label"},[t])]),r=n.mark!==void 0?ri(n.mark):null;return r!==null&&o.append(r),$("div",{class:"field"},[o,$("span",{class:n.mono?"field-value mono":"field-value"},[e])])}function ct(t,e,n={}){let o=n.open===!0,r=$("span",{class:"chev","aria-hidden":"true"});r.innerHTML='<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="square" stroke-linejoin="miter"><path d="M9 6 L15 12 L9 18"/></svg>';let i=$("button",{class:`opener-head${n.tone==="danger"?" danger":""}`,type:"button","aria-expanded":String(o)},[$("span",{},[t]),r]),s=$("div",{class:"opener-body"},e),a=$("section",{class:"card"},[i,s]),c=()=>{i.classList.toggle("open",o),i.setAttribute("aria-expanded",String(o)),s.hidden=!o,r.classList.toggle("open",o)};return i.addEventListener("click",()=>{o=!o,c()}),c(),a}function Th(t){return t==="TRUE"?"BitGraph Verified":t==="FALSE"?"Verification Failed":"Not Fully Verified"}function Hh(t){return t===void 0?"":`#${Number(t).toLocaleString("en-US")}`}function Ch(t){return new Date(t*1e3).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})}function cn(t,e){return new Date(t*1e3).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",second:"2-digit",...e?{timeZoneName:"short"}:{}})}function Rh(t){return new Date(t*1e3).toLocaleString("en-US",{month:"numeric",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit",timeZoneName:"short"})}function sc(t){let e=t.bounds,n=i=>$("span",{class:"when-grey"},[i]),o=i=>$("span",{class:"when-dark"},[i]),r=$("div",{class:"when"});if(e.notBefore!==void 0||e.notAfter!==void 0){let i=e.notBefore??e.notAfter;r.append($("div",{class:"when-date"},[Ch(i.timestamp)]));let s=$("div",{class:"when-line"});e.notBefore!==void 0&&e.notAfter!==void 0?s.append(n("after "),o(cn(e.notBefore.timestamp,!0)),n(", then an anchor at "),o(cn(e.notAfter.timestamp,!1)),n(" (not an upper bound)")):e.notBefore!==void 0?s.append(n("after "),o(cn(e.notBefore.timestamp,!0))):e.notAfter!==void 0&&s.append(n("no lower bound in this bundle; an anchor followed at "),o(cn(e.notAfter.timestamp,!0)),n(" (not an upper bound)")),r.append(s)}else r.append($("div",{class:"when-line"},[n("no verified Ethereum bound in this bundle")]));return r}function ei(t){if(t.fused===void 0)return null;let e=i=>$("span",{class:"when-grey"},[i]),n=i=>$("span",{class:"when-dark"},[i]),o=$("div",{class:"when"}),r=$("div",{class:"when-line"});return t.fused.floor!==null?r.append(e("fused bytes assembled after "),n(cn(t.fused.floor.timestamp,!0)),e(`, the last anchor before slot ${t.fused.span?.slotCounter??"?"}`)):r.append(e(t.fused.floorDetail)),o.append(r),o}var $h=/\.(jpe?g|png|gif|webp|avif|bmp|svg)$/i,Ph=/\.(mp4|m4v|mov|webm|ogv)$/i,Dh=/\.(mp3|wav|m4a|aac|flac|ogg|oga)$/i,Nh=/\.(txt|md|markdown|json|csv|tsv|log|xml|yaml|yml|html?|css|js|ts|py|sh|rtf)$/i;function Mh(t){let e=t.subarray(0,Math.min(2048,t.length));if(!e.length)return!1;let n=0;for(let o of e){if(o===0)return!1;(o===9||o===10||o===13||o>=32)&&n++}return n/e.length>.97}function Lh(t,e){let n=t.toLowerCase();return n.endsWith(".pdf")?"pdf":$h.test(n)?"image":Ph.test(n)?"video":Dh.test(n)?"audio":Nh.test(n)||Mh(e)?"text":"other"}function Oh(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(t<10*1024?1:0)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function Fh(t,e,n){if(n==="image"||n==="video"){let o=URL.createObjectURL(t),r=n==="image"?$("img",{src:o,alt:t.name,style:"display:block;max-width:100%;max-height:min(70vh,640px);width:auto;height:auto;object-fit:contain;border-radius:0"}):$("video",{src:o,controls:"",style:"display:block;max-width:100%;max-height:min(70vh,640px);border-radius:0"});return $("div",{style:"padding:20px;display:flex;align-items:center;justify-content:center"},[r])}if(n==="audio"){let o=URL.createObjectURL(t);return $("div",{style:"padding:20px 16px"},[$("audio",{src:o,controls:"",style:"display:block;width:100%"})])}if(n==="text")try{let o=new TextDecoder("utf-8",{fatal:!1}).decode(e.subarray(0,6e3)),r=o.split(`
|
|
153
|
-
`),i=
|
|
154
|
-
`).slice(0,3e3),s=
|
|
155
|
-
\u2026`:"")])}catch{return null}return null}function
|
|
152
|
+
-----END CERTIFICATE-----`;function sh(){return nc.replace(/-----BEGIN CERTIFICATE-----/,"").replace(/-----END CERTIFICATE-----/,"").replace(/\s+/g,"")}function rc(){return new Uint8Array(B.Buffer.from(sh(),"base64"))}async function ic(t,e){let n=[],r={},o,i,s,a,c,f=()=>({documentValid:!1,checks:n,failure:[...n].reverse().find(u=>!u.pass)?.detail,...o!==void 0?{pcr0:o}:{},pcrs:r,...i!==void 0?{moduleId:i}:{},...s!==void 0?{timestamp:s}:{},...a!==void 0?{certChainLength:a}:{},...c!==void 0?{userDataB64:c}:{}});try{let u=fh(t);if(u===null)return n.push({name:"CBOR Decode",pass:!1,detail:"reportB64 is not valid base64"}),f();let d=Xe(u,0).value;if(!Array.isArray(d)||d.length<4)return n.push({name:"CBOR Decode",pass:!1,detail:"Not a valid COSE_Sign1 array"}),f();n.push({name:"CBOR Decode",pass:!0,detail:"COSE_Sign1 envelope parsed"});let h=d[0],l=d[2],m=d[3];if(!(h instanceof Uint8Array)||!(l instanceof Uint8Array)||!(m instanceof Uint8Array))return n.push({name:"COSE Structure",pass:!1,detail:"Missing protected/payload/signature"}),f();let p=Xe(l,0).value;if(!p||typeof p!="object"||Array.isArray(p))return n.push({name:"Payload Decode",pass:!1,detail:"Could not decode attestation payload"}),f();r=mh(p),o=r[0],i=typeof p.module_id=="string"?p.module_id:void 0,s=typeof p.timestamp=="number"?p.timestamp:void 0;let w=p.user_data;c=w instanceof Uint8Array&&w.length>0?B.Buffer.from(w).toString("base64"):void 0;let b=p.cabundle,k=p.certificate;if(!(k instanceof Uint8Array))return n.push({name:"Leaf Certificate",pass:!1,detail:"No leaf certificate in attestation"}),f();a=(Array.isArray(b)?b.length:0)+1;let v=Zo(k),O=hh(h,l),z=await Yo(m,O,v.publicKey);if(n.push({name:"ECDSA P-384 Signature",pass:z,detail:z?"Attestation signed by leaf certificate":"Signature verification failed against leaf certificate public key"}),!z)return f();if(!Array.isArray(b)||b.length===0||!b.every(A=>A instanceof Uint8Array))return n.push({name:"Certificate Chain",pass:!1,detail:"Empty cabundle"}),f();let S=[...b,k].map(Zo),_=!0,F="";for(let A=1;A<S.length;A++){let C=S[A],M=S[A-1];if(!await Yo(C.signature,C.tbsCertificate,M.publicKey)){_=!1,F=`Certificate ${A} signature invalid (parent: ${A-1})`;break}}if(n.push({name:"Certificate Chain",pass:_,detail:_?`${S.length} certificates, each signed by parent`:F}),!_)return f();let G=e?.trustedRootCaDer===void 0,q=Zo(e?.trustedRootCaDer??rc()),ge=S[0],D=await Yo(ge.signature,ge.tbsCertificate,q.publicKey);if(n.push({name:"AWS Nitro Root CA",pass:D,detail:D?G?"Chain anchored to AWS Nitro Root G1 (CN=aws.nitro-enclaves)":"Chain anchored to the supplied trust root (non-default trust material)":G?"Top of chain not signed by AWS Nitro Root CA":"Top of chain not signed by the supplied trust root"}),!D)return f();let ae=!0,re=`All ${S.length} certificate validity windows contain the document timestamp`;if(s===void 0)ae=!1,re="Attestation document carries no timestamp; certificate validity cannot be evaluated offline";else for(let A=0;A<S.length;A++){let C=S[A];if(s<C.notBeforeMs||s>C.notAfterMs){ae=!1,re=`Certificate ${A} validity window [${new Date(C.notBeforeMs).toISOString()}, ${new Date(C.notAfterMs).toISOString()}] does not contain the document timestamp ${new Date(s).toISOString()}`;break}}if(n.push({name:"Certificate Validity Window",pass:ae,detail:re}),!ae)return f();let L;e?.expectedPcr0!==void 0&&(L=o===e.expectedPcr0,n.push({name:"PCR0 Match",pass:L,detail:L?"PCR0 inside attestation matches declared measurement":`PCR0 mismatch: expected ${e.expectedPcr0.slice(0,16)}..., got ${(o??"").slice(0,16)}...`}));let E;return e?.expectedUserDataB64!==void 0&&(E=c!==void 0&&c===e.expectedUserDataB64,n.push({name:"Bound to this proof",pass:E,detail:E?"Attestation user_data matches this proof's canonical hash":c!==void 0?"Attestation user_data does not match this proof":"Attestation carries no user_data to bind"})),{documentValid:!0,checks:n,...o!==void 0?{pcr0:o}:{},pcrs:r,...i!==void 0?{moduleId:i}:{},...s!==void 0?{timestamp:s}:{},certChainLength:a,...c!==void 0?{userDataB64:c}:{},...L!==void 0?{pcr0Matches:L}:{},...E!==void 0?{userDataMatches:E}:{}}}catch(u){return n.push({name:"Verification Error",pass:!1,detail:u instanceof Error?u.message:String(u)}),f()}}async function Xo(t,e,n){let r=[],o=[],i={proofsWithDeclaredMeasurement:0,proofsWithDocument:0,documentsValidated:0,documentsFailed:0,pcr0Matches:0,pcr0Mismatches:0,userDataBound:0,userDataUnbound:0};for(let s of t.proofs){let a=s.measurement!==void 0&&s.measurement.length>0?s.measurement:void 0;a!==void 0&&i.proofsWithDeclaredMeasurement++;let c=ch(s),f={proofHash:s.proofHash,declaredMeasurementPresent:a!==void 0,...a!==void 0?{declaredMeasurement:a}:{},documentPresent:c!==void 0,...c?.format!==void 0?{attestationFormat:c.format}:{},documentValidated:!1,checks:[]};if(c!==void 0){i.proofsWithDocument++;let u=await ic(c.reportB64,{...a!==void 0?{expectedPcr0:a}:{},expectedUserDataB64:bo(s.proof),...n?.trustedRootCaDer!==void 0?{trustedRootCaDer:n.trustedRootCaDer}:{}});f.documentValidated=u.documentValid,f.checks=u.checks,u.pcr0!==void 0&&(f.attestedPcr0=u.pcr0),f.pcrs=u.pcrs,u.moduleId!==void 0&&(f.moduleId=u.moduleId),u.timestamp!==void 0&&(f.timestamp=u.timestamp),u.certChainLength!==void 0&&(f.certChainLength=u.certChainLength),u.userDataB64!==void 0&&(f.userDataB64=u.userDataB64),u.documentValid?(i.documentsValidated++,u.pcr0Matches!==void 0&&(f.pcr0MatchesDeclared=u.pcr0Matches,u.pcr0Matches?i.pcr0Matches++:(i.pcr0Mismatches++,o.push({code:"attestation-measurement-mismatch",...Go(s),message:"the validated attestation document's PCR0 does not equal the proof's declared environment.measurement. Declared and attested measurements are reported separately and disagree here.",details:{proofHash:s.proofHash,declared:a,...u.pcr0!==void 0?{attested:u.pcr0}:{}}}))),u.userDataMatches!==void 0&&(f.userDataBoundToProof=u.userDataMatches,u.userDataMatches?i.userDataBound++:(i.userDataUnbound++,o.push({code:"attestation-user-data-mismatch",...Go(s),message:"the validated attestation document's user_data is not bound to this proof's canonical hash. A genuine attestation lifted from another proof would look exactly like this.",details:{proofHash:s.proofHash,...u.userDataB64!==void 0?{userDataB64:u.userDataB64}:{}}})))):(i.documentsFailed++,u.failure!==void 0&&(f.validationFailure=u.failure),o.push({code:"attestation-invalid",...Go(s),message:`attestation document failed offline validation: ${u.failure??"unknown"}. Presence of a document is reported separately and proves nothing by itself.`,details:{proofHash:s.proofHash}}))}r.push(f)}return e!==void 0&&ah(e,r),{records:r,findings:o,counts:i}}function ah(t,e){let n=new Map(e.map(r=>[r.proofHash,r]));for(let r of t.groups){if(!r.attestationPresent)continue;let o=r.proofHashes.map(f=>n.get(f)).filter(f=>f!==void 0&&f.documentPresent);if(o.length===0)continue;let i=o.filter(f=>f.documentValidated),s=o.length-i.length,a=[...new Set(i.map(f=>f.attestedPcr0).filter(f=>f!==void 0))].sort(),c=a.length===1?a[0]:void 0;r.attested={status:s===0&&i.length>0?"validated":"validation-failed",...c!==void 0?{attestedMeasurement:c}:{},...c!==void 0&&r.measurement!==void 0?{matchesDeclared:c===r.measurement}:{},validatedProofCount:i.length,failedProofCount:s,...a.length>1?{attestedMeasurements:a}:{}}}}function ch(t){let e=t.proof.environment;if(e===null||typeof e!="object"||Array.isArray(e))return;let n=e.attestation;if(n===null||typeof n!="object"||Array.isArray(n))return;let r=n.reportB64;if(typeof r!="string"||r.length===0)return;let o=n.format;return{reportB64:r,...typeof o=="string"?{format:o}:{}}}function Go(t){let e=t.sources[0]?.path;return e!==void 0?{path:e}:{}}function fh(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4!==0;)e+="=";let n=B.Buffer.from(e,"base64");return n.toString("base64")!==e?null:new Uint8Array(n)}function Jo(t){return t<24?new Uint8Array([t]):t<256?new Uint8Array([24,t]):t<65536?new Uint8Array([25,t>>8,t&255]):new Uint8Array([26,t>>>24&255,t>>>16&255,t>>>8&255,t&255])}function Wo(t){let e=Jo(t.length);e[0]=e[0]&31|64;let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n}function uh(t){let e=new TextEncoder().encode(t),n=Jo(e.length);n[0]=n[0]&31|96;let r=new Uint8Array(n.length+e.length);return r.set(n,0),r.set(e,n.length),r}function dh(t){let e=Jo(t.length);e[0]=e[0]&31|128;let n=e.length+t.reduce((i,s)=>i+s.length,0),r=new Uint8Array(n),o=0;r.set(e,o),o+=e.length;for(let i of t)r.set(i,o),o+=i.length;return r}function hh(t,e){return dh([uh("Signature1"),Wo(t),Wo(new Uint8Array(0)),Wo(e)])}function Xe(t,e=0){let n=t[e];if(n===void 0)throw new Error("CBOR: unexpected end of input");let r=n>>5,o=n&31;e++;let i=a=>{let c=t[a];if(c===void 0)throw new Error("CBOR: unexpected end of input");return c};function s(){if(o<24)return o;if(o===24){let a=i(e);return e+=1,a}if(o===25){let a=i(e)<<8|i(e+1);return e+=2,a}if(o===26){let a=(i(e)<<24|i(e+1)<<16|i(e+2)<<8|i(e+3))>>>0;return e+=4,a}if(o===27){let a=0;for(let c=0;c<8;c++)a=a*256+i(e+c);return e+=8,a}throw new Error(`Unsupported CBOR length info: ${o}`)}switch(r){case 0:return{value:s(),offset:e};case 1:return{value:-1-s(),offset:e};case 2:{let a=s();if(e+a>t.length)throw new Error("CBOR: byte string is truncated");return{value:t.slice(e,e+a),offset:e+a}}case 3:{let a=s();if(e+a>t.length)throw new Error("CBOR: text string is truncated");return{value:new TextDecoder().decode(t.slice(e,e+a)),offset:e+a}}case 4:{if(o===31){let f=[];for(;i(e)!==255;){let u=Xe(t,e);f.push(u.value),e=u.offset}return{value:f,offset:e+1}}let a=s(),c=[];for(let f=0;f<a;f++){let u=Xe(t,e);c.push(u.value),e=u.offset}return{value:c,offset:e}}case 5:{if(o===31){let f={};for(;i(e)!==255;){let u=Xe(t,e);e=u.offset;let d=Xe(t,e);e=d.offset,f[String(u.value)]=d.value}return{value:f,offset:e+1}}let a=s(),c={};for(let f=0;f<a;f++){let u=Xe(t,e);e=u.offset;let d=Xe(t,e);e=d.offset,c[String(u.value)]=d.value}return{value:c,offset:e}}case 6:return s(),Xe(t,e);case 7:{if(o===20)return{value:!1,offset:e};if(o===21)return{value:!0,offset:e};if(o===22)return{value:null,offset:e};if(o===23)return{value:void 0,offset:e};throw new Error(`Unsupported CBOR simple value: ${o}`)}default:throw new Error(`Unsupported CBOR major type: ${r}`)}}function Zo(t){let n=ln(t,0).contentStart,r=se(t,n),o=t.slice(n,r.end);n=r.end,n=se(t,n).end;let s=se(t,n),a=t.slice(s.contentStart+1,s.end),c=ph(a,48),{publicKey:f,notBeforeMs:u,notAfterMs:d}=lh(o);return{tbsCertificate:o,signature:c,publicKey:f,notBeforeMs:u,notAfterMs:d}}function se(t,e){let n=t[e];if(n===void 0)throw new Error("DER: unexpected end of input");let r=e+1,o=t[r++];if(o===void 0)throw new Error("DER: unexpected end of input");if(o&128){let s=o&127;o=0;for(let a=0;a<s;a++){let c=t[r++];if(c===void 0)throw new Error("DER: unexpected end of input");o=o*256+c}}let i=r+o;if(i>t.length)throw new Error("DER: element is truncated");return{tag:n,contentStart:r,contentEnd:i,end:i}}function ln(t,e){let n=se(t,e);if(n.tag!==48)throw new Error(`Expected SEQUENCE at offset ${e}, got tag 0x${n.tag.toString(16)}`);return n}function lh(t){let n=ln(t,0).contentStart;t[n]===160&&(n=se(t,n).end),n=se(t,n).end,n=se(t,n).end,n=se(t,n).end;let r=ln(t,n),o=r.contentStart,i=se(t,o);o=i.end;let s=se(t,o),a=oc(t,i),c=oc(t,s);n=r.end,n=se(t,n).end;let u=ln(t,n).contentStart;u=se(t,u).end;let h=se(t,u);return{publicKey:t.slice(h.contentStart+1,h.end),notBeforeMs:a,notAfterMs:c}}function oc(t,e){let n=String.fromCharCode(...t.slice(e.contentStart,e.contentEnd)),r,o;if(e.tag===23){if(!/^\d{12}Z$/.test(n))throw new Error(`DER: malformed UTCTime "${n}"`);let u=Number.parseInt(n.slice(0,2),10);r=u<50?2e3+u:1900+u,o=n.slice(2)}else if(e.tag===24){if(!/^\d{14}Z$/.test(n))throw new Error(`DER: malformed GeneralizedTime "${n}"`);r=Number.parseInt(n.slice(0,4),10),o=n.slice(4)}else throw new Error(`DER: expected a Time value, got tag 0x${e.tag.toString(16)}`);let i=Number.parseInt(o.slice(0,2),10),s=Number.parseInt(o.slice(2,4),10),a=Number.parseInt(o.slice(4,6),10),c=Number.parseInt(o.slice(6,8),10),f=Number.parseInt(o.slice(8,10),10);return Date.UTC(r,i-1,s,a,c,f)}function ph(t,e){let r=ln(t,0).contentStart,o=se(t,r);if(o.tag!==2)throw new Error("Expected INTEGER for r");let i=t.slice(o.contentStart,o.end);r=o.end;let s=se(t,r);if(s.tag!==2)throw new Error("Expected INTEGER for s");let a=t.slice(s.contentStart,s.end);if(i[0]===0&&i.length>e&&(i=i.slice(1)),a[0]===0&&a.length>e&&(a=a.slice(1)),i.length>e||a.length>e)throw new Error("ECDSA signature component longer than the curve coordinate size");let c=new Uint8Array(e*2);return c.set(i,e-i.length),c.set(a,e*2-a.length),c}async function Yo(t,e,n){if(n.length!==97||n[0]!==4||t.length!==96)return!1;try{let r=await fo.subtle.importKey("raw",n,{name:"ECDSA",namedCurve:"P-384"},!1,["verify"]);return await fo.subtle.verify({name:"ECDSA",hash:"SHA-384"},r,t,e)}catch{return!1}}function mh(t){let e={},n=t.pcrs;if(!n||typeof n!="object")return e;for(let[r,o]of Object.entries(n))if(o instanceof Uint8Array){let i=B.Buffer.from(o).toString("hex");i.replace(/0/g,"").length>0&&(e[Number(r)]=i)}return e}y();var cr="0.4.1";function sc(){return cr}async function Qo(t,e){let n=e?.startedAt??new Date().toISOString(),r=await Po(t,e?.trustAnchors!==void 0?{trustAnchors:e.trustAnchors}:void 0),o=await Do(t),i=await No(t,o),s=Oo(t),a=Uo(t),c=await zo(t,a),f=qo(t,o,a,c),u=await Xo(t,s,e?.trustedRootCaDer!==void 0?{trustedRootCaDer:e.trustedRootCaDer}:void 0);return{runMetadata:{toolVersion:sc(),startedAt:n,bundlePath:t.bundlePath,container:t.container},ingest:t,verification:r,reconstruction:o,anomalies:i,authorities:s,anchors:a,witnesses:c,temporal:f,attestations:u}}y();y();y();y();y();function fr(t){let e=!1;for(let n of t){if(n==="FALSE")return"FALSE";n==="UNDETERMINED"&&(e=!0)}return e?"UNDETERMINED":"TRUE"}y();y();var ei="0.10.0";var xh=[{pcr0:"8530a6399399c4f23d89f5a1faa2e8bf2e09a5959f117070fca08148377f92c902c695fc926c17f67f35f110327dca92",label:"genesis",period:"2026-05-15 to 2026-06-27"},{pcr0:"bb9dd158703603ec222fe565495ceaa7edc08f665da5c1cddad91442ac2211731390267036d79deb720d13fb704f648a",label:"enclave v2 (reproducible)",period:"2026-06-27 to 2026-07-05"},{pcr0:"e2fccbae77ee40aac4830e84f195e05d69eb4547bbd961f4d3459feba10807140424aca42ad03810354982598c86b9cb",label:"enclave v4 (reproducible)",period:"2026-07-05 to 2026-07-29"},{pcr0:"6483cedffed74680ffb287507744a398b288c3fb943eb3f2e4fe889f8b60b3d575ad8942350360b69a1bd7bf713df27f",label:"enclave v5 (reproducible)",period:"2026-07-29 to 2026-09-05"},{pcr0:"cd8ba52d340fb1be78610b59953ded2ceca23be1cfcc7ab504a26b8fdcd7ba92090f49e28a32d008df046ec4212f77bf",label:"enclave v6 (reproducible)",period:"2026-09-05 onward"}],Eh=new Set(["unexplained-counter-positions","chain-break-missing","epochlink-terminal-missing","epochlink-dangling"]);async function dc(t,e){let n=e,r=await Qo(t,{startedAt:""});if(n?.fuseEvidence===void 0){let o=await Bh(t);n={...n,fuseEvidence:o.evidence,fuseOriginHexes:o.originHexes}}return vh(r,n)}async function Bh(t){let e=new Map,n=new Set,r=[],o=new Set;for(let s of t.proofs){let a=kt(s.proof);if(a===null)continue;let c=qt(s.proof.artifact.digestB64),f=c!==null?we(c):null,u=a.originDigest!==void 0?we(a.originDigest):null;r.push({proof:s,artifactHex:f,originHex:u}),f!==null&&o.add(f),u!==null&&o.add(u)}if(r.length===0)return{evidence:e,originHexes:n};let i=new Map;for await(let s of Ro(t,o))i.has(s.sha256Hex)||i.set(s.sha256Hex,s.bytes);Ve();try{for(let s of r){let a=s.artifactHex!==null?i.get(s.artifactHex):void 0,c=s.originHex!==null?i.get(s.originHex):void 0;c!==void 0&&s.originHex!==null&&n.add(s.originHex);let f=a??c;f!==void 0&&e.set(s.proof.proofHash,await Io({proof:s.proof.proof,bytes:f}))}}finally{Ve()}return{evidence:e,originHexes:n}}function vh(t,e){let n=e?.webCryptoAvailable??!0,r=new Map(t.anchors.anchors.map(p=>[p.proofHash,p])),o=new Map(t.attestations.records.map(p=>[p.proofHash,p])),i=new Map;for(let p of t.temporal.segments)for(let w of p.memberProofHashes)i.set(w,p);let s=new Map;for(let p of t.witnesses.outcomes){if(p.anchorProofHash===void 0)continue;let w=s.get(p.anchorProofHash)??[];w.push(p),s.set(p.anchorProofHash,w)}let a=new Map;for(let p of t.ingest.artifacts)for(let w of p.matchedProofHashes)!a.has(w)&&p.paths[0]!==void 0&&a.set(w,p.paths[0]);let c=[],f=[];for(let p of t.ingest.proofs){let w=r.get(p.proofHash);w!==void 0?f.push(Ph(p,w,s.get(p.proofHash)??[])):c.push(Ah(p,o.get(p.proofHash),i.get(p.proofHash),a.get(p.proofHash),n,e?.fuseEvidence,r))}ac(c),ac(f);let u=Mh(t),d=Dh(t,c,f,e?.fuseOriginHexes),h=Nh(f.length>0),l=[...c.map(p=>p.result),...f.map(p=>p.result),...u.map(p=>p.result)],m=l.length===0?"UNDETERMINED":fr(l);return{check:"bitgraph-check/1",result:m,summary:Lh(m,c,f,u),recordings:c,anchors:f,contradictions:u,notes:d,notChecked:h,evaluator:{name:"bitgraph-player",version:ei,audit:cr},network:"none"}}function ac(t){let e=n=>[n.epochId??"",n.counter!==void 0&&/^[0-9]+$/.test(n.counter)?BigInt(n.counter):void 0];t.sort((n,r)=>{let[o,i]=e(n),[s,a]=e(r);return o!==s?o<s?-1:1:i===void 0||a===void 0?i===void 0?a===void 0?0:1:-1:i<a?-1:i>a?1:0})}function Ah(t,e,n,r,o,i,s){let a=[],c=t.verification,f=t.proof.artifact.digestB64;c?.tier==="full"?a.push({name:"file",result:c.status==="verified"||c.status==="failed"?"TRUE":"UNDETERMINED",detail:c.status==="verified"||c.status==="failed"?`${r??"the matched file"} hashes to the recorded digest ${f}`:`no file in this bundle hashes to the recorded digest ${f}`}):a.push({name:"file",result:"UNDETERMINED",detail:`no file in this bundle hashes to the recorded digest ${f}; the recording cannot be bound to bytes in hand`}),c===void 0?a.push({name:"signature",result:"UNDETERMINED",detail:"the proof was not verified"}):c.status==="failed"?a.push({name:"signature",result:"FALSE",detail:`the proof does not verify: ${c.reason??"unspecified failure"}`}):a.push({name:"signature",result:"TRUE",detail:`Ed25519 signature and slot binding verify under signer key ${ri(t.publicKeyB64)}`});let u=Th(e,o);a.push(u.line),a.push(Hh(u.attestedPcr0,u.line.result));let d=kt(t.proof),h;if(d!==null){let m=Ih(n,s,t.slotCounter,t.chainId),p=Sh(d.placement,d.originDigest!==void 0?t.proof.attribution?.message??null:null,i?.get(t.proofHash),m,t);a.push(p.line),h=p.fused}let l=fr(a.map(m=>m.result));return{proofHash:t.proofHash,digestB64:f,...t.epochId!==void 0?{epochId:t.epochId}:{},chainId:t.chainId,...t.counter!==void 0?{counter:t.counter}:{},...t.slotCounter!==void 0?{slotCounter:t.slotCounter}:{},...t.publicKeyB64!==void 0?{publicKeyB64:t.publicKeyB64}:{},...r!==void 0&&c?.tier==="full"?{filePath:r}:{},lines:a,result:l,bounds:Ch(n),...h!==void 0?{fused:h}:{}}}var ni="bitgraph:main";function Ih(t,e,n,r=ni){if(r!==ni||t===void 0||e===void 0||n===void 0||!/^[0-9]+$/.test(n))return null;let o=BigInt(n),i;for(let s of t.lowerBounds){if(s.kind!=="not-before")continue;let a=e.get(s.anchorProofHash);if(a===void 0||a.counter===void 0||!/^[0-9]+$/.test(a.counter)||BigInt(a.counter)>=o)continue;if(i===void 0){i=s;continue}let c=s.blockNumber!==void 0?BigInt(s.blockNumber):BigInt(s.timestamp),f=i.blockNumber!==void 0?BigInt(i.blockNumber):BigInt(i.timestamp);c>f&&(i=s)}return i===void 0?null:{...i.blockNumber!==void 0?{blockNumber:i.blockNumber}:{},blockHash:i.blockHash,timestamp:i.timestamp,anchorProofHash:i.anchorProofHash,evidence:"counter-order"}}var kh="floor undetermined: no anchor precedes this slot in its epoch";function cc(t){return`anchored block ${t.blockNumber!==void 0?`#${t.blockNumber}`:t.blockHash} (${new Date(t.timestamp*1e3).toISOString()})`}function Sh(t,e,n,r,o){let i=o.slotCounter??"?",s=t!==null?` (placement ${t})`:" (placement undeclared)",a=r!==null?`assembled after ${cc(r)}, the last verified anchor preceding slot ${i} in this epoch`:o.chainId!==ni?`floor undetermined: the slot is on chain "${o.chainId}", not the anchored chain`:kh,c=n?.span!==void 0&&n.span!==null?{slotCounter:n.span.slotCounter,commitCounter:n.span.commitCounter,positions:n.span.positions}:o.slotCounter!==void 0&&o.counter!==void 0?{slotCounter:o.slotCounter,commitCounter:o.counter,positions:(BigInt(o.counter)-BigInt(o.slotCounter)).toString()}:null,f=(n?.statements??[]).map(h=>r!==null?h.replace(`at position ${i},`,`at position ${i}, which followed ${cc(r)},`):h),u=(h,l)=>({category:h,placement:n?.placement??t,originDigestB64:n?.originDigestB64??e,evidence:l,statements:f,floor:r,floorDetail:a,span:c});if(n===void 0)return{line:{name:"fused",result:"UNDETERMINED",detail:`marked fused${s}, but neither the fused bytes nor ${e!==null?"the original":"an original"} is in this bundle, so the commitment to slot ${i} cannot be checked`},fused:u("NO_EVIDENCE",null)};let d=n.category==="FUSED_FROM_ORIGIN"||n.fileDigestB64!==n.artifactDigestB64&&n.category!=="NO_MATCH"?"original":"fused-bytes";switch(n.category){case"FUSED_DIRECT":return{line:{name:"fused",result:"TRUE",detail:`the fused bytes carry the commitment to slot ${i}${s}`},fused:u(n.category,"fused-bytes")};case"FUSED_FROM_ORIGIN":return{line:{name:"fused",result:"TRUE",detail:`the original rebuilds the committed fused bytes${s}; they carry the commitment to slot ${i}`},fused:u(n.category,"original")};case"INVALID_SLOT_COMMITMENT":return{line:{name:"fused",result:"FALSE",detail:`the fused bytes do not carry the commitment to this proof's slot ${i}: ${n.reason??""}`},fused:u(n.category,d)};case"INVALID_ORIGIN_ATTRIBUTION":return{line:{name:"fused",result:"FALSE",detail:`the declared origin contradicts the origin inside the fused bytes: ${n.reason??""}`},fused:u(n.category,d)};case"RECONSTRUCTION_MISMATCH":return{line:{name:"fused",result:"FALSE",detail:`the file matching the declared origin does not rebuild the committed fused bytes: ${n.reason??""}`},fused:u(n.category,"original")};case"UNDETERMINED_PLACEMENT":return{line:{name:"fused",result:"UNDETERMINED",detail:`${n.reason??"the placement is not registered"}; this verifier cannot check the commitment`},fused:u(n.category,d)};case"INVALID_UNDERLYING_PROOF":return{line:{name:"fused",result:"UNDETERMINED",detail:"not checked: the proof itself does not verify (see the signature line)"},fused:u(n.category,d)};default:return{line:{name:"fused",result:"UNDETERMINED",detail:`the commitment could not be checked: ${n.reason??n.category}`},fused:u(n.category,d)}}}function Th(t,e){return t===void 0||!t.documentPresent?{line:{name:"attestation",result:"UNDETERMINED",detail:"no attestation document in this proof"}}:e?t.documentValidated?t.userDataBoundToProof!==!0?{line:{name:"attestation",result:"FALSE",detail:"attestation document validates but its user_data is not this proof: the document belongs to some other proof"},attestedPcr0:t.attestedPcr0}:t.pcr0MatchesDeclared!==!0?{line:{name:"attestation",result:"FALSE",detail:`attestation validates and binds this proof, but its PCR0 ${pn(t.attestedPcr0)} is not the measurement the signed body declares ${pn(t.declaredMeasurement)}`},attestedPcr0:t.attestedPcr0}:{line:{name:"attestation",result:"TRUE",detail:`AWS Nitro attestation validates to the AWS root, binds this exact proof (user_data), and attests PCR0 ${pn(t.attestedPcr0)}`},attestedPcr0:t.attestedPcr0}:{line:{name:"attestation",result:"FALSE",detail:`attestation document does not validate: ${t.validationFailure??"unspecified failure"}`}}:{line:{name:"attestation",result:"UNDETERMINED",detail:"attestation not checked: this environment cannot verify ECDSA P-384 (no WebCrypto); open the verifier from a file or https page, or run bitgraph-play check"}}}function Hh(t,e){if(e!=="TRUE"||t===void 0)return{name:"enclave",result:"UNDETERMINED",detail:"enclave identity rests on a validated attestation, which this recording does not have here"};let n=xh.find(r=>r.pcr0===t.toLowerCase());return n===void 0?{name:"enclave",result:"UNDETERMINED",detail:`PCR0 ${pn(t)} is not among the BitGraph enclave measurements this verifier knows (player ${ei}); compare it against the measurements published at bitgraph.ing/docs/self-host-tee`}:{name:"enclave",result:"TRUE",detail:`PCR0 ${pn(t)} is the published BitGraph ${n.label} measurement (${n.period})`}}function Ch(t){if(t===void 0)return{status:"unanchored",detail:"no verified Ethereum anchor bounds this recording in this bundle"};let e=fc(t.lowerBounds,"not-before"),n=fc(t.upperBounds,"not-after"),r=e===void 0?void 0:uc(e),o=n===void 0?void 0:uc(n),i=r!==void 0&&o!==void 0?"lower-bounded-with-following-anchor":r!==void 0?"lower-bounded":o!==void 0?"upper-bounded":"unanchored",s=i==="unanchored"?"no verified Ethereum anchor bounds this recording in this bundle":`recorded ${Rh(i,r,o)}`;return{status:i,...r!==void 0?{notBefore:r}:{},...o!==void 0?{notAfter:o}:{},detail:s}}function Rh(t,e,n){switch(t){case"lower-bounded-with-following-anchor":return`after Ethereum block ${ht(e)} (header verified in this bundle); precedes an anchor that consumed block ${ht(n)} (header verified), an anchor-latency assumption rather than an upper bound on this recording`+ti(e.weaker||n.weaker);case"lower-bounded":return`after Ethereum block ${ht(e)} (header verified in this bundle); no verified upper bound here`+ti(e.weaker);case"upper-bounded":return`before Ethereum block ${ht(n)} (header verified in this bundle); no verified lower bound here`+ti(n.weaker);default:return"with no verified Ethereum bound in this bundle"}}function fc(t,e){let n=t.filter(o=>o.kind===e);return n.length===0?void 0:[...n].sort((o,i)=>{let s=o.blockNumber!==void 0?BigInt(o.blockNumber):BigInt(o.timestamp),a=i.blockNumber!==void 0?BigInt(i.blockNumber):BigInt(i.timestamp);return s!==a?e==="not-before"?s>a?-1:1:s<a?-1:1:o.weaker!==i.weaker?o.weaker?1:-1:0})[0]}function uc(t){return{...t.blockNumber!==void 0?{blockNumber:t.blockNumber}:{},blockHash:t.blockHash,timestamp:t.timestamp,anchorProofHash:t.anchorProofHash,evidence:t.evidence,weaker:t.weaker}}function $h(t){switch(t.status){case"lower-bounded-with-following-anchor":return`after Ethereum block ${ht(t.notBefore)}, then an anchor at block ${ht(t.notAfter)}`;case"lower-bounded":return`after Ethereum block ${ht(t.notBefore)}`;case"upper-bounded":return`before Ethereum block ${ht(t.notAfter)}`;default:return"with no Ethereum bound in this bundle"}}function ht(t){return t.blockNumber!==void 0?t.blockNumber:t.blockHash}function ti(t){return t?"; ordered by counter position within the epoch, since the recordings between are not in this bundle":""}function Ph(t,e,n){let r=[],o=t.verification;o===void 0?r.push({name:"signature",result:"UNDETERMINED",detail:"the anchor proof was not verified"}):o.status==="failed"?r.push({name:"signature",result:"FALSE",detail:`the anchor proof does not verify: ${o.reason??"unspecified failure"}`}):r.push({name:"signature",result:"TRUE",detail:`anchor proof verifies under signer key ${ri(t.publicKeyB64)}`});let i;if(n.length>0){let s=n.find(a=>a.verified);if(s!==void 0)i=s.witnessPath,r.push({name:"witness",result:"TRUE",detail:`block header ${s.witnessPath} hashes (keccak-256) to the anchored block hash${e.blockNumber!==void 0?` of block ${e.blockNumber}`:""}`});else{let a=n[0];i=a.witnessPath,r.push({name:"witness",result:"FALSE",detail:`block header ${a.witnessPath} contradicts this anchor: ${a.detail??a.reason??"witness verification failed"}`})}}return{proofHash:t.proofHash,...t.epochId!==void 0?{epochId:t.epochId}:{},chainId:t.chainId,...t.counter!==void 0?{counter:t.counter}:{},...e.blockNumber!==void 0?{blockNumber:e.blockNumber}:{},...e.blockHash!==void 0?{blockHash:e.blockHash}:{},...i!==void 0?{witnessPath:i}:{},lines:r,result:fr(r.map(s=>s.result))}}function Mh(t){let e=[],n=new Set,r=o=>{n.has(o)||(n.add(o),e.push({name:"contradiction",result:"FALSE",detail:o}))};for(let o of t.anomalies.anomalies)Eh.has(o.code)||r(`${o.code}: ${o.message}`);for(let o of t.anomalies.divergences)r(`${o.kind}: ${o.explanation}`);for(let o of t.authorities.anomalies)r(`${o.code}: ${o.message}`);for(let o of t.witnesses.findings)(o.code==="witness-unmatched"||o.code==="witness-malformed"||o.code==="witness-rlp-invalid")&&r(`${o.code}: ${o.message}`);for(let o of t.ingest.findings)o.code==="proofhash-mismatch"&&r(`${o.code}: ${o.message}${o.path!==void 0?` (${o.path})`:""}`);return e}function Dh(t,e,n,r){let o=[],i=0n,s=0;for(let d of t.anomalies.anomalies)if(d.code==="unexplained-counter-positions"){let h=d.details?.count;h!==void 0&&/^[0-9]+$/.test(h)&&(i+=BigInt(h))}else d.code==="chain-break-missing"&&(s+=d.proofHashes.length);i>0n&&o.push(`${i} causal position${i===1n?"":"s"} between the earliest and latest recording here ${i===1n?"is":"are"} not in this bundle: normal for an export, which is an excerpt of the chain; a full-epoch audit checks them`),s>0&&o.push(`${s} recording${s===1?"":"s"} link${s===1?"s":""} to a predecessor that is not in this bundle: normal for an export`);let a=t.ingest.artifacts.filter(d=>d.matchedProofHashes.length===0&&r?.has(d.sha256Hex)===!0);a.length>0&&o.push(`${a.length} file${a.length===1?"":"s"} in this bundle ${a.length===1?"is":"are"} the original of a fused recording: ${a.slice(0,5).map(d=>d.paths[0]??"(unnamed)").join(", ")}${a.length>5?", \u2026":""}. The original itself receives only the ceiling (it existed no later than the commit); the fused bytes receive the interval`);let c=t.ingest.artifacts.filter(d=>d.matchedProofHashes.length===0&&r?.has(d.sha256Hex)!==!0);if(c.length>0&&e.length>0){let d=c.slice(0,5).map(h=>`${h.paths[0]??"(unnamed)"} (sha256:${h.sha256Hex.slice(0,16)}\u2026)`).join(", ");o.push(`${c.length} file${c.length===1?"":"s"} in this bundle match${c.length===1?"es":""} no recording here: ${d}${c.length>5?", \u2026":""}. If ${c.length===1?"it":"one of them"} was meant to be a recorded file, its bytes differ from what was recorded`)}let f=n.filter(d=>d.witnessPath===void 0);f.length>0&&o.push(`${f.length} Ethereum anchor${f.length===1?"":"s"} in this bundle ha${f.length===1?"s":"ve"} no block-header witness file, so ${f.length===1?"its":"their"} block hash${f.length===1?" is":"es are"} not verified here and no bound is derived from ${f.length===1?"it":"them"}`);for(let d of t.ingest.unsupportedVersions)o.push(`${d.path} is proof-shaped but its version "${d.version}" is not bitgraph/1; it was not checked`);let u=t.ingest.counts;if((u.exactDuplicates>0||u.semanticDuplicates>0)&&o.push(`${u.exactDuplicates+u.semanticDuplicates} duplicate proof file${u.exactDuplicates+u.semanticDuplicates===1?"":"s"} collapsed to one recording each`),t.ingest.manifest!==void 0)for(let d of t.ingest.findings)typeof d.code=="string"&&d.code.startsWith("manifest-")&&o.push(`${d.code}: ${d.message}`);return e.length===0&&n.length===0&&o.push("no BitGraph proofs were found in this bundle"),o}function Nh(t){let e=[];return t&&e.push("whether the anchored Ethereum blocks are canonical: their headers are recomputed here, but canonicality needs an Ethereum node or a block explorer"),e.push("whether the public ledger holds these exact recordings at these positions: this is an offline check; drop the file on bitgraph.ing to compare against the ledger"),e.push("whether an epoch key was later quarantined: that is published outside any bundle"),e}function Lh(t,e,n,r){if(e.length===0&&n.length===0)return"UNDETERMINED: no BitGraph proofs were found in this bundle.";let o=e.length,i=`${o} recording${o===1?"":"s"}`;if(t==="TRUE"){let a=e[0];return o===1&&a!==void 0?`TRUE: this file was recorded${a.counter!==void 0?` at position ${a.counter}${a.epochId!==void 0?` of epoch ${ri(a.epochId)}`:""}`:""}, ${$h(a.bounds)}.`:`TRUE: ${i} verified: files match, signatures and attestations hold, enclave measurements published${n.length>0?", Ethereum bounds verified from block headers in the bundle":""}.`}if(t==="FALSE")return`FALSE: evidence in this bundle contradicts itself. ${[...e.flatMap(c=>c.lines.filter(f=>f.result==="FALSE").map(f=>`${f.name}: ${f.detail}`)),...n.flatMap(c=>c.lines.filter(f=>f.result==="FALSE").map(f=>`${f.name}: ${f.detail}`)),...r.map(c=>c.detail)][0]??""}`.trim();let s=[...e.flatMap(a=>a.lines.filter(c=>c.result==="UNDETERMINED").map(c=>c.detail)),...n.flatMap(a=>a.lines.filter(c=>c.result==="UNDETERMINED").map(c=>c.detail))];return`UNDETERMINED: nothing here contradicts the ${i}, but the evidence does not fully decide. ${s[0]??""}`.trim()}function ri(t){return t===void 0?"(none)":t.length>12?`${t.slice(0,12)}\u2026`:t}function pn(t){return t===void 0?"(none)":t.length>16?`${t.slice(0,16)}\u2026`:t}In.sha512Async=async(...t)=>Rn(In.concatBytes(...t));var bc=typeof globalThis.crypto<"u"&&globalThis.crypto.subtle!==void 0;function yc(t){return new Promise((e,n)=>{let r=[],o=()=>{t.readEntries(i=>{if(i.length===0){e(r);return}r.push(...i),o()},n)};o()})}function Oh(t){return new Promise((e,n)=>t.file(e,n))}async function ai(t,e,n){if(t.isFile){let r=await Oh(t);n.push({path:e+t.name,file:r});return}if(t.isDirectory){let r=t.createReader(),o=await yc(r);for(let i of o)i.name!==".DS_Store"&&await ai(i,`${e}${t.name}/`,n)}}async function Fh(t){let n=Array.from(t.items??[]).map(o=>typeof o.webkitGetAsEntry=="function"?o.webkitGetAsEntry():null).filter(o=>o!==null);if(n.length===0)return Array.from(t.files??[]).map(o=>({path:o.name,file:o}));let r=[];if(n.length===1&&n[0]!==void 0&&n[0].isDirectory){let o=n[0];for(let i of await yc(o.createReader()))i.name!==".DS_Store"&&await ai(i,"",r)}else for(let o of n)await ai(o,"",r);return r.length===0?Array.from(t.files??[]).map(o=>({path:o.name,file:o})):r}function hc(t){let e=Array.from(t.files??[]),n=e.map(s=>s.webkitRelativePath||s.name),r=n.map(s=>s.indexOf("/")),o=n.length>0&&r.every(s=>s>0)?n[0].slice(0,r[0]):void 0,i=o!==void 0&&n.every(s=>s.startsWith(`${o}/`));return e.map((s,a)=>({path:i?n[a].slice(o.length+1):n[a],file:s})).filter(s=>!s.path.endsWith("/.DS_Store")&&s.path!==".DS_Store")}function _h(t){return t.map(e=>({path:e.path,open:()=>e.file.arrayBuffer().then(n=>new Uint8Array(n))}))}function $(t,e={},n=[]){let r=document.createElement(t);for(let[o,i]of Object.entries(e))o==="class"?r.className=i:r.setAttribute(o,i);for(let o of n)r.append(typeof o=="string"?document.createTextNode(o):o);return r}function ci(t){return t==="TRUE"?null:$("span",{class:t==="FALSE"?"mark false":"mark undet"},[t])}function gn(t,e,n={}){let r=$("div",{class:"field-head"},[$("span",{class:"field-label"},[t])]),o=n.mark!==void 0?ci(n.mark):null;return o!==null&&r.append(o),$("div",{class:"field"},[r,$("span",{class:n.mono?"field-value mono":"field-value"},[e])])}function lt(t,e,n={}){let r=n.open===!0,o=$("span",{class:"chev","aria-hidden":"true"});o.innerHTML='<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="square" stroke-linejoin="miter"><path d="M9 6 L15 12 L9 18"/></svg>';let i=$("button",{class:`opener-head${n.tone==="danger"?" danger":""}`,type:"button","aria-expanded":String(r)},[$("span",{},[t]),o]),s=$("div",{class:"opener-body"},e),a=$("section",{class:"card"},[i,s]),c=()=>{i.classList.toggle("open",r),i.setAttribute("aria-expanded",String(r)),s.hidden=!r,o.classList.toggle("open",r)};return i.addEventListener("click",()=>{r=!r,c()}),c(),a}function Uh(t){return t==="TRUE"?"BitGraph Verified":t==="FALSE"?"Verification Failed":"Not Fully Verified"}function jh(t){return t===void 0?"":`#${Number(t).toLocaleString("en-US")}`}function Kh(t){return new Date(t*1e3).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})}function mn(t,e){return new Date(t*1e3).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",second:"2-digit",...e?{timeZoneName:"short"}:{}})}function Vh(t){return new Date(t*1e3).toLocaleString("en-US",{month:"numeric",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit",timeZoneName:"short"})}function lc(t){let e=t.bounds,n=i=>$("span",{class:"when-grey"},[i]),r=i=>$("span",{class:"when-dark"},[i]),o=$("div",{class:"when"});if(e.notBefore!==void 0||e.notAfter!==void 0){let i=e.notBefore??e.notAfter;o.append($("div",{class:"when-date"},[Kh(i.timestamp)]));let s=$("div",{class:"when-line"});e.notBefore!==void 0&&e.notAfter!==void 0?s.append(n("after "),r(mn(e.notBefore.timestamp,!0)),n(", then an anchor at "),r(mn(e.notAfter.timestamp,!1)),n(" (not an upper bound)")):e.notBefore!==void 0?s.append(n("after "),r(mn(e.notBefore.timestamp,!0))):e.notAfter!==void 0&&s.append(n("no lower bound in this bundle; an anchor followed at "),r(mn(e.notAfter.timestamp,!0)),n(" (not an upper bound)")),o.append(s)}else o.append($("div",{class:"when-line"},[n("no verified Ethereum bound in this bundle")]));return o}function oi(t){if(t.fused===void 0)return null;let e=i=>$("span",{class:"when-grey"},[i]),n=i=>$("span",{class:"when-dark"},[i]),r=$("div",{class:"when"}),o=$("div",{class:"when-line"});return t.fused.floor!==null?o.append(e("fused bytes assembled after "),n(mn(t.fused.floor.timestamp,!0)),e(`, the last anchor before slot ${t.fused.span?.slotCounter??"?"}`)):o.append(e(t.fused.floorDetail)),r.append(o),r}var zh=/\.(jpe?g|png|gif|webp|avif|bmp|svg)$/i,qh=/\.(mp4|m4v|mov|webm|ogv)$/i,Gh=/\.(mp3|wav|m4a|aac|flac|ogg|oga)$/i,Wh=/\.(txt|md|markdown|json|csv|tsv|log|xml|yaml|yml|html?|css|js|ts|py|sh|rtf)$/i;function Zh(t){let e=t.subarray(0,Math.min(2048,t.length));if(!e.length)return!1;let n=0;for(let r of e){if(r===0)return!1;(r===9||r===10||r===13||r>=32)&&n++}return n/e.length>.97}function Yh(t,e){let n=t.toLowerCase();return n.endsWith(".pdf")?"pdf":zh.test(n)?"image":qh.test(n)?"video":Gh.test(n)?"audio":Wh.test(n)||Zh(e)?"text":"other"}function Xh(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(t<10*1024?1:0)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function Jh(t,e,n){if(n==="image"||n==="video"){let r=URL.createObjectURL(t),o=n==="image"?$("img",{src:r,alt:t.name,style:"display:block;max-width:100%;max-height:min(70vh,640px);width:auto;height:auto;object-fit:contain;border-radius:0"}):$("video",{src:r,controls:"",style:"display:block;max-width:100%;max-height:min(70vh,640px);border-radius:0"});return $("div",{style:"padding:20px;display:flex;align-items:center;justify-content:center"},[o])}if(n==="audio"){let r=URL.createObjectURL(t);return $("div",{style:"padding:20px 16px"},[$("audio",{src:r,controls:"",style:"display:block;width:100%"})])}if(n==="text")try{let r=new TextDecoder("utf-8",{fatal:!1}).decode(e.subarray(0,6e3)),o=r.split(`
|
|
153
|
+
`),i=o.slice(0,24).join(`
|
|
154
|
+
`).slice(0,3e3),s=o.length>24||r.length>i.length||e.byteLength>6e3;return $("pre",{class:"excerpt"},[i+(s?`
|
|
155
|
+
\u2026`:"")])}catch{return null}return null}function pc(t,e,n,r){let o=t.lines.find(s=>s.name==="file"),i=$("div",{class:r?"file-row above":"file-row"});if(t.filePath!==void 0){let s=$("span",{class:"file-ident"},[$("span",{class:"file-name"},[t.filePath])]);e!==void 0&&s.append(document.createTextNode(` \xB7 ${Xh(e.size)}`)),i.append(s);let a=$("span",{class:"file-right"});e!==void 0&&n!==void 0&&(n==="image"||n==="text"||n==="pdf")&&a.append($("a",{class:"bg-arrow-link",href:URL.createObjectURL(e),target:"_blank",rel:"noopener"},["Open ",$("span",{class:"arrow","aria-hidden":"true"},["\u2192"])]));let c=o!==void 0?ci(o.result):null;c!==null&&a.append(c),a.childNodes.length>0&&i.append(a)}else{i.append($("span",{class:"file-missing"},["file not in this bundle"]));let s=o!==void 0?ci(o.result):null;s!==null&&i.append(s)}return i}function Je(t,e,n=!1){return gn(t,e,{mono:n})}function mc(t,e){let n=document.getElementById("title-action");if(n===null)return;let r=$("a",{class:"bg-arrow-link",href:"#"},[t+" ",$("span",{class:"arrow","aria-hidden":"true"},["\u2192"])]);r.addEventListener("click",o=>{o.preventDefault(),e()}),n.replaceChildren(r)}function gc(t){let e={file:"File",signature:"Signature",attestation:"Hardware Enclave attestation",enclave:"Enclave identity",witness:"Block header",contradiction:"Contradiction",fused:"Fused artifact"};return t.lines.map(n=>gn(e[n.name]??n.name,n.detail,{mark:n.result}))}function Qh(t,e,n,r){let o=e==="before"?"Recorded after this block":e==="after"?"An anchor followed this recording (not an upper bound)":`Ethereum anchor ${n+1}`,i=[];if(t.blockNumber!==void 0&&i.push(Je("Block",jh(t.blockNumber),!0)),r!==void 0&&i.push(Je("Block Time",Vh(r))),t.blockHash!==void 0&&i.push(Je("Block Hash",t.blockHash,!0)),t.counter!==void 0&&i.push(Je("Anchor position",`#${t.counter}`,!0)),t.blockNumber!==void 0){let s=$("a",{class:"field-link",href:`https://etherscan.io/block/${t.blockNumber}`,target:"_blank",rel:"noopener"},[`https://etherscan.io/block/${t.blockNumber}`]);i.push($("div",{class:"field"},[$("span",{class:"field-label"},["Etherscan"]),s]))}for(let s of t.lines)i.push(gn(s.name==="witness"?"Block header":"Anchor signature",s.detail,{mark:s.result}));return t.witnessPath===void 0&&i.push(gn("Block header","no block-header witness in this bundle, so this anchor's block hash is not verified here and it bounds nothing")),lt(t.result==="TRUE"?o:`${o} [${t.result}]`,i)}async function el(t,e,n,r){e.replaceChildren();let o=()=>location.reload();if(t.recordings.length===0&&t.anchors.length===0){n.textContent="No BitGraph Found",e.append($("section",{class:"card primary"},[$("div",{class:"notice"},["No BitGraph proof was found in what you chose. A recording is a folder named for the file it holds, like BitGraph (photo.jpg). Inside it are proof.json, the file itself, and an ethereum-anchors folder."])])),mc("Choose a recording folder",o),e.append(lt("Report JSON",[$("pre",{class:"json"},[JSON.stringify(t,null,2)])]));let f=document.getElementById("more");f.replaceChildren(),f.hidden=!0;return}n.textContent=Uh(t.result);let i=t.recordings.length===1?t.recordings[0]:void 0,s=$("section",{class:"card primary"});if(t.result!=="TRUE"&&s.append($("div",{class:`notice ${t.result.toLowerCase()}`},[t.summary])),i!==void 0){s.append(lc(i));let f=oi(i);f!==null&&s.append(f);let u=i.filePath!==void 0?r.get(i.filePath):void 0,d,h=null;if(u!==void 0){let l=new Uint8Array(await u.arrayBuffer());d=Yh(u.name,l),h=Jh(u,l,d)}h!==null&&s.append(h),s.append(pc(i,u,d,h!==null)),i.counter!==void 0&&s.append(Je("Position",`#${i.counter}${i.epochId!==void 0?` \xB7 epoch ${i.epochId}`:""}`,!0)),s.append(Je("File Hash",i.digestB64,!0))}else if(t.recordings.length>1)for(let f of t.recordings)s.append(pc(f,f.filePath!==void 0?r.get(f.filePath):void 0,void 0,!1));else s.append(Je("Recordings","no recordings in this bundle"));if(e.append(s),mc("Check another BitGraph",o),i!==void 0){let f=i.lines.filter(u=>u.result!=="TRUE").length;e.append(lt(f===0?"Recording checks":`Recording checks ${f} not verified`,gc(i),{open:t.result!=="TRUE"}))}else t.recordings.forEach((f,u)=>{e.append(lt(`Recording ${u+1}: ${f.filePath??f.digestB64.slice(0,16)+"\u2026"} [${f.result}]`,[lc(f),...oi(f)!==null?[oi(f)]:[],...f.counter!==void 0?[Je("Position",`#${f.counter}${f.epochId!==void 0?` \xB7 epoch ${f.epochId}`:""}`,!0)]:[],Je("File Hash",f.digestB64,!0),...gc(f)],{open:f.result!=="TRUE"}))});let a=new Map;for(let f of t.recordings)f.bounds.notBefore&&a.set(f.bounds.notBefore.anchorProofHash,f.bounds.notBefore.timestamp),f.bounds.notAfter&&a.set(f.bounds.notAfter.anchorProofHash,f.bounds.notAfter.timestamp);t.anchors.forEach((f,u)=>{let d="other";i!==void 0&&(i.bounds.notBefore?.anchorProofHash===f.proofHash?d="before":i.bounds.notAfter?.anchorProofHash===f.proofHash&&(d="after")),e.append(Qh(f,d,u,a.get(f.proofHash)))}),t.contradictions.length>0&&e.append(lt(`Contradictions ${t.contradictions.length}`,t.contradictions.map(f=>gn("Contradiction",f.detail,{mark:"FALSE"})),{open:!0,tone:"danger"})),t.notes.length>0&&e.append(lt(`Notes ${t.notes.length}`,[$("ul",{class:"list"},t.notes.map(f=>$("li",{},[f])))])),e.append(lt("Not checked",[$("ul",{class:"list"},t.notChecked.map(f=>$("li",{},[f])))])),e.append(lt("Report JSON",[$("pre",{class:"json"},[JSON.stringify(t,null,2)])]));let c=document.getElementById("more");c.replaceChildren(),c.hidden=!0}async function ii(t){let e=document.getElementById("drop"),n=document.getElementById("results"),r=document.getElementById("status");if(t.length===0){r.textContent="Nothing readable was dropped.";return}e.classList.add("busy"),r.textContent=`Checking ${t.length} file${t.length===1?"":"s"}\u2026`;try{let o=await Ho(_h(t),{label:"dropped"}),i=await dc(o,{webCryptoAvailable:bc});document.getElementById("camera").hidden=!0,document.getElementById("deck").hidden=!0,document.querySelector(".bitgraph-wrap")?.classList.add("bitgraph-results"),document.querySelector(".bitgraph-hero")?.classList.add("results"),r.textContent="",n.hidden=!1;let s=new Map(t.map(a=>[a.path,a.file]));await el(i,n,document.getElementById("title"),s),document.title=`${i.result} \xB7 BitGraph verify`}catch(o){r.textContent=`The check could not run: ${o.message}`}finally{e.classList.remove("busy")}}function si(){let t=document.querySelector(".bitgraph-wrap");t&&t.style.setProperty("--bg-wrap-min",`${Math.round(window.innerHeight)}px`)}function tl(){let t=document.getElementById("drop"),e=document.getElementById("status"),n=document.getElementById("pick-files"),r=document.getElementById("pick-folder");si(),window.addEventListener("resize",si),window.addEventListener("orientationchange",si),bc||(e.textContent="This browser context has no WebCrypto, so attestations will read UNDETERMINED here; open the file directly (file://) or over https, or run bitgraph-play check.");let o=!1,i=!1,s=!1,a=()=>{t.classList.toggle("hot",o||i||s),t.classList.toggle("over",s)};t.addEventListener("mouseenter",()=>{o=!0,a()}),t.addEventListener("mouseleave",()=>{o=!1,a()}),t.addEventListener("focusin",()=>{i=!0,a()}),t.addEventListener("focusout",()=>{i=!1,a()});let c=f=>{f.preventDefault(),f.stopPropagation()};for(let f of["dragenter","dragover"])t.addEventListener(f,u=>{c(u),s=!0,a()}),document.body.addEventListener(f,c);for(let f of["dragleave","drop"])t.addEventListener(f,u=>{c(u),s=!1,a()}),document.body.addEventListener(f,c);t.addEventListener("drop",f=>{let u=f.dataTransfer;u!==null&&(e.textContent="Reading the drop\u2026",Fh(u).then(d=>{if(d.length===0){e.textContent="Nothing readable was dropped. Click the box and choose the recording's folder instead.";return}return ii(d)},d=>{e.textContent=`The drop could not be read here: ${d.message}. Click the box and choose the recording's folder instead.`}))}),t.addEventListener("click",()=>r.click()),t.addEventListener("keydown",f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),r.click())}),n.addEventListener("change",()=>void ii(hc(n))),r.addEventListener("change",()=>void ii(hc(r)))}document.addEventListener("DOMContentLoaded",tl);})();
|
|
156
156
|
|
|
157
157
|
</script>
|
|
158
158
|
</body>
|