var Log;(()=>{var e={187:e=>{"use strict";var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var o=Number.isNaN||function(e){return e!=e};function i(){i.init.call(this)}e.exports=i,e.exports.once=function(e,t){return new Promise((function(r,n){function o(r){e.removeListener(t,i),n(r)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",o),r([].slice.call(arguments))}y(e,t,i,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&y(e,"error",t,{once:!0})}(e,o)}))},i.EventEmitter=i,i.prototype._events=void 0,i.prototype._eventsCount=0,i.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?i.defaultMaxListeners:e._maxListeners}function u(e,t,r,n){var o,i,s,u;if(a(r),void 0===(i=e._events)?(i=e._events=Object.create(null),e._eventsCount=0):(void 0!==i.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),i=e._events),s=i[t]),void 0===s)s=i[t]=r,++e._eventsCount;else if("function"==typeof s?s=i[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(o=c(e))>0&&s.length>o&&!s.warned){s.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=e,f.type=t,f.count=s.length,u=f,console&&console.warn&&console.warn(u)}return e}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=f.bind(n);return o.listener=r,n.wrapFn=o,o}function l(e,t,r){var n=e._events;if(void 0===n)return[];var o=n[t];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)n(c,this,t);else{var u=c.length,f=p(c,u);for(r=0;r=0;i--)if(r[i]===t||r[i].listener===t){s=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},i.prototype.listeners=function(e){return l(this,e,!0)},i.prototype.rawListeners=function(e){return l(this,e,!1)},i.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},i.prototype.listenerCount=d,i.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},717:e=>{"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},117:(e,t,r)=>{var n=r(187),o=r(717);function i(e){if(!(this instanceof i))return new i(e);"number"==typeof e&&(e={max:e}),e||(e={}),n.EventEmitter.call(this),this.cache={},this.head=this.tail=null,this.length=0,this.max=e.max||1e3,this.maxAge=e.maxAge||0}e.exports=i,o(i,n.EventEmitter),Object.defineProperty(i.prototype,"keys",{get:function(){return Object.keys(this.cache)}}),i.prototype.clear=function(){this.cache={},this.head=this.tail=null,this.length=0},i.prototype.remove=function(e){if("string"!=typeof e&&(e=""+e),this.cache.hasOwnProperty(e)){var t=this.cache[e];return delete this.cache[e],this._unlink(e,t.prev,t.next),t.value}},i.prototype._unlink=function(e,t,r){this.length--,0===this.length?this.head=this.tail=null:this.head===e?(this.head=t,this.cache[this.head].next=null):this.tail===e?(this.tail=r,this.cache[this.tail].prev=null):(this.cache[t].next=r,this.cache[r].prev=t)},i.prototype.peek=function(e){if(this.cache.hasOwnProperty(e)){var t=this.cache[e];if(this._checkAge(e,t))return t.value}},i.prototype.set=function(e,t){var r;if("string"!=typeof e&&(e=""+e),this.cache.hasOwnProperty(e)){if((r=this.cache[e]).value=t,this.maxAge&&(r.modified=Date.now()),e===this.head)return t;this._unlink(e,r.prev,r.next)}else r={value:t,modified:0,next:null,prev:null},this.maxAge&&(r.modified=Date.now()),this.cache[e]=r,this.length===this.max&&this.evict();return this.length++,r.next=null,r.prev=this.head,this.head&&(this.cache[this.head].next=e),this.head=e,this.tail||(this.tail=e),t},i.prototype._checkAge=function(e,t){return!(this.maxAge&&Date.now()-t.modified>this.maxAge&&(this.remove(e),this.emit("evict",{key:e,value:t.value}),1))},i.prototype.get=function(e){if("string"!=typeof e&&(e=""+e),this.cache.hasOwnProperty(e)){var t=this.cache[e];if(this._checkAge(e,t))return this.head!==e&&(e===this.tail?(this.tail=t.next,this.cache[this.tail].prev=null):this.cache[t.prev].next=t.next,this.cache[t.next].prev=t.prev,this.cache[this.head].next=e,t.prev=this.head,t.next=null,this.head=e),t.value}},i.prototype.evict=function(){if(this.tail){var e=this.tail,t=this.remove(this.tail);this.emit("evict",{key:e,value:t})}}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";r.r(n),r.d(n,{AccessController:()=>zt,Entry:()=>Tt,IPFSBlockStorage:()=>Rt,LRUStorage:()=>Vt,Log:()=>Ht,MemoryStorage:()=>Ft,Sorting:()=>_t});var e={};r.r(e),r.d(e,{code:()=>Ct,decode:()=>It,encode:()=>jt,name:()=>xt});class t{constructor(e,t){this.id=e,this.time=t||0}tick(){return new t(this.id,++this.time)}merge(e){return this.time=Math.max(this.time,e.time),new t(this.id,this.time)}clone(){return new t(this.id,this.time)}static compare(e,t){const r=e.time-t.time;return 0===r&&e.id!==t.id?e.idnull!=e;var s=Math.pow(2,31),a=Math.pow(2,7),c=Math.pow(2,14),u=Math.pow(2,21),f=Math.pow(2,28),h=Math.pow(2,35),l=Math.pow(2,42),d=Math.pow(2,49),p=Math.pow(2,56),y=Math.pow(2,63);const w={encode:function e(t,r,n){r=r||[];for(var o=n=n||0;t>=s;)r[n++]=255&t|128,t/=128;for(;-128&t;)r[n++]=255&t|128,t>>>=7;return r[n]=0|t,e.bytes=n-o+1,r},decode:function e(t,r){var n,o=0,i=0,s=r=r||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[s++],o+=i<28?(127&n)<=128);return e.bytes=s-r,o},encodingLength:function(e){return e[w.decode(e,t),w.decode.bytes],v=(e,t,r=0)=>(w.encode(e,t,r),t),b=e=>w.encodingLength(e),m=(new Uint8Array(0),e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}),E=(e,t)=>{const r=t.byteLength,n=b(e),o=n+b(r),i=new Uint8Array(o+r);return v(e,i,0),v(r,i,n),i.set(t,o),new k(e,r,t,i)};class k{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const A=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,s=new Uint8Array(i);e[t];){var f=r[e.charCodeAt(t)];if(255===f)return;for(var h=0,l=i-1;(0!==f||h>>0,s[l]=f%256>>>0,f=f/256>>>0;if(0!==f)throw new Error("Non-zero carry");o=h,t++}if(" "!==e[t]){for(var d=i-o;d!==i&&0===s[d];)d++;for(var p=new Uint8Array(n+(i-d)),y=n;d!==i;)p[y++]=s[d++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,o=0,i=t.length;o!==i&&0===t[o];)o++,r++;for(var s=(i-o)*f+1>>>0,u=new Uint8Array(s);o!==i;){for(var h=t[o],l=0,d=s-1;(0!==h||l>>0,u[d]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=l,o++}for(var p=s-n;p!==s&&0===u[p];)p++;for(var y=c.repeat(r);pnew j({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class S{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new x(e,t,r),this.decoder=new C(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const U=({name:e,prefix:t,encode:r,decode:n})=>new S(e,t,r,n),$=({prefix:e,name:t,alphabet:r})=>{const{encode:n,decode:o}=A(r,t);return U({prefix:e,name:t,encode:n,decode:e=>m(o(e))})},L=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>U({prefix:t,name:e,encode:e=>((e,t,r)=>{const n="="===t[t.length-1],o=(1<r;)s-=r,i+=t[o&a>>s];if(s&&(i+=t[o&a<((e,t,r,n)=>{const o={};for(let e=0;e=8&&(a-=8,s[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s})(t,n,r,e)}),B=$({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),O=($({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),L({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5})),N=(L({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),L({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),L({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),L({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),L({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),L({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),L({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),L({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),(e,t)=>{const{bytes:r,version:n}=e;return 0===n?z(r,M(e),t||B.encoder):P(r,M(e),t||O.encoder)}),T=new WeakMap,M=e=>{const t=T.get(e);if(null==t){const t=new Map;return T.set(e,t),t}return t};class D{constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{const{code:e,multihash:t}=this;if(e!==R)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==F)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return D.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=E(e,t);return D.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return D.equals(this,e)}static equals(e,t){const r=t;return r&&e.code===r.code&&e.version===r.version&&((e,t)=>{if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&((e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r{const t=m(e),[r,n]=g(t),[o,i]=g(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new k(r,o,s,t)})(r);return D.create(e,n,o)}return null}static create(e,t,r){if("number"!=typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==R)throw new Error(`Version 0 CID must use dag-pb (code: ${R}) block encoding`);return new D(e,t,r,r.bytes);case 1:{const n=V(e,t,r.bytes);return new D(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return D.create(0,R,e)}static createV1(e,t){return D.create(1,e,t)}static decode(e){const[t,r]=D.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=D.inspectBytes(e),r=t.size-t.multihashSize,n=m(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const o=n.subarray(t.multihashSize-t.digestSize),i=new k(t.multihashCode,t.digestSize,o,n);return[0===t.version?D.createV0(i):D.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=g(e.subarray(t));return t+=n,r};let n=r(),o=R;if(18===n?(n=0,t=0):o=r(),0!==n&&1!==n)throw new RangeError(`Invalid CID version ${n}`);const i=t,s=r(),a=r(),c=t+a;return{version:n,codec:o,multihashCode:s,digestSize:a,multihashSize:c-i,size:c}}static parse(e,t){const[r,n]=_(e,t),o=D.decode(n);if(0===o.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return M(o).set(r,e),o}}const _=(e,t)=>{switch(e[0]){case"Q":{const r=t||B;return[B.prefix,r.decode(`${B.prefix}${e}`)]}case B.prefix:{const r=t||B;return[B.prefix,r.decode(e)]}case O.prefix:{const r=t||O;return[O.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}},z=(e,t,r)=>{const{prefix:n}=r;if(n!==B.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const o=t.get(n);if(null==o){const o=r.encode(e).slice(1);return t.set(n,o),o}return o},P=(e,t,r)=>{const{prefix:n}=r,o=t.get(n);if(null==o){const o=r.encode(e);return t.set(n,o),o}return o},R=112,F=18,V=(e,t,r)=>{const n=b(e),o=n+b(t),i=new Uint8Array(o+r.byteLength);return v(e,i,0),v(t,i,n),i.set(r,o),i},q=Symbol.for("@ipld/js-cid/CID"),K=({name:e,code:t,encode:r})=>new G(e,t,r);class G{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?E(this.code,t):t.then((e=>E(this.code,e)))}throw Error("Unknown type, must be binary type")}}function W({enumerable:e=!0,configurable:t=!1}={}){return{enumerable:e,configurable:t,writable:!1}}function*H(e,t){if(null!=t&&"object"==typeof t)if(Array.isArray(t))for(const[r,n]of t.entries()){const t=[...e,r],o=D.asCID(n);o?yield[t.join("/"),o]:"object"==typeof n&&(yield*J(n,t))}else{const r=D.asCID(t);r?yield[e.join("/"),r]:yield*J(t,e)}}function*J(e,t){if(null==e||e instanceof Uint8Array)return;const r=D.asCID(e);r&&(yield[t.join("/"),r]);for(const[r,n]of Object.entries(e)){const e=[...t,r];yield*H(e,n)}}function*Q(e,t){if(Array.isArray(t))for(const[r,n]of t.entries()){const t=[...e,r];yield t.join("/"),"object"!=typeof n||D.asCID(n)||(yield*Z(n,t))}else yield*Z(t,e)}function*Z(e,t){if(null!=e&&"object"==typeof e)for(const[r,n]of Object.entries(e)){const e=[...t,r];yield e.join("/"),null==n||n instanceof Uint8Array||"object"!=typeof n||D.asCID(n)||(yield*Q(e,n))}}class X{constructor({cid:e,bytes:t,value:r}){if(!e||!t||void 0===r)throw new Error("Missing required argument");this.cid=e,this.bytes=t,this.value=r,this.asBlock=this,Object.defineProperties(this,{cid:W(),bytes:W(),value:W(),asBlock:W()})}links(){return J(this.value,[])}tree(){return Z(this.value,[])}get(e="/"){return function(e,t){let r=e;for(const[e,n]of t.entries()){if(r=r[n],null==r)throw new Error(`Object has no property at ${t.slice(0,e+1).map((e=>`[${JSON.stringify(e)}]`)).join("")}`);const o=D.asCID(r);if(o)return{value:o,remaining:t.slice(e+1).join("/")}}return{value:r}}(this.value,e.split("/").filter(Boolean))}}async function Y({value:e,codec:t,hasher:r}){if(void 0===e)throw new Error('Missing required argument "value"');if(!t||!r)throw new Error("Missing required argument: codec or hasher");const n=t.encode(e),o=await r.digest(n),i=D.create(1,t.code,o);return new X({value:e,bytes:n,cid:i})}const ee=["string","number","bigint","symbol"],te=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];class re{constructor(e,t,r){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=r}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.majore.major?1:0}}re.uint=new re(0,"uint",!0),re.negint=new re(1,"negint",!0),re.bytes=new re(2,"bytes",!0),re.string=new re(3,"string",!0),re.array=new re(4,"array",!1),re.map=new re(5,"map",!1),re.tag=new re(6,"tag",!1),re.float=new re(7,"float",!0),re.false=new re(7,"false",!0),re.true=new re(7,"true",!0),re.null=new re(7,"null",!0),re.undefined=new re(7,"undefined",!0),re.break=new re(7,"break",!0);class ne{constructor(e,t,r){this.type=e,this.value=t,this.encodedLength=r,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}}const oe=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&"function"==typeof globalThis.Buffer.isBuffer,ie=new TextDecoder,se=new TextEncoder;function ae(e){return oe&&globalThis.Buffer.isBuffer(e)}function ce(e){return e instanceof Uint8Array?ae(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}const ue=oe?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):we(e,t,r):(e,t,r)=>r-t>64?ie.decode(e.subarray(t,r)):we(e,t,r),fe=oe?e=>e.length>64?globalThis.Buffer.from(e):ye(e):e=>e.length>64?se.encode(e):ye(e),he=e=>Uint8Array.from(e),le=oe?(e,t,r)=>ae(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),de=oe?(e,t)=>(e=e.map((e=>e instanceof Uint8Array?e:globalThis.Buffer.from(e))),ce(globalThis.Buffer.concat(e,t))):(e,t)=>{const r=new Uint8Array(t);let n=0;for(let t of e)n+t.length>r.length&&(t=t.subarray(0,r.length-n)),r.set(t,n),n+=t.length;return r},pe=oe?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function ye(e,t=1/0){let r;const n=e.length;let o=null;const i=[];for(let s=0;s55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function we(e,t,r){const n=[];for(;t239?4:o>223?3:o>191?2:1;if(t+s<=r){let r,n,a,c;switch(s){case 1:o<128&&(i=o);break;case 2:r=e[t+1],128==(192&r)&&(c=(31&o)<<6|63&r,c>127&&(i=c));break;case 3:r=e[t+1],n=e[t+2],128==(192&r)&&128==(192&n)&&(c=(15&o)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(i=c));break;case 4:r=e[t+1],n=e[t+2],a=e[t+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(c=(15&o)<<18|(63&r)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(i=c))}}null===i?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|1023&i),n.push(i),t+=s}return function(e){const t=e.length;if(t<=ge)return String.fromCharCode.apply(String,e);let r="",n=0;for(;nr.length/2?(t=this.cursor===r.length?r:r.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=le(r,0,this.cursor)}else t=de(this.chunks,this.cursor);return e&&this.reset(),t}}const be="CBOR decode error:",me="CBOR encode error:",Ee=[];function ke(e,t,r){if(e.length-t>>8,255&n])}else if(r>>24&255,n>>>16&255,n>>>8&255,255&n])}else{const n=BigInt(r);if(!(n>BigInt(32)&BigInt(4294967295));r[8]=255&o,o>>=8,r[7]=255&o,o>>=8,r[6]=255&o,o>>=8,r[5]=255&o,r[4]=255&i,i>>=8,r[3]=255&i,i>>=8,r[2]=255&i,i>>=8,r[1]=255&i,e.push(r)}}}Se.encodedSize=function(e){return Ue.encodedSize(e.value)},Ue.encodedSize=function(e){return et.value?1:0};const $e=BigInt(-1),Le=BigInt(1);function Be(e,t){const r=t.value,n="bigint"==typeof r?r*$e-Le:-1*r-1;Ue(e,t.type.majorEncoded,n)}function Oe(e,t,r,n){ke(e,t,r+n);const o=le(e,t+r,t+r+n);return new ne(re.bytes,o,r+n)}function Ne(e,t,r,n){return Oe(e,t,1,r)}function Te(e){return void 0===e.encodedBytes&&(e.encodedBytes=e.type===re.string?fe(e.value):e.value),e.encodedBytes}function Me(e,t){const r=Te(t);Ue(e,t.type.majorEncoded,r.length),e.push(r)}function De(e,t,r,n,o){const i=r+n;ke(e,t,i);const s=new ne(re.string,ue(e,t+r,t+i),i);return!0===o.retainStringBytes&&(s.byteValue=le(e,t+r,t+i)),s}function _e(e,t,r,n){return De(e,t,1,r,n)}Be.encodedSize=function(e){const t=e.value,r="bigint"==typeof t?t*$e-Le:-1*t-1;return rt.value?-1:0},Me.encodedSize=function(e){const t=Te(e);return Ue.encodedSize(t.length)+t.length},Me.compareTokens=function(e,t){return r=Te(e),n=Te(t),r.lengthn.length?1:function(e,t){if(ae(e)&&ae(t))return e.compare(t);for(let r=0;r>23,n=8388607&t;if(255===r)Ze.setUint16(0,31744,!1);else if(0===r)Ze.setUint16(0,(2147483648&e)>>16|n>>13,!1);else{const e=r-127;e<-24?Ze.setUint16(0,0):e<-14?Ze.setUint16(0,(2147483648&t)>>16|1<<24+e,!1):Ze.setUint16(0,(2147483648&t)>>16|e+15<<10|n>>13,!1)}}}function et(e,t){if(e.length-t<2)throw new Error(`${be} not enough data for float16`);const r=(e[t]<<8)+e[t+1];if(31744===r)return 1/0;if(64512===r)return-1/0;if(32256===r)return NaN;const n=r>>10&31,o=1023&r;let i;return i=0===n?o*2**-24:31!==n?(o+1024)*2**(n-25):0===o?1/0:NaN,32768&r?-i:i}function tt(e){Ze.setFloat32(0,e,!1)}function rt(e,t){if(e.length-t<4)throw new Error(`${be} not enough data for float32`);const r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function nt(e,t){if(e.length-t<8)throw new Error(`${be} not enough data for float64`);const r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}function ot(e,t,r){throw new Error(`${be} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function it(e){return()=>{throw new Error(`${be} ${e}`)}}Je.compareTokens=Se.compareTokens;const st=[];for(let e=0;e<=23;e++)st[e]=ot;st[24]=function(e,t,r,n){return new ne(re.uint,xe(e,t+1,n),2)},st[25]=function(e,t,r,n){return new ne(re.uint,Ce(e,t+1,n),3)},st[26]=function(e,t,r,n){return new ne(re.uint,je(e,t+1,n),5)},st[27]=function(e,t,r,n){return new ne(re.uint,Ie(e,t+1,n),9)},st[28]=ot,st[29]=ot,st[30]=ot,st[31]=ot;for(let e=32;e<=55;e++)st[e]=ot;st[56]=function(e,t,r,n){return new ne(re.negint,-1-xe(e,t+1,n),2)},st[57]=function(e,t,r,n){return new ne(re.negint,-1-Ce(e,t+1,n),3)},st[58]=function(e,t,r,n){return new ne(re.negint,-1-je(e,t+1,n),5)},st[59]=function(e,t,r,n){const o=Ie(e,t+1,n);if("bigint"!=typeof o){const e=-1-o;if(e>=Number.MIN_SAFE_INTEGER)return new ne(re.negint,e,9)}if(!0!==n.allowBigInt)throw new Error(`${be} integers outside of the safe integer range are not supported`);return new ne(re.negint,$e-BigInt(o),9)},st[60]=ot,st[61]=ot,st[62]=ot,st[63]=ot;for(let e=64;e<=87;e++)st[e]=Ne;st[88]=function(e,t,r,n){return Oe(e,t,2,xe(e,t+1,n))},st[89]=function(e,t,r,n){return Oe(e,t,3,Ce(e,t+1,n))},st[90]=function(e,t,r,n){return Oe(e,t,5,je(e,t+1,n))},st[91]=function(e,t,r,n){const o=Ie(e,t+1,n);if("bigint"==typeof o)throw new Error(`${be} 64-bit integer bytes lengths not supported`);return Oe(e,t,9,o)},st[92]=ot,st[93]=ot,st[94]=ot,st[95]=it("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)st[e]=_e;st[120]=function(e,t,r,n){return De(e,t,2,xe(e,t+1,n),n)},st[121]=function(e,t,r,n){return De(e,t,3,Ce(e,t+1,n),n)},st[122]=function(e,t,r,n){return De(e,t,5,je(e,t+1,n),n)},st[123]=function(e,t,r,n){const o=Ie(e,t+1,n);if("bigint"==typeof o)throw new Error(`${be} 64-bit integer string lengths not supported`);return De(e,t,9,o,n)},st[124]=ot,st[125]=ot,st[126]=ot,st[127]=it("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)st[e]=Re;st[152]=function(e,t,r,n){return Pe(0,0,2,xe(e,t+1,n))},st[153]=function(e,t,r,n){return Pe(0,0,3,Ce(e,t+1,n))},st[154]=function(e,t,r,n){return Pe(0,0,5,je(e,t+1,n))},st[155]=function(e,t,r,n){const o=Ie(e,t+1,n);if("bigint"==typeof o)throw new Error(`${be} 64-bit integer array lengths not supported`);return Pe(0,0,9,o)},st[156]=ot,st[157]=ot,st[158]=ot,st[159]=function(e,t,r,n){if(!1===n.allowIndefinite)throw new Error(`${be} indefinite length items not allowed`);return Pe(0,0,1,1/0)};for(let e=160;e<=183;e++)st[e]=qe;st[184]=function(e,t,r,n){return Ve(0,0,2,xe(e,t+1,n))},st[185]=function(e,t,r,n){return Ve(0,0,3,Ce(e,t+1,n))},st[186]=function(e,t,r,n){return Ve(0,0,5,je(e,t+1,n))},st[187]=function(e,t,r,n){const o=Ie(e,t+1,n);if("bigint"==typeof o)throw new Error(`${be} 64-bit integer map lengths not supported`);return Ve(0,0,9,o)},st[188]=ot,st[189]=ot,st[190]=ot,st[191]=function(e,t,r,n){if(!1===n.allowIndefinite)throw new Error(`${be} indefinite length items not allowed`);return Ve(0,0,1,1/0)};for(let e=192;e<=215;e++)st[e]=Ge;st[216]=function(e,t,r,n){return new ne(re.tag,xe(e,t+1,n),2)},st[217]=function(e,t,r,n){return new ne(re.tag,Ce(e,t+1,n),3)},st[218]=function(e,t,r,n){return new ne(re.tag,je(e,t+1,n),5)},st[219]=function(e,t,r,n){return new ne(re.tag,Ie(e,t+1,n),9)},st[220]=ot,st[221]=ot,st[222]=ot,st[223]=ot;for(let e=224;e<=243;e++)st[e]=it("simple values are not supported");st[244]=ot,st[245]=ot,st[246]=ot,st[247]=function(e,t,r,n){if(!1===n.allowUndefined)throw new Error(`${be} undefined values are not supported`);return!0===n.coerceUndefinedToNull?new ne(re.null,null,1):new ne(re.undefined,void 0,1)},st[248]=it("simple values are not supported"),st[249]=function(e,t,r,n){return He(et(e,t+1),3,n)},st[250]=function(e,t,r,n){return He(rt(e,t+1),5,n)},st[251]=function(e,t,r,n){return He(nt(e,t+1),9,n)},st[252]=ot,st[253]=ot,st[254]=ot,st[255]=function(e,t,r,n){if(!1===n.allowIndefinite)throw new Error(`${be} indefinite length items not allowed`);return new ne(re.break,void 0,1)};const at=[];for(let e=0;e<24;e++)at[e]=new ne(re.uint,e,1);for(let e=-1;e>=-24;e--)at[31-e]=new ne(re.negint,e,1);at[64]=new ne(re.bytes,new Uint8Array(0),1),at[96]=new ne(re.string,"",1),at[128]=new ne(re.array,0,1),at[160]=new ne(re.map,0,1),at[244]=new ne(re.false,!1,1),at[245]=new ne(re.true,!0,1),at[246]=new ne(re.null,null,1);const ct={float64:!1,mapSorter:function(e,t){const r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);const o=r.type.major,i=ut[o].compareTokens(r,n);return 0===i&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i},quickEncodeToken:function(e){switch(e.type){case re.false:return he([244]);case re.true:return he([245]);case re.null:return he([246]);case re.bytes:return e.value.length?void 0:he([64]);case re.string:return""===e.value?he([96]):void 0;case re.array:return 0===e.value?he([128]):void 0;case re.map:return 0===e.value?he([160]):void 0;case re.uint:return e.value<24?he([Number(e.value)]):void 0;case re.negint:if(e.value>=-24)return he([31-Number(e.value)])}}},ut=function(){const e=[];return e[re.uint.major]=Se,e[re.negint.major]=Be,e[re.bytes.major]=Me,e[re.string.major]=ze,e[re.array.major]=Fe,e[re.map.major]=Ke,e[re.tag.major]=We,e[re.float.major]=Je,e}(),ft=new ve;class ht{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do{if(t.obj===e)return!0}while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${me} object contains circular references`);return new ht(t,e)}}const lt={null:new ne(re.null,null),undefined:new ne(re.undefined,void 0),true:new ne(re.true,!0),false:new ne(re.false,!1),emptyArray:new ne(re.array,0),emptyMap:new ne(re.map,0)},dt={number:(e,t,r,n)=>Number.isInteger(e)&&Number.isSafeInteger(e)?new ne(e>=0?re.uint:re.negint,e):new ne(re.float,e),bigint:(e,t,r,n)=>e>=BigInt(0)?new ne(re.uint,e):new ne(re.negint,e),Uint8Array:(e,t,r,n)=>new ne(re.bytes,e),string:(e,t,r,n)=>new ne(re.string,e),boolean:(e,t,r,n)=>e?lt.true:lt.false,null:(e,t,r,n)=>lt.null,undefined:(e,t,r,n)=>lt.undefined,ArrayBuffer:(e,t,r,n)=>new ne(re.bytes,new Uint8Array(e)),DataView:(e,t,r,n)=>new ne(re.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),Array(e,t,r,n){if(!e.length)return!0===r.addBreakTokens?[lt.emptyArray,new ne(re.break)]:lt.emptyArray;n=ht.createCheck(n,e);const o=[];let i=0;for(const t of e)o[i++]=pt(t,r,n);return r.addBreakTokens?[new ne(re.array,e.length),o,new ne(re.break)]:[new ne(re.array,e.length),o]},Object(e,t,r,n){const o="Object"!==t,i=o?e.keys():Object.keys(e),s=o?e.size:i.length;if(!s)return!0===r.addBreakTokens?[lt.emptyMap,new ne(re.break)]:lt.emptyMap;n=ht.createCheck(n,e);const a=[];let c=0;for(const t of i)a[c++]=[pt(t,r,n),pt(o?e.get(t):e[t],r,n)];return function(e,t){t.mapSorter&&e.sort(t.mapSorter)}(a,r),r.addBreakTokens?[new ne(re.map,s),a,new ne(re.break)]:[new ne(re.map,s),a]}};dt.Map=dt.Object,dt.Buffer=dt.Uint8Array;for(const e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))dt[`${e}Array`]=dt.DataView;function pt(e,t={},r){const n=function(e){if(null===e)return"null";if(void 0===e)return"undefined";if(!0===e||!1===e)return"boolean";const t=typeof e;if(ee.includes(t))return t;if("function"===t)return"Function";if(Array.isArray(e))return"Array";if(function(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}(e))return"Buffer";return function(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(te.includes(t))return t}(e)||"Object"}(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||dt[n];if("function"==typeof o){const i=o(e,n,t,r);if(null!=i)return i}const i=dt[n];if(!i)throw new Error(`${me} unsupported type: ${n}`);return i(e,n,t,r)}function yt(e,t,r,n){if(Array.isArray(t))for(const o of t)yt(e,o,r,n);else r[t.type.major](e,t,n)}function wt(e,t,r){const n=pt(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){const e=r.quickEncodeToken(n);if(e)return e;const o=t[n.type.major];if(o.encodedSize){const e=o.encodedSize(n,r),t=new ve(e);if(o(t,n,r),1!==t.chunks.length)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return ce(t.chunks[0])}}return ft.reset(),yt(ft,n,t,r),ft.toBytes(!0)}const gt={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0};class vt{constructor(e,t={}){this.pos=0,this.data=e,this.options=t}done(){return this.pos>=this.data.length}next(){const e=this.data[this.pos];let t=at[e];if(void 0===t){const r=st[e];if(!r)throw new Error(`${be} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);const n=31&e;t=r(this.data,this.pos,n,this.options)}return this.pos+=t.encodedLength,t}}const bt=Symbol.for("DONE"),mt=Symbol.for("BREAK");function Et(e,t){if(e.done())return bt;const r=e.next();if(r.type===re.break)return mt;if(r.type.terminal)return r.value;if(r.type===re.array)return function(e,t,r){const n=[];for(let o=0;o{return t=e,r=kt,r=Object.assign({},ct,r),wt(t,ut,r);var t,r},It=e=>function(e,t){if(!(e instanceof Uint8Array))throw new Error(`${be} data to decode must be a Uint8Array`);const r=(t=Object.assign({},gt,t)).tokenizer||new vt(e,t),n=Et(r,t);if(n===bt)throw new Error(`${be} did not find any content to decode`);if(n===mt)throw new Error(`${be} got unexpected break`);if(!r.done())throw new Error(`${be} too many terminals, data makes no sense`);return n}(e,At),St=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),Ut=K({name:"sha2-256",code:18,encode:St("SHA-256")}),$t=(K({name:"sha2-512",code:19,encode:St("SHA-512")}),e),Lt=Ut,Bt=B,Ot=e=>e&&void 0!==e.id&&void 0!==e.next&&void 0!==e.payload&&void 0!==e.v&&void 0!==e.clock&&void 0!==e.refs,Nt=async e=>{const{cid:t,bytes:r}=await Y({value:e,codec:$t,hasher:Lt}),n=t.toString(Bt),i=new o(e.clock.id,e.clock.time);return{...e,clock:i,hash:n,bytes:r}},Tt={create:async(e,t,r,n=null,s=[],a=[])=>{if(!i(e))throw new Error("Identity is required, cannot create entry");if(!i(t))throw new Error("Entry requires an id");if(!i(r))throw new Error("Entry requires a payload");if(!i(s)||!Array.isArray(s))throw new Error("'next' argument is not an array");const c={id:t,payload:r,next:s,refs:a,clock:n=n||new o(e.publicKey),v:2},{bytes:u}=await Y({value:c,codec:$t,hasher:Lt}),f=await e.provider.sign(e,u);return c.key=e.publicKey,c.identity=e.toJSON(),c.sig=f,Nt(c)},verify:async(e,t)=>{if(!e)throw new Error("Identity-provider is required, cannot verify entry");if(!Ot(t))throw new Error("Invalid Log entry");if(!t.key)throw new Error("Entry doesn't have a key");if(!t.sig)throw new Error("Entry doesn't have a signature");const r={id:t.id,payload:t.payload,next:t.next,refs:t.refs,clock:t.clock,v:t.v},{bytes:n}=await Y({value:r,codec:$t,hasher:Lt});return e.verify(t.sig,t.key,n)},decode:async e=>{const{value:t}=await async function({bytes:e,codec:t,hasher:r}){if(!e)throw new Error('Missing required argument "bytes"');if(!t||!r)throw new Error("Missing required argument: codec or hasher");const n=t.decode(e),o=await r.digest(e),i=D.create(1,t.code,o);return new X({value:n,bytes:e,cid:i})}({bytes:e,codec:$t,hasher:Lt});return Nt(t)},isEntry:Ot,isEqual:(e,t)=>e&&t&&e.hash===t.hash};function Mt(e,t,r){const n=o.compare(e.clock,t.clock);return 0===n?r(e,t):n}function Dt(e,t,r){return e.clock.id===t.clock.id?r(e,t):e.clock.ide,n=(e,t)=>Dt(e,t,r);return((e,t)=>Mt(e,t,n))(e,t)},NoZeroes:function(e){const t=`Your log's tiebreaker function, ${e.name}, has returned zero and therefore cannot be`;return(r,n)=>{const o=e(r,n);if(0===o)throw Error(t);return o}}},zt=class{async canAppend(e,t){return!0}};var Pt=r(117);const Rt=(e,{ipfs:t,timeout:r,pin:n})=>({add:async(o,i)=>{const s=D.parse(o,B);if(await t.block.put(i,{cid:s.bytes,version:s.version,format:"dag-cbor",mhtype:"sha2-256",pin:n,timeout:r}),e)return e.add(i)},get:async n=>{const o=D.parse(n,B);return await t.block.get(o,{timeout:r})||(e?e.get(n):void 0)},merge:async e=>{},values:()=>({})}),Ft=e=>{let t={};return{add:async(r,n)=>{if(t[r]=n,e)return e.add(n)},get:async r=>t[r]?t[r]:e?e.get(r):void 0,merge:async e=>{t=Object.assign({},t,e?e.values():{})},values:()=>t}},Vt=(e,{size:t}={})=>{const r=new Pt(t||1e6);return{add:async(t,n)=>{if(r.set(t,n),e)return e.add(n)},get:async t=>r.peek(t)?r.get(t):e?e.get(t):void 0,merge:async e=>{e&&Object.keys(e.values()).forEach((t=>{const n=e.get(t);r.set(t,n)}))},values:()=>r.keys.reduce(((e,t)=>(e[t]=r.get(t),e)),{})}},{LastWriteWins:qt,NoZeroes:Kt}=_t,Gt=(e,t)=>Math.max(e,t.clock.time),Wt=Ft(),Ht=(e,{logId:t,logHeads:r,access:n,storage:s,sortFn:a}={})=>{if(!i(e))throw new Error("Identity is required");if(i(r)&&!Array.isArray(r))throw new Error("'logHeads' argument must be an array");const c=t||(new Date).getTime().toString();r=Array.from(new Set(r||[])),n=n||new zt,s=s||Wt,a=Kt(a||qt);const u=()=>r.slice().sort(a).reverse(),f=()=>{const t=Math.max(0,u().reduce(Gt,0));return new o(e.publicKey,t)},h=async e=>s.get(e).then(Tt.decode),l=async t=>{const o=e.provider;if(t.id!==c)throw new Error(`Entry's id (${t.id}) doesn't match the log's id (${c}).`);if(!await n.canAppend(t,o))throw new Error(`Could not append entry:\nKey "${t.identity.id}" is not allowed to write to the log`);if(!await Tt.verify(o,t))throw new Error(`Could not validate signature for entry "${t.hash}"`);r=p(Array.from(new Set([...u(),t]))),await s.add(t.hash,t.bytes)},d=async function*(e,t){t=t||(()=>!1);let r=(e=e||u()).sort(a);const n={};let o;for(;r.length>0&&!0!==await t(o);)if(o=r.pop(),o){yield o;for(const e of[...o.next,...o.refs])if(!n[e]){n[e]=!0;const t=await h(e);t&&(r=[t,...r].sort(a))}}},p=e=>{const t={};for(const r of e)for(const e of r.next)t[e]=r.hash;const r=[];for(const n of e)t[n.hash]||r.push(n);return r};return{id:c,clock:f,heads:u,values:async()=>{const e=[];for await(const t of d())e.unshift(t);return e},access:n,identity:e,storage:s,get:h,append:async(t,o={pointerCount:1})=>{const i=await(async(e=1)=>{let t=2,r=0;const n=[],o=()=>r>=e;for await(const e of d(null,o))r++,r===t&&(e.hash&&n.push(e.hash),t*=2);return n})(o.pointerCount),a=u().map((e=>e.hash)),h=await Tt.create(e,c,t,f().tick(),a,i);if(!await n.canAppend(h,e.provider))throw new Error(`Could not append entry:\nKey "${e.id}" is not allowed to write to the log`);return r=[h],await s.add(h.hash,h.bytes),h},join:async e=>{if(!e)throw new Error("Log instance not defined");if(!(t=e)||void 0===t.id||void 0===t.clock||void 0===t.heads||void 0===t.values||void 0===t.access||void 0===t.identity||void 0===t.storage)throw new Error("Given argument is not an instance of Log");var t;for(const t of e.heads())await l(t);await s.merge(e.storage)},joinEntry:l,traverse:d,iterator:async function*({amount:e=-1,gt:t,gte:r,lt:n,lte:o}){if(0===e)return;if("string"==typeof o&&(o=[await h(o)]),"string"==typeof n){const e=await h(n);n=await Promise.all(e.next.map((e=>h(e))))}if(i(n)&&!Array.isArray(n))throw new Error("lt must be a string or an array of Entries");if(i(o)&&!Array.isArray(o))throw new Error("lte must be a string or an array of Entries");const s=(n||o||u()).filter(i),a=t||r?await h(t||r):null,c=a||-1===e?-1:o||n?e-1:e;let f=0;const l=a&&-1!==e&&!n&&!o,p=l?new Pt(e+2):null;let y=0;const w=d(s,(async e=>!!e&&(f>=c&&-1!==c||!(!a||!Tt.isEqual(e,a))||(f++,!1))));for await(const e of w){const r=n&&Tt.isEqual(e,s),o=t&&Tt.isEqual(e,a);r||o||(l?p.set(y++,e.hash):yield e)}if(l){const t=p.keys.length-1,r=t-e,n=p.keys.slice(r,t);for(const e of n){const t=p.get(e),r=await h(t);yield r}}}}}})(),Log=n})();