!function(e,t,r,i,n){var s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},o="function"==typeof s.parcelRequire6d65&&s.parcelRequire6d65,a=o.cache||{},c="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(t,r){if(!a[t]){if(!e[t]){var i="function"==typeof s.parcelRequire6d65&&s.parcelRequire6d65;if(!r&&i)return i(t,!0);if(o)return o(t,!0);if(c&&"string"==typeof t)return c(t);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}d.resolve=function(r){return e[t][1][r]||r},d.cache={};var l=a[t]=new u.Module(t);e[t][0].call(l.exports,d,l,l.exports,this)}return a[t].exports;function d(e){return u(d.resolve(e))}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=a,u.parent=o,u.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(u,"root",{get:function(){return s.parcelRequire6d65}}),s.parcelRequire6d65=u;for(var l=0;l{const e=u("hash"),t=u("source"),r=u("title"),i=u("time");if(function(){const i=document.getElementById("video"),n=document.getElementById("contextBackground"),s=document.getElementById("contextMenu");i.oncontextmenu=e=>{n.classList.toggle("is-hidden"),s.style.left=e.pageX+"px",s.style.top=e.pageY+"px",e.preventDefault()},n.onclick=e=>{e.stopPropagation(),n.classList.toggle("is-hidden")};const o=`http://ipfsvideo.cc?hash=${e}${r&&"&title="+encodeURIComponent(r)||""}${t&&"&source="+encodeURIComponent(t)||""}`;document.getElementById("contextMenu-url").onclick=e=>{navigator.clipboard.writeText(o)},document.getElementById("contextMenu-urlWithTime").onclick=e=>{navigator.clipboard.writeText(`${o}&time=${Math.round(i.currentTime)}`)}}(),r&&(document.title=r),e){document.getElementById("help").style.display="none",d(),window.addEventListener("resize",d);const r=document.getElementById("video");r.style.display="block";const s="ipfs-"+Math.random();l("Connecting to IPFS");const a=await n.create({repo:s});if(l("Connected"),o.default.DefaultConfig.loader=c.default,o.default.DefaultConfig.debug=!1,o.default.isSupported()){const n=new o.default;n.config.ipfs=a,n.config.ipfsHash=e,l("Video loading"),n.loadSource(t||"master.m3u8"),n.attachMedia(r),n.on(o.default.Events.MANIFEST_PARSED,(()=>{l("Video loaded",!0),i&&(r.currentTime=i),r.play()}))}}}))},{"ipfs-core":"iJfvU","hls.js":"juo1D","hlsjs-ipfs-loader":"1xTo6","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],iJfvU:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./components/index.js"),n=e("libp2p-crypto"),s=e("is-ipfs"),o=e("multiformats/cid"),a=e("multiaddr"),c=e("peer-id"),u=e("ipfs-utils/src/files/glob-source.js"),l=e("ipfs-utils/src/files/url-source.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=d(n),h=d(s),p=d(c),g=d(u),y=d(l);const m=i.create,b=f.default,v=h.default,w=o.CID,_=a.Multiaddr,E=p.default,S=g.default,T=y.default;r.CID=w,r.PeerId=E,r.create=m,r.crypto=b,r.globSource=S,r.isIPFS=v,r.multiaddr=_,r.urlSource=T},{"./components/index.js":"RQOpu","libp2p-crypto":"bb1cb","is-ipfs":"40iuV","multiformats/cid":"9ooAY",multiaddr:"8Mu1u","peer-id":"8Bdb3","ipfs-utils/src/files/glob-source.js":"lHksA","ipfs-utils/src/files/url-source.js":"jQSIS"}],RQOpu:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("merge-options"),n=e("ipfs-utils/src/env.js"),s=e("debug"),o=e("err-code"),a=e("ipfs-unixfs"),c=e("@ipld/dag-pb"),u=e("@ipld/dag-cbor"),l=e("multiformats/hashes/identity"),d=e("multiformats/basics"),f=e("ipfs-core-config/init-assets"),h=e("../errors.js"),p=e("uint8arrays/from-string"),g=e("./start.js"),y=e("./stop.js"),m=e("./dns.js"),b=e("./is-online.js"),v=e("./resolve.js"),w=e("./pin/index.js"),_=e("./ipns.js"),E=e("./name/index.js"),S=e("./refs/index.js"),T=e("./refs/local.js"),A=e("./bitswap/index.js"),k=e("./bootstrap/index.js"),I=e("./block/index.js"),R=e("./root.js"),P=e("./version.js"),O=e("./id.js"),C=e("./config/index.js"),j=e("./dag/index.js"),D=e("../preload.js"),M=e("../mfs-preload.js"),x=e("./files/index.js"),B=e("./key/index.js"),L=e("./object/index.js"),N=e("./repo/index.js"),U=e("./stats/index.js"),F=e("./storage.js"),K=e("./network.js"),z=e("../utils/service.js"),V=e("./swarm/index.js"),q=e("./ping.js"),G=e("./dht.js"),H=e("./pubsub.js"),$=e("ipfs-core-utils/multicodecs"),W=e("ipfs-core-utils/multihashes"),Y=e("ipfs-core-utils/multibases");function X(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function Z(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var Q=X(i),J=X(s),ee=X(o),te=Z(c),re=Z(u);const ie=Q.default.bind({ignoreUndefined:!0}),ne=J.default("ipfs");class se{constructor({print:e,storage:t,codecs:r,options:i}){const{peerId:n,repo:s,keychain:o}=t,a=z.Service.create(K.Network),c=D.createPreloader(i.preload),u=m.createDns(),l=b.createIsOnline({network:a}),f=new _.IPNSAPI(i),h=Object.values(d.hashes);(i.ipld&&i.ipld.hashers?i.ipld.hashers:[]).forEach((e=>h.push(e))),this.hashers=new W.Multihashes({hashers:h,loadHasher:i.ipld&&i.ipld.loadHasher});const p=Object.values(d.bases);(i.ipld&&i.ipld.bases?i.ipld.bases:[]).forEach((e=>p.push(e))),this.bases=new Y.Multibases({bases:p,loadBase:i.ipld&&i.ipld.loadBase});const F=new w.PinAPI({repo:s,codecs:r}),$=new I.BlockAPI({codecs:r,hashers:this.hashers,preload:c,repo:s}),X=new E.NameAPI({dns:u,ipns:f,repo:s,codecs:r,peerId:n,isOnline:l,keychain:o,options:i}),Z=v.createResolve({repo:s,codecs:r,bases:this.bases,name:X}),Q=new j.DagAPI({repo:s,codecs:r,hashers:this.hashers,preload:c}),J=Object.assign(S.createRefs({repo:s,codecs:r,resolve:Z,preload:c}),{local:T.createLocal({repo:t.repo})}),{add:te,addAll:re,cat:ie,get:ne,ls:se}=new R.RootAPI({preload:c,repo:s,options:i.EXPERIMENTAL}),oe=x.createFiles({repo:s,preload:c,hashers:this.hashers,options:i}),ae=M.createMfsPreloader({files:oe,preload:c,options:i.preload});this.preload=c,this.name=X,this.ipns=f,this.pin=F,this.resolve=Z,this.block=$,this.refs=J,this.start=g.createStart({network:a,peerId:n,repo:s,preload:c,ipns:f,mfsPreload:ae,print:e,keychain:o,options:i}),this.stop=y.createStop({network:a,preload:c,mfsPreload:ae,ipns:f,repo:s}),this.dht=G.createDht({network:a,repo:s}),this.pubsub=H.createPubsub({network:a,config:i.config}),this.dns=u,this.isOnline=l,this.id=O.createId({network:a,peerId:n}),this.version=P.createVersion({repo:s}),this.bitswap=new A.BitswapAPI({network:a}),this.bootstrap=new k.BootstrapAPI({repo:s}),this.config=C.createConfig({repo:s}),this.ping=q.createPing({network:a}),this.add=te,this.addAll=re,this.cat=ie,this.get=ne,this.ls=se,this.dag=Q,this.files=oe,this.key=new B.KeyAPI({keychain:o}),this.object=new L.ObjectAPI({preload:c,codecs:r,repo:s}),this.repo=new N.RepoAPI({repo:s,hashers:this.hashers}),this.stats=new U.StatsAPI({repo:s,network:a}),this.swarm=new V.SwarmAPI({network:a}),Object.defineProperty(this,"libp2p",{get(){const e=a.try();return e?e.libp2p:void 0}});const ce=()=>Promise.reject(ee.default(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED"));this.commands=ce,this.diag={cmds:ce,net:ce,sys:ce},this.log={level:ce,ls:ce,tail:async function*(){throw ee.default(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")}},this.mount=ce,this.codecs=r}async init(){throw new h.AlreadyInitializedError}}r.create=async function(e={}){const t=(e=ie({start:!0,EXPERIMENTAL:{},preload:{enabled:!n.isTest,addresses:["/dns4/node0.preload.ipfs.io/https","/dns4/node1.preload.ipfs.io/https","/dns4/node2.preload.ipfs.io/https","/dns4/node3.preload.ipfs.io/https"]}},e)).init||{},r={name:l.identity.name,code:l.identity.code,encode:e=>e,decode:e=>e},i=Object.values(d.codecs);[te,re,r].concat(e.ipld&&e.ipld.codecs||[]).forEach((e=>i.push(e)));const s=new $.Multicodecs({codecs:i,loadCodec:e.ipld&&e.ipld.loadCodec}),o=e.silent?ne:console.log,c=await F.Storage.start(o,s,e),u=await c.repo.config.getAll(),h=new se({storage:c,print:o,codecs:s,options:{...e,config:u}});if(await h.preload.start(),h.ipns.startOffline(c),c.isNew&&!t.emptyRepo){const e=await(async e=>{const t=te.encode({Data:new a.UnixFS({type:"directory"}).marshal(),Links:[]}),r=await e.block.put(t,{mhtype:"sha2-256",format:"dag-pb"});return await e.pin.add(r),r})(h);ne("adding default assets"),await f.initAssets({addAll:h.addAll,print:o}),ne("initializing IPNS keyspace"),await h.ipns.initializeKeyspace(c.peerId.privKey,p.fromString(`/ipfs/${e}`))}return!1!==e.start&&await h.start(),h}},{"merge-options":"fupyv","ipfs-utils/src/env.js":"flyHr",debug:"bO5wM","err-code":"chZjB","ipfs-unixfs":"dF9VO","@ipld/dag-pb":"i2cdx","@ipld/dag-cbor":"3498i","multiformats/hashes/identity":"eYCZn","multiformats/basics":"lPcQG","ipfs-core-config/init-assets":"d1lP3","../errors.js":"j69o8","uint8arrays/from-string":"dF7Y4","./start.js":"93XEg","./stop.js":"kkxN3","./dns.js":"4N8JT","./is-online.js":"2KSm7","./resolve.js":"faFUb","./pin/index.js":"hDUM1","./ipns.js":"fTgTV","./name/index.js":"u6g6o","./refs/index.js":"9Y9Id","./refs/local.js":"lEaxs","./bitswap/index.js":"lGDjO","./bootstrap/index.js":"dh9oy","./block/index.js":"jcbA3","./root.js":"3wOOx","./version.js":"8mBfq","./id.js":"bQa6q","./config/index.js":"3uMSz","./dag/index.js":"9rLzF","../preload.js":"kBOEV","../mfs-preload.js":"7arhH","./files/index.js":"1yxa2","./key/index.js":"aJXOU","./object/index.js":"kwMxL","./repo/index.js":"1qDVo","./stats/index.js":"1NkyG","./storage.js":"bI63q","./network.js":"1MCQb","../utils/service.js":"ethcf","./swarm/index.js":"cGDFf","./ping.js":"dHQEh","./dht.js":"kOgiu","./pubsub.js":"7IJgU","ipfs-core-utils/multicodecs":"4I7TQ","ipfs-core-utils/multihashes":"febSG","ipfs-core-utils/multibases":"lr7wI"}],fupyv:[function(e,t,r){"use strict";const i=e("is-plain-obj"),{hasOwnProperty:n}=Object.prototype,{propertyIsEnumerable:s}=Object,o=(e,t,r)=>Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}),a=this,c={concatArrays:!1,ignoreUndefined:!1},u=e=>{const t=[];for(const r in e)n.call(e,r)&&t.push(r);if(Object.getOwnPropertySymbols){const r=Object.getOwnPropertySymbols(e);for(const i of r)s.call(e,i)&&t.push(i)}return t};function l(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return u(e).forEach((r=>{o(t,r,l(e[r]))})),t}(e):i(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return u(e).forEach((r=>{o(t,r,l(e[r]))})),t}(e):e}const d=(e,t,r,i)=>(r.forEach((r=>{void 0===t[r]&&i.ignoreUndefined||(r in e&&e[r]!==Object.getPrototypeOf(e)?o(e,r,f(e[r],t[r],i)):o(e,r,l(t[r])))})),e);function f(e,t,r){return r.concatArrays&&Array.isArray(e)&&Array.isArray(t)?((e,t,r)=>{let i=e.slice(0,0),s=0;return[e,t].forEach((t=>{const a=[];for(let r=0;r!a.includes(e))),r)})),i})(e,t,r):i(t)&&i(e)?d(e,t,u(t),r):l(t)}t.exports=function(...e){const t=f(l(c),this!==a&&this||{},c);let r={_:{}};for(const n of e)if(void 0!==n){if(!i(n))throw new TypeError("`"+n+"` is not an Option Object");r=f(r,{_:n},t)}return r._}},{"is-plain-obj":"jGt65"}],jGt65:[function(e,t,r){"use strict";t.exports=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}},{}],flyHr:[function(e,t,r){var i=e("process");const n=e("is-electron"),s="object"==typeof window&&"object"==typeof document&&9===document.nodeType,o=n(),a=s&&!o,c=o&&!s,u=o&&s,l="function"==typeof e&&void 0!==i&&void 0!==i.release&&"node"===i.release.name&&!o,d="function"==typeof importScripts&&"undefined"!=typeof self&&"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,f=void 0!==i&&void 0!==i.env&&!1,h="undefined"!=typeof navigator&&"ReactNative"===navigator.product;t.exports={isTest:f,isElectron:o,isElectronMain:c,isElectronRenderer:u,isNode:l,isBrowser:a,isWebWorker:d,isEnvWithDom:s,isReactNative:h}},{process:"bjUAi","is-electron":"e6ybt"}],bjUAi:[function(e,t,r){var i,n,s=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function c(e){if(i===setTimeout)return setTimeout(e,0);if((i===o||!i)&&setTimeout)return i=setTimeout,setTimeout(e,0);try{return i(e,0)}catch(t){try{return i.call(null,e,0)}catch(t){return i.call(this,e,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:o}catch(e){i=o}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var u,l=[],d=!1,f=-1;function h(){d&&u&&(d=!1,u.length?l=u.concat(l):f=-1,l.length&&p())}function p(){if(!d){var e=c(h);d=!0;for(var t=l.length;t;){for(u=l,l=[];++f1)for(var r=1;r=0)}},{process:"bjUAi"}],bO5wM:[function(e,t,r){var i=e("process");r.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;e.splice(1,0,r,"color: inherit");let i=0,n=0;e[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(i++,"%c"===e&&(n=i))})),e.splice(n,0,r)},r.save=function(e){try{e?r.storage.setItem("debug",e):r.storage.removeItem("debug")}catch(e){}},r.load=function(){let e;try{e=r.storage.getItem("debug")}catch(e){}!e&&void 0!==i&&"env"in i&&(e=void 0);return e},r.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},r.storage=function(){try{return localStorage}catch(e){}}(),r.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),r.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],r.log=console.debug||console.log||(()=>{}),t.exports=e("./common")(r);const{formatters:n}=t.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},{process:"bjUAi","./common":"5mxUS"}],"5mxUS":[function(e,t,r){t.exports=function(t){function r(e){let t,n,s,o=null;function a(...e){if(!a.enabled)return;const i=a,n=Number(new Date),s=n-(t||n);i.diff=s,i.prev=t,i.curr=n,t=n,e[0]=r.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let o=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((t,n)=>{if("%%"===t)return"%";o++;const s=r.formatters[n];if("function"==typeof s){const r=e[o];t=s.call(i,r),e.splice(o,1),o--}return t})),r.formatArgs.call(i,e);(i.log||r.log).apply(i,e)}return a.namespace=e,a.useColors=r.useColors(),a.color=r.selectColor(e),a.extend=i,a.destroy=r.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(n!==r.namespaces&&(n=r.namespaces,s=r.enabled(e)),s),set:e=>{o=e}}),"function"==typeof r.init&&r.init(a),a}function i(e,t){const i=r(this.namespace+(void 0===t?":":t)+e);return i.log=this.log,i}function n(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return r.debug=r,r.default=r,r.coerce=function(e){return e instanceof Error?e.stack||e.message:e},r.disable=function(){const e=[...r.names.map(n),...r.skips.map(n).map((e=>"-"+e))].join(",");return r.enable(""),e},r.enable=function(e){let t;r.save(e),r.namespaces=e,r.names=[],r.skips=[];const i=("string"==typeof e?e:"").split(/[\s,]+/),n=i.length;for(t=0;t{r[e]=t[e]})),r.names=[],r.skips=[],r.formatters={},r.selectColor=function(e){let t=0;for(let r=0;r=1.5*r;return Math.round(e/r)+" "+i+(n?"s":"")}t.exports=function(e,t){t=t||{};var r,l,d=typeof e;if("string"===d&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*c;case"weeks":case"week":case"w":return r*a;case"days":case"day":case"d":return r*o;case"hours":case"hour":case"hrs":case"hr":case"h":return r*s;case"minutes":case"minute":case"mins":case"min":case"m":return r*n;case"seconds":case"second":case"secs":case"sec":case"s":return r*i;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===d&&isFinite(e))return t.long?(r=e,(l=Math.abs(r))>=o?u(r,l,o,"day"):l>=s?u(r,l,s,"hour"):l>=n?u(r,l,n,"minute"):l>=i?u(r,l,i,"second"):r+" ms"):function(e){var t=Math.abs(e);return t>=o?Math.round(e/o)+"d":t>=s?Math.round(e/s)+"h":t>=n?Math.round(e/n)+"m":t>=i?Math.round(e/i)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],chZjB:[function(e,t,r){"use strict";function i(e,t){for(const r in t)Object.defineProperty(e,r,{value:t[r],enumerable:!0,configurable:!0});return e}t.exports=function(e,t,r){if(!e||"string"==typeof e)throw new TypeError("Please pass an Error to err-code");r||(r={}),"object"==typeof t&&(r=t,t=""),t&&(r.code=t);try{return i(e,r)}catch(t){r.message=e.message,r.stack=e.stack;const n=function(){};n.prototype=Object.create(Object.getPrototypeOf(e));return i(new n,r)}}},{}],dF9VO:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("err-code"),n=e("./unixfs.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=s(i);const a=n.Data,c=["raw","directory","file","metadata","symlink","hamt-sharded-directory"],u=["directory","hamt-sharded-directory"],l=parseInt("0644",8),d=parseInt("0755",8);function f(e){if(null!=e)return"number"==typeof e?4095&e:"0"===(e=e.toString()).substring(0,1)?4095&parseInt(e,8):4095&parseInt(e,10)}function h(e){if(null==e)return;let t;if(null!=e.secs&&(t={secs:e.secs,nsecs:e.nsecs}),null!=e.Seconds&&(t={secs:e.Seconds,nsecs:e.FractionalNanoseconds}),Array.isArray(e)&&(t={secs:e[0],nsecs:e[1]}),e instanceof Date){const r=e.getTime(),i=Math.floor(r/1e3);t={secs:i,nsecs:1e3*(r-1e3*i)}}if(Object.prototype.hasOwnProperty.call(t,"secs")){if(null!=t&&null!=t.nsecs&&(t.nsecs<0||t.nsecs>999999999))throw o.default(new Error("mtime-nsecs must be within the range [0,999999999]"),"ERR_INVALID_MTIME_NSECS");return t}}class p{static unmarshal(e){const t=a.decode(e),r=a.toObject(t,{defaults:!1,arrays:!0,longs:Number,objects:!1}),i=new p({type:c[r.Type],data:r.Data,blockSizes:r.blocksizes,mode:r.mode,mtime:r.mtime?{secs:r.mtime.Seconds,nsecs:r.mtime.FractionalNanoseconds}:void 0});return i._originalMode=r.mode||0,i}constructor(e={type:"file"}){const{type:t,data:r,blockSizes:i,hashType:n,fanout:s,mtime:a,mode:u}=e;if(t&&!c.includes(t))throw o.default(new Error("Type: "+t+" is not valid"),"ERR_INVALID_TYPE");this.type=t||"file",this.data=r,this.hashType=n,this.fanout=s,this.blockSizes=i||[],this._originalMode=0,this.mode=f(u),a&&(this.mtime=h(a),this.mtime&&!this.mtime.nsecs&&(this.mtime.nsecs=0))}set mode(e){this._mode=this.isDirectory()?d:l;const t=f(e);void 0!==t&&(this._mode=t)}get mode(){return this._mode}isDirectory(){return Boolean(this.type&&u.includes(this.type))}addBlockSize(e){this.blockSizes.push(e)}removeBlockSize(e){this.blockSizes.splice(e,1)}fileSize(){if(this.isDirectory())return 0;let e=0;return this.blockSizes.forEach((t=>{e+=t})),this.data&&(e+=this.data.length),e}marshal(){let e;switch(this.type){case"raw":e=a.DataType.Raw;break;case"directory":e=a.DataType.Directory;break;case"file":e=a.DataType.File;break;case"metadata":e=a.DataType.Metadata;break;case"symlink":e=a.DataType.Symlink;break;case"hamt-sharded-directory":e=a.DataType.HAMTShard;break;default:throw o.default(new Error("Type: "+e+" is not valid"),"ERR_INVALID_TYPE")}let t,r,i=this.data;if(this.data&&this.data.length||(i=void 0),null!=this.mode&&(t=4294963200&this._originalMode|(f(this.mode)||0),t!==l||this.isDirectory()||(t=void 0),t===d&&this.isDirectory()&&(t=void 0)),null!=this.mtime){const e=h(this.mtime);e&&(r={Seconds:e.secs,FractionalNanoseconds:e.nsecs},0===r.FractionalNanoseconds&&delete r.FractionalNanoseconds)}const n={Type:e,Data:i,filesize:this.isDirectory()?void 0:this.fileSize(),blocksizes:this.blockSizes,hashType:this.hashType,fanout:this.fanout,mode:t,mtime:r};return a.encode(n).finish()}}r.UnixFS=p,r.parseMode=f,r.parseMtime=h},{"err-code":"chZjB","./unixfs.js":"l2F50"}],l2F50:[function(e,t,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(r,"__esModule",{value:!0});var n=i(e("protobufjs/minimal.js"));const s=n.default.Reader,o=n.default.Writer,a=n.default.util,c=n.default.roots["ipfs-unixfs"]||(n.default.roots["ipfs-unixfs"]={}),u=c.Data=(()=>{function e(e){if(this.blocksizes=[],e)for(var t=Object.keys(e),r=0;r>>3){case 1:i.Type=e.int32();break;case 2:i.Data=e.bytes();break;case 3:i.filesize=e.uint64();break;case 4:if(i.blocksizes&&i.blocksizes.length||(i.blocksizes=[]),2==(7&n))for(var o=e.uint32()+e.pos;e.pos>>0,e.filesize.high>>>0).toNumber(!0))),e.blocksizes){if(!Array.isArray(e.blocksizes))throw TypeError(".Data.blocksizes: array expected");t.blocksizes=[];for(var r=0;r>>0,e.blocksizes[r].high>>>0).toNumber(!0))}if(null!=e.hashType&&(a.Long?(t.hashType=a.Long.fromValue(e.hashType)).unsigned=!0:"string"==typeof e.hashType?t.hashType=parseInt(e.hashType,10):"number"==typeof e.hashType?t.hashType=e.hashType:"object"==typeof e.hashType&&(t.hashType=new a.LongBits(e.hashType.low>>>0,e.hashType.high>>>0).toNumber(!0))),null!=e.fanout&&(a.Long?(t.fanout=a.Long.fromValue(e.fanout)).unsigned=!0:"string"==typeof e.fanout?t.fanout=parseInt(e.fanout,10):"number"==typeof e.fanout?t.fanout=e.fanout:"object"==typeof e.fanout&&(t.fanout=new a.LongBits(e.fanout.low>>>0,e.fanout.high>>>0).toNumber(!0))),null!=e.mode&&(t.mode=e.mode>>>0),null!=e.mtime){if("object"!=typeof e.mtime)throw TypeError(".Data.mtime: object expected");t.mtime=c.UnixTime.fromObject(e.mtime)}return t},e.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.blocksizes=[]),t.defaults){if(r.Type=t.enums===String?"Raw":0,t.bytes===String?r.Data="":(r.Data=[],t.bytes!==Array&&(r.Data=a.newBuffer(r.Data))),a.Long){var i=new a.Long(0,0,!0);r.filesize=t.longs===String?i.toString():t.longs===Number?i.toNumber():i}else r.filesize=t.longs===String?"0":0;if(a.Long){i=new a.Long(0,0,!0);r.hashType=t.longs===String?i.toString():t.longs===Number?i.toNumber():i}else r.hashType=t.longs===String?"0":0;if(a.Long){i=new a.Long(0,0,!0);r.fanout=t.longs===String?i.toString():t.longs===Number?i.toNumber():i}else r.fanout=t.longs===String?"0":0;r.mode=0,r.mtime=null}if(null!=e.Type&&e.hasOwnProperty("Type")&&(r.Type=t.enums===String?c.Data.DataType[e.Type]:e.Type),null!=e.Data&&e.hasOwnProperty("Data")&&(r.Data=t.bytes===String?a.base64.encode(e.Data,0,e.Data.length):t.bytes===Array?Array.prototype.slice.call(e.Data):e.Data),null!=e.filesize&&e.hasOwnProperty("filesize")&&("number"==typeof e.filesize?r.filesize=t.longs===String?String(e.filesize):e.filesize:r.filesize=t.longs===String?a.Long.prototype.toString.call(e.filesize):t.longs===Number?new a.LongBits(e.filesize.low>>>0,e.filesize.high>>>0).toNumber(!0):e.filesize),e.blocksizes&&e.blocksizes.length){r.blocksizes=[];for(var n=0;n>>0,e.blocksizes[n].high>>>0).toNumber(!0):e.blocksizes[n]}return null!=e.hashType&&e.hasOwnProperty("hashType")&&("number"==typeof e.hashType?r.hashType=t.longs===String?String(e.hashType):e.hashType:r.hashType=t.longs===String?a.Long.prototype.toString.call(e.hashType):t.longs===Number?new a.LongBits(e.hashType.low>>>0,e.hashType.high>>>0).toNumber(!0):e.hashType),null!=e.fanout&&e.hasOwnProperty("fanout")&&("number"==typeof e.fanout?r.fanout=t.longs===String?String(e.fanout):e.fanout:r.fanout=t.longs===String?a.Long.prototype.toString.call(e.fanout):t.longs===Number?new a.LongBits(e.fanout.low>>>0,e.fanout.high>>>0).toNumber(!0):e.fanout),null!=e.mode&&e.hasOwnProperty("mode")&&(r.mode=e.mode),null!=e.mtime&&e.hasOwnProperty("mtime")&&(r.mtime=c.UnixTime.toObject(e.mtime,t)),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,n.default.util.toJSONOptions)},e.DataType=function(){const e={},t=Object.create(e);return t[e[0]="Raw"]=0,t[e[1]="Directory"]=1,t[e[2]="File"]=2,t[e[3]="Metadata"]=3,t[e[4]="Symlink"]=4,t[e[5]="HAMTShard"]=5,t}(),e})(),l=c.UnixTime=(()=>{function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:i.Seconds=e.int64();break;case 2:i.FractionalNanoseconds=e.fixed32();break;default:e.skipType(7&n)}}if(!i.hasOwnProperty("Seconds"))throw a.ProtocolError("missing required 'Seconds'",{instance:i});return i},e.fromObject=function(e){if(e instanceof c.UnixTime)return e;var t=new c.UnixTime;return null!=e.Seconds&&(a.Long?(t.Seconds=a.Long.fromValue(e.Seconds)).unsigned=!1:"string"==typeof e.Seconds?t.Seconds=parseInt(e.Seconds,10):"number"==typeof e.Seconds?t.Seconds=e.Seconds:"object"==typeof e.Seconds&&(t.Seconds=new a.LongBits(e.Seconds.low>>>0,e.Seconds.high>>>0).toNumber())),null!=e.FractionalNanoseconds&&(t.FractionalNanoseconds=e.FractionalNanoseconds>>>0),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults){if(a.Long){var i=new a.Long(0,0,!1);r.Seconds=t.longs===String?i.toString():t.longs===Number?i.toNumber():i}else r.Seconds=t.longs===String?"0":0;r.FractionalNanoseconds=0}return null!=e.Seconds&&e.hasOwnProperty("Seconds")&&("number"==typeof e.Seconds?r.Seconds=t.longs===String?String(e.Seconds):e.Seconds:r.Seconds=t.longs===String?a.Long.prototype.toString.call(e.Seconds):t.longs===Number?new a.LongBits(e.Seconds.low>>>0,e.Seconds.high>>>0).toNumber():e.Seconds),null!=e.FractionalNanoseconds&&e.hasOwnProperty("FractionalNanoseconds")&&(r.FractionalNanoseconds=e.FractionalNanoseconds),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,n.default.util.toJSONOptions)},e})(),d=c.Metadata=(()=>{function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3==1)i.MimeType=e.string();else e.skipType(7&n)}return i},e.fromObject=function(e){if(e instanceof c.Metadata)return e;var t=new c.Metadata;return null!=e.MimeType&&(t.MimeType=String(e.MimeType)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.MimeType=""),null!=e.MimeType&&e.hasOwnProperty("MimeType")&&(r.MimeType=e.MimeType),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,n.default.util.toJSONOptions)},e})();r.Data=u,r.Metadata=d,r.UnixTime=l,r.default=c},{"protobufjs/minimal.js":"grAXL"}],grAXL:[function(e,t,r){"use strict";t.exports=e("./src/index-minimal")},{"./src/index-minimal":"3OMTL"}],"3OMTL":[function(e,t,r){"use strict";var i=r;function n(){i.util._configure(),i.Writer._configure(i.BufferWriter),i.Reader._configure(i.BufferReader)}i.build="minimal",i.Writer=e("./writer"),i.BufferWriter=e("./writer_buffer"),i.Reader=e("./reader"),i.BufferReader=e("./reader_buffer"),i.util=e("./util/minimal"),i.rpc=e("./rpc"),i.roots=e("./roots"),i.configure=n,n()},{"./writer":"eDEax","./writer_buffer":"a3zLo","./reader":"hwSZz","./reader_buffer":"51B7L","./util/minimal":"kCaEH","./rpc":"flYC1","./roots":"aq70a"}],eDEax:[function(e,t,r){"use strict";t.exports=d;var i,n=e("./util/minimal"),s=n.LongBits,o=n.base64,a=n.utf8;function c(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}function u(){}function l(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function d(){this.len=0,this.head=new c(u,0,0),this.tail=this.head,this.states=null}var f=function(){return n.Buffer?function(){return(d.create=function(){return new i})()}:function(){return new d}};function h(e,t,r){t[r]=255&e}function p(e,t){this.len=e,this.next=void 0,this.val=t}function g(e,t,r){for(;e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function y(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}d.create=f(),d.alloc=function(e){return new n.Array(e)},n.Array!==Array&&(d.alloc=n.pool(d.alloc,n.Array.prototype.subarray)),d.prototype._push=function(e,t,r){return this.tail=this.tail.next=new c(e,t,r),this.len+=t,this},p.prototype=Object.create(c.prototype),p.prototype.fn=function(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e},d.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new p((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},d.prototype.int32=function(e){return e<0?this._push(g,10,s.fromNumber(e)):this.uint32(e)},d.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},d.prototype.uint64=function(e){var t=s.from(e);return this._push(g,t.length(),t)},d.prototype.int64=d.prototype.uint64,d.prototype.sint64=function(e){var t=s.from(e).zzEncode();return this._push(g,t.length(),t)},d.prototype.bool=function(e){return this._push(h,1,e?1:0)},d.prototype.fixed32=function(e){return this._push(y,4,e>>>0)},d.prototype.sfixed32=d.prototype.fixed32,d.prototype.fixed64=function(e){var t=s.from(e);return this._push(y,4,t.lo)._push(y,4,t.hi)},d.prototype.sfixed64=d.prototype.fixed64,d.prototype.float=function(e){return this._push(n.float.writeFloatLE,4,e)},d.prototype.double=function(e){return this._push(n.float.writeDoubleLE,8,e)};var m=n.Array.prototype.set?function(e,t,r){t.set(e,r)}:function(e,t,r){for(var i=0;i>>0;if(!t)return this._push(h,1,0);if(n.isString(e)){var r=d.alloc(t=o.length(e));o.decode(e,r,0),e=r}return this.uint32(t)._push(m,t,e)},d.prototype.string=function(e){var t=a.length(e);return t?this.uint32(t)._push(a.write,t,e):this._push(h,1,0)},d.prototype.fork=function(){return this.states=new l(this),this.head=this.tail=new c(u,0,0),this.len=0,this},d.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new c(u,0,0),this.len=0),this},d.prototype.ldelim=function(){var e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this},d.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),r=0;e;)e.fn(e.val,t,r),r+=e.len,e=e.next;return t},d._configure=function(e){i=e,d.create=f(),i._configure()}},{"./util/minimal":"kCaEH"}],kCaEH:[function(e,t,r){var i=arguments[3],n=r;function s(e,t,r){for(var i=Object.keys(t),n=0;n0)},n.Buffer=function(){try{var e=n.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(e){return null}}(),n._Buffer_from=null,n._Buffer_allocUnsafe=null,n.newBuffer=function(e){return"number"==typeof e?n.Buffer?n._Buffer_allocUnsafe(e):new n.Array(e):n.Buffer?n._Buffer_from(e):"undefined"==typeof Uint8Array?e:new Uint8Array(e)},n.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,n.Long=n.global.dcodeIO&&n.global.dcodeIO.Long||n.global.Long||n.inquire("long"),n.key2Re=/^true|false|0|1$/,n.key32Re=/^-?(?:0|[1-9][0-9]*)$/,n.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,n.longToHash=function(e){return e?n.LongBits.from(e).toHash():n.LongBits.zeroHash},n.longFromHash=function(e,t){var r=n.LongBits.fromHash(e);return n.Long?n.Long.fromBits(r.lo,r.hi,t):r.toNumber(Boolean(t))},n.merge=s,n.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},n.newError=o,n.ProtocolError=o("ProtocolError"),n.oneOfGetter=function(e){for(var t={},r=0;r-1;--r)if(1===t[e[r]]&&void 0!==this[e[r]]&&null!==this[e[r]])return e[r]}},n.oneOfSetter=function(e){return function(t){for(var r=0;r1&&"="===e.charAt(t);)++r;return Math.ceil(3*e.length)/4-r};for(var n=new Array(64),s=new Array(123),o=0;o<64;)s[n[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;i.encode=function(e,t,r){for(var i,s=null,o=[],a=0,c=0;t>2],i=(3&u)<<4,c=1;break;case 1:o[a++]=n[i|u>>4],i=(15&u)<<2,c=2;break;case 2:o[a++]=n[i|u>>6],o[a++]=n[63&u],c=0}a>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,o)),a=0)}return c&&(o[a++]=n[i],o[a++]=61,1===c&&(o[a++]=61)),s?(a&&s.push(String.fromCharCode.apply(String,o.slice(0,a))),s.join("")):String.fromCharCode.apply(String,o.slice(0,a))};var a="invalid encoding";i.decode=function(e,t,r){for(var i,n=r,o=0,c=0;c1)break;if(void 0===(u=s[u]))throw Error(a);switch(o){case 0:i=u,o=1;break;case 1:t[r++]=i<<2|(48&u)>>4,i=u,o=2;break;case 2:t[r++]=(15&i)<<4|(60&u)>>2,i=u,o=3;break;case 3:t[r++]=(3&i)<<6|u,o=0}}if(1===o)throw Error(a);return r-n},i.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}},{}],"8QYdM":[function(e,t,r){"use strict";function i(){this._listeners={}}t.exports=i,i.prototype.on=function(e,t,r){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:r||this}),this},i.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var r=this._listeners[e],i=0;i0?0:2147483648,r,i);else if(isNaN(t))e(2143289344,r,i);else if(t>34028234663852886e22)e((n<<31|2139095040)>>>0,r,i);else if(t<11754943508222875e-54)e((n<<31|Math.round(t/1401298464324817e-60))>>>0,r,i);else{var s=Math.floor(Math.log(t)/Math.LN2);e((n<<31|s+127<<23|8388607&Math.round(t*Math.pow(2,-s)*8388608))>>>0,r,i)}}function r(e,t,r){var i=e(t,r),n=2*(i>>31)+1,s=i>>>23&255,o=8388607&i;return 255===s?o?NaN:n*(1/0):0===s?1401298464324817e-60*n*o:n*Math.pow(2,s-150)*(o+8388608)}e.writeFloatLE=t.bind(null,n),e.writeFloatBE=t.bind(null,s),e.readFloatLE=r.bind(null,o),e.readFloatBE=r.bind(null,a)}(),"undefined"!=typeof Float64Array?function(){var t=new Float64Array([-0]),r=new Uint8Array(t.buffer),i=128===r[7];function n(e,i,n){t[0]=e,i[n]=r[0],i[n+1]=r[1],i[n+2]=r[2],i[n+3]=r[3],i[n+4]=r[4],i[n+5]=r[5],i[n+6]=r[6],i[n+7]=r[7]}function s(e,i,n){t[0]=e,i[n]=r[7],i[n+1]=r[6],i[n+2]=r[5],i[n+3]=r[4],i[n+4]=r[3],i[n+5]=r[2],i[n+6]=r[1],i[n+7]=r[0]}function o(e,i){return r[0]=e[i],r[1]=e[i+1],r[2]=e[i+2],r[3]=e[i+3],r[4]=e[i+4],r[5]=e[i+5],r[6]=e[i+6],r[7]=e[i+7],t[0]}function a(e,i){return r[7]=e[i],r[6]=e[i+1],r[5]=e[i+2],r[4]=e[i+3],r[3]=e[i+4],r[2]=e[i+5],r[1]=e[i+6],r[0]=e[i+7],t[0]}e.writeDoubleLE=i?n:s,e.writeDoubleBE=i?s:n,e.readDoubleLE=i?o:a,e.readDoubleBE=i?a:o}():function(){function t(e,t,r,i,n,s){var o=i<0?1:0;if(o&&(i=-i),0===i)e(0,n,s+t),e(1/i>0?0:2147483648,n,s+r);else if(isNaN(i))e(0,n,s+t),e(2146959360,n,s+r);else if(i>17976931348623157e292)e(0,n,s+t),e((o<<31|2146435072)>>>0,n,s+r);else{var a;if(i<22250738585072014e-324)e((a=i/5e-324)>>>0,n,s+t),e((o<<31|a/4294967296)>>>0,n,s+r);else{var c=Math.floor(Math.log(i)/Math.LN2);1024===c&&(c=1023),e(4503599627370496*(a=i*Math.pow(2,-c))>>>0,n,s+t),e((o<<31|c+1023<<20|1048576*a&1048575)>>>0,n,s+r)}}}function r(e,t,r,i,n){var s=e(i,n+t),o=e(i,n+r),a=2*(o>>31)+1,c=o>>>20&2047,u=4294967296*(1048575&o)+s;return 2047===c?u?NaN:a*(1/0):0===c?5e-324*a*u:a*Math.pow(2,c-1075)*(u+4503599627370496)}e.writeDoubleLE=t.bind(null,n,0,4),e.writeDoubleBE=t.bind(null,s,4,0),e.readDoubleLE=r.bind(null,o,0,4),e.readDoubleBE=r.bind(null,a,4,0)}(),e}function n(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function s(e,t,r){t[r]=e>>>24,t[r+1]=e>>>16&255,t[r+2]=e>>>8&255,t[r+3]=255&e}function o(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function a(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}t.exports=i(i)},{}],"3GHL4":[function(require,module,exports){"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}module.exports=inquire},{}],ergn2:[function(e,t,r){"use strict";var i=r;i.length=function(e){for(var t=0,r=0,i=0;i191&&i<224?s[o++]=(31&i)<<6|63&e[t++]:i>239&&i<365?(i=((7&i)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,s[o++]=55296+(i>>10),s[o++]=56320+(1023&i)):s[o++]=(15&i)<<12|(63&e[t++])<<6|63&e[t++],o>8191&&((n||(n=[])).push(String.fromCharCode.apply(String,s)),o=0);return n?(o&&n.push(String.fromCharCode.apply(String,s.slice(0,o))),n.join("")):String.fromCharCode.apply(String,s.slice(0,o))},i.write=function(e,t,r){for(var i,n,s=r,o=0;o>6|192,t[r++]=63&i|128):55296==(64512&i)&&56320==(64512&(n=e.charCodeAt(o+1)))?(i=65536+((1023&i)<<10)+(1023&n),++o,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-s}},{}],lRkSe:[function(e,t,r){"use strict";t.exports=function(e,t,r){var i=r||8192,n=i>>>1,s=null,o=i;return function(r){if(r<1||r>n)return e(r);o+r>i&&(s=e(i),o=0);var a=t.call(s,o,o+=r);return 7&o&&(o=1+(7|o)),a}}},{}],kTtk9:[function(e,t,r){"use strict";t.exports=n;var i=e("../util/minimal");function n(e,t){this.lo=e>>>0,this.hi=t>>>0}var s=n.zero=new n(0,0);s.toNumber=function(){return 0},s.zzEncode=s.zzDecode=function(){return this},s.length=function(){return 1};var o=n.zeroHash="\0\0\0\0\0\0\0\0";n.fromNumber=function(e){if(0===e)return s;var t=e<0;t&&(e=-e);var r=e>>>0,i=(e-r)/4294967296>>>0;return t&&(i=~i>>>0,r=~r>>>0,++r>4294967295&&(r=0,++i>4294967295&&(i=0))),new n(r,i)},n.from=function(e){if("number"==typeof e)return n.fromNumber(e);if(i.isString(e)){if(!i.Long)return n.fromNumber(parseInt(e,10));e=i.Long.fromString(e)}return e.low||e.high?new n(e.low>>>0,e.high>>>0):s},n.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,r=~this.hi>>>0;return t||(r=r+1>>>0),-(t+4294967296*r)}return this.lo+4294967296*this.hi},n.prototype.toLong=function(e){return i.Long?new i.Long(0|this.lo,0|this.hi,Boolean(e)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(e)}};var a=String.prototype.charCodeAt;n.fromHash=function(e){return e===o?s:new n((a.call(e,0)|a.call(e,1)<<8|a.call(e,2)<<16|a.call(e,3)<<24)>>>0,(a.call(e,4)|a.call(e,5)<<8|a.call(e,6)<<16|a.call(e,7)<<24)>>>0)},n.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},n.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},n.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},n.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}},{"../util/minimal":"kCaEH"}],a3zLo:[function(e,t,r){"use strict";t.exports=s;var i=e("./writer");(s.prototype=Object.create(i.prototype)).constructor=s;var n=e("./util/minimal");function s(){i.call(this)}function o(e,t,r){e.length<40?n.utf8.write(e,t,r):t.utf8Write?t.utf8Write(e,r):t.write(e,r)}s._configure=function(){s.alloc=n._Buffer_allocUnsafe,s.writeBytesBuffer=n.Buffer&&n.Buffer.prototype instanceof Uint8Array&&"set"===n.Buffer.prototype.set.name?function(e,t,r){t.set(e,r)}:function(e,t,r){if(e.copy)e.copy(t,r,0,e.length);else for(var i=0;i>>0;return this.uint32(t),t&&this._push(s.writeBytesBuffer,t,e),this},s.prototype.string=function(e){var t=n.Buffer.byteLength(e);return this.uint32(t),t&&this._push(o,t,e),this},s._configure()},{"./writer":"eDEax","./util/minimal":"kCaEH"}],hwSZz:[function(e,t,r){"use strict";t.exports=c;var i,n=e("./util/minimal"),s=n.LongBits,o=n.utf8;function a(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function c(e){this.buf=e,this.pos=0,this.len=e.length}var u,l="undefined"!=typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new c(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new c(e);throw Error("illegal buffer")},d=function(){return n.Buffer?function(e){return(c.create=function(e){return n.Buffer.isBuffer(e)?new i(e):l(e)})(e)}:l};function f(){var e=new s(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw a(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw a(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function h(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function p(){if(this.pos+8>this.len)throw a(this,8);return new s(h(this.buf,this.pos+=4),h(this.buf,this.pos+=4))}c.create=d(),c.prototype._slice=n.Array.prototype.subarray||n.Array.prototype.slice,c.prototype.uint32=(u=4294967295,function(){if(u=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return u;if(u=(u|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return u;if((this.pos+=5)>this.len)throw this.pos=this.len,a(this,10);return u}),c.prototype.int32=function(){return 0|this.uint32()},c.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)|0},c.prototype.bool=function(){return 0!==this.uint32()},c.prototype.fixed32=function(){if(this.pos+4>this.len)throw a(this,4);return h(this.buf,this.pos+=4)},c.prototype.sfixed32=function(){if(this.pos+4>this.len)throw a(this,4);return 0|h(this.buf,this.pos+=4)},c.prototype.float=function(){if(this.pos+4>this.len)throw a(this,4);var e=n.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},c.prototype.double=function(){if(this.pos+8>this.len)throw a(this,4);var e=n.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},c.prototype.bytes=function(){var e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw a(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(t,r):t===r?new this.buf.constructor(0):this._slice.call(this.buf,t,r)},c.prototype.string=function(){var e=this.bytes();return o.read(e,0,e.length)},c.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw a(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw a(this)}while(128&this.buf[this.pos++]);return this},c.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},c._configure=function(e){i=e,c.create=d(),i._configure();var t=n.Long?"toLong":"toNumber";n.merge(c.prototype,{int64:function(){return f.call(this)[t](!1)},uint64:function(){return f.call(this)[t](!0)},sint64:function(){return f.call(this).zzDecode()[t](!1)},fixed64:function(){return p.call(this)[t](!0)},sfixed64:function(){return p.call(this)[t](!1)}})}},{"./util/minimal":"kCaEH"}],"51B7L":[function(e,t,r){"use strict";t.exports=s;var i=e("./reader");(s.prototype=Object.create(i.prototype)).constructor=s;var n=e("./util/minimal");function s(e){i.call(this,e)}s._configure=function(){n.Buffer&&(s.prototype._slice=n.Buffer.prototype.slice)},s.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},s._configure()},{"./reader":"hwSZz","./util/minimal":"kCaEH"}],flYC1:[function(e,t,r){"use strict";r.Service=e("./rpc/service")},{"./rpc/service":"cl9qf"}],cl9qf:[function(e,t,r){"use strict";t.exports=n;var i=e("../util/minimal");function n(e,t,r){if("function"!=typeof e)throw TypeError("rpcImpl must be a function");i.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(r)}(n.prototype=Object.create(i.EventEmitter.prototype)).constructor=n,n.prototype.rpcCall=function e(t,r,n,s,o){if(!s)throw TypeError("request must be specified");var a=this;if(!o)return i.asPromise(e,a,t,r,n,s);if(a.rpcImpl)try{return a.rpcImpl(t,r[a.requestDelimited?"encodeDelimited":"encode"](s).finish(),(function(e,r){if(e)return a.emit("error",e,t),o(e);if(null!==r){if(!(r instanceof n))try{r=n[a.responseDelimited?"decodeDelimited":"decode"](r)}catch(e){return a.emit("error",e,t),o(e)}return a.emit("data",r,t),o(null,r)}a.end(!0)}))}catch(e){return a.emit("error",e,t),void setTimeout((function(){o(e)}),0)}else setTimeout((function(){o(Error("already ended"))}),0)},n.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},{"../util/minimal":"kCaEH"}],aq70a:[function(e,t,r){"use strict";t.exports={}},{}],i2cdx:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("./pb-decode.js"),s=e("./pb-encode.js"),o=e("./util.js");r.createLink=o.createLink,r.createNode=o.createNode,r.prepare=o.prepare,r.validate=o.validate,r.code=112,r.decode=function(e){const t=n.decodeNode(e),r={};return t.Data&&(r.Data=t.Data),t.Links&&(r.Links=t.Links.map((e=>{const t={};try{t.Hash=i.CID.decode(e.Hash)}catch(e){}if(!t.Hash)throw new Error("Invalid Hash field found in link, expected CID");return void 0!==e.Name&&(t.Name=e.Name),void 0!==e.Tsize&&(t.Tsize=e.Tsize),t}))),r},r.encode=function(e){o.validate(e);const t={};return e.Links&&(t.Links=e.Links.map((e=>{const t={};return e.Hash&&(t.Hash=e.Hash.bytes),void 0!==e.Name&&(t.Name=e.Name),void 0!==e.Tsize&&(t.Tsize=e.Tsize),t}))),e.Data&&(t.Data=e.Data),s.encodeNode(t)},r.name="dag-pb"},{"multiformats/cid":"9ooAY","./pb-decode.js":"ld3PU","./pb-encode.js":"5nPbE","./util.js":"1YHGP"}],"9ooAY":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./varint.js"),n=e("./hashes/digest.js"),s=e("./bases/base58.js"),o=e("./bases/base32.js"),a=e("./bytes.js");class c{constructor(e,t,r,i){this.code=t,this.version=e,this.multihash=r,this.bytes=i,this.byteOffset=i.byteOffset,this.byteLength=i.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:m,byteLength:m,code:y,version:y,multihash:y,bytes:y,_baseCache:m,asCID:m})}toV0(){if(0===this.version)return this;{const{code:e,multihash:t}=this;if(e!==f)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==h)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return c.createV0(t)}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=n.create(e,t);return c.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&n.equals(this.multihash,e.multihash)}toString(e){const{bytes:t,version:r,_baseCache:i}=this;return 0===r?l(t,i,e||s.base58btc.encoder):d(t,i,e||o.base32.encoder)}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return b(/^0\.0/,v),!(!e||!e[g]&&e.asCID!==e)}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof c)return e;if(null!=e&&e.asCID===e){const{version:t,code:r,multihash:i,bytes:n}=e;return new c(t,r,i,n||p(t,r,i.bytes))}if(null!=e&&!0===e[g]){const{version:t,multihash:r,code:i}=e,s=n.decode(r);return c.create(t,i,s)}return null}static create(e,t,r){if("number"!=typeof t)throw new Error("String codecs are no longer supported");switch(e){case 0:if(t!==f)throw new Error(`Version 0 CID must use dag-pb (code: ${f}) block encoding`);return new c(e,t,r,r.bytes);case 1:{const i=p(e,t,r.bytes);return new c(e,t,r,i)}default:throw new Error("Invalid version")}}static createV0(e){return c.create(0,f,e)}static createV1(e,t){return c.create(1,e,t)}static decode(e){const[t,r]=c.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=c.inspectBytes(e),r=t.size-t.multihashSize,i=a.coerce(e.subarray(r,r+t.multihashSize));if(i.byteLength!==t.multihashSize)throw new Error("Incorrect length");const s=i.subarray(t.multihashSize-t.digestSize),o=new n.Digest(t.multihashCode,t.digestSize,s,i);return[0===t.version?c.createV0(o):c.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=i.decode(e.subarray(t));return t+=n,r};let n=r(),s=f;if(18===n?(n=0,t=0):1===n&&(s=r()),0!==n&&1!==n)throw new RangeError(`Invalid CID version ${n}`);const o=t,a=r(),c=r(),u=t+c;return{version:n,codec:s,multihashCode:a,digestSize:c,multihashSize:u-o,size:u}}static parse(e,t){const[r,i]=u(e,t),n=c.decode(i);return n._baseCache.set(r,e),n}}const u=(e,t)=>{switch(e[0]){case"Q":{const r=t||s.base58btc;return[s.base58btc.prefix,r.decode(`${s.base58btc.prefix}${e}`)]}case s.base58btc.prefix:{const r=t||s.base58btc;return[s.base58btc.prefix,r.decode(e)]}case o.base32.prefix:{const r=t||o.base32;return[o.base32.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)]}},l=(e,t,r)=>{const{prefix:i}=r;if(i!==s.base58btc.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const n=t.get(i);if(null==n){const n=r.encode(e).slice(1);return t.set(i,n),n}return n},d=(e,t,r)=>{const{prefix:i}=r,n=t.get(i);if(null==n){const n=r.encode(e);return t.set(i,n),n}return n},f=112,h=18,p=(e,t,r)=>{const n=i.encodingLength(e),s=n+i.encodingLength(t),o=new Uint8Array(s+r.byteLength);return i.encodeTo(e,o,0),i.encodeTo(t,o,n),o.set(r,s),o},g=Symbol.for("@ipld/js-cid/CID"),y={writable:!1,configurable:!1,enumerable:!0},m={writable:!1,enumerable:!1,configurable:!1},b=(e,t)=>{if(!e.test("0.0.0-dev"))throw new Error(t);console.warn(t)},v="CID.isCID(v) is deprecated and will be removed in the next major release.\nFollowing code pattern:\n\nif (CID.isCID(value)) {\n doSomethingWithCID(value)\n}\n\nIs replaced with:\n\nconst cid = CID.asCID(value)\nif (cid) {\n // Make sure to use cid instead of value\n doSomethingWithCID(cid)\n}\n";r.CID=c},{"./varint.js":"ivDPm","./hashes/digest.js":"kpRBg","./bases/base58.js":"4n7mA","./bases/base32.js":"5k9Tu","./bytes.js":"6I0Ku"}],ivDPm:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../vendor/varint.js");r.decode=e=>[i.decode(e),i.decode.bytes],r.encodeTo=(e,t,r=0)=>(i.encode(e,t,r),t),r.encodingLength=e=>i.encodingLength(e)},{"../vendor/varint.js":"h72ss"}],h72ss:[function(e,t,r){"use strict";var i=function e(t,r,i){r=r||[];var s=i=i||0;for(;t>=n;)r[i++]=255&t|128,t/=128;for(;-128&t;)r[i++]=255&t|128,t>>>=7;return r[i]=0|t,e.bytes=i-s+1,r},n=Math.pow(2,31);var s=function e(t,r){var i,n=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");i=t[o++],n+=s<28?(127&i)<=128);return e.bytes=o-r,n};var o=Math.pow(2,7),a=Math.pow(2,14),c=Math.pow(2,21),u=Math.pow(2,28),l=Math.pow(2,35),d=Math.pow(2,42),f=Math.pow(2,49),h=Math.pow(2,56),p=Math.pow(2,63),g={encode:i,decode:s,encodingLength:function(e){return e{const r=t.byteLength,i=n.encodingLength(e),o=i+n.encodingLength(r),a=new Uint8Array(o+r);return n.encodeTo(e,a,0),n.encodeTo(r,a,i),a.set(t,o),new s(e,r,t,a)},r.decode=e=>{const t=i.coerce(e),[r,o]=n.decode(t),[a,c]=n.decode(t.subarray(o)),u=t.subarray(o+c);if(u.byteLength!==a)throw new Error("Incorrect length");return new s(r,a,u,t)},r.equals=(e,t)=>e===t||e.code===t.code&&e.size===t.size&&i.equals(e.bytes,t.bytes)},{"../bytes.js":"6I0Ku","../varint.js":"ivDPm"}],"6I0Ku":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const i=new Uint8Array(0);r.coerce=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")},r.empty=i,r.equals=(e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r{const t=e.match(/../g);return t?new Uint8Array(t.map((e=>parseInt(e,16)))):i},r.fromString=e=>(new TextEncoder).encode(e),r.isBinary=e=>e instanceof ArrayBuffer||ArrayBuffer.isView(e),r.toHex=e=>e.reduce(((e,t)=>e+t.toString(16).padStart(2,"0")),""),r.toString=e=>(new TextDecoder).decode(e)},{}],"4n7mA":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./base.js");const n=i.baseX({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),s=i.baseX({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});r.base58btc=n,r.base58flickr=s},{"./base.js":"6uTk1"}],"6uTk1":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../../vendor/base-x.js"),n=e("../bytes.js");class s{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class o{constructor(e,t,r){this.name=e,this.prefix=t,this.baseDecode=r}decode(e){if("string"==typeof e){if(e[0]===this.prefix)return this.baseDecode(e.slice(1));throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`)}throw Error("Can only multibase decode strings")}or(e){return c(this,e)}}class a{constructor(e){this.decoders=e}or(e){return c(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const c=(e,t)=>new a({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class u{constructor(e,t,r,i){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=i,this.encoder=new s(e,t,r),this.decoder=new o(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const l=({name:e,prefix:t,encode:r,decode:i})=>new u(e,t,r,i);r.Codec=u,r.baseX=({prefix:e,name:t,alphabet:r})=>{const{encode:s,decode:o}=i(r,t);return l({prefix:e,name:t,encode:s,decode:e=>n.coerce(o(e))})},r.from=l,r.or=c,r.rfc4648=({name:e,prefix:t,bitsPerChar:r,alphabet:i})=>l({prefix:t,name:e,encode:e=>((e,t,r)=>{const i="="===t[t.length-1],n=(1<r;)o-=r,s+=t[n&a>>o];if(o&&(s+=t[n&a<((e,t,r,i)=>{const n={};for(let e=0;e=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o})(t,i,r,e)})},{"../../vendor/base-x.js":"bImXU","../bytes.js":"6I0Ku"}],bImXU:[function(e,t,r){"use strict";var i=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var d=0,f=s-1;(0!==l||d>>0,o[f]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");n=d,t++}if(" "!==e[t]){for(var h=s-n;h!==s&&0===o[h];)h++;for(var p=new Uint8Array(i+(s-h)),g=i;h!==s;)p[g++]=o[h++];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,i=0,n=0,s=t.length;n!==s&&0===t[n];)n++,r++;for(var o=(s-n)*l+1>>>0,u=new Uint8Array(o);n!==s;){for(var d=t[n],f=0,h=o-1;(0!==d||f>>0,u[h]=d%a>>>0,d=d/a>>>0;if(0!==d)throw new Error("Non-zero carry");i=f,n++}for(var p=o-i;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p=64)throw new Error("protobuf: varint overflow");if(t>=e.length)throw new Error("protobuf: unexpected end of data");const n=e[t++];if(r+=i<28?(127&n)<e.length)throw new Error("protobuf: unexpected end of data");return[e.subarray(t,i),i]}function o(e,t){let r;return[r,t]=n(e,t),[7&r,r>>3,t]}function a(e){const t={},r=e.length;let a=0;for(;ar)throw new Error("protobuf: (PBLink) unexpected end of data");return t}r.decodeNode=function(e){const t=e.length;let r,i,n=0,c=!1;for(;nt)throw new Error("protobuf: (PBNode) unexpected end of data");const u={};return i&&(u.Data=i),u.Links=r||[],u}},{}],"5nPbE":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const i=new TextEncoder,n=2**32;function s(e,t){let r=t.length;if("number"==typeof e.Tsize){if(e.Tsize<0)throw new Error("Tsize cannot be negative");if(!Number.isSafeInteger(e.Tsize))throw new Error("Tsize too large for encoding");r=a(t,r,e.Tsize)-1,t[r]=24}if("string"==typeof e.Name){const n=i.encode(e.Name);r-=n.length,t.set(n,r),r=a(t,r,n.length)-1,t[r]=18}return e.Hash&&(r-=e.Hash.length,t.set(e.Hash,r),r=a(t,r,e.Hash.length)-1,t[r]=10),t.length-r}function o(e){let t=0;if(e.Hash){const r=e.Hash.length;t+=1+r+c(r)}if("string"==typeof e.Name){const r=i.encode(e.Name).length;t+=1+r+c(r)}return"number"==typeof e.Tsize&&(t+=1+c(e.Tsize)),t}function a(e,t,r){const i=t-=c(r);for(;r>=2147483648;)e[t++]=127&r|128,r/=128;for(;r>=128;)e[t++]=127&r|128,r>>>=7;return e[t]=r,i}function c(e){return e%2==0&&e++,Math.floor((function(e){let t=0;e>=n&&(e=Math.floor(e/n),t=32);e>=65536&&(e>>>=16,t+=16);e>=256&&(e>>>=8,t+=8);return t+u[e]}(e)+6)/7)}const u=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8];r.encodeNode=function(e){const t=function(e){let t=0;if(e.Data){const r=e.Data.length;t+=1+r+c(r)}if(e.Links)for(const r of e.Links){const e=o(r);t+=1+e+c(e)}return t}(e),r=new Uint8Array(t);let i=t;if(e.Data&&(i-=e.Data.length,r.set(e.Data,i),i=a(r,i,e.Data.length)-1,r[i]=10),e.Links)for(let t=e.Links.length-1;t>=0;t--){const n=s(e.Links[t],r.subarray(0,i));i-=n,i=a(r,i,n)-1,r[i]=18}return r}},{}],"1YHGP":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid");const n=["Data","Links"],s=["Hash","Name","Tsize"],o=new TextEncoder;function a(e,t){if(e===t)return 0;const r=e.Name?o.encode(e.Name):[],i=t.Name?o.encode(t.Name):[];let n=r.length,s=i.length;for(let e=0,t=Math.min(n,s);e!t.includes(e)))}function u(e){if("object"==typeof e.asCID){const t=i.CID.asCID(e);if(!t)throw new TypeError("Invalid DAG-PB form");return{Hash:t}}if("object"!=typeof e||Array.isArray(e))throw new TypeError("Invalid DAG-PB form");const t={};if(e.Hash){let r=i.CID.asCID(e.Hash);try{r||("string"==typeof e.Hash?r=i.CID.parse(e.Hash):e.Hash instanceof Uint8Array&&(r=i.CID.decode(e.Hash)))}catch(e){throw new TypeError(`Invalid DAG-PB form: ${e.message}`)}r&&(t.Hash=r)}if(!t.Hash)throw new TypeError("Invalid DAG-PB form");return"string"==typeof e.Name&&(t.Name=e.Name),"number"==typeof e.Tsize&&(t.Tsize=e.Tsize),t}function l(e){if((e instanceof Uint8Array||"string"==typeof e)&&(e={Data:e}),"object"!=typeof e||Array.isArray(e))throw new TypeError("Invalid DAG-PB form");const t={};if(void 0!==e.Data)if("string"==typeof e.Data)t.Data=o.encode(e.Data);else{if(!(e.Data instanceof Uint8Array))throw new TypeError("Invalid DAG-PB form");t.Data=e.Data}if(void 0!==e.Links){if(!Array.isArray(e.Links))throw new TypeError("Invalid DAG-PB form");t.Links=e.Links.map(u),t.Links.sort(a)}else t.Links=[];return t}r.createLink=function(e,t,r){return u({Hash:r,Name:e,Tsize:t})},r.createNode=function(e,t=[]){return l({Data:e,Links:t})},r.prepare=l,r.validate=function(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new TypeError("Invalid DAG-PB form");if(!c(e,n))throw new TypeError("Invalid DAG-PB form (extraneous properties)");if(void 0!==e.Data&&!(e.Data instanceof Uint8Array))throw new TypeError("Invalid DAG-PB form (Data must be a Uint8Array)");if(!Array.isArray(e.Links))throw new TypeError("Invalid DAG-PB form (Links must be an array)");for(let t=0;t0&&-1===a(r,e.Links[t-1]))throw new TypeError("Invalid DAG-PB form (links must be sorted by Name bytes)")}}},{"multiformats/cid":"9ooAY"}],"3498i":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("cborg"),n=e("multiformats/cid");function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var o=s(i);const a={float64:!0,typeEncoders:{Object:function(e){if(e.asCID!==e)return null;const t=n.CID.asCID(e);if(!t)return null;const r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new o.Token(o.Type.tag,42),new o.Token(o.Type.bytes,r)]},undefined:function(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")},number:function(e){if(Number.isNaN(e))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}}};const c={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,tags:[]};c.tags[42]=function(e){if(0!==e[0])throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return n.CID.decode(e.subarray(1))};r.code=113,r.decode=e=>o.decode(e,c),r.encode=e=>o.encode(e,a),r.name="dag-cbor"},{cborg:"iZrkE","multiformats/cid":"9ooAY"}],iZrkE:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./lib/encode.js"),n=e("./lib/decode.js"),s=e("./lib/token.js");r.encode=i.encode,r.decode=n.decode,r.Token=s.Token,r.Type=s.Type},{"./lib/encode.js":"72LuQ","./lib/decode.js":"dbDwZ","./lib/token.js":"jVUGz"}],"72LuQ":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./is.js"),n=e("./token.js"),s=e("./bl.js"),o=e("./common.js"),a=e("./jump.js"),c=e("./byte-utils.js"),u=e("./0uint.js"),l=e("./1negint.js"),d=e("./2bytes.js"),f=e("./3string.js"),h=e("./4array.js"),p=e("./5map.js"),g=e("./6tag.js"),y=e("./7float.js");const m={float64:!1,mapSorter:function(e,t){const r=Array.isArray(e[0])?e[0][0]:e[0],i=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==i.type)return r.type.compare(i.type);const n=r.type.major,s=b[n].compareTokens(r,i);0===s&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone");return s},quickEncodeToken:a.quickEncodeToken},b=[];b[n.Type.uint.major]=u.encodeUint,b[n.Type.negint.major]=l.encodeNegint,b[n.Type.bytes.major]=d.encodeBytes,b[n.Type.string.major]=f.encodeString,b[n.Type.array.major]=h.encodeArray,b[n.Type.map.major]=p.encodeMap,b[n.Type.tag.major]=g.encodeTag,b[n.Type.float.major]=y.encodeFloat;const v=new s.Bl;class w{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(`${o.encodeErrPrefix} object contains circular references`);return new w(t,e)}}const _={null:new n.Token(n.Type.null,null),undefined:new n.Token(n.Type.undefined,void 0),true:new n.Token(n.Type.true,!0),false:new n.Token(n.Type.false,!1),emptyArray:new n.Token(n.Type.array,0),emptyMap:new n.Token(n.Type.map,0)},E={number:(e,t,r,i)=>Number.isInteger(e)&&Number.isSafeInteger(e)?e>=0?new n.Token(n.Type.uint,e):new n.Token(n.Type.negint,e):new n.Token(n.Type.float,e),bigint:(e,t,r,i)=>e>=BigInt(0)?new n.Token(n.Type.uint,e):new n.Token(n.Type.negint,e),Uint8Array:(e,t,r,i)=>new n.Token(n.Type.bytes,e),string:(e,t,r,i)=>new n.Token(n.Type.string,e),boolean:(e,t,r,i)=>e?_.true:_.false,null:(e,t,r,i)=>_.null,undefined:(e,t,r,i)=>_.undefined,ArrayBuffer:(e,t,r,i)=>new n.Token(n.Type.bytes,new Uint8Array(e)),DataView:(e,t,r,i)=>new n.Token(n.Type.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),Array(e,t,r,i){if(!e.length)return!0===r.addBreakTokens?[_.emptyArray,new n.Token(n.Type.break)]:_.emptyArray;i=w.createCheck(i,e);const s=[];let o=0;for(const t of e)s[o++]=S(t,r,i);return r.addBreakTokens?[new n.Token(n.Type.array,e.length),s,new n.Token(n.Type.break)]:[new n.Token(n.Type.array,e.length),s]},Object(e,t,r,i){const s="Object"!==t,o=s?e.keys():Object.keys(e),a=s?e.size:o.length;if(!a)return!0===r.addBreakTokens?[_.emptyMap,new n.Token(n.Type.break)]:_.emptyMap;i=w.createCheck(i,e);const c=[];let u=0;for(const t of o)c[u++]=[S(t,r,i),S(s?e.get(t):e[t],r,i)];return function(e,t){t.mapSorter&&e.sort(t.mapSorter)}(c,r),r.addBreakTokens?[new n.Token(n.Type.map,a),c,new n.Token(n.Type.break)]:[new n.Token(n.Type.map,a),c]}};E.Map=E.Object,E.Buffer=E.Uint8Array;for(const e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))E[`${e}Array`]=E.DataView;function S(e,t={},r){const n=i.is(e),s=t&&t.typeEncoders&&t.typeEncoders[n]||E[n];if("function"==typeof s){const i=s(e,n,t,r);if(null!=i)return i}const a=E[n];if(!a)throw new Error(`${o.encodeErrPrefix} unsupported type: ${n}`);return a(e,n,t,r)}function T(e,t,r,i){if(Array.isArray(t))for(const n of t)T(e,n,r,i);else r[t.type.major](e,t,i)}function A(e,t,r){const i=S(e,r);if(!Array.isArray(i)&&r.quickEncodeToken){const e=r.quickEncodeToken(i);if(e)return e;const n=t[i.type.major];if(n.encodedSize){const e=n.encodedSize(i,r),t=new s.Bl(e);if(n(t,i,r),1!==t.chunks.length)throw new Error(`Unexpected error: pre-calculated length for ${i} was wrong`);return c.asU8A(t.chunks[0])}}return T(v,i,t,r),v.toBytes(!0)}r.Ref=w,r.encode=function(e,t){return t=Object.assign({},m,t),A(e,b,t)},r.encodeCustom=A,r.objectToTokens=S},{"./is.js":"bPQoh","./token.js":"jVUGz","./bl.js":"25Ozo","./common.js":"aoxj4","./jump.js":"FaFBb","./byte-utils.js":"9dmLv","./0uint.js":"9zilL","./1negint.js":"2sjxL","./2bytes.js":"8Tv7U","./3string.js":"56Ua8","./4array.js":"4ePxQ","./5map.js":"28THk","./6tag.js":"5TCWp","./7float.js":"5T30n"}],bPQoh:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const i=["string","number","bigint","symbol"],n=["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"];r.is=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(i.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";const r=function(e){const t=Object.prototype.toString.call(e).slice(8,-1);return n.includes(t)?t:void 0}(e);return r||"Object"}},{}],jVUGz:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});class i{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}}i.uint=new i(0,"uint",!0),i.negint=new i(1,"negint",!0),i.bytes=new i(2,"bytes",!0),i.string=new i(3,"string",!0),i.array=new i(4,"array",!1),i.map=new i(5,"map",!1),i.tag=new i(6,"tag",!1),i.float=new i(7,"float",!0),i.false=new i(7,"false",!0),i.true=new i(7,"true",!0),i.null=new i(7,"null",!0),i.undefined=new i(7,"undefined",!0),i.break=new i(7,"break",!0);r.Token=class{constructor(e,t,r){this.type=e,this.value=t,this.encodedLength=r,this.encodedBytes=void 0}toString(){return`Token[${this.type}].${this.value}`}},r.Type=i},{}],"25Ozo":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./byte-utils.js");r.Bl=class{constructor(e=256){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.chunks=[],this.cursor=0,this.maxCursor=-1,null!==this._initReuseChunk&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let t=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){const r=t.length-(this.maxCursor-this.cursor)-1;t.set(e,r)}else{if(t){const e=t.length-(this.maxCursor-this.cursor)-1;er.length/2?(t=this.cursor===r.length?r:r.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=i.slice(r,0,this.cursor)}else t=i.concat(this.chunks,this.cursor);return e&&this.reset(),t}}},{"./byte-utils.js":"9dmLv"}],"9dmLv":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const i=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&"function"==typeof globalThis.Buffer.isBuffer,n=new TextDecoder,s=new TextEncoder;function o(e){return i&&globalThis.Buffer.isBuffer(e)}function a(e){return e instanceof Uint8Array?o(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}const c=i?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):m(e,t,r):(e,t,r)=>r-t>64?n.decode(e.subarray(t,r)):m(e,t,r),u=i?e=>e.length>64?globalThis.Buffer.from(e):y(e):e=>e.length>64?s.encode(e):y(e),l=i?(e,t,r)=>o(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),d=i?(e,t)=>(e=e.map((e=>e instanceof Uint8Array?e:globalThis.Buffer.from(e))),a(globalThis.Buffer.concat(e,t))):(e,t)=>{const r=new Uint8Array(t);let i=0;for(let t of e)i+t.length>r.length&&(t=t.subarray(0,r.length-i)),r.set(t,i),i+=t.length;return r},f=i?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e),h=i?e=>"string"==typeof e?e:globalThis.Buffer.from(g(e)).toString("hex"):e=>"string"==typeof e?e:Array.prototype.reduce.call(g(e),((e,t)=>`${e}${t.toString(16).padStart(2,"0")}`),""),p=i?e=>e instanceof Uint8Array?e:globalThis.Buffer.from(e,"hex"):e=>e instanceof Uint8Array?e:e.length?new Uint8Array(e.split("").map(((e,t,r)=>t%2==0?`0x${e}${r[t+1]}`:"")).filter(Boolean).map((e=>parseInt(e,16)))):new Uint8Array(0);function g(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")}function y(e,t=1/0){let r;const i=e.length;let n=null;const s=[];for(let o=0;o55295&&r<57344){if(!n){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===i){(t-=3)>-1&&s.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(t-=3)>-1&&s.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.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;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function m(e,t,r){const i=[];for(;t239?4:n>223?3:n>191?2:1;if(t+o<=r){let r,i,a,c;switch(o){case 1:n<128&&(s=n);break;case 2:r=e[t+1],128==(192&r)&&(c=(31&n)<<6|63&r,c>127&&(s=c));break;case 3:r=e[t+1],i=e[t+2],128==(192&r)&&128==(192&i)&&(c=(15&n)<<12|(63&r)<<6|63&i,c>2047&&(c<55296||c>57343)&&(s=c));break;case 4:r=e[t+1],i=e[t+2],a=e[t+3],128==(192&r)&&128==(192&i)&&128==(192&a)&&(c=(15&n)<<18|(63&r)<<12|(63&i)<<6|63&a,c>65535&&c<1114112&&(s=c))}}null===s?(s=65533,o=1):s>65535&&(s-=65536,i.push(s>>>10&1023|55296),s=56320|1023&s),i.push(s),t+=o}return b(i)}function b(e){const t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);let r="",i=0;for(;iUint8Array.from(e),r.fromHex=p,r.fromString=u,r.slice=l,r.toHex=h,r.toString=c,r.useBuffer=i},{}],aoxj4:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const i="CBOR decode error:",n=[];n[23]=1,n[24]=2,n[25]=3,n[26]=5,n[27]=9,r.assertEnoughData=function(e,t,r){if(e.length-t>>5}`)}function g(e){return()=>{throw new Error(`${f.decodeErrPrefix} ${e}`)}}const y=[];for(let e=0;e<=23;e++)y[e]=p;y[24]=n.decodeUint8,y[25]=n.decodeUint16,y[26]=n.decodeUint32,y[27]=n.decodeUint64,y[28]=p,y[29]=p,y[30]=p,y[31]=p;for(let e=32;e<=55;e++)y[e]=p;y[56]=s.decodeNegint8,y[57]=s.decodeNegint16,y[58]=s.decodeNegint32,y[59]=s.decodeNegint64,y[60]=p,y[61]=p,y[62]=p,y[63]=p;for(let e=64;e<=87;e++)y[e]=o.decodeBytesCompact;y[88]=o.decodeBytes8,y[89]=o.decodeBytes16,y[90]=o.decodeBytes32,y[91]=o.decodeBytes64,y[92]=p,y[93]=p,y[94]=p,y[95]=g("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)y[e]=a.decodeStringCompact;y[120]=a.decodeString8,y[121]=a.decodeString16,y[122]=a.decodeString32,y[123]=a.decodeString64,y[124]=p,y[125]=p,y[126]=p,y[127]=g("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)y[e]=c.decodeArrayCompact;y[152]=c.decodeArray8,y[153]=c.decodeArray16,y[154]=c.decodeArray32,y[155]=c.decodeArray64,y[156]=p,y[157]=p,y[158]=p,y[159]=c.decodeArrayIndefinite;for(let e=160;e<=183;e++)y[e]=u.decodeMapCompact;y[184]=u.decodeMap8,y[185]=u.decodeMap16,y[186]=u.decodeMap32,y[187]=u.decodeMap64,y[188]=p,y[189]=p,y[190]=p,y[191]=u.decodeMapIndefinite;for(let e=192;e<=215;e++)y[e]=l.decodeTagCompact;y[216]=l.decodeTag8,y[217]=l.decodeTag16,y[218]=l.decodeTag32,y[219]=l.decodeTag64,y[220]=p,y[221]=p,y[222]=p,y[223]=p;for(let e=224;e<=243;e++)y[e]=g("simple values are not supported");y[244]=p,y[245]=p,y[246]=p,y[247]=d.decodeUndefined,y[248]=g("simple values are not supported"),y[249]=d.decodeFloat16,y[250]=d.decodeFloat32,y[251]=d.decodeFloat64,y[252]=p,y[253]=p,y[254]=p,y[255]=d.decodeBreak;const m=[];for(let e=0;e<24;e++)m[e]=new i.Token(i.Type.uint,e,1);for(let e=-1;e>=-24;e--)m[31-e]=new i.Token(i.Type.negint,e,1);m[64]=new i.Token(i.Type.bytes,new Uint8Array(0),1),m[96]=new i.Token(i.Type.string,"",1),m[128]=new i.Token(i.Type.array,0,1),m[160]=new i.Token(i.Type.map,0,1),m[244]=new i.Token(i.Type.false,!1,1),m[245]=new i.Token(i.Type.true,!0,1),m[246]=new i.Token(i.Type.null,null,1),r.jump=y,r.quick=m,r.quickEncodeToken=function(e){switch(e.type){case i.Type.false:return h.fromArray([244]);case i.Type.true:return h.fromArray([245]);case i.Type.null:return h.fromArray([246]);case i.Type.bytes:return e.value.length?void 0:h.fromArray([64]);case i.Type.string:return""===e.value?h.fromArray([96]):void 0;case i.Type.array:return 0===e.value?h.fromArray([128]):void 0;case i.Type.map:return 0===e.value?h.fromArray([160]):void 0;case i.Type.uint:return e.value<24?h.fromArray([Number(e.value)]):void 0;case i.Type.negint:if(e.value>=-24)return h.fromArray([31-Number(e.value)])}}},{"./token.js":"jVUGz","./0uint.js":"9zilL","./1negint.js":"2sjxL","./2bytes.js":"8Tv7U","./3string.js":"56Ua8","./4array.js":"4ePxQ","./5map.js":"28THk","./6tag.js":"5TCWp","./7float.js":"5T30n","./common.js":"aoxj4","./byte-utils.js":"9dmLv"}],"9zilL":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./token.js"),n=e("./common.js");const s=[24,256,65536,4294967296,BigInt("18446744073709551616")];function o(e,t,r){n.assertEnoughData(e,t,1);const i=e[t];if(!0===r.strict&&i>>8,255&i])}else if(r>>24&255,i>>>16&255,i>>>8&255,255&i])}else{const i=BigInt(r);if(!(i>BigInt(32)&BigInt(4294967295));r[8]=255&n,n>>=8,r[7]=255&n,n>>=8,r[6]=255&n,n>>=8,r[5]=255&n,r[4]=255&s,s>>=8,r[3]=255&s,s>>=8,r[2]=255&s,s>>=8,r[1]=255&s,e.push(r)}}}l.encodedSize=function(e){return d.encodedSize(e.value)},d.encodedSize=function(e){return et.value?1:0},r.decodeUint16=function(e,t,r,n){return new i.Token(i.Type.uint,a(e,t+1,n),3)},r.decodeUint32=function(e,t,r,n){return new i.Token(i.Type.uint,c(e,t+1,n),5)},r.decodeUint64=function(e,t,r,n){return new i.Token(i.Type.uint,u(e,t+1,n),9)},r.decodeUint8=function(e,t,r,n){return new i.Token(i.Type.uint,o(e,t+1,n),2)},r.encodeUint=l,r.encodeUintValue=d,r.readUint16=a,r.readUint32=c,r.readUint64=u,r.readUint8=o,r.uintBoundaries=s},{"./token.js":"jVUGz","./common.js":"aoxj4"}],"2sjxL":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./token.js"),n=e("./0uint.js"),s=e("./common.js");const o=BigInt(-1),a=BigInt(1);function c(e,t){const r=t.value,i="bigint"==typeof r?r*o-a:-1*r-1;n.encodeUintValue(e,t.type.majorEncoded,i)}c.encodedSize=function(e){const t=e.value,r="bigint"==typeof t?t*o-a:-1*t-1;return rt.value?-1:0},r.decodeNegint16=function(e,t,r,s){return new i.Token(i.Type.negint,-1-n.readUint16(e,t+1,s),3)},r.decodeNegint32=function(e,t,r,s){return new i.Token(i.Type.negint,-1-n.readUint32(e,t+1,s),5)},r.decodeNegint64=function(e,t,r,a){const c=n.readUint64(e,t+1,a);if("bigint"!=typeof c){const e=-1-c;if(e>=Number.MIN_SAFE_INTEGER)return new i.Token(i.Type.negint,e,9)}if(!0!==a.allowBigInt)throw new Error(`${s.decodeErrPrefix} integers outside of the safe integer range are not supported`);return new i.Token(i.Type.negint,o-BigInt(c),9)},r.decodeNegint8=function(e,t,r,s){return new i.Token(i.Type.negint,-1-n.readUint8(e,t+1,s),2)},r.encodeNegint=c},{"./token.js":"jVUGz","./0uint.js":"9zilL","./common.js":"aoxj4"}],"8Tv7U":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./token.js"),n=e("./common.js"),s=e("./0uint.js"),o=e("./byte-utils.js");function a(e,t,r,s){n.assertEnoughData(e,t,r+s);const a=o.slice(e,t+r,t+r+s);return new i.Token(i.Type.bytes,a,r+s)}function c(e){return void 0===e.encodedBytes&&(e.encodedBytes=e.type===i.Type.string?o.fromString(e.value):e.value),e.encodedBytes}function u(e,t){const r=c(t);s.encodeUintValue(e,t.type.majorEncoded,r.length),e.push(r)}function l(e,t){return e.lengtht.length?1:o.compare(e,t)}u.encodedSize=function(e){const t=c(e);return s.encodeUintValue.encodedSize(t.length)+t.length},u.compareTokens=function(e,t){return l(c(e),c(t))},r.compareBytes=l,r.decodeBytes16=function(e,t,r,i){return a(e,t,3,s.readUint16(e,t+1,i))},r.decodeBytes32=function(e,t,r,i){return a(e,t,5,s.readUint32(e,t+1,i))},r.decodeBytes64=function(e,t,r,i){const o=s.readUint64(e,t+1,i);if("bigint"==typeof o)throw new Error(`${n.decodeErrPrefix} 64-bit integer bytes lengths not supported`);return a(e,t,9,o)},r.decodeBytes8=function(e,t,r,i){return a(e,t,2,s.readUint8(e,t+1,i))},r.decodeBytesCompact=function(e,t,r,i){return a(e,t,1,r)},r.encodeBytes=u},{"./token.js":"jVUGz","./common.js":"aoxj4","./0uint.js":"9zilL","./byte-utils.js":"9dmLv"}],"56Ua8":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./token.js"),n=e("./common.js"),s=e("./0uint.js"),o=e("./2bytes.js"),a=e("./byte-utils.js");function c(e,t,r,s){const o=r+s;return n.assertEnoughData(e,t,o),new i.Token(i.Type.string,a.toString(e,t+r,t+o),o)}const u=o.encodeBytes;r.decodeString16=function(e,t,r,i){return c(e,t,3,s.readUint16(e,t+1,i))},r.decodeString32=function(e,t,r,i){return c(e,t,5,s.readUint32(e,t+1,i))},r.decodeString64=function(e,t,r,i){const o=s.readUint64(e,t+1,i);if("bigint"==typeof o)throw new Error(`${n.decodeErrPrefix} 64-bit integer string lengths not supported`);return c(e,t,9,o)},r.decodeString8=function(e,t,r,i){return c(e,t,2,s.readUint8(e,t+1,i))},r.decodeStringCompact=function(e,t,r,i){return c(e,t,1,r)},r.encodeString=u},{"./token.js":"jVUGz","./common.js":"aoxj4","./0uint.js":"9zilL","./2bytes.js":"8Tv7U","./byte-utils.js":"9dmLv"}],"4ePxQ":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./token.js"),n=e("./0uint.js"),s=e("./common.js");function o(e,t,r,n){return new i.Token(i.Type.array,n,r)}function a(e,t){n.encodeUintValue(e,i.Type.array.majorEncoded,t.value)}a.compareTokens=n.encodeUint.compareTokens,r.decodeArray16=function(e,t,r,i){return o(0,0,3,n.readUint16(e,t+1,i))},r.decodeArray32=function(e,t,r,i){return o(0,0,5,n.readUint32(e,t+1,i))},r.decodeArray64=function(e,t,r,i){const a=n.readUint64(e,t+1,i);if("bigint"==typeof a)throw new Error(`${s.decodeErrPrefix} 64-bit integer array lengths not supported`);return o(0,0,9,a)},r.decodeArray8=function(e,t,r,i){return o(0,0,2,n.readUint8(e,t+1,i))},r.decodeArrayCompact=function(e,t,r,i){return o(0,0,1,r)},r.decodeArrayIndefinite=function(e,t,r,i){if(!1===i.allowIndefinite)throw new Error(`${s.decodeErrPrefix} indefinite length items not allowed`);return o(0,0,1,1/0)},r.encodeArray=a},{"./token.js":"jVUGz","./0uint.js":"9zilL","./common.js":"aoxj4"}],"28THk":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./token.js"),n=e("./0uint.js"),s=e("./common.js");function o(e,t,r,n){return new i.Token(i.Type.map,n,r)}function a(e,t){n.encodeUintValue(e,i.Type.map.majorEncoded,t.value)}a.compareTokens=n.encodeUint.compareTokens,r.decodeMap16=function(e,t,r,i){return o(0,0,3,n.readUint16(e,t+1,i))},r.decodeMap32=function(e,t,r,i){return o(0,0,5,n.readUint32(e,t+1,i))},r.decodeMap64=function(e,t,r,i){const a=n.readUint64(e,t+1,i);if("bigint"==typeof a)throw new Error(`${s.decodeErrPrefix} 64-bit integer map lengths not supported`);return o(0,0,9,a)},r.decodeMap8=function(e,t,r,i){return o(0,0,2,n.readUint8(e,t+1,i))},r.decodeMapCompact=function(e,t,r,i){return o(0,0,1,r)},r.decodeMapIndefinite=function(e,t,r,i){if(!1===i.allowIndefinite)throw new Error(`${s.decodeErrPrefix} indefinite length items not allowed`);return o(0,0,1,1/0)},r.encodeMap=a},{"./token.js":"jVUGz","./0uint.js":"9zilL","./common.js":"aoxj4"}],"5TCWp":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./token.js"),n=e("./0uint.js");function s(e,t){n.encodeUintValue(e,i.Type.tag.majorEncoded,t.value)}s.compareTokens=n.encodeUint.compareTokens,r.decodeTag16=function(e,t,r,s){return new i.Token(i.Type.tag,n.readUint16(e,t+1,s),3)},r.decodeTag32=function(e,t,r,s){return new i.Token(i.Type.tag,n.readUint32(e,t+1,s),5)},r.decodeTag64=function(e,t,r,s){return new i.Token(i.Type.tag,n.readUint64(e,t+1,s),9)},r.decodeTag8=function(e,t,r,s){return new i.Token(i.Type.tag,n.readUint8(e,t+1,s),2)},r.decodeTagCompact=function(e,t,r,n){return new i.Token(i.Type.tag,r,1)},r.encodeTag=s},{"./token.js":"jVUGz","./0uint.js":"9zilL"}],"5T30n":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./token.js"),n=e("./common.js"),s=e("./0uint.js");function o(e,t,r){if(r){if(!1===r.allowNaN&&Number.isNaN(e))throw new Error(`${n.decodeErrPrefix} NaN values are not supported`);if(!1===r.allowInfinity&&(e===1/0||e===-1/0))throw new Error(`${n.decodeErrPrefix} Infinity values are not supported`)}return new i.Token(i.Type.float,e,t)}function a(e,t,r){const n=t.value;if(!1===n)e.push([20|i.Type.float.majorEncoded]);else if(!0===n)e.push([21|i.Type.float.majorEncoded]);else if(null===n)e.push([22|i.Type.float.majorEncoded]);else if(void 0===n)e.push([23|i.Type.float.majorEncoded]);else{let t,i=!1;r&&!0===r.float64||(d(n),t=f(l,1),n===t||Number.isNaN(n)?(l[0]=249,e.push(l.slice(0,3)),i=!0):(h(n),t=p(l,1),n===t&&(l[0]=250,e.push(l.slice(0,5)),i=!0))),i||(s=n,u.setFloat64(0,s,!1),t=g(l,1),l[0]=251,e.push(l.slice(0,9)))}var s}a.encodedSize=function(e,t){const r=e.value;if(!1===r||!0===r||null==r)return 1;let i;if(!t||!0!==t.float64){if(d(r),i=f(l,1),r===i||Number.isNaN(r))return 3;if(h(r),i=p(l,1),r===i)return 5}return 9};const c=new ArrayBuffer(9),u=new DataView(c,1),l=new Uint8Array(c,0);function d(e){if(e===1/0)u.setUint16(0,31744,!1);else if(e===-1/0)u.setUint16(0,64512,!1);else if(Number.isNaN(e))u.setUint16(0,32256,!1);else{u.setFloat32(0,e);const t=u.getUint32(0),r=(2139095040&t)>>23,i=8388607&t;if(255===r)u.setUint16(0,31744,!1);else if(0===r)u.setUint16(0,(2147483648&e)>>16|i>>13,!1);else{const e=r-127;e<-24?u.setUint16(0,0):e<-14?u.setUint16(0,(2147483648&t)>>16|1<<24+e,!1):u.setUint16(0,(2147483648&t)>>16|e+15<<10|i>>13,!1)}}}function f(e,t){if(e.length-t<2)throw new Error(`${n.decodeErrPrefix} 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 i=r>>10&31,s=1023&r;let o;return o=0===i?s*2**-24:31!==i?(s+1024)*2**(i-25):0===s?1/0:NaN,32768&r?-o:o}function h(e){u.setFloat32(0,e,!1)}function p(e,t){if(e.length-t<4)throw new Error(`${n.decodeErrPrefix} not enough data for float32`);const r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function g(e,t){if(e.length-t<8)throw new Error(`${n.decodeErrPrefix} not enough data for float64`);const r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}a.compareTokens=s.encodeUint.compareTokens,r.decodeBreak=function(e,t,r,s){if(!1===s.allowIndefinite)throw new Error(`${n.decodeErrPrefix} indefinite length items not allowed`);return new i.Token(i.Type.break,void 0,1)},r.decodeFloat16=function(e,t,r,i){return o(f(e,t+1),3,i)},r.decodeFloat32=function(e,t,r,i){return o(p(e,t+1),5,i)},r.decodeFloat64=function(e,t,r,i){return o(g(e,t+1),9,i)},r.decodeUndefined=function(e,t,r,s){if(!1===s.allowUndefined)throw new Error(`${n.decodeErrPrefix} undefined values are not supported`);return new i.Token(i.Type.undefined,void 0,1)},r.encodeFloat=a},{"./token.js":"jVUGz","./common.js":"aoxj4","./0uint.js":"9zilL"}],dbDwZ:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./common.js"),n=e("./token.js"),s=e("./jump.js");const o={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0};class a{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=s.quick[e];if(void 0===t){const r=s.jump[e];if(!r)throw new Error(`${i.decodeErrPrefix} 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 c=Symbol.for("DONE"),u=Symbol.for("BREAK");function l(e,t){if(e.done())return c;const r=e.next();if(r.type===n.Type.break)return u;if(r.type.terminal)return r.value;if(r.type===n.Type.array)return function(e,t,r){const n=[];for(let s=0;sn.coerce(e)});r.identity=s},{"./hasher.js":"5z3Qi","../bytes.js":"6I0Ku"}],"5z3Qi":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./digest.js");class n{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}async digest(e){if(e instanceof Uint8Array){const t=await this.encode(e);return i.create(this.code,t)}throw Error("Unknown type, must be binary type")}}r.Hasher=n,r.from=({name:e,code:t,encode:r})=>new n(e,t,r)},{"./digest.js":"kpRBg"}],lPcQG:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./bases/identity.js"),n=e("./bases/base2.js"),s=e("./bases/base8.js"),o=e("./bases/base10.js"),a=e("./bases/base16.js"),c=e("./bases/base32.js"),u=e("./bases/base36.js"),l=e("./bases/base58.js"),d=e("./bases/base64.js"),f=e("./hashes/sha2.js"),h=e("./hashes/identity.js"),p=e("./codecs/raw.js"),g=e("./codecs/json.js");e("./index.js");var y=e("./cid.js"),m=e("./hashes/hasher.js"),b=e("./hashes/digest.js"),v=e("./varint.js"),w=e("./bytes.js");const _={...i,...n,...s,...o,...a,...c,...u,...l,...d},E={...f,...h},S={raw:p,json:g};r.CID=y.CID,r.hasher=m,r.digest=b,r.varint=v,r.bytes=w,r.bases=_,r.codecs=S,r.hashes=E},{"./bases/identity.js":"4EVux","./bases/base2.js":"5EiC2","./bases/base8.js":"bGEV7","./bases/base10.js":"esjPe","./bases/base16.js":"iQzgO","./bases/base32.js":"5k9Tu","./bases/base36.js":"7VmDr","./bases/base58.js":"4n7mA","./bases/base64.js":"gaFBW","./hashes/sha2.js":"7i9MT","./hashes/identity.js":"eYCZn","./codecs/raw.js":"fdfgp","./codecs/json.js":"cRmep","./index.js":"3ANyW","./cid.js":"9ooAY","./hashes/hasher.js":"5z3Qi","./hashes/digest.js":"kpRBg","./varint.js":"ivDPm","./bytes.js":"6I0Ku"}],"4EVux":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./base.js"),n=e("../bytes.js");const s=i.from({prefix:"\0",name:"identity",encode:e=>n.toString(e),decode:e=>n.fromString(e)});r.identity=s},{"./base.js":"6uTk1","../bytes.js":"6I0Ku"}],"5EiC2":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const i=e("./base.js").rfc4648({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});r.base2=i},{"./base.js":"6uTk1"}],bGEV7:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const i=e("./base.js").rfc4648({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});r.base8=i},{"./base.js":"6uTk1"}],esjPe:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const i=e("./base.js").baseX({prefix:"9",name:"base10",alphabet:"0123456789"});r.base10=i},{"./base.js":"6uTk1"}],iQzgO:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./base.js");const n=i.rfc4648({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),s=i.rfc4648({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});r.base16=n,r.base16upper=s},{"./base.js":"6uTk1"}],"7VmDr":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./base.js");const n=i.baseX({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),s=i.baseX({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});r.base36=n,r.base36upper=s},{"./base.js":"6uTk1"}],gaFBW:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./base.js");const n=i.rfc4648({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),s=i.rfc4648({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),o=i.rfc4648({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),a=i.rfc4648({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});r.base64=n,r.base64pad=s,r.base64url=o,r.base64urlpad=a},{"./base.js":"6uTk1"}],"7i9MT":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./hasher.js");const n=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),s=i.from({name:"sha2-256",code:18,encode:n("SHA-256")}),o=i.from({name:"sha2-512",code:19,encode:n("SHA-512")});r.sha256=s,r.sha512=o},{"./hasher.js":"5z3Qi"}],fdfgp:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../bytes.js");r.code=85,r.decode=e=>i.coerce(e),r.encode=e=>i.coerce(e),r.name="raw"},{"../bytes.js":"6I0Ku"}],cRmep:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const i=new TextEncoder,n=new TextDecoder;r.code=512,r.decode=e=>JSON.parse(n.decode(e)),r.encode=e=>i.encode(JSON.stringify(e)),r.name="json"},{}],"3ANyW":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./cid.js"),n=e("./varint.js"),s=e("./bytes.js"),o=e("./hashes/hasher.js"),a=e("./hashes/digest.js");r.CID=i.CID,r.varint=n,r.bytes=s,r.hasher=o,r.digest=a},{"./cid.js":"9ooAY","./varint.js":"ivDPm","./bytes.js":"6I0Ku","./hashes/hasher.js":"5z3Qi","./hashes/digest.js":"kpRBg"}],d1lP3:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.initAssets=function(){}},{}],j69o8:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});class i extends Error{constructor(e="not initialized"){super(e),this.name="NotInitializedError",this.code=i.code}}i.code="ERR_NOT_INITIALIZED";class n extends Error{constructor(e="cannot initialize an initializing node"){super(e),this.name="AlreadyInitializingError",this.code=s.code}}n.code="ERR_ALREADY_INITIALIZING";class s extends Error{constructor(e="cannot re-initialize an initialized node"){super(e),this.name="AlreadyInitializedError",this.code=s.code}}s.code="ERR_ALREADY_INITIALIZED";class o extends Error{constructor(e="not started"){super(e),this.name="NotStartedError",this.code=o.code}}o.code="ERR_NOT_STARTED";class a extends Error{constructor(e="cannot start, already startin"){super(e),this.name="AlreadyStartingError",this.code=a.code}}a.code="ERR_ALREADY_STARTING";class c extends Error{constructor(e="cannot start, already started"){super(e),this.name="AlreadyStartedError",this.code=c.code}}c.code="ERR_ALREADY_STARTED";class u extends Error{constructor(e="not enabled"){super(e),this.name="NotEnabledError",this.code=u.code}}u.code="ERR_NOT_ENABLED",r.AlreadyInitializedError=s,r.AlreadyInitializingError=n,r.AlreadyStartedError=c,r.AlreadyStartingError=a,r.NotEnabledError=u,r.NotInitializedError=i,r.NotStartedError=o},{}],dF7Y4:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./util/bases.js");r.fromString=function(e,t="utf8"){const r=i[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}},{"./util/bases.js":"6UNPX"}],"6UNPX":[function(e,t,r){"use strict";var i=e("multiformats/basics");function n(e,t,r,i){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:i}}}const s=n("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),o=n("ascii","a",(e=>{let t="a";for(let r=0;r{e=e.substring(1);const t=new Uint8Array(e.length);for(let r=0;r{const{libp2p:l}=await i.Service.start(e,{peerId:r,repo:s,print:c,options:u});await Promise.all([o.startOnline({keychain:n,libp2p:l,peerId:r,repo:s}),t.start(),a.start()])}}},{"../utils/service.js":"ethcf"}],ethcf:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../errors.js"),n=e("../utils.js");class s{static create({start:e,stop:t}){return new s(e,t)}static async start(e,t){const{state:r,activate:n}=e;switch(r.status){case"stopped":try{const r=n(t);e.state={status:"starting",ready:r};const i=await r;return e.state={status:"started",value:i},i}catch(t){throw e.state={status:"stopped"},t}case"starting":throw new i.AlreadyStartingError;case"started":throw new i.AlreadyStartedError;case"stopping":return await r.ready,await s.start(e,t);default:return s.panic(e)}}static async stop(e){const{state:t,deactivate:r}=e;switch(t.status){case"stopped":break;case"starting":try{await t.ready}catch(e){}return await s.stop(e);case"stopping":return await t.ready;case"started":r&&await r(t.value),e.state={status:"stopped"};break;default:s.panic(t)}}static try({state:e}){return"started"===e.status?e.value:null}static async use({state:e},t){switch(e.status){case"started":return e.value;case"starting":return await n.withTimeout(e.ready,t);default:throw new i.NotStartedError}}static panic({state:e}){const t=JSON.stringify({status:e.status});throw RangeError(`Service in invalid state ${t}, should never happen if you see this please report a bug`)}constructor(e,t){this.activate=e,this.deactivate=t,this.state={status:"stopped"}}async use(e){return await s.use(this,e)}try(){return s.try(this)}}r.Service=s},{"../errors.js":"j69o8","../utils.js":"cT4uN"}],cT4uN:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("is-ipfs"),n=e("multiformats/cid"),s=e("interface-datastore/key"),o=e("err-code"),a=e("ipfs-core-utils/with-timeout-option"),c=e("ipfs-core-utils/to-cid-and-path"),u=e("@ipld/dag-pb");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function d(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var f=l(i),h=l(o),p=d(u);const g=new s.Key("/local/filesroot"),y=a.withTimeoutOption((async(e,t)=>await e)),m=async function*(e,t,r,i,s){const o=async e=>{const t=await r.getCodec(e.code),n=await i.blocks.get(e,s);return t.decode(n)},a=t.split("/").filter(Boolean);let c=await o(e),u=e;for(a.length||(yield{value:c,remainderPath:""});a.length;){const r=a.shift();if(!r)throw h.default(new Error(`Could not resolve path "${t}"`),"ERR_INVALID_PATH");if(e.code===p.code&&Array.isArray(c.Links)){const e=c.Links.find((e=>e.Name===r));if(e){yield{value:e.Hash,remainderPath:a.join("/")},c=await o(e.Hash),u=e.Hash;continue}}if(!Object.prototype.hasOwnProperty.call(c,r))throw h.default(new Error(`no link named "${r}" under ${u}`),"ERR_NO_LINK");c=c[r],yield{value:c,remainderPath:a.join("/")},n.CID.asCID(c)&&(u=c,c=await o(c))}};r.MFS_MAX_CHUNK_SIZE=262144,r.MFS_MAX_LINKS=174,r.MFS_ROOT_KEY=g,r.OFFLINE_ERROR="This command must be run in online mode. Try running 'ipfs daemon' first.",r.mapFile=e=>{if("file"!==e.type&&"directory"!==e.type&&"raw"!==e.type)throw new Error(`Unknown node type '${e.type}'`);const t={cid:e.cid,path:e.path,name:e.name,size:e.size,type:"file"};return"directory"===e.type&&(t.type="dir"),"file"===e.type&&(t.size=e.unixfs.fileSize()),"file"!==e.type&&"directory"!==e.type||(t.mode=e.unixfs.mode,void 0!==e.unixfs.mtime&&(t.mtime=e.unixfs.mtime)),t},r.normalizeCidPath=e=>e instanceof Uint8Array?n.CID.decode(e).toString():(0===(e=e.toString()).indexOf("/ipfs/")&&(e=e.substring(6)),"/"===e.charAt(e.length-1)&&(e=e.substring(0,e.length-1)),e),r.normalizePath=e=>{if(n.CID.asCID(e))return`/ipfs/${e}`;const t=e.toString();try{return`/ipfs/${n.CID.parse(t)}`}catch{}if(f.default.path(t))return t;throw h.default(new Error(`invalid path: ${e}`),"ERR_BAD_PATH")},r.resolve=m,r.resolvePath=async function(e,t,r,i={}){const{cid:s,path:o}=c.toCidAndPath(r);o&&(i.path=o);let a=s,u=i.path||"";if(u.startsWith("/")&&(u=u.substring(1)),i.path)try{for await(const{value:r,remainderPath:o}of m(s,i.path,t,e,{signal:i.signal})){if(!n.CID.asCID(r))break;u=o,a=r}}catch(e){throw e.message.startsWith("Object has no property")&&(e.message=`no link named "${u.split("/")[0]}" under ${a}`,e.code="ERR_NO_LINK"),e}return{cid:a,remainderPath:u||""}},r.withTimeout=y},{"is-ipfs":"40iuV","multiformats/cid":"9ooAY","interface-datastore/key":"9hGOz","err-code":"chZjB","ipfs-core-utils/with-timeout-option":"j29MK","ipfs-core-utils/to-cid-and-path":"jN5CZ","@ipld/dag-pb":"i2cdx"}],"40iuV":[function(e,t,r){"use strict";const{base58btc:i}=e("multiformats/bases/base58"),{base32:n}=e("multiformats/bases/base32"),s=e("multiformats/hashes/digest"),{Multiaddr:o}=e("multiaddr"),a=e("mafmt"),{CID:c}=e("multiformats/cid"),{URL:u}=e("iso-url"),{toString:l}=e("uint8arrays/to-string"),d=/^https?:\/\/[^/]+\/(ip[fn]s)\/([^/?#]+)/,f=/^\/(ip[fn]s)\/([^/?#]+)/,h=/^https?:\/\/([^/]+)\.(ip[fn]s)\.[^/?]+/,p=/^(([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])\.)+([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])$/;function g(e){try{return"string"==typeof e?Boolean(c.parse(e)):e instanceof Uint8Array?Boolean(c.decode(e)):Boolean(c.asCID(e))}catch(e){return!1}}function y(e){if(!e)return!1;if(o.isMultiaddr(e))return!0;try{return new o(e),!0}catch(e){return!1}}function m(e,t,r=1,i=2){const n=w(e);if(!n)return!1;const s=n.match(t);if(!s)return!1;if("ipfs"!==s[r])return!1;let o=s[i];return o&&t===h&&(o=o.toLowerCase()),g(o)}function b(e,t,r=1,i=2){const n=w(e);if(!n)return!1;const s=n.match(t);if(!s)return!1;if("ipns"!==s[r])return!1;let o=s[i];if(o&&t===h){if(o=o.toLowerCase(),g(o))return!0;try{!o.includes(".")&&o.includes("-")&&(o=o.replace(/--/g,"@").replace(/-/g,".").replace(/@/g,"-"));const{hostname:e}=new u(`http://${o}`);return p.test(e)}catch(e){return!1}}return!0}function v(e){return"string"==typeof e}function w(e){return e instanceof Uint8Array?l(e,"base58btc"):!!v(e)&&e}const _=e=>m(e,h,2,1),E=e=>b(e,h,2,1),S=e=>_(e)||E(e),T=e=>m(e,d)||_(e),A=e=>b(e,d)||E(e),k=e=>T(e)||A(e)||S(e),I=e=>m(e,f)||b(e,f);t.exports={multihash:function(e){const t=w(e);try{s.decode(i.decode("z"+t))}catch{return!1}return!0},multiaddr:y,peerMultiaddr:function(e){return y(e)&&a.P2P.matches(e)},cid:g,base32cid:e=>function(e){try{n.decode(e)}catch{return!1}return!0}(e)&&g(e),ipfsSubdomain:_,ipnsSubdomain:E,subdomain:S,subdomainGatewayPattern:h,ipfsUrl:T,ipnsUrl:A,url:k,pathGatewayPattern:d,ipfsPath:e=>m(e,f),ipnsPath:e=>b(e,f),path:I,pathPattern:f,urlOrPath:e=>k(e)||I(e),cidPath:e=>v(e)&&!g(e)&&m(`/ipfs/${e}`,f)}},{"multiformats/bases/base58":"4n7mA","multiformats/bases/base32":"5k9Tu","multiformats/hashes/digest":"kpRBg",multiaddr:"8Mu1u",mafmt:"l1lok","multiformats/cid":"9ooAY","iso-url":"86VPZ","uint8arrays/to-string":"hC8JB"}],"8Mu1u":[function(e,t,r){"use strict";const i=e("./codec"),n=e("./protocols-table"),s=e("varint"),{CID:o}=e("multiformats/cid"),{base58btc:a}=e("multiformats/bases/base58"),c=e("err-code"),u=Symbol.for("nodejs.util.inspect.custom"),{toString:l}=e("uint8arrays/to-string"),{equals:d}=e("uint8arrays/equals"),f=new Map,h=Symbol.for("@multiformats/js-multiaddr/multiaddr");class p{constructor(e){if(null==e&&(e=""),Object.defineProperty(this,h,{value:!0}),e instanceof Uint8Array)this.bytes=i.fromBytes(e);else if("string"==typeof e){if(e.length>0&&"/"!==e.charAt(0))throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=i.fromString(e)}else{if(!p.isMultiaddr(e))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=i.fromBytes(e.bytes)}}toString(){return i.bytesToString(this.bytes)}toJSON(){return this.toString()}toOptions(){const e={},t=this.toString().split("/");return e.family="ip4"===t[1]?4:6,e.host=t[2],e.transport=t[3],e.port=parseInt(t[4]),e}protos(){return this.protoCodes().map((e=>Object.assign({},n(e))))}protoCodes(){const e=[],t=this.bytes;let r=0;for(;re.name))}tuples(){return i.bytesToTuples(this.bytes)}stringTuples(){const e=i.bytesToTuples(this.bytes);return i.tuplesToStringTuples(e)}encapsulate(e){return e=new p(e),new p(this.toString()+e.toString())}decapsulate(e){const t=e.toString(),r=this.toString(),i=r.lastIndexOf(t);if(i<0)throw new Error("Address "+this+" does not contain subaddress: "+e);return new p(r.slice(0,i))}decapsulateCode(e){const t=this.tuples();for(let r=t.length-1;r>=0;r--)if(t[r][0]===e)return new p(i.tuplesToBytes(t.slice(0,r)));return this}getPeerId(){try{const e=this.stringTuples().filter((e=>e[0]===n.names.ipfs.code)).pop();if(e&&e[1]){const t=e[1];return"Q"===t[0]||"1"===t[0]?l(a.decode(`z${t}`),"base58btc"):l(o.parse(t).multihash.bytes,"base58btc")}return null}catch(e){return null}}getPath(){let e=null;try{e=this.stringTuples().filter((e=>!!n(e[0]).path))[0][1],e||(e=null)}catch(t){e=null}return e}equals(e){return d(this.bytes,e.bytes)}async resolve(){const e=this.protos().find((e=>e.resolvable));if(!e)return[this];const t=f.get(e.name);if(!t)throw c(new Error(`no available resolver for ${e.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await t(this)).map((e=>new p(e)))}nodeAddress(){const e=this.protoCodes(),t=this.protoNames(),r=this.toString().split("/").slice(1);if(r.length<4)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6}/{address}/{tcp, udp}/{port}".');if(4!==e[0]&&41!==e[0]&&54!==e[0]&&55!==e[0])throw new Error(`no protocol with name: "'${t[0]}'". Must have a valid family name: "{ip4, ip6, dns4, dns6}".`);if("tcp"!==r[2]&&"udp"!==r[2])throw new Error(`no protocol with name: "'${t[1]}'". Must have a valid transport protocol: "{tcp, udp}".`);return{family:41===e[0]||55===e[0]?6:4,address:r[1],port:parseInt(r[3])}}isThinWaistAddress(e){const t=(e||this).protos();return 2===t.length&&((4===t[0].code||41===t[0].code)&&(6===t[1].code||273===t[1].code))}static fromNodeAddress(e,t){if(!e)throw new Error("requires node address object");if(!t)throw new Error("requires transport protocol");let r;switch(e.family){case 4:r="ip4";break;case 6:r="ip6";break;default:throw Error(`Invalid addr family. Got '${e.family}' instead of 4 or 6`)}return new p("/"+[r,e.address,t,e.port].join("/"))}static isName(e){return!!p.isMultiaddr(e)&&e.protos().some((e=>e.resolvable))}static isMultiaddr(e){return e instanceof p||Boolean(e&&e[h])}[u](){return""}inspect(){return""}}p.protocols=n,p.resolvers=f,t.exports={Multiaddr:p,multiaddr:function(e){return new p(e)},protocols:n,resolvers:f}},{"./codec":"heFUu","./protocols-table":"5Z4cQ",varint:"aN1CO","multiformats/cid":"9ooAY","multiformats/bases/base58":"4n7mA","err-code":"chZjB","uint8arrays/to-string":"hC8JB","uint8arrays/equals":"eY3cX"}],heFUu:[function(e,t,r){"use strict";const i=e("./convert"),n=e("./protocols-table"),s=e("varint"),{concat:o}=e("uint8arrays/concat"),{toString:a}=e("uint8arrays/to-string");function c(e){const t=[],r=e.split("/").slice(1);if(1===r.length&&""===r[0])return[];for(let i=0;i=r.length)throw v("invalid address: "+e);if(o.path){t.push([s,b(r.slice(i).join("/"))]);break}t.push([s,r[i]])}else t.push([s])}return t}function u(e){const t=[];return e.map((e=>{const r=w(e);return t.push(r.name),e.length>1&&t.push(e[1]),null})),b(t.join("/"))}function l(e){return e.map((e=>{Array.isArray(e)||(e=[e]);const t=w(e);return e.length>1?[t.code,i.toBytes(t.code,e[1])]:[t.code]}))}function d(e){return e.map((e=>{const t=w(e);return e[1]?[t.code,i.toString(t.code,e[1])]:[t.code]}))}function f(e){return y(o(e.map((e=>{const t=w(e);let r=Uint8Array.from(s.encode(t.code));return e.length>1&&(r=o([r,e[1]])),r}))))}function h(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;return s.decode(t)+s.decode.bytes}function p(e){const t=[];let r=0;for(;re.length)throw v("Invalid address Uint8Array: "+a(e,"base16"));t.push([i,u])}return t}function g(e){return f(l(c(e=b(e))))}function y(e){const t=m(e);if(t)throw t;return Uint8Array.from(e)}function m(e){try{p(e)}catch(e){return e}}function b(e){return"/"+e.trim().split("/").filter((e=>e)).join("/")}function v(e){return new Error("Error parsing address: "+e)}function w(e){return n(e[0])}t.exports={stringToStringTuples:c,stringTuplesToString:u,tuplesToStringTuples:d,stringTuplesToTuples:l,bytesToTuples:p,tuplesToBytes:f,bytesToString:function(e){const t=p(e);return u(d(t))},stringToBytes:g,fromString:function(e){return g(e)},fromBytes:y,validateBytes:m,isValidBytes:function(e){return void 0===m(e)},cleanPath:b,ParseError:v,protoFromTuple:w,sizeForAddr:h}},{"./convert":"gfu3m","./protocols-table":"5Z4cQ",varint:"aN1CO","uint8arrays/concat":"4EBjG","uint8arrays/to-string":"hC8JB"}],gfu3m:[function(e,t,r){"use strict";const i=e("./ip"),n=e("./protocols-table"),{CID:s}=e("multiformats/cid"),{base32:o}=e("multiformats/bases/base32"),{base58btc:a}=e("multiformats/bases/base58"),c=e("multiformats/hashes/digest"),u=e("varint"),{toString:l}=e("uint8arrays/to-string"),{fromString:d}=e("uint8arrays/from-string"),{concat:f}=e("uint8arrays/concat");function h(e,t){return t instanceof Uint8Array?h.toString(e,t):h.toBytes(e,t)}function p(e){if(!i.isIP(e))throw new Error("invalid ip address");return i.toBytes(e)}function g(e){const t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function y(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function m(e){const t=e.slice(0,e.length-2),r=e.slice(e.length-2);return l(t,"base32")+":"+y(r)}t.exports=h,h.toString=function(e,t){switch(n(e).code){case 4:case 41:return function(e){const t=i.toString(e);if(!t||!i.isIP(t))throw new Error("invalid ip address");return t}(t);case 6:case 273:case 33:case 132:return y(t).toString();case 53:case 54:case 55:case 56:case 400:case 777:return function(e){const t=u.decode(e);if((e=e.slice(u.decode.bytes)).length!==t)throw new Error("inconsistent lengths");return l(e)}(t);case 421:return function(e){const t=u.decode(e),r=e.slice(u.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return l(r,"base58btc")}(t);case 444:case 445:return m(t);default:return l(t,"base16")}},h.toBytes=function(e,t){switch(n(e).code){case 4:case 41:return p(t);case 6:case 273:case 33:case 132:return g(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 777:return function(e){const t=d(e),r=Uint8Array.from(u.encode(t.length));return f([r,t],r.length+t.length)}(t);case 421:return function(e){let t;t="Q"===e[0]||"1"===e[0]?c.decode(a.decode(`z${e}`)).bytes:s.parse(e).multihash.bytes;const r=Uint8Array.from(u.encode(t.length));return f([r,t],r.length+t.length)}(t);case 444:return function(e){const t=e.split(":");if(2!==t.length)throw new Error("failed to parse onion addr: "+t+" does not contain a port number");if(16!==t[0].length)throw new Error("failed to parse onion addr: "+t[0]+" not a Tor onion address.");const r=o.decode("b"+t[0]),i=parseInt(t[1],10);if(i<1||i>65536)throw new Error("Port number is not in range(1, 65536)");const n=g(i);return f([r,n],r.length+n.length)}(t);case 445:return function(e){const t=e.split(":");if(2!==t.length)throw new Error("failed to parse onion addr: "+t+" does not contain a port number");if(56!==t[0].length)throw new Error("failed to parse onion addr: "+t[0]+" not a Tor onion3 address.");const r=o.decode("b"+t[0]),i=parseInt(t[1],10);if(i<1||i>65536)throw new Error("Port number is not in range(1, 65536)");const n=g(i);return f([r,n],r.length+n.length)}(t);default:return d(t,"base16")}}},{"./ip":"dqiuc","./protocols-table":"5Z4cQ","multiformats/cid":"9ooAY","multiformats/bases/base32":"5k9Tu","multiformats/bases/base58":"4n7mA","multiformats/hashes/digest":"kpRBg",varint:"aN1CO","uint8arrays/to-string":"hC8JB","uint8arrays/from-string":"dF7Y4","uint8arrays/concat":"4EBjG"}],dqiuc:[function(e,t,r){"use strict";const i=e("is-ip"),{toString:n}=e("uint8arrays/to-string"),s=i,o=i.v4,a=i.v6,c=function(e,t,r){let i;if(r=~~r,o(e))i=t||new Uint8Array(r+4),e.split(/\./g).map((function(e){i[r++]=255&parseInt(e,10)}));else if(a(e)){const s=e.split(":",8);let a;for(a=0;a0;a--)e.push("0");s.splice.apply(s,e)}for(i=t||new Uint8Array(r+16),a=0;a>8&255,i[r++]=255&e}}if(!i)throw Error("Invalid ip address: "+e);return i};t.exports={isIP:s,isV4:o,isV6:a,toBytes:c,toString:function(e,t,r){t=~~t,r=r||e.length-t;const i=[];let n;const s=new DataView(e.buffer);if(4===r){for(let n=0;ni({exact:!0}).test(e);n.v4=e=>i.v4({exact:!0}).test(e),n.v6=e=>i.v6({exact:!0}).test(e),n.version=e=>n(e)?n.v4(e)?4:6:void 0,t.exports=n},{"ip-regex":"foGrp"}],foGrp:[function(e,t,r){"use strict";const i="[a-fA-F\\d:]",n=e=>e&&e.includeBoundaries?`(?:(?<=\\s|^)(?=${i})|(?<=${i})(?=\\s|$))`:"",s="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",o="[a-fA-F\\d]{1,4}",a=`\n(?:\n(?:${o}:){7}(?:${o}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:${o}:){6}(?:${s}|:${o}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:${o}:){5}(?::${s}|(?::${o}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:${o}:){4}(?:(?::${o}){0,1}:${s}|(?::${o}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:${o}:){3}(?:(?::${o}){0,2}:${s}|(?::${o}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:${o}:){2}(?:(?::${o}){0,3}:${s}|(?::${o}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:${o}:){1}(?:(?::${o}){0,4}:${s}|(?::${o}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::${o}){0,5}:${s}|(?::${o}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),c=new RegExp(`(?:^${s}$)|(?:^${a}$)`),u=new RegExp(`^${s}$`),l=new RegExp(`^${a}$`),d=e=>e&&e.exact?c:new RegExp(`(?:${n(e)}${s}${n(e)})|(?:${n(e)}${a}${n(e)})`,"g");d.v4=e=>e&&e.exact?u:new RegExp(`${n(e)}${s}${n(e)}`,"g"),d.v6=e=>e&&e.exact?l:new RegExp(`${n(e)}${a}${n(e)}`,"g"),t.exports=d},{}],hC8JB:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./util/bases.js");r.toString=function(e,t="utf8"){const r=i[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}},{"./util/bases.js":"6UNPX"}],"5Z4cQ":[function(e,t,r){"use strict";function i(e){if("number"==typeof e){if(i.codes[e])return i.codes[e];throw new Error("no protocol with code: "+e)}if("string"==typeof e){if(i.names[e])return i.names[e];throw new Error("no protocol with name: "+e)}throw new Error("invalid protocol id type: "+e)}const n=-1;function s(e,t,r,i,n){return{code:e,size:t,name:r,resolvable:Boolean(i),path:Boolean(n)}}i.lengthPrefixedVarSize=n,i.V=n,i.table=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,n,"ip6zone"],[53,n,"dns","resolvable"],[54,n,"dns4","resolvable"],[55,n,"dns6","resolvable"],[56,n,"dnsaddr","resolvable"],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,n,"unix",!1,"path"],[421,n,"ipfs"],[421,n,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,n,"garlic64"],[460,0,"quic"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,n,"memory"]],i.names={},i.codes={},i.table.map((e=>{const t=s.apply(null,e);return i.codes[t.code]=t,i.names[t.name]=t,null})),i.object=s,t.exports=i},{}],aN1CO:[function(e,t,r){t.exports={encode:e("./encode.js"),decode:e("./decode.js"),encodingLength:e("./length.js")}},{"./encode.js":"j1gSN","./decode.js":"9agvx","./length.js":"3Fbt5"}],j1gSN:[function(e,t,r){t.exports=function e(t,r,n){if(Number.MAX_SAFE_INTEGER&&t>Number.MAX_SAFE_INTEGER)throw e.bytes=0,new RangeError("Could not encode varint");r=r||[];var s=n=n||0;for(;t>=i;)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-s+1,r};var i=Math.pow(2,31)},{}],"9agvx":[function(e,t,r){t.exports=function e(t,r){var i,n=0,s=0,o=r=r||0,a=t.length;do{if(o>=a||s>49)throw e.bytes=0,new RangeError("Could not decode varint");i=t[o++],n+=s<28?(127&i)<=128);return e.bytes=o-r,n}},{}],"3Fbt5":[function(e,t,r){var i=Math.pow(2,7),n=Math.pow(2,14),s=Math.pow(2,21),o=Math.pow(2,28),a=Math.pow(2,35),c=Math.pow(2,42),u=Math.pow(2,49),l=Math.pow(2,56),d=Math.pow(2,63);t.exports=function(e){return ee+t.length),0));const r=new Uint8Array(t);let i=0;for(const t of e)r.set(t,i),i+=t.length;return r}},{}],eY3cX:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.equals=function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;rP(R(S,T),S),A=T(),k=P(R(A,E,A),R(E,A),R(A,E),A,E);function I(e){return function(t){if(!i.isMultiaddr(t))try{t=new i(t)}catch(e){return!1}const r=e(t.protoNames());return null!==r&&(!0===r||!1===r?r:0===r.length)}}function R(...e){function t(t){if(t.length(r="function"==typeof e?e().partialMatch(t):e.partialMatch(t),Array.isArray(r)&&(t=r),null===r))),r}return{toString:function(){return"{ "+e.join(" ")+" }"},input:e,matches:I(t),partialMatch:t}}function P(...e){function t(t){let r=null;return e.some((e=>{const i="function"==typeof e?e().partialMatch(t):e.partialMatch(t);return!!i&&(r=i,!0)})),r}return{toString:function(){return"{ "+e.join(" ")+" }"},input:e,matches:I(t),partialMatch:t}}function O(e){const t=e;return{toString:function(){return t},matches:function(e){let r;if("string"==typeof e||e instanceof Uint8Array)try{r=new i(e)}catch(e){return!1}else r=e;const n=r.protoNames();return 1===n.length&&n[0]===t},partialMatch:function(e){return 0===e.length?null:e[0]===t?e.slice(1):null}}}t.exports={DNS:a,DNS4:n,DNS6:s,DNSADDR:o,IP:c,TCP:u,UDP:l,QUIC:f,UTP:d,HTTP:g,HTTPS:y,WebSockets:h,WebSocketsSecure:p,WebSocketStar:b,WebRTCStar:m,WebRTCDirect:v,Reliable:w,Stardust:_,Circuit:A,P2P:k,IPFS:k}},{multiaddr:"8Mu1u"}],"86VPZ":[function(e,t,r){"use strict";const{URLWithLegacySupport:i,format:n,URLSearchParams:s,defaultBase:o}=e("./src/url"),a=e("./src/relative");t.exports={URL:i,URLSearchParams:s,format:n,relative:a,defaultBase:o}},{"./src/url":"86S6m","./src/relative":"ki4KM"}],"86S6m":[function(e,t,r){"use strict";const i="undefined"!=typeof navigator&&"ReactNative"===navigator.product;const n=self.URL,s=i?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:"";t.exports={URLWithLegacySupport:class{constructor(e="",t=s){this.super=new n(e,t),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(e){this.super.hash=e}set host(e){this.super.host=e}set hostname(e){this.super.hostname=e}set href(e){this.super.href=e}set password(e){this.super.password=e}set pathname(e){this.super.pathname=e}set port(e){this.super.port=e}set protocol(e){this.super.protocol=e}set search(e){this.super.search=e}set username(e){this.super.username=e}static createObjectURL(e){return n.createObjectURL(e)}static revokeObjectURL(e){n.revokeObjectURL(e)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}},URLSearchParams:self.URLSearchParams,defaultBase:s,format:function(e){if("string"==typeof e){return new n(e).toString()}if(!(e instanceof n)){const t=e.username&&e.password?`${e.username}:${e.password}@`:"",r=e.auth?e.auth+"@":"",i=e.port?":"+e.port:"",n=e.protocol?e.protocol+"//":"",s=e.host||"",o=e.hostname||"",a=e.search||(e.query?"?"+e.query:""),c=e.hash||"",u=e.pathname||"";return`${n}${t||r}${s||o+i}${e.path||u+a}${c}`}}}},{}],ki4KM:[function(e,t,r){"use strict";const{URLWithLegacySupport:i,format:n}=e("./url");t.exports=(e,t={},r={},s)=>{let o,a=t.protocol?t.protocol.replace(":",""):"http";a=(r[a]||s||a)+":";try{o=new i(e)}catch(e){o={}}const c=Object.assign({},t,{protocol:a||o.protocol,host:t.host||o.host});return new i(e,n(c)).toString()}},{"./url":"86S6m"}],"9hGOz":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("nanoid"),n=e("uint8arrays/to-string"),s=e("uint8arrays/from-string");const o="/",a=(new TextEncoder).encode(o),c=a[0];class u{constructor(e,t){if("string"==typeof e)this._buf=s.fromString(e);else{if(!(e instanceof Uint8Array))throw new Error("Invalid key, should be String of Uint8Array");this._buf=e}if(null==t&&(t=!0),t&&this.clean(),0===this._buf.byteLength||this._buf[0]!==c)throw new Error("Invalid key")}toString(e="utf8"){return n.toString(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new u(e.join(o))}static random(){return new u(i.nanoid().replace(/-/g,""))}static asKey(e){return e instanceof Uint8Array||"string"==typeof e?new u(e):e.uint8Array?new u(e.uint8Array()):null}clean(){if(this._buf&&0!==this._buf.byteLength||(this._buf=a),this._buf[0]!==c){const e=new Uint8Array(this._buf.byteLength+1);e.fill(c,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===c;)this._buf=this._buf.subarray(0,-1)}less(e){const t=this.list(),r=e.list();for(let e=0;en)return!1}return t.lengthe.namespaces())),[].concat(...t))]);var t}}r.Key=u},{nanoid:"dmVhu","uint8arrays/to-string":"hC8JB","uint8arrays/from-string":"dF7Y4"}],dmVhu:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"nanoid",(()=>c)),i.export(r,"customAlphabet",(()=>a)),i.export(r,"customRandom",(()=>o)),i.export(r,"urlAlphabet",(()=>n.urlAlphabet)),i.export(r,"random",(()=>s));var n=e("./url-alphabet/index.js");let s=e=>crypto.getRandomValues(new Uint8Array(e)),o=(e,t,r)=>{let i=(2<{let s="";for(;;){let o=r(n),a=n;for(;a--;)if(s+=e[o[a]&i]||"",s.length===t)return s}}},a=(e,t)=>o(e,t,s),c=(e=21)=>{let t="",r=crypto.getRandomValues(new Uint8Array(e));for(;e--;){let i=63&r[e];t+=i<36?i.toString(36):i<62?(i-26).toString(36).toUpperCase():i<63?"_":"-"}return t}},{"./url-alphabet/index.js":"lbsD0","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],lbsD0:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"urlAlphabet",(()=>n));let n="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"},{"@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],h08wk:[function(e,t,r){r.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},r.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.exportAll=function(e,t){return Object.keys(e).forEach((function(r){"default"===r||"__esModule"===r||t.hasOwnProperty(r)||Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[r]}})})),t},r.export=function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,get:r})}},{}],j29MK:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("timeout-abort-controller"),n=e("any-signal"),s=e("parse-duration"),o=e("./errors.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=a(i),u=a(s);r.withTimeoutOption=function(e,t){return(...r)=>{const i=r[null==t?r.length-1:t];if(!i||!i.timeout)return e(...r);const s="string"==typeof i.timeout?u.default(i.timeout):i.timeout,a=new c.default(s);i.signal=n.anySignal([i.signal,a.signal]);const l=e(...r),d=new Promise(((e,t)=>{a.signal.addEventListener("abort",(()=>{t(new o.TimeoutError)}))})),f=Date.now(),h=()=>{if(a.signal.aborted)throw new o.TimeoutError;if(Date.now()-f>s)throw a.abort(),new o.TimeoutError};return l[Symbol.asyncIterator]?async function*(){const e=l[Symbol.asyncIterator]();try{for(;;){const{value:t,done:r}=await Promise.race([e.next(),d]);if(r)break;h(),yield t}}catch(e){throw h(),e}finally{a.clear(),e.return&&e.return()}}():(async()=>{try{const e=await Promise.race([l,d]);return h(),e}catch(e){throw h(),e}finally{a.clear()}})()}}},{"timeout-abort-controller":"hzClg","any-signal":"kXgRR","parse-duration":"fGYtw","./errors.js":"2ffCq"}],hzClg:[function(e,t,r){"use strict";const{AbortController:i}="undefined"!=typeof self?self:"undefined"!=typeof window?window:e("abort-controller"),n=e("retimer");class s extends i{constructor(e){super(),this._ms=e,this._timer=n((()=>this.abort()),e),Object.setPrototypeOf(this,s.prototype)}abort(){return this._timer.clear(),super.abort()}clear(){this._timer.clear()}reset(){this._timer.clear(),this._timer=n((()=>this.abort()),this._ms)}}t.exports=s,t.exports.TimeoutController=s},{"abort-controller":"lNJ7z",retimer:"gJ6S6"}],lNJ7z:[function(e,t,r){"use strict";const{AbortController:i,AbortSignal:n}="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0;t.exports=i,t.exports.AbortSignal=n,t.exports.default=i},{}],gJ6S6:[function(e,t,r){"use strict";var i=e("./time");function n(e,t,r){var n=this;this._started=i(),this._rescheduled=0,this._scheduled=t,this._args=r,this._timer=setTimeout((function t(){n._rescheduled>0?(n._scheduled=n._rescheduled-(i()-n._started),n._timer=setTimeout(t,n._scheduled),n._rescheduled=0):e.apply(null,n._args)}),t)}n.prototype.reschedule=function(e){var t=i();return!(t+e-(this._started+this._scheduled)<0)&&(this._started=t,this._rescheduled=e,!0)},n.prototype.clear=function(){clearTimeout(this._timer)},t.exports=function(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("timeout needed");var e;if(arguments.length>0){e=new Array(arguments.length-2);for(var t=0;t{await Promise.all([t.stop(),r.stop(),s.stop(),i.Service.stop(e),n.close()])}}},{"../utils/service.js":"ethcf"}],"4N8JT":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-config/dns"),n=e("ipfs-core-utils/with-timeout-option");r.createDns=function(){return n.withTimeoutOption((async(e,t={recursive:!0})=>{if("string"!=typeof e)throw new Error("Invalid arguments, domain must be a string");return e=function(e){return e.endsWith(".eth")&&(e=e.replace(/.eth$/,".eth.link")),e}(e),i.resolveDnslink(e,t)}))}},{"ipfs-core-config/dns":"HOLZZ","ipfs-core-utils/with-timeout-option":"j29MK"}],HOLZZ:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./utils/tlru.js"),n=e("p-queue"),s=e("ipfs-utils/src/http.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(n),c=o(s);const u=new i.TLRU(1e3),l=new(a.default.default?a.default.default:a.default)({concurrency:4}),d=e=>{if(e.Path)return e.Path;throw new Error(e.Message)};r.resolveDnslink=async function(e,t){return(async(e,t={})=>{const r=new URLSearchParams(t);r.set("arg",e);const i=r.toString();if(!t.nocache&&u.has(i)){const e=u.get(i);return d(e)}const n=await l.add((async()=>{const e=await c.default.get("https://ipfs.io/api/v0/dns",{searchParams:r}),t=new URL(e.url).search.slice(1),i=await e.json();return u.set(t,i,6e4),i}));return d(n)})(e,t)}},{"./utils/tlru.js":"2qTdj","p-queue":"biPlv","ipfs-utils/src/http.js":"ifXXn"}],"2qTdj":[function(e,t,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(r,"__esModule",{value:!0});var n=i(e("hashlru"));r.TLRU=class{constructor(e){this.lru=n.default(e)}get(e){const t=this.lru.get(e);if(t)return t.expire&&t.expire=e&&(t=0,i=r,r=Object.create(null))}return{has:function(e){return void 0!==r[e]||void 0!==i[e]},remove:function(e){void 0!==r[e]&&(r[e]=void 0),void 0!==i[e]&&(i[e]=void 0)},get:function(e){var t=r[e];return void 0!==t?t:void 0!==(t=i[e])?(n(e,t),t):void 0},set:function(e,t){void 0!==r[e]?r[e]=t:n(e,t)},clear:function(){r=Object.create(null),i=Object.create(null)}}}},{}],biPlv:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const i=e("eventemitter3"),n=e("p-timeout"),s=e("./priority-queue"),o=()=>{},a=new n.TimeoutError;r.default=class extends i{constructor(e){var t,r,i,n;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=o,this._resolveIdle=o,!("number"==typeof(e=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:s.default},e)).intervalCap&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==(r=null===(t=e.intervalCap)||void 0===t?void 0:t.toString())&&void 0!==r?r:""}\` (${typeof e.intervalCap})`);if(void 0===e.interval||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(n=null===(i=e.interval)||void 0===i?void 0:i.toString())&&void 0!==n?n:""}\` (${typeof e.interval})`);this._carryoverConcurrencyCount=e.carryoverConcurrencyCount,this._isIntervalIgnored=e.intervalCap===1/0||0===e.interval,this._intervalCap=e.intervalCap,this._interval=e.interval,this._queue=new e.queueClass,this._queueClass=e.queueClass,this.concurrency=e.concurrency,this._timeout=e.timeout,this._throwOnTimeout=!0===e.throwOnTimeout,this._isPaused=!1===e.autoStart}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount{this._onResumeInterval()}),t)),!0;this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0}return!1}_tryToStartAnother(){if(0===this._queue.size)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){const e=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother){const t=this._queue.dequeue();return!!t&&(this.emit("active"),t(),e&&this._initializeIntervalIfNeeded(),!0)}}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||void 0!==this._intervalId||(this._intervalId=setInterval((()=>{this._onInterval()}),this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){0===this._intervalCount&&0===this._pendingCount&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(e){if(!("number"==typeof e&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this._concurrency=e,this._processQueue()}async add(e,t={}){return new Promise(((r,i)=>{this._queue.enqueue((async()=>{this._pendingCount++,this._intervalCount++;try{const s=void 0===this._timeout&&void 0===t.timeout?e():n.default(Promise.resolve(e()),void 0===t.timeout?this._timeout:t.timeout,(()=>{(void 0===t.throwOnTimeout?this._throwOnTimeout:t.throwOnTimeout)&&i(a)}));r(await s)}catch(e){i(e)}this._next()}),t),this._tryToStartAnother(),this.emit("add")}))}async addAll(e,t){return Promise.all(e.map((async e=>this.add(e,t))))}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}async onEmpty(){if(0!==this._queue.size)return new Promise((e=>{const t=this._resolveEmpty;this._resolveEmpty=()=>{t(),e()}}))}async onIdle(){if(0!==this._pendingCount||0!==this._queue.size)return new Promise((e=>{const t=this._resolveIdle;this._resolveIdle=()=>{t(),e()}}))}get size(){return this._queue.size}sizeBy(e){return this._queue.filter(e).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(e){this._timeout=e}}},{eventemitter3:"btRgg","p-timeout":"2SalH","./priority-queue":"hkJNA"}],btRgg:[function(e,t,r){"use strict";var i=Object.prototype.hasOwnProperty,n="~";function s(){}function o(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,r,i,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new o(r,i||e,s),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function c(e,t){0==--e._eventsCount?e._events=new s:delete e._events[t]}function u(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(n=!1)),u.prototype.eventNames=function(){var e,t,r=[];if(0===this._eventsCount)return r;for(t in e=this._events)i.call(e,t)&&r.push(n?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},u.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,s=r.length,o=new Array(s);inew Promise(((s,o)=>{if("number"!=typeof t||t<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(t===1/0)return void s(e);const a=setTimeout((()=>{if("function"==typeof r){try{s(r())}catch(e){o(e)}return}const i=r instanceof Error?r:new n("string"==typeof r?r:`Promise timed out after ${t} milliseconds`);"function"==typeof e.cancel&&e.cancel(),o(i)}),t);i(e.then(s,o),(()=>{clearTimeout(a)}))}));t.exports=s,t.exports.default=s,t.exports.TimeoutError=n},{"p-finally":"4tkVQ"}],"4tkVQ":[function(e,t,r){"use strict";t.exports=(e,t)=>(t=t||(()=>{}),e.then((e=>new Promise((e=>{e(t())})).then((()=>e))),(e=>new Promise((e=>{e(t())})).then((()=>{throw e})))))},{}],hkJNA:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const i=e("./lower-bound");r.default=class{constructor(){this._queue=[]}enqueue(e,t){const r={priority:(t=Object.assign({priority:0},t)).priority,run:e};if(this.size&&this._queue[this.size-1].priority>=t.priority)return void this._queue.push(r);const n=i.default(this._queue,r,((e,t)=>t.priority-e.priority));this._queue.splice(n,0,r)}dequeue(){const e=this._queue.shift();return null==e?void 0:e.run}filter(e){return this._queue.filter((t=>t.priority===e.priority)).map((e=>e.run))}get size(){return this._queue.length}}},{"./lower-bound":"9Swn9"}],"9Swn9":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t,r){let i=0,n=e.length;for(;n>0;){const s=n/2|0;let o=i+s;r(e[o],t)<=0?(i=++o,n-=s+1):n=s}return i}},{}],ifXXn:[function(e,t,r){"use strict";const{fetch:i,Request:n,Headers:s}=e("./http/fetch"),{TimeoutError:o,HTTPError:a}=e("./http/error"),c=e("merge-options").bind({ignoreUndefined:!0}),{URL:u,URLSearchParams:l}=e("iso-url"),{AbortController:d}=e("native-abort-controller"),f=e("any-signal"),h={throwHttpErrors:!0,credentials:"same-origin"};class p{constructor(e={}){this.opts=c(h,e)}async fetch(e,t={}){const r=c(this.opts,t),h=new s(r.headers);if("string"!=typeof e&&!(e instanceof u||e instanceof n))throw new TypeError("`resource` must be a string, URL, or Request");const p=new u(e.toString(),r.base),{searchParams:m,transformSearchParams:b,json:v}=r;m&&(p.search="function"==typeof b?b(new l(r.searchParams)):new l(r.searchParams)),v&&(r.body=JSON.stringify(r.json),h.set("content-type","application/json"));const w=new d,_=f([w.signal,r.signal]),E=await((e,t,r)=>{if(void 0===t)return e;const i=Date.now(),n=()=>Date.now()-i>=t;return new Promise(((i,s)=>{const a=setTimeout((()=>{n()&&(s(new o),r.abort())}),t),c=e=>t=>{clearTimeout(a),n()?s(new o):e(t)};e.then(c(i),c(s))}))})(i(p.toString(),{...r,signal:_,timeout:void 0,headers:h}),r.timeout,w);if(!E.ok&&r.throwHttpErrors)throw r.handleError&&await r.handleError(E),new a(E);return E.iterator=function(){return y(E.body)},E.ndjson=async function*(){for await(const e of g(E.iterator()))t.transform?yield t.transform(e):yield e},E}post(e,t={}){return this.fetch(e,{...t,method:"POST"})}get(e,t={}){return this.fetch(e,{...t,method:"GET"})}put(e,t={}){return this.fetch(e,{...t,method:"PUT"})}delete(e,t={}){return this.fetch(e,{...t,method:"DELETE"})}options(e,t={}){return this.fetch(e,{...t,method:"OPTIONS"})}}const g=async function*(e){const t=new TextDecoder;let r="";for await(const i of e){r+=t.decode(i,{stream:!0});const e=r.split(/\r?\n/);for(let t=0;t0&&(yield JSON.parse(r))}r=e[e.length-1]}r+=t.decode(),r=r.trim(),0!==r.length&&(yield JSON.parse(r))},y=e=>{if(v(e)){const t=e[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:t.next.bind(t),return:r=>(e.destroy(),"function"==typeof t.return?t.return():Promise.resolve({done:!0,value:r}))})}}if(b(e)){const t=e.getReader();return async function*(){try{for(;;){const{done:e,value:r}=await t.read();if(e)return;r&&(yield r)}}finally{t.releaseLock()}}()}if(m(e))return e;throw new TypeError("Body can't be converted to AsyncIterable")},m=e=>"object"==typeof e&&null!==e&&"function"==typeof e[Symbol.asyncIterator],b=e=>e&&"function"==typeof e.getReader,v=e=>Object.prototype.hasOwnProperty.call(e,"readable")&&Object.prototype.hasOwnProperty.call(e,"writable");p.HTTPError=a,p.TimeoutError=o,p.streamToAsyncIterator=y,p.post=(e,t)=>new p(t).post(e,t),p.get=(e,t)=>new p(t).get(e,t),p.put=(e,t)=>new p(t).put(e,t),p.delete=(e,t)=>new p(t).delete(e,t),p.options=(e,t)=>new p(t).options(e,t),t.exports=p},{"./http/fetch":"8A13C","./http/error":"7OuWB","merge-options":"fupyv","iso-url":"86VPZ","native-abort-controller":"6zwoZ","any-signal":"kXgRR"}],"8A13C":[function(e,t,r){"use strict";const{TimeoutError:i,AbortError:n}=e("./error"),{Response:s,Request:o,Headers:a,default:c}=e("../fetch"),u=c,l=e=>{const t=new a;for(const r of e.trim().split(/[\r\n]+/)){const e=r.indexOf(": ");e>0&&t.set(r.slice(0,e),r.slice(e+1))}return t};class d extends s{constructor(e,t,r){super(t,r),Object.defineProperty(this,"url",{value:e})}}t.exports={fetch:(e,t={})=>null!=t.onUploadProgress?((e,t={})=>{const r=new XMLHttpRequest;r.open(t.method||"GET",e.toString(),!0);const{timeout:o,headers:c}=t;if(o&&o>0&&o<1/0&&(r.timeout=o),null!=t.overrideMimeType&&r.overrideMimeType(t.overrideMimeType),c)for(const[e,t]of new a(c))r.setRequestHeader(e,t);return t.signal&&(t.signal.onabort=()=>r.abort()),t.onUploadProgress&&(r.upload.onprogress=t.onUploadProgress),r.responseType="arraybuffer",new Promise(((e,o)=>{const a=t=>{switch(t.type){case"error":e(s.error());break;case"load":e(new d(r.responseURL,r.response,{status:r.status,statusText:r.statusText,headers:l(r.getAllResponseHeaders())}));break;case"timeout":o(new i);break;case"abort":o(new n)}};r.onerror=a,r.onload=a,r.ontimeout=a,r.onabort=a,r.send(t.body)}))})(e,t):u(e,t),Request:o,Headers:a}},{"./error":"7OuWB","../fetch":"6Y5cD"}],"7OuWB":[function(e,t,r){"use strict";class i extends Error{constructor(e="Request timed out"){super(e),this.name="TimeoutError"}}r.TimeoutError=i;class n extends Error{constructor(e="The operation was aborted."){super(e),this.name="AbortError"}}r.AbortError=n;class s extends Error{constructor(e){super(e.statusText),this.name="HTTPError",this.response=e}}r.HTTPError=s},{}],"6Y5cD":[function(e,t,r){"use strict";const{isElectronMain:i}=e("./env");t.exports=e(i?"electron-fetch":"native-fetch")},{"./env":"flyHr","electron-fetch":"lHksA","native-fetch":"kdks4"}],lHksA:[function(e,t,r){},{}],kdks4:[function(e,t,r){"use strict";globalThis.fetch&&globalThis.Headers&&globalThis.Request&&globalThis.Response?t.exports={default:globalThis.fetch,Headers:globalThis.Headers,Request:globalThis.Request,Response:globalThis.Response}:t.exports={default:e("node-fetch").default,Headers:e("node-fetch").Headers,Request:e("node-fetch").Request,Response:e("node-fetch").Response}},{"node-fetch":"1F7gr"}],"1F7gr":[function(e,t,r){"use strict";var i=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==i)return i;throw new Error("unable to locate global object")}();t.exports=r=i.fetch,i.fetch&&(r.default=i.fetch.bind(i)),r.Headers=i.Headers,r.Request=i.Request,r.Response=i.Response},{}],"2KSm7":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.createIsOnline=function({network:e}){return()=>{const t=e.try();return null!=t&&Boolean(t.libp2p.isStarted())}}},{}],faFUb:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("is-ipfs"),n=e("multiformats/cid"),s=e("peer-id"),o=e("ipfs-core-utils/with-timeout-option"),a=e("../utils.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(i),l=c(s);r.createResolve=function({repo:e,codecs:t,bases:r,name:i}){return o.withTimeoutOption((async function(s,o={}){if(!u.default.path(s))throw new Error("invalid argument "+s);if(u.default.ipnsPath(s))for await(const e of i.resolve(s,o))s=e;const[,c,d,...f]=s.split("/"),h=o.cidBase?await r.getBase(o.cidBase):void 0,p=function(e){try{return l.default.parse(e).toBytes()}catch{return n.CID.parse(e).bytes}}(d);if(0===f.length){return`/${c}/${h?h.encoder.encode(p):d}`}const g=n.CID.decode(p);s=f.join("/");const y=a.resolve(g,s,t,e,o);let m=g,b=s;for await(const e of y)n.CID.asCID(e.value)&&(m=e.value,b=e.remainderPath);return`/ipfs/${m.toString(h&&h.encoder)}${b?"/"+b:""}`}))}},{"is-ipfs":"40iuV","multiformats/cid":"9ooAY","peer-id":"8Bdb3","ipfs-core-utils/with-timeout-option":"j29MK","../utils.js":"cT4uN"}],"8Bdb3":[function(e,t,r){"use strict";const{CID:i}=e("multiformats/cid"),n=e("multiformats/bases/base32"),s=e("multiformats/bases/base36"),o=e("multiformats/bases/base58"),a=e("multiformats/bases/base64"),{base58btc:c}=e("multiformats/bases/base58"),{base32:u}=e("multiformats/bases/base32"),{base16:l}=e("multiformats/bases/base16"),d=e("multiformats/hashes/digest"),f=e("libp2p-crypto/src/keys"),h=e("class-is"),{PeerIdProto:p}=e("./proto"),{equals:g}=e("uint8arrays/equals"),{fromString:y}=e("uint8arrays/from-string"),{toString:m}=e("uint8arrays/to-string"),{identity:b}=e("multiformats/hashes/identity"),v={...n,...s,...o,...a},w=Object.keys(v).reduce(((e,t)=>e.or(v[t])),u.decoder);const _=h(class{constructor(e,t,r){if(!(e instanceof Uint8Array))throw new Error("invalid id provided");if(t&&r&&!g(t.public.bytes,r.bytes))throw new Error("inconsistent arguments");this._id=e,this._idB58String=c.encode(this.id).substring(1),this._privKey=t,this._pubKey=r}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){if(this._pubKey)return this._pubKey;if(this._privKey)return this._privKey.public;try{const e=d.decode(this.id);e.code===b.code&&(this._pubKey=f.unmarshalPublicKey(e.digest))}catch(e){}return this._pubKey}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return f.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return f.marshalPrivateKey(this.privKey)}marshal(e){return p.encode({id:this.toBytes(),pubKey:this.marshalPubKey(),privKey:e?null:this.marshalPrivKey()}).finish()}toPrint(){let e=this.toB58String();e.startsWith("Qm")&&(e=e.slice(2));let t=6;return e.length"}toJSON(){return{id:this.toB58String(),privKey:A(this.marshalPrivKey()),pubKey:A(this.marshalPubKey())}}toHexString(){return l.encode(this.id).substring(1)}toBytes(){return this.id}toB58String(){return this._idB58String}toString(){if(!this._idCIDString){const e=i.createV1(114,d.decode(this.id));Object.defineProperty(this,"_idCIDString",{value:e.toString(),enumerable:!1})}return this._idCIDString}equals(e){if(e instanceof Uint8Array)return g(this.id,e);if(e.id)return g(this.id,e.id);throw new Error("not valid Id")}isEqual(e){return this.equals(e)}isValid(){return Boolean(this.privKey&&this.privKey.public&&this.privKey.public.bytes&&this.pubKey.bytes instanceof Uint8Array&&g(this.privKey.public.bytes,this.pubKey.bytes))}hasInlinePublicKey(){try{if(d.decode(this.id).code===b.code)return!0}catch(e){}return!1}},{className:"PeerId",symbolName:"@libp2p/js-peer-id/PeerId"});r=t.exports=_;const E=e=>e.bytes.length<=42?d.create(b.code,e.bytes).bytes:e.hash(),S=async(e,t)=>{const r=await E(t);return new _(r,e,t)};r.create=async e=>{(e=e||{}).bits=e.bits||2048,e.keyType=e.keyType||"RSA";const t=await f.generateKeyPair(e.keyType,e.bits);return S(t,t.public)},r.createFromHexString=e=>new _(l.decode("f"+e)),r.createFromBytes=e=>{try{const t=i.decode(e);if(!T(t))throw new Error("Supplied PeerID CID is invalid");return r.createFromCID(t)}catch{if(d.decode(e).code!==b.code)throw new Error("Supplied PeerID CID is invalid");return new _(e)}},r.createFromB58String=e=>r.createFromBytes(c.decode("z"+e));const T=e=>114===e.code||112===e.code;function A(e){if(e)return m(e,"base64pad")}r.createFromCID=e=>{if(!(e=i.asCID(e))||!T(e))throw new Error("Supplied PeerID CID is invalid");return new _(e.multihash.bytes)},r.createFromPubKey=async e=>{let t=e;if("string"==typeof t&&(t=y(e,"base64pad")),!(t instanceof Uint8Array))throw new Error("Supplied key is neither a base64 string nor a Uint8Array");const r=await f.unmarshalPublicKey(t);return S(void 0,r)},r.createFromPrivKey=async e=>{if("string"==typeof e&&(e=y(e,"base64pad")),!(e instanceof Uint8Array))throw new Error("Supplied key is neither a base64 string nor a Uint8Array");const t=await f.unmarshalPrivateKey(e);return S(t,t.public)},r.createFromJSON=async e=>{const t=c.decode("z"+e.id),r=e.privKey&&y(e.privKey,"base64pad"),i=e.pubKey&&y(e.pubKey,"base64pad"),n=i&&await f.unmarshalPublicKey(i);if(!r)return new _(t,void 0,n);const s=await f.unmarshalPrivateKey(r),o=await E(s.public);let a;if(n&&(a=await E(n)),n&&!g(o,a))throw new Error("Public and private key do not match");if(t&&!g(o,t))throw new Error("Id and private key do not match");return new _(t,s,n)},r.createFromProtobuf=async e=>{"string"==typeof e&&(e=y(e,"base16"));let t,r,{id:i,privKey:n,pubKey:s}=p.decode(e);if(n=!!n&&await f.unmarshalPrivateKey(n),s=!!s&&await f.unmarshalPublicKey(s),n&&(r=await E(n.public)),s&&(t=await E(s)),n){if(s&&!g(r,t))throw new Error("Public and private key do not match");return new _(r,n,n.public)}if(s)return new _(t,void 0,s);if(i)return new _(i);throw new Error("Protobuf did not contain any usable key material")},r.parse=e=>("1"!==e.charAt(0)&&"Q"!==e.charAt(0)||(e=`z${e}`),r.createFromBytes(w.decode(e))),r.isPeerId=e=>Boolean("object"==typeof e&&e._id&&e._idB58String)},{"multiformats/cid":"9ooAY","multiformats/bases/base32":"5k9Tu","multiformats/bases/base36":"7VmDr","multiformats/bases/base58":"4n7mA","multiformats/bases/base64":"gaFBW","multiformats/bases/base16":"iQzgO","multiformats/hashes/digest":"kpRBg","libp2p-crypto/src/keys":"kWJWg","class-is":"gx31A","./proto":"c0IJt","uint8arrays/equals":"eY3cX","uint8arrays/from-string":"dF7Y4","uint8arrays/to-string":"hC8JB","multiformats/hashes/identity":"eYCZn"}],kWJWg:[function(e,t,r){"use strict";const i=e("./keys");e("node-forge/lib/asn1"),e("node-forge/lib/pbe");const n=e("node-forge/lib/forge"),s=e("err-code"),{fromString:o}=e("uint8arrays/from-string"),a=e("./importer"),c={rsa:e("./rsa-class"),ed25519:e("./ed25519-class"),secp256k1:e("./secp256k1-class")(i,e("../random-bytes"))},u="secp256k1 support requires libp2p-crypto-secp256k1 package",l="ERR_MISSING_PACKAGE";function d(e){const t=c[e.toLowerCase()];if(!t){const t=Object.keys(c).join(" / ");throw s(new Error(`invalid or unsupported key type ${e}. Must be ${t}`),"ERR_UNSUPPORTED_KEY_TYPE")}return t}const f=async e=>{const t=i.PrivateKey.decode(e),r=t.Data;switch(t.Type){case i.KeyType.RSA:return c.rsa.unmarshalRsaPrivateKey(r);case i.KeyType.Ed25519:return c.ed25519.unmarshalEd25519PrivateKey(r);case i.KeyType.Secp256k1:if(c.secp256k1)return c.secp256k1.unmarshalSecp256k1PrivateKey(r);throw s(new Error(u),l);default:d(t.Type)}};t.exports={supportedKeys:c,keysPBM:i,keyStretcher:e("./key-stretcher"),generateEphemeralKeyPair:e("./ephemeral-keys"),generateKeyPair:async(e,t)=>d(e).generateKeyPair(t),generateKeyPairFromSeed:async(e,t,r)=>{const i=d(e);if("ed25519"!==e.toLowerCase())throw s(new Error("Seed key derivation is unimplemented for RSA or secp256k1"),"ERR_UNSUPPORTED_KEY_DERIVATION_TYPE");return i.generateKeyPairFromSeed(t,r)},unmarshalPublicKey:e=>{const t=i.PublicKey.decode(e),r=t.Data;switch(t.Type){case i.KeyType.RSA:return c.rsa.unmarshalRsaPublicKey(r);case i.KeyType.Ed25519:return c.ed25519.unmarshalEd25519PublicKey(r);case i.KeyType.Secp256k1:if(c.secp256k1)return c.secp256k1.unmarshalSecp256k1PublicKey(r);throw s(new Error(u),l);default:d(t.Type)}},marshalPublicKey:(e,t)=>(d(t=(t||"rsa").toLowerCase()),e.bytes),unmarshalPrivateKey:f,marshalPrivateKey:(e,t)=>(d(t=(t||"rsa").toLowerCase()),e.bytes),import:async(e,t)=>{try{const r=await a.import(e,t);return f(r)}catch(e){}const r=n.pki.decryptRsaPrivateKey(e,t);if(null===r)throw s(new Error("Cannot read the key, most likely the password is wrong or not a RSA key"),"ERR_CANNOT_DECRYPT_PEM");let i=n.asn1.toDer(n.pki.privateKeyToAsn1(r));return i=o(i.getBytes(),"ascii"),c.rsa.unmarshalRsaPrivateKey(i)}}},{"./keys":"jWSTZ","node-forge/lib/asn1":"bcsXQ","node-forge/lib/pbe":"gUP8s","node-forge/lib/forge":"4OuPD","err-code":"chZjB","uint8arrays/from-string":"dF7Y4","./importer":"jyqjk","./rsa-class":"1sbpX","./ed25519-class":"dh3ng","./secp256k1-class":"jXCAP","../random-bytes":"gsnuW","./key-stretcher":"kdBuU","./ephemeral-keys":"ds3K5"}],jWSTZ:[function(e,t,r){"use strict";var i,n,s=e("protobufjs/minimal"),o=s.Reader,a=s.Writer,c=s.util,u=s.roots["libp2p-crypto-keys"]||(s.roots["libp2p-crypto-keys"]={});u.KeyType=(i={},(n=Object.create(i))[i[0]="RSA"]=0,n[i[1]="Ed25519"]=1,n[i[2]="Secp256k1"]=2,n),u.PublicKey=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:i.Type=e.int32();break;case 2:i.Data=e.bytes();break;default:e.skipType(7&n)}}if(!i.hasOwnProperty("Type"))throw c.ProtocolError("missing required 'Type'",{instance:i});if(!i.hasOwnProperty("Data"))throw c.ProtocolError("missing required 'Data'",{instance:i});return i},e.fromObject=function(e){if(e instanceof u.PublicKey)return e;var t=new u.PublicKey;switch(e.Type){case"RSA":case 0:t.Type=0;break;case"Ed25519":case 1:t.Type=1;break;case"Secp256k1":case 2:t.Type=2}return null!=e.Data&&("string"==typeof e.Data?c.base64.decode(e.Data,t.Data=c.newBuffer(c.base64.length(e.Data)),0):e.Data.length&&(t.Data=e.Data)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.Type=t.enums===String?"RSA":0,t.bytes===String?r.Data="":(r.Data=[],t.bytes!==Array&&(r.Data=c.newBuffer(r.Data)))),null!=e.Type&&e.hasOwnProperty("Type")&&(r.Type=t.enums===String?u.KeyType[e.Type]:e.Type),null!=e.Data&&e.hasOwnProperty("Data")&&(r.Data=t.bytes===String?c.base64.encode(e.Data,0,e.Data.length):t.bytes===Array?Array.prototype.slice.call(e.Data):e.Data),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},e}(),u.PrivateKey=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:i.Type=e.int32();break;case 2:i.Data=e.bytes();break;default:e.skipType(7&n)}}if(!i.hasOwnProperty("Type"))throw c.ProtocolError("missing required 'Type'",{instance:i});if(!i.hasOwnProperty("Data"))throw c.ProtocolError("missing required 'Data'",{instance:i});return i},e.fromObject=function(e){if(e instanceof u.PrivateKey)return e;var t=new u.PrivateKey;switch(e.Type){case"RSA":case 0:t.Type=0;break;case"Ed25519":case 1:t.Type=1;break;case"Secp256k1":case 2:t.Type=2}return null!=e.Data&&("string"==typeof e.Data?c.base64.decode(e.Data,t.Data=c.newBuffer(c.base64.length(e.Data)),0):e.Data.length&&(t.Data=e.Data)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.Type=t.enums===String?"RSA":0,t.bytes===String?r.Data="":(r.Data=[],t.bytes!==Array&&(r.Data=c.newBuffer(r.Data)))),null!=e.Type&&e.hasOwnProperty("Type")&&(r.Type=t.enums===String?u.KeyType[e.Type]:e.Type),null!=e.Data&&e.hasOwnProperty("Data")&&(r.Data=t.bytes===String?c.base64.encode(e.Data,0,e.Data.length):t.bytes===Array?Array.prototype.slice.call(e.Data):e.Data),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,s.util.toJSONOptions)},e}(),t.exports=u},{"protobufjs/minimal":"grAXL"}],bcsXQ:[function(e,t,r){var i=e("./forge");e("./util"),e("./oids");var n=t.exports=i.asn1=i.asn1||{};function s(e,t,r){if(r>t){var i=new Error("Too few bytes to parse DER.");throw i.available=e.length(),i.remaining=t,i.requested=r,i}}n.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},n.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},n.create=function(e,t,r,s,o){if(i.util.isArray(s)){for(var a=[],c=0;ct){if(i.strict){var p=new Error("Too few bytes to read ASN.1 value.");throw p.available=e.length(),p.remaining=t,p.requested=h,p}h=t}var g=32==(32&c);if(g)if(d=[],void 0===h)for(;;){if(s(e,t,2),e.bytes(2)===String.fromCharCode(0,0)){e.getBytes(2),t-=2;break}a=e.length(),d.push(o(e,t,r+1,i)),t-=a-e.length()}else for(;h>0;)a=e.length(),d.push(o(e,h,r+1,i)),t-=a-e.length(),h-=a-e.length();if(void 0===d&&u===n.Class.UNIVERSAL&&l===n.Type.BITSTRING&&(f=e.bytes(h)),void 0===d&&i.decodeBitStrings&&u===n.Class.UNIVERSAL&&l===n.Type.BITSTRING&&h>1){var y=e.read,m=t,b=0;if(l===n.Type.BITSTRING&&(s(e,t,1),b=e.getByte(),t--),0===b)try{a=e.length();var v=o(e,t,r+1,{verbose:i.verbose,strict:!0,decodeBitStrings:!0}),w=a-e.length();t-=w,l==n.Type.BITSTRING&&w++;var _=v.tagClass;w!==h||_!==n.Class.UNIVERSAL&&_!==n.Class.CONTEXT_SPECIFIC||(d=[v])}catch(e){}void 0===d&&(e.read=y,t=m)}if(void 0===d){if(void 0===h){if(i.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");h=t}if(l===n.Type.BMPSTRING)for(d="";h>0;h-=2)s(e,t,2),d+=String.fromCharCode(e.getInt16()),t-=2;else d=e.getBytes(h)}var E=void 0===f?null:{bitStringContents:f};return n.create(u,l,g,d,E)}n.fromDer=function(e,t){return void 0===t&&(t={strict:!0,decodeBitStrings:!0}),"boolean"==typeof t&&(t={strict:t,decodeBitStrings:!0}),"strict"in t||(t.strict=!0),"decodeBitStrings"in t||(t.decodeBitStrings=!0),"string"==typeof e&&(e=i.util.createBuffer(e)),o(e,e.length(),0,t)},n.toDer=function(e){var t=i.util.createBuffer(),r=e.tagClass|e.type,s=i.util.createBuffer(),o=!1;if("bitStringContents"in e&&(o=!0,e.original&&(o=n.equals(e,e.original))),o)s.putBytes(e.bitStringContents);else if(e.composed){e.constructed?r|=32:s.putByte(0);for(var a=0;a1&&(0===e.value.charCodeAt(0)&&0==(128&e.value.charCodeAt(1))||255===e.value.charCodeAt(0)&&128==(128&e.value.charCodeAt(1)))?s.putBytes(e.value.substr(1)):s.putBytes(e.value);if(t.putByte(r),s.length()<=127)t.putByte(127&s.length());else{var c=s.length(),u="";do{u+=String.fromCharCode(255&c),c>>>=8}while(c>0);t.putByte(128|u.length);for(a=u.length-1;a>=0;--a)t.putByte(u.charCodeAt(a))}return t.putBuffer(s),t},n.oidToDer=function(e){var t,r,n,s,o=e.split("."),a=i.util.createBuffer();a.putByte(40*parseInt(o[0],10)+parseInt(o[1],10));for(var c=2;c>>=7,t||(s|=128),r.push(s),t=!1}while(n>0);for(var u=r.length-1;u>=0;--u)a.putByte(r[u])}return a},n.derToOid=function(e){var t;"string"==typeof e&&(e=i.util.createBuffer(e));var r=e.getByte();t=Math.floor(r/40)+"."+r%40;for(var n=0;e.length()>0;)n<<=7,128&(r=e.getByte())?n+=127&r:(t+="."+(n+r),n=0);return t},n.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var i=parseInt(e.substr(2,2),10)-1,n=parseInt(e.substr(4,2),10),s=parseInt(e.substr(6,2),10),o=parseInt(e.substr(8,2),10),a=0;if(e.length>11){var c=e.charAt(10),u=10;"+"!==c&&"-"!==c&&(a=parseInt(e.substr(10,2),10),u+=2)}if(t.setUTCFullYear(r,i,n),t.setUTCHours(s,o,a,0),u&&("+"===(c=e.charAt(u))||"-"===c)){var l=60*parseInt(e.substr(u+1,2),10)+parseInt(e.substr(u+4,2),10);l*=6e4,"+"===c?t.setTime(+t-l):t.setTime(+t+l)}return t},n.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),i=parseInt(e.substr(4,2),10)-1,n=parseInt(e.substr(6,2),10),s=parseInt(e.substr(8,2),10),o=parseInt(e.substr(10,2),10),a=parseInt(e.substr(12,2),10),c=0,u=0,l=!1;"Z"===e.charAt(e.length-1)&&(l=!0);var d=e.length-5,f=e.charAt(d);"+"!==f&&"-"!==f||(u=60*parseInt(e.substr(d+1,2),10)+parseInt(e.substr(d+4,2),10),u*=6e4,"+"===f&&(u*=-1),l=!0);return"."===e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),l?(t.setUTCFullYear(r,i,n),t.setUTCHours(s,o,a,c),t.setTime(+t+u)):(t.setFullYear(r,i,n),t.setHours(s,o,a,c)),t},n.dateToUtcTime=function(e){if("string"==typeof e)return e;var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var i=0;i=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=e,r},n.derToInteger=function(e){"string"==typeof e&&(e=i.util.createBuffer(e));var t=8*e.length();if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)},n.validate=function(e,t,r,s){var o=!1;if(e.tagClass!==t.tagClass&&void 0!==t.tagClass||e.type!==t.type&&void 0!==t.type)s&&(e.tagClass!==t.tagClass&&s.push("["+t.name+'] Expected tag class "'+t.tagClass+'", got "'+e.tagClass+'"'),e.type!==t.type&&s.push("["+t.name+'] Expected type "'+t.type+'", got "'+e.type+'"'));else if(e.constructed===t.constructed||void 0===t.constructed){if(o=!0,t.value&&i.util.isArray(t.value))for(var a=0,c=0;o&&c0&&(s+="\n");for(var o="",c=0;c1?s+="0x"+i.util.bytesToHex(e.value.slice(1)):s+="(none)",e.value.length>0){var f=e.value.charCodeAt(0);1==f?s+=" (1 unused bit shown)":f>1&&(s+=" ("+f+" unused bits shown)")}}else e.type===n.Type.OCTETSTRING?(a.test(e.value)||(s+="("+e.value+") "),s+="0x"+i.util.bytesToHex(e.value)):e.type===n.Type.UTF8?s+=i.util.decodeUtf8(e.value):e.type===n.Type.PRINTABLESTRING||e.type===n.Type.IA5String?s+=e.value:a.test(e.value)?s+="0x"+i.util.bytesToHex(e.value):0===e.value.length?s+="[null]":s+=e.value}return s}},{"./forge":"4OuPD","./util":"df43p","./oids":"7VPL4"}],"4OuPD":[function(e,t,r){t.exports={options:{usePureJavaScript:!1}}},{}],df43p:[function(e,t,r){var i=arguments[3],n=e("buffer").Buffer,s=e("process"),o=e("./forge"),a=e("./baseN"),c=t.exports=o.util=o.util||{};function u(e){if(8!==e&&16!==e&&24!==e&&32!==e)throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}function l(e){if(this.data="",this.read=0,"string"==typeof e)this.data=e;else if(c.isArrayBuffer(e)||c.isArrayBufferView(e))if(void 0!==n&&e instanceof n)this.data=e.toString("binary");else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch(e){for(var r=0;r15?(r=Date.now(),o(e)):(t.push(e),1===t.length&&n.setAttribute("a",i=!i))}}c.nextTick=c.setImmediate}(),c.isNodejs=void 0!==s&&s.versions&&s.versions.node,c.globalScope=c.isNodejs?i:"undefined"==typeof self?window:self,c.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},c.isArrayBuffer=function(e){return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer},c.isArrayBufferView=function(e){return e&&c.isArrayBuffer(e.buffer)&&void 0!==e.byteLength},c.ByteBuffer=l,c.ByteStringBuffer=l;var d=4096;function f(e,t){t=t||{},this.read=t.readOffset||0,this.growSize=t.growSize||1024;var r=c.isArrayBuffer(e),i=c.isArrayBufferView(e);if(r||i)return this.data=r?new DataView(e):new DataView(e.buffer,e.byteOffset,e.byteLength),void(this.write="writeOffset"in t?t.writeOffset:this.data.byteLength);this.data=new DataView(new ArrayBuffer(0)),this.write=0,null!=e&&this.putBytes(e),"writeOffset"in t&&(this.write=t.writeOffset)}c.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>d&&(this.data.substr(0,1),this._constructedStringLength=0)},c.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},c.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},c.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},c.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return this.data=r,this._optimizeConstructedString(t),this},c.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},c.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(c.encodeUtf8(e))},c.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},c.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},c.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},c.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255))},c.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},c.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},c.ByteStringBuffer.prototype.putInt=function(e,t){u(t);var r="";do{t-=8,r+=String.fromCharCode(e>>t&255)}while(t>0);return this.putBytes(r)},c.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<0);return t},c.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},c.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},c.ByteStringBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},c.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},c.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},c.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},c.ByteStringBuffer.prototype.copy=function(){var e=c.createBuffer(this.data);return e.read=this.read,e},c.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},c.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},c.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},c.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t=e)return this;t=Math.max(t||this.growSize,e);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),i=new Uint8Array(this.length()+t);return i.set(r),this.data=new DataView(i.buffer),this},c.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},c.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var r=0;r>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},c.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},c.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},c.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},c.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},c.DataBuffer.prototype.putInt=function(e,t){u(t),this.accommodate(t/8);do{t-=8,this.data.setInt8(this.write++,e>>t&255)}while(t>0);return this},c.DataBuffer.prototype.putSignedInt=function(e,t){return u(t),this.accommodate(t/8),e<0&&(e+=2<0);return t},c.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},c.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},c.DataBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},c.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},c.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},c.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},c.DataBuffer.prototype.copy=function(){return new c.DataBuffer(this)},c.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},c.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},c.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},c.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return r},c.xorBytes=function(e,t,r){for(var i="",n="",s="",o=0,a=0;r>0;--r,++o)n=e.charCodeAt(o)^t.charCodeAt(o),a>=10&&(i+=s,s="",a=0),s+=String.fromCharCode(n),++a;return i+=s},c.hexToBytes=function(e){var t="",r=0;for(!0&e.length&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)};var h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",p=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],g="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";c.encode64=function(e,t){for(var r,i,n,s="",o="",a=0;a>2),s+=h.charAt((3&r)<<4|i>>4),isNaN(i)?s+="==":(s+=h.charAt((15&i)<<2|n>>6),s+=isNaN(n)?"=":h.charAt(63&n)),t&&s.length>t&&(o+=s.substr(0,t)+"\r\n",s=s.substr(t));return o+=s},c.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,i,n,s="",o=0;o>4),64!==i&&(s+=String.fromCharCode((15&r)<<4|i>>2),64!==n&&(s+=String.fromCharCode((3&i)<<6|n)));return s},c.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},c.decodeUtf8=function(e){return decodeURIComponent(escape(e))},c.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:a.encode,decode:a.decode}},c.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},c.binary.raw.decode=function(e,t,r){var i=t;i||(i=new Uint8Array(e.length));for(var n=r=r||0,s=0;s>2),s+=h.charAt((3&r)<<4|i>>4),isNaN(i)?s+="==":(s+=h.charAt((15&i)<<2|n>>6),s+=isNaN(n)?"=":h.charAt(63&n)),t&&s.length>t&&(o+=s.substr(0,t)+"\r\n",s=s.substr(t));return o+=s},c.binary.base64.decode=function(e,t,r){var i,n,s,o,a=t;a||(a=new Uint8Array(3*Math.ceil(e.length/4))),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var c=0,u=r=r||0;c>4,64!==s&&(a[u++]=(15&n)<<4|s>>2,64!==o&&(a[u++]=(3&s)<<6|o));return t?u-r:a.subarray(0,u)},c.binary.base58.encode=function(e,t){return c.binary.baseN.encode(e,g,t)},c.binary.base58.decode=function(e,t){return c.binary.baseN.decode(e,g,t)},c.text={utf8:{},utf16:{}},c.text.utf8.encode=function(e,t,r){e=c.encodeUtf8(e);var i=t;i||(i=new Uint8Array(e.length));for(var n=r=r||0,s=0;s0?(n=r[i].substring(0,o),s=r[i].substring(o+1)):(n=r[i],s=null),n in t||(t[n]=[]),n in Object.prototype||null===s||t[n].push(unescape(s))}return t};return void 0===e?(null===S&&(S="undefined"!=typeof window&&window.location&&window.location.search?r(window.location.search.substring(1)):{}),t=S):t=r(e),t},c.parseFragment=function(e){var t=e,r="",i=e.indexOf("?");i>0&&(t=e.substring(0,i),r=e.substring(i+1));var n=t.split("/");return n.length>0&&""===n[0]&&n.shift(),{pathString:t,queryString:r,path:n,query:""===r?{}:c.getQueryVariables(r)}},c.makeRequest=function(e){var t=c.parseFragment(e),r={path:t.pathString,query:t.queryString,getPath:function(e){return void 0===e?t.path:t.path[e]},getQuery:function(e,r){var i;return void 0===e?i=t.query:(i=t.query[e])&&void 0!==r&&(i=i[r]),i},getQueryLast:function(e,t){var i=r.getQuery(e);return i?i[i.length-1]:t}};return r},c.makeLink=function(e,t,r){e=jQuery.isArray(e)?e.join("/"):e;var i=jQuery.param(t||{});return r=r||"",e+(i.length>0?"?"+i:"")+(r.length>0?"#"+r:"")},c.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},c.format=function(e){for(var t,r,i=/%./g,n=0,s=[],o=0;t=i.exec(e);){(r=e.substring(o,i.lastIndex-2)).length>0&&s.push(r),o=i.lastIndex;var a=t[0][1];switch(a){case"s":case"o":n");break;case"%":s.push("%");break;default:s.push("<%"+a+"?>")}}return s.push(e.substring(o)),s.join("")},c.formatNumber=function(e,t,r,i){var n=e,s=isNaN(t=Math.abs(t))?2:t,o=void 0===r?",":r,a=void 0===i?".":i,c=n<0?"-":"",u=parseInt(n=Math.abs(+n||0).toFixed(s),10)+"",l=u.length>3?u.length%3:0;return c+(l?u.substr(0,l)+a:"")+u.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+a)+(s?o+Math.abs(n-u).toFixed(s).slice(2):"")},c.formatSize=function(e){return e=e>=1073741824?c.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?c.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?c.formatNumber(e/1024,0)+" KiB":c.formatNumber(e,0)+" bytes"},c.bytesFromIP=function(e){return-1!==e.indexOf(".")?c.bytesFromIPv4(e):-1!==e.indexOf(":")?c.bytesFromIPv6(e):null},c.bytesFromIPv4=function(e){if(4!==(e=e.split(".")).length)return null;for(var t=c.createBuffer(),r=0;rr[i].end-r[i].start&&(i=r.length-1)):r.push({start:a,end:a})}t.push(s)}if(r.length>0){var u=r[i];u.end-u.start>0&&(t.splice(u.start,u.end-u.start+1,""),0===u.start&&t.unshift(""),7===u.end&&t.push(""))}return t.join(":")},c.estimateCores=function(e,t){if("function"==typeof e&&(t=e,e={}),e=e||{},"cores"in c&&!e.update)return t(null,c.cores);if("undefined"!=typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return c.cores=navigator.hardwareConcurrency,t(null,c.cores);if("undefined"==typeof Worker)return c.cores=1,t(null,c.cores);if("undefined"==typeof Blob)return c.cores=2,t(null,c.cores);var r=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",(function(e){for(var t=Date.now(),r=t+4;Date.now()a.st&&n.stn.st&&a.st0;)a.push(u%s),u=u/s|0}for(n=0;0===e[n]&&n=0;--n)i+=t[a[n]]}else i=function(e,t){var r=0,i=t.length,n=t.charAt(0),s=[0];for(r=0;r0;)s.push(a%i),a=a/i|0}var c="";for(r=0;0===e.at(r)&&r=0;--r)c+=t[s[r]];return c}(e,t);if(r){var l=new RegExp(".{1,"+r+"}","g");i=i.match(l).join("\r\n")}return i},n.decode=function(e,t){if("string"!=typeof e)throw new TypeError('"input" must be a string.');if("string"!=typeof t)throw new TypeError('"alphabet" must be a string.');var r=s[t];if(!r){r=s[t]=[];for(var n=0;n>=8;for(;d>0;)c.push(255&d),d>>=8}for(var f=0;e[f]===a&&f=0;c--)P>>=8,P+=A.at(c)+R.at(c),R.setAt(c,255&P);I.putBuffer(R)}w=I,d.putBuffer(S)}return d.truncate(d.length()-s),d},o.pbe.getCipher=function(e,t,r){switch(e){case o.oids.pkcs5PBES2:return o.pbe.getCipherForPBES2(e,t,r);case o.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case o.oids["pbewithSHAAnd40BitRC2-CBC"]:return o.pbe.getCipherForPKCS12PBE(e,t,r);default:var i=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw i.oid=e,i.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],i}},o.pbe.getCipherForPBES2=function(e,t,r){var n,a={},c=[];if(!s.validate(t,u,a,c))throw(n=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=c,n;if((e=s.derToOid(a.kdfOid))!==o.oids.pkcs5PBKDF2)throw(n=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=e,n.supportedOids=["pkcs5PBKDF2"],n;if((e=s.derToOid(a.encOid))!==o.oids["aes128-CBC"]&&e!==o.oids["aes192-CBC"]&&e!==o.oids["aes256-CBC"]&&e!==o.oids["des-EDE3-CBC"]&&e!==o.oids.desCBC)throw(n=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=e,n.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],n;var l,d,h=a.kdfSalt,p=i.util.createBuffer(a.kdfIterationCount);switch(p=p.getInt(p.length()<<3),o.oids[e]){case"aes128-CBC":l=16,d=i.aes.createDecryptionCipher;break;case"aes192-CBC":l=24,d=i.aes.createDecryptionCipher;break;case"aes256-CBC":l=32,d=i.aes.createDecryptionCipher;break;case"des-EDE3-CBC":l=24,d=i.des.createDecryptionCipher;break;case"desCBC":l=8,d=i.des.createDecryptionCipher}var g=f(a.prfOid),y=i.pkcs5.pbkdf2(r,h,p,l,g),m=a.encIv,b=d(y);return b.start(m),b},o.pbe.getCipherForPKCS12PBE=function(e,t,r){var n={},a=[];if(!s.validate(t,l,n,a))throw(g=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=a,g;var c,u,d,h=i.util.createBuffer(n.salt),p=i.util.createBuffer(n.iterations);switch(p=p.getInt(p.length()<<3),e){case o.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:c=24,u=8,d=i.des.startDecrypting;break;case o.oids["pbewithSHAAnd40BitRC2-CBC"]:c=5,u=8,d=function(e,t){var r=i.rc2.createDecryptionCipher(e,40);return r.start(t,null),r};break;default:var g;throw(g=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=e,g}var y=f(n.prfOid),m=o.pbe.generatePkcs12Key(r,h,1,p,c,y);return y.start(),d(m,o.pbe.generatePkcs12Key(r,h,2,p,u,y))},o.pbe.opensslDeriveBytes=function(e,t,r,n){if(null==n){if(!("md5"in i.md))throw new Error('"md5" hash algorithm unavailable.');n=i.md.md5.create()}null===t&&(t="");for(var s=[d(n,e+t)],o=16,a=1;o>>=2;for(n=0;n>8^255&d^99,s[g]=d,o[d]=g,h=(f=e[d])<<24^d<<16^d<<8^d^f,p=((r=e[g])^(i=e[r])^(n=e[i]))<<24^(g^n)<<16^(g^i^n)<<8^g^r^n;for(var m=0;m<4;++m)c[m][g]=h,u[m][d]=p,h=h<<24|h>>>8,p=p<<24|p>>>8;0===g?g=y=1:(g=r^e[e[e[r^n]]],y^=e[e[y]])}}function f(e,t){for(var r,i=e.slice(0),n=1,o=i.length,c=4*(o+6+1),l=o;l>>16&255]<<24^s[r>>>8&255]<<16^s[255&r]<<8^s[r>>>24]^a[n]<<24,n++):o>6&&l%o==4&&(r=s[r>>>24]<<24^s[r>>>16&255]<<16^s[r>>>8&255]<<8^s[255&r]),i[l]=i[l-o]^r;if(t){for(var d,f=u[0],h=u[1],p=u[2],g=u[3],y=i.slice(0),m=(l=0,(c=i.length)-4);l>>24]]^h[s[d>>>16&255]]^p[s[d>>>8&255]]^g[s[255&d]];i=y}return i}function h(e,t,r,i){var n,a,l,d,f,h,p,g,y,m,b,v,w=e.length/4-1;i?(n=u[0],a=u[1],l=u[2],d=u[3],f=o):(n=c[0],a=c[1],l=c[2],d=c[3],f=s),h=t[0]^e[0],p=t[i?3:1]^e[1],g=t[2]^e[2],y=t[i?1:3]^e[3];for(var _=3,E=1;E>>24]^a[p>>>16&255]^l[g>>>8&255]^d[255&y]^e[++_],b=n[p>>>24]^a[g>>>16&255]^l[y>>>8&255]^d[255&h]^e[++_],v=n[g>>>24]^a[y>>>16&255]^l[h>>>8&255]^d[255&p]^e[++_],y=n[y>>>24]^a[h>>>16&255]^l[p>>>8&255]^d[255&g]^e[++_],h=m,p=b,g=v;r[0]=f[h>>>24]<<24^f[p>>>16&255]<<16^f[g>>>8&255]<<8^f[255&y]^e[++_],r[i?3:1]=f[p>>>24]<<24^f[g>>>16&255]<<16^f[y>>>8&255]<<8^f[255&h]^e[++_],r[2]=f[g>>>24]<<24^f[y>>>16&255]<<16^f[h>>>8&255]<<8^f[255&p]^e[++_],r[i?1:3]=f[y>>>24]<<24^f[h>>>16&255]<<16^f[p>>>8&255]<<8^f[255&g]^e[++_]}function p(e){var t,r="AES-"+((e=e||{}).mode||"CBC").toUpperCase(),n=(t=e.decrypt?i.cipher.createDecipher(r,e.key):i.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var s=null;r instanceof i.util.ByteBuffer&&(s=r,r={}),(r=r||{}).output=s,r.iv=e,n.call(t,r)},t}},{"./forge":"4OuPD","./cipher":"jMIHu","./cipherModes":"9MNR1","./util":"df43p"}],jMIHu:[function(e,t,r){var i=e("./forge");e("./util"),t.exports=i.cipher=i.cipher||{},i.cipher.algorithms=i.cipher.algorithms||{},i.cipher.createCipher=function(e,t){var r=e;if("string"==typeof r&&(r=i.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new i.cipher.BlockCipher({algorithm:r,key:t,decrypt:!1})},i.cipher.createDecipher=function(e,t){var r=e;if("string"==typeof r&&(r=i.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new i.cipher.BlockCipher({algorithm:r,key:t,decrypt:!0})},i.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),i.cipher.algorithms[e]=t},i.cipher.getAlgorithm=function(e){return(e=e.toUpperCase())in i.cipher.algorithms?i.cipher.algorithms[e]:null};var n=i.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};n.prototype.start=function(e){e=e||{};var t={};for(var r in e)t[r]=e[r];t.decrypt=this._decrypt,this._finish=!1,this._input=i.util.createBuffer(),this.output=e.output||i.util.createBuffer(),this.mode.start(t)},n.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},n.prototype.finish=function(e){!e||"ECB"!==this.mode.name&&"CBC"!==this.mode.name||(this.mode.pad=function(t){return e(this.blockSize,t,!1)},this.mode.unpad=function(t){return e(this.blockSize,t,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t))&&(this._finish=!0,this.update(),!(this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t))&&!(this.mode.afterFinish&&!this.mode.afterFinish(this.output,t)))}},{"./forge":"4OuPD","./util":"df43p"}],"9MNR1":[function(e,t,r){var i=e("./forge");e("./util"),i.cipher=i.cipher||{};var n=t.exports=i.cipher.modes=i.cipher.modes||{};function s(e,t){if("string"==typeof e&&(e=i.util.createBuffer(e)),i.util.isArray(e)&&e.length>4){var r=e;e=i.util.createBuffer();for(var n=0;n0))return!0;for(var i=0;i0))return!0;for(var i=0;i0)return!1;var r=e.length(),i=e.at(r-1);return!(i>this.blockSize<<2)&&(e.truncate(i),!0)},n.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},n.cbc.prototype.start=function(e){if(null===e.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=s(e.iv,this.blockSize),this._prev=this._iv.slice(0)}},n.cbc.prototype.encrypt=function(e,t,r){if(e.length()0))return!0;for(var i=0;i0))return!0;for(var i=0;i0)return!1;var r=e.length(),i=e.at(r-1);return!(i>this.blockSize<<2)&&(e.truncate(i),!0)},n.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=i.util.createBuffer(),this._partialBytes=0},n.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=s(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},n.cfb.prototype.encrypt=function(e,t,r){var i=e.length();if(0===i)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&i>=this.blockSize)for(var n=0;n0&&(s=this.blockSize-s),this._partialOutput.clear();for(n=0;n0)e.read-=this.blockSize;else for(n=0;n0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0}},n.cfb.prototype.decrypt=function(e,t,r){var i=e.length();if(0===i)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&i>=this.blockSize)for(var n=0;n0&&(s=this.blockSize-s),this._partialOutput.clear();for(n=0;n0)e.read-=this.blockSize;else for(n=0;n0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0}},n.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=i.util.createBuffer(),this._partialBytes=0},n.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=s(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},n.ofb.prototype.encrypt=function(e,t,r){var i=e.length();if(0===e.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&i>=this.blockSize)for(var n=0;n0&&(s=this.blockSize-s),this._partialOutput.clear();for(n=0;n0)e.read-=this.blockSize;else for(n=0;n0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0}},n.ofb.prototype.decrypt=n.ofb.prototype.encrypt,n.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=i.util.createBuffer(),this._partialBytes=0},n.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=s(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},n.ctr.prototype.encrypt=function(e,t,r){var i=e.length();if(0===i)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&i>=this.blockSize)for(var n=0;n0&&(s=this.blockSize-s),this._partialOutput.clear();for(n=0;n0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0}o(this._inBlock)},n.ctr.prototype.decrypt=n.ctr.prototype.encrypt,n.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=i.util.createBuffer(),this._partialBytes=0,this._R=3774873600},n.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t,r=i.util.createBuffer(e.iv);if(this._cipherLength=0,t="additionalData"in e?i.util.createBuffer(e.additionalData):i.util.createBuffer(),this._tagLength="tagLength"in e?e.tagLength:128,this._tag=null,e.decrypt&&(this._tag=i.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var n=r.length();if(12===n)this._j0=[r.getInt32(),r.getInt32(),r.getInt32(),1];else{for(this._j0=[0,0,0,0];r.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(a(8*n)))}this._inBlock=this._j0.slice(0),o(this._inBlock),this._partialBytes=0,t=i.util.createBuffer(t),this._aDataLength=a(8*t.length());var s=t.length()%this.blockSize;for(s&&t.fillWithByte(0,this.blockSize-s),this._s=[0,0,0,0];t.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()])},n.gcm.prototype.encrypt=function(e,t,r){var i=e.length();if(0===i)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&i>=this.blockSize){for(var n=0;n0&&(s=this.blockSize-s),this._partialOutput.clear();for(n=0;n0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),o(this._inBlock)},n.gcm.prototype.decrypt=function(e,t,r){var i=e.length();if(i0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),o(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var n=0;n0;--i)t[i]=e[i]>>>1|(1&e[i-1])<<31;t[0]=e[0]>>>1,r&&(t[0]^=this._R)},n.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],r=0;r<32;++r){var i=e[r/8|0]>>>4*(7-r%8)&15,n=this._m[r][i];t[0]^=n[0],t[1]^=n[1],t[2]^=n[2],t[3]^=n[3]}return t},n.gcm.prototype.ghash=function(e,t,r){return t[0]^=r[0],t[1]^=r[1],t[2]^=r[2],t[3]^=r[3],this.tableMultiply(t)},n.gcm.prototype.generateHashTable=function(e,t){for(var r=8/t,i=4*r,n=16*r,s=new Array(n),o=0;o>>1,n=new Array(r);n[i]=e.slice(0);for(var s=i>>>1;s>0;)this.pow(n[2*s],n[s]=[]),s>>=1;for(s=2;s8?3:1,m=[],b=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],v=0,w=0;w>>4^E))<<4,_^=t=65535&((E^=t)>>>-16^_),_^=(t=858993459&(_>>>2^(E^=t<<-16)))<<2,_^=t=65535&((E^=t)>>>-16^_),_^=(t=1431655765&(_>>>1^(E^=t<<-16)))<<1,_^=t=16711935&((E^=t)>>>8^_),t=(_^=(t=1431655765&(_>>>1^(E^=t<<8)))<<1)<<8|(E^=t)>>>20&240,_=E<<24|E<<8&16711680|E>>>8&65280|E>>>24&240,E=t;for(var S=0;S>>26,E=E<<2|E>>>26):(_=_<<1|_>>>27,E=E<<1|E>>>27),E&=-15;var T=r[(_&=-15)>>>28]|i[_>>>24&15]|n[_>>>20&15]|s[_>>>16&15]|o[_>>>12&15]|a[_>>>8&15]|c[_>>>4&15],A=u[E>>>28]|l[E>>>24&15]|d[E>>>20&15]|f[E>>>16&15]|h[E>>>12&15]|p[E>>>8&15]|g[E>>>4&15];t=65535&(A>>>16^T),m[v++]=T^t,m[v++]=A^t<<16}}return m}(t),this._init=!0}},n("DES-ECB",i.cipher.modes.ecb),n("DES-CBC",i.cipher.modes.cbc),n("DES-CFB",i.cipher.modes.cfb),n("DES-OFB",i.cipher.modes.ofb),n("DES-CTR",i.cipher.modes.ctr),n("3DES-ECB",i.cipher.modes.ecb),n("3DES-CBC",i.cipher.modes.cbc),n("3DES-CFB",i.cipher.modes.cfb),n("3DES-OFB",i.cipher.modes.ofb),n("3DES-CTR",i.cipher.modes.ctr);var s=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],o=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],a=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],c=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],u=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],l=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],d=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],f=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function h(e,t,r,i){var n,h,p=32===e.length?3:9;n=3===p?i?[30,-2,-2]:[0,32,2]:i?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var g=t[0],y=t[1];g^=(h=252645135&(g>>>4^y))<<4,g^=(h=65535&(g>>>16^(y^=h)))<<16,g^=h=858993459&((y^=h)>>>2^g),g^=h=16711935&((y^=h<<2)>>>8^g),g=(g^=(h=1431655765&(g>>>1^(y^=h<<8)))<<1)<<1|g>>>31,y=(y^=h)<<1|y>>>31;for(var m=0;m>>4|y<<28)^e[w+1];h=g,g=y,y=h^(o[_>>>24&63]|c[_>>>16&63]|l[_>>>8&63]|f[63&_]|s[E>>>24&63]|a[E>>>16&63]|u[E>>>8&63]|d[63&E])}h=g,g=y,y=h}y=y>>>1|y<<31,y^=h=1431655765&((g=g>>>1|g<<31)>>>1^y),y^=(h=16711935&(y>>>8^(g^=h<<1)))<<8,y^=(h=858993459&(y>>>2^(g^=h)))<<2,y^=h=65535&((g^=h)>>>16^y),y^=h=252645135&((g^=h<<16)>>>4^y),g^=h<<4,r[0]=g,r[1]=y}function p(e){var t,r="DES-"+((e=e||{}).mode||"CBC").toUpperCase(),n=(t=e.decrypt?i.cipher.createDecipher(r,e.key):i.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var s=null;r instanceof i.util.ByteBuffer&&(s=r,r={}),(r=r||{}).output=s,r.iv=e,n.call(t,r)},t}},{"./forge":"4OuPD","./cipher":"jMIHu","./cipherModes":"9MNR1","./util":"df43p"}],fYbz5:[function(e,t,r){var i=e("./forge");t.exports=i.md=i.md||{},i.md.algorithms=i.md.algorithms||{}},{"./forge":"4OuPD"}],j1TyX:[function(e,t,r){var i=e("buffer").Buffer,n=e("./forge");e("./hmac"),e("./md"),e("./util");var s,o=n.pkcs5=n.pkcs5||{};n.util.isNodejs&&!n.options.usePureJavaScript&&(s=e("crypto")),t.exports=n.pbkdf2=o.pbkdf2=function(e,t,r,o,a,c){if("function"==typeof a&&(c=a,a=null),n.util.isNodejs&&!n.options.usePureJavaScript&&s.pbkdf2&&(null===a||"object"!=typeof a)&&(s.pbkdf2Sync.length>4||!a||"sha1"===a))return"string"!=typeof a&&(a="sha1"),e=i.from(e,"binary"),t=i.from(t,"binary"),c?4===s.pbkdf2Sync.length?s.pbkdf2(e,t,r,o,(function(e,t){if(e)return c(e);c(null,t.toString("binary"))})):s.pbkdf2(e,t,r,o,a,(function(e,t){if(e)return c(e);c(null,t.toString("binary"))})):4===s.pbkdf2Sync.length?s.pbkdf2Sync(e,t,r,o).toString("binary"):s.pbkdf2Sync(e,t,r,o,a).toString("binary");if(null==a&&(a="sha1"),"string"==typeof a){if(!(a in n.md.algorithms))throw new Error("Unknown hash algorithm: "+a);a=n.md[a].create()}var u=a.digestLength;if(o>4294967295*u){var l=new Error("Derived key is too long.");if(c)return c(l);throw l}var d=Math.ceil(o/u),f=o-(d-1)*u,h=n.hmac.create();h.start(a,e);var p,g,y,m="";if(!c){for(var b=1;b<=d;++b){h.start(null,null),h.update(t),h.update(n.util.int32ToBytes(b)),p=y=h.digest().getBytes();for(var v=2;v<=r;++v)h.start(null,null),h.update(y),g=h.digest().getBytes(),p=n.util.xorBytes(p,g,u),y=g;m+=bd)return c(null,m);h.start(null,null),h.update(t),h.update(n.util.int32ToBytes(b)),p=y=h.digest().getBytes(),v=2,_()}function _(){if(v<=r)return h.start(null,null),h.update(y),g=h.digest().getBytes(),p=n.util.xorBytes(p,g,u),y=g,++v,n.util.setImmediate(_);m+=bt.blockLength&&(t.start(),t.update(o.bytes()),o=t.digest()),r=i.util.createBuffer(),n=i.util.createBuffer(),u=o.length();for(c=0;c65&&-1!==o){var a=t[o];","===a?(++o,t=t.substr(0,o)+"\r\n "+t.substr(o)):t=t.substr(0,o)+"\r\n"+a+t.substr(o+1),s=n-o-1,o=-1,++n}else" "!==t[n]&&"\t"!==t[n]&&","!==t[n]||(o=n);return t}function o(e){return e.replace(/^\s+/,"")}n.encode=function(e,t){t=t||{};var r,n="-----BEGIN "+e.type+"-----\r\n";if(e.procType&&(n+=s(r={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]})),e.contentDomain&&(n+=s(r={name:"Content-Domain",values:[e.contentDomain]})),e.dekInfo&&(r={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&r.values.push(e.dekInfo.parameters),n+=s(r)),e.headers)for(var o=0;o>>0,a>>>0];for(var u=n.fullMessageLength.length-1;u>=0;--u)n.fullMessageLength[u]+=a[1],a[1]=a[0]+(n.fullMessageLength[u]/4294967296>>>0),n.fullMessageLength[u]=n.fullMessageLength[u]>>>0,a[0]=a[1]/4294967296>>>0;return t.putBytes(s),c(e,r,t),(t.read>2048||0===t.length())&&t.compact(),n},n.digest=function(){var o=i.util.createBuffer();o.putBytes(t.bytes());var a,u=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize&n.blockLength-1;o.putBytes(s.substr(0,n.blockLength-u));for(var l=8*n.fullMessageLength[0],d=0;d>>0,o.putInt32(l>>>0),l=a>>>0;o.putInt32(l);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};c(f,r,o);var h=i.util.createBuffer();return h.putInt32(f.h0),h.putInt32(f.h1),h.putInt32(f.h2),h.putInt32(f.h3),h.putInt32(f.h4),h.putInt32(f.h5),h.putInt32(f.h6),h.putInt32(f.h7),h},n};var s=null,o=!1,a=null;function c(e,t,r){for(var i,n,s,o,c,u,l,d,f,h,p,g,y,m=r.length();m>=64;){for(c=0;c<16;++c)t[c]=r.getInt32();for(;c<64;++c)i=((i=t[c-2])>>>17|i<<15)^(i>>>19|i<<13)^i>>>10,n=((n=t[c-15])>>>7|n<<25)^(n>>>18|n<<14)^n>>>3,t[c]=i+t[c-7]+n+t[c-16]|0;for(u=e.h0,l=e.h1,d=e.h2,f=e.h3,h=e.h4,p=e.h5,g=e.h6,y=e.h7,c=0;c<64;++c)s=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),o=u&l|d&(u^l),i=y+((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(g^h&(p^g))+a[c]+t[c],y=g,g=p,p=h,h=f+i>>>0,f=d,d=l,l=u,u=i+(n=s+o)>>>0;e.h0=e.h0+u|0,e.h1=e.h1+l|0,e.h2=e.h2+d|0,e.h3=e.h3+f|0,e.h4=e.h4+h|0,e.h5=e.h5+p|0,e.h6=e.h6+g|0,e.h7=e.h7+y|0,m-=64}}},{"./forge":"4OuPD","./md":"fYbz5","./util":"df43p"}],"5YtEX":[function(e,t,r){var i=e("process"),n=e("./forge");e("./util");var s=null;!n.util.isNodejs||n.options.usePureJavaScript||i.versions["node-webkit"]||(s=e("crypto")),(t.exports=n.prng=n.prng||{}).create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},r=e.md,i=new Array(32),o=0;o<32;++o)i[o]=r.create();function a(){if(t.pools[0].messageLength>=32)return c();var e=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(e)),c()}function c(){t.reseeds=4294967295===t.reseeds?0:t.reseeds+1;var e=t.plugin.md.create();e.update(t.keyBytes);for(var r=1,i=0;i<32;++i)t.reseeds%r==0&&(e.update(t.pools[i].digest().getBytes()),t.pools[i].start()),r<<=1;t.keyBytes=e.digest().getBytes(),e.start(),e.update(t.keyBytes);var n=e.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(n),t.generated=0}function u(e){var t=null,r=n.util.globalScope,i=r.crypto||r.msCrypto;i&&i.getRandomValues&&(t=function(e){return i.getRandomValues(e)});var s=n.util.createBuffer();if(t)for(;s.length()>16)))<<16,f=4294967295&(l=(2147483647&(l+=u>>15))+(l>>31));for(c=0;c<3;++c)d=f>>>(c<<3),d^=Math.floor(256*Math.random()),s.putByte(String.fromCharCode(255&d))}return s.getBytes(e)}return t.pools=i,t.pool=0,t.generate=function(e,r){if(!r)return t.generateSync(e);var i=t.plugin.cipher,s=t.plugin.increment,o=t.plugin.formatKey,a=t.plugin.formatSeed,u=n.util.createBuffer();t.key=null,function l(d){if(d)return r(d);if(u.length()>=e)return r(null,u.getBytes(e));t.generated>1048575&&(t.key=null);if(null===t.key)return n.util.nextTick((function(){!function(e){if(t.pools[0].messageLength>=32)return c(),e();var r=32-t.pools[0].messageLength<<5;t.seedFile(r,(function(r,i){if(r)return e(r);t.collect(i),c(),e()}))}(l)}));var f=i(t.key,t.seed);t.generated+=f.length,u.putBytes(f),t.key=o(i(t.key,s(t.seed))),t.seed=a(i(t.key,t.seed)),n.util.setImmediate(l)}()},t.generateSync=function(e){var r=t.plugin.cipher,i=t.plugin.increment,s=t.plugin.formatKey,o=t.plugin.formatSeed;t.key=null;for(var c=n.util.createBuffer();c.length()1048575&&(t.key=null),null===t.key&&a();var u=r(t.key,t.seed);t.generated+=u.length,c.putBytes(u),t.key=s(r(t.key,i(t.seed))),t.seed=o(r(t.key,t.seed))}return c.getBytes(e)},s?(t.seedFile=function(e,t){s.randomBytes(e,(function(e,r){if(e)return t(e);t(null,r.toString())}))},t.seedFileSync=function(e){return s.randomBytes(e).toString()}):(t.seedFile=function(e,t){try{t(null,u(e))}catch(e){t(e)}},t.seedFileSync=u),t.collect=function(e){for(var r=e.length,i=0;i>n&255);t.collect(i)},t.registerWorker=function(e){if(e===self)t.seedFile=function(e,t){self.addEventListener("message",(function e(r){var i=r.data;i.forge&&i.forge.prng&&(self.removeEventListener("message",e),t(i.forge.prng.err,i.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:e}}})};else{e.addEventListener("message",(function(r){var i=r.data;i.forge&&i.forge.prng&&t.seedFile(i.forge.prng.needed,(function(t,r){e.postMessage({forge:{prng:{err:t,bytes:r}}})}))}))}},t}},{process:"lHksA","./forge":"4OuPD","./util":"df43p",crypto:"lHksA"}],k5bWr:[function(e,t,r){var i=e("./forge");e("./util");var n=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],s=[1,2,3,5],o=function(e,t){return e<>16-t},a=function(e,t){return(65535&e)>>t|e<<16-t&65535};t.exports=i.rc2=i.rc2||{},i.rc2.expandKey=function(e,t){"string"==typeof e&&(e=i.util.createBuffer(e)),t=t||128;var r,s=e,o=e.length(),a=t,c=Math.ceil(a/8),u=255>>(7&a);for(r=o;r<128;r++)s.putByte(n[s.at(r-1)+s.at(r-o)&255]);for(s.setAt(128-c,n[s.at(128-c)&u]),r=127-c;r>=0;r--)s.setAt(r,n[s.at(r+1)^s.at(r+c)]);return s};var c=function(e,t,r){var n,c,u,l,d=!1,f=null,h=null,p=null,g=[];for(e=i.rc2.expandKey(e,t),u=0;u<64;u++)g.push(e.getInt16Le());r?(n=function(e){for(u=0;u<4;u++)e[u]+=g[l]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),e[u]=o(e[u],s[u]),l++},c=function(e){for(u=0;u<4;u++)e[u]+=g[63&e[(u+3)%4]]}):(n=function(e){for(u=3;u>=0;u--)e[u]=a(e[u],s[u]),e[u]-=g[l]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),l--},c=function(e){for(u=3;u>=0;u--)e[u]-=g[63&e[(u+3)%4]]});var y=function(e){var t=[];for(u=0;u<4;u++){var i=f.getInt16Le();null!==p&&(r?i^=p.getInt16Le():p.putInt16Le(i)),t.push(65535&i)}l=r?0:63;for(var n=0;n=8;)y([[5,n],[1,c],[6,n],[1,c],[5,n]])},finish:function(e){var t=!0;if(r)if(e)t=e(8,f,!r);else{var i=8===f.length()?8:8-f.length();f.fillWithByte(i,i)}if(t&&(d=!0,m.update()),!r&&(t=0===f.length()))if(e)t=e(8,h,!r);else{var n=h.length(),s=h.at(n-1);s>n?t=!1:h.truncate(s)}return t}}};i.rc2.startEncrypting=function(e,t,r){var n=i.rc2.createEncryptionCipher(e,128);return n.start(t,r),n},i.rc2.createEncryptionCipher=function(e,t){return c(e,t,!0)},i.rc2.startDecrypting=function(e,t,r){var n=i.rc2.createDecryptionCipher(e,128);return n.start(t,r),n},i.rc2.createDecryptionCipher=function(e,t){return c(e,t,!1)}},{"./forge":"4OuPD","./util":"df43p"}],"9ROH2":[function(e,t,r){var i=e("./forge");if(e("./asn1"),e("./jsbn"),e("./oids"),e("./pkcs1"),e("./prime"),e("./random"),e("./util"),void 0===n)var n=i.jsbn.BigInteger;var s=i.util.isNodejs?e("crypto"):null,o=i.asn1,a=i.util;i.pki=i.pki||{},t.exports=i.pki.rsa=i.rsa=i.rsa||{};var c=i.pki,u=[6,4,2,4,2,4,6,2],l={name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},d={name:"RSAPrivateKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},f={name:"RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},h=i.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},p=function(e){var t;if(!(e.algorithm in c.oids)){var r=new Error("Unknown message digest algorithm.");throw r.algorithm=e.algorithm,r}t=c.oids[e.algorithm];var i=o.oidToDer(t).getBytes(),n=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]),s=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]);s.value.push(o.create(o.Class.UNIVERSAL,o.Type.OID,!1,i)),s.value.push(o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,""));var a=o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,e.digest().getBytes());return n.value.push(s),n.value.push(a),o.toDer(n).getBytes()},g=function(e,t,r){if(r)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);var s;t.dP||(t.dP=t.d.mod(t.p.subtract(n.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(n.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));do{s=new n(i.util.bytesToHex(i.random.getBytes(t.n.bitLength()/8)),16)}while(s.compareTo(t.n)>=0||!s.gcd(t.n).equals(n.ONE));for(var o=(e=e.multiply(s.modPow(t.e,t.n)).mod(t.n)).mod(t.p).modPow(t.dP,t.p),a=e.mod(t.q).modPow(t.dQ,t.q);o.compareTo(a)<0;)o=o.add(t.p);var c=o.subtract(a).multiply(t.qInv).mod(t.p).multiply(t.q).add(a);return c=c.multiply(s.modInverse(t.n)).mod(t.n)};function y(e,t,r){var n=i.util.createBuffer(),s=Math.ceil(t.n.bitLength()/8);if(e.length>s-11){var o=new Error("Message is too long for PKCS#1 v1.5 padding.");throw o.length=e.length,o.max=s-11,o}n.putByte(0),n.putByte(r);var a,c=s-3-e.length;if(0===r||1===r){a=0===r?0:255;for(var u=0;u0;){var l=0,d=i.random.getBytes(c);for(u=0;u1;){if(255!==o.getByte()){--o.read;break}++u}else if(2===c)for(u=0;o.length()>1;){if(0===o.getByte()){--o.read;break}++u}if(0!==o.getByte()||u!==s-3-o.length())throw new Error("Encryption block is invalid.");return o.getBytes()}function b(e,t,r){"function"==typeof t&&(r=t,t={});var s={algorithm:{name:(t=t||{}).algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};function o(){a(e.pBits,(function(t,i){return t?r(t):(e.p=i,null!==e.q?u(t,e.q):void a(e.qBits,u))}))}function a(e,t){i.prime.generateProbablePrime(e,s,t)}function u(t,i){if(t)return r(t);if(e.q=i,e.p.compareTo(e.q)<0){var s=e.p;e.p=e.q,e.q=s}if(0!==e.p.subtract(n.ONE).gcd(e.e).compareTo(n.ONE))return e.p=null,void o();if(0!==e.q.subtract(n.ONE).gcd(e.e).compareTo(n.ONE))return e.q=null,void a(e.qBits,u);if(e.p1=e.p.subtract(n.ONE),e.q1=e.q.subtract(n.ONE),e.phi=e.p1.multiply(e.q1),0!==e.phi.gcd(e.e).compareTo(n.ONE))return e.p=e.q=null,void o();if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits)return e.q=null,void a(e.qBits,u);var l=e.e.modInverse(e.phi);e.keys={privateKey:c.rsa.setPrivateKey(e.n,e.e,l,e.p,e.q,l.mod(e.p1),l.mod(e.q1),e.q.modInverse(e.p)),publicKey:c.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}"prng"in t&&(s.prng=t.prng),o()}function v(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var r=i.util.hexToBytes(t);return r.length>1&&(0===r.charCodeAt(0)&&0==(128&r.charCodeAt(1))||255===r.charCodeAt(0)&&128==(128&r.charCodeAt(1)))?r.substr(1):r}function w(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function _(e){return i.util.isNodejs&&"function"==typeof s[e]}function E(e){return void 0!==a.globalScope&&"object"==typeof a.globalScope.crypto&&"object"==typeof a.globalScope.crypto.subtle&&"function"==typeof a.globalScope.crypto.subtle[e]}function S(e){return void 0!==a.globalScope&&"object"==typeof a.globalScope.msCrypto&&"object"==typeof a.globalScope.msCrypto.subtle&&"function"==typeof a.globalScope.msCrypto.subtle[e]}function T(e){for(var t=i.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),n=0;n0;)l.putByte(0),--d;return l.putBytes(i.util.hexToBytes(u)),l.getBytes()},c.rsa.decrypt=function(e,t,r,s){var o=Math.ceil(t.n.bitLength()/8);if(e.length!==o){var a=new Error("Encrypted message length is invalid.");throw a.length=e.length,a.expected=o,a}var c=new n(i.util.createBuffer(e).toHex(),16);if(c.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var u=g(c,t,r).toString(16),l=i.util.createBuffer(),d=o-Math.ceil(u.length/2);d>0;)l.putByte(0),--d;return l.putBytes(i.util.hexToBytes(u)),!1!==s?m(l.getBytes(),t,r):l.getBytes()},c.rsa.createKeyPairGenerationState=function(e,t,r){"string"==typeof e&&(e=parseInt(e,10)),e=e||2048;var s,o=(r=r||{}).prng||i.random,a={nextBytes:function(e){for(var t=o.getBytesSync(e.length),r=0;r>1,pBits:e-(e>>1),pqState:0,num:null,keys:null}).e.fromInt(s.eInt),s},c.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var r=new n(null);r.fromInt(30);for(var i,s=0,o=function(e,t){return e|t},a=+new Date,l=0;null===e.keys&&(t<=0||ld?e.pqState=0:e.num.isProbablePrime(w(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(u[s++%8],0):2===e.pqState?e.pqState=0===e.num.subtract(n.ONE).gcd(e.e).compareTo(n.ONE)?3:0:3===e.pqState&&(e.pqState=0,null===e.p?e.p=e.num:e.q=e.num,null!==e.p&&null!==e.q&&++e.state,e.num=null)}else if(1===e.state)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(2===e.state)e.p1=e.p.subtract(n.ONE),e.q1=e.q.subtract(n.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(3===e.state)0===e.phi.gcd(e.e).compareTo(n.ONE)?++e.state:(e.p=null,e.q=null,e.state=0);else if(4===e.state)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(5===e.state){var h=e.e.modInverse(e.phi);e.keys={privateKey:c.rsa.setPrivateKey(e.n,e.e,h,e.p,e.q,h.mod(e.p1),h.mod(e.q1),e.q.modInverse(e.p)),publicKey:c.rsa.setPublicKey(e.n,e.e)}}l+=(i=+new Date)-a,a=i}return null!==e.keys},c.rsa.generateKeyPair=function(e,t,r,n){if(1===arguments.length?"object"==typeof e?(r=e,e=void 0):"function"==typeof e&&(n=e,e=void 0):2===arguments.length?"number"==typeof e?"function"==typeof t?(n=t,t=void 0):"number"!=typeof t&&(r=t,t=void 0):(r=e,n=t,e=void 0,t=void 0):3===arguments.length&&("number"==typeof t?"function"==typeof r&&(n=r,r=void 0):(n=r,r=t,t=void 0)),r=r||{},void 0===e&&(e=r.bits||2048),void 0===t&&(t=r.e||65537),!i.options.usePureJavaScript&&!r.prng&&e>=256&&e<=16384&&(65537===t||3===t))if(n){if(_("generateKeyPair"))return s.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},(function(e,t,r){if(e)return n(e);n(null,{privateKey:c.privateKeyFromPem(r),publicKey:c.publicKeyFromPem(t)})}));if(E("generateKey")&&E("exportKey"))return a.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:T(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then((function(e){return a.globalScope.crypto.subtle.exportKey("pkcs8",e.privateKey)})).then(void 0,(function(e){n(e)})).then((function(e){if(e){var t=c.privateKeyFromAsn1(o.fromDer(i.util.createBuffer(e)));n(null,{privateKey:t,publicKey:c.setRsaPublicKey(t.n,t.e)})}}));if(S("generateKey")&&S("exportKey")){var u=a.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:T(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);return u.oncomplete=function(e){var t=e.target.result,r=a.globalScope.msCrypto.subtle.exportKey("pkcs8",t.privateKey);r.oncomplete=function(e){var t=e.target.result,r=c.privateKeyFromAsn1(o.fromDer(i.util.createBuffer(t)));n(null,{privateKey:r,publicKey:c.setRsaPublicKey(r.n,r.e)})},r.onerror=function(e){n(e)}},void(u.onerror=function(e){n(e)})}}else if(_("generateKeyPairSync")){var l=s.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:c.privateKeyFromPem(l.privateKey),publicKey:c.publicKeyFromPem(l.publicKey)}}var d=c.rsa.createKeyPairGenerationState(e,t,r);if(!n)return c.rsa.stepKeyPairGenerationState(d,0),d.keys;b(d,r,n)},c.setRsaPublicKey=c.rsa.setPublicKey=function(e,t){var r={n:e,e:t,encrypt:function(e,t,n){if("string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===t)t={encode:function(e,t,r){return y(e,t,2).getBytes()}};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={encode:function(e,t){return i.pkcs1.encode_rsa_oaep(t,e,n)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(t))t={encode:function(e){return e}};else if("string"==typeof t)throw new Error('Unsupported encryption scheme: "'+t+'".');var s=t.encode(e,r,!0);return c.rsa.encrypt(s,r,!0)},verify:function(e,t,i){"string"==typeof i?i=i.toUpperCase():void 0===i&&(i="RSASSA-PKCS1-V1_5"),"RSASSA-PKCS1-V1_5"===i?i={verify:function(e,t){return t=m(t,r,!0),e===o.fromDer(t).value[1].value}}:"NONE"!==i&&"NULL"!==i&&null!==i||(i={verify:function(e,t){return e===(t=m(t,r,!0))}});var n=c.rsa.decrypt(t,r,!0,!1);return i.verify(e,n,r.n.bitLength())}};return r},c.setRsaPrivateKey=c.rsa.setPrivateKey=function(e,t,r,n,s,o,a,u){var l={n:e,e:t,d:r,p:n,q:s,dP:o,dQ:a,qInv:u,decrypt:function(e,t,r){"string"==typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5");var n=c.rsa.decrypt(e,l,!1,!1);if("RSAES-PKCS1-V1_5"===t)t={decode:m};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={decode:function(e,t){return i.pkcs1.decode_rsa_oaep(t,e,r)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(t))throw new Error('Unsupported encryption scheme: "'+t+'".');t={decode:function(e){return e}}}return t.decode(n,l,!1)},sign:function(e,t){var r=!1;"string"==typeof t&&(t=t.toUpperCase()),void 0===t||"RSASSA-PKCS1-V1_5"===t?(t={encode:p},r=1):"NONE"!==t&&"NULL"!==t&&null!==t||(t={encode:function(){return e}},r=1);var i=t.encode(e,l.n.bitLength());return c.rsa.encrypt(i,l,r)}};return l},c.wrapRsaPrivateKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,o.integerToDer(0).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(c.oids.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,o.toDer(e).getBytes())])},c.privateKeyFromAsn1=function(e){var t,r,s,a,u,f,h,p,g={},y=[];if(o.validate(e,l,g,y)&&(e=o.fromDer(i.util.createBuffer(g.privateKey))),g={},y=[],!o.validate(e,d,g,y)){var m=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw m.errors=y,m}return t=i.util.createBuffer(g.privateKeyModulus).toHex(),r=i.util.createBuffer(g.privateKeyPublicExponent).toHex(),s=i.util.createBuffer(g.privateKeyPrivateExponent).toHex(),a=i.util.createBuffer(g.privateKeyPrime1).toHex(),u=i.util.createBuffer(g.privateKeyPrime2).toHex(),f=i.util.createBuffer(g.privateKeyExponent1).toHex(),h=i.util.createBuffer(g.privateKeyExponent2).toHex(),p=i.util.createBuffer(g.privateKeyCoefficient).toHex(),c.setRsaPrivateKey(new n(t,16),new n(r,16),new n(s,16),new n(a,16),new n(u,16),new n(f,16),new n(h,16),new n(p,16))},c.privateKeyToAsn1=c.privateKeyToRSAPrivateKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,o.integerToDer(0).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(e.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(e.e)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(e.d)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(e.p)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(e.q)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(e.dP)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(e.dQ)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(e.qInv))])},c.publicKeyFromAsn1=function(e){var t={},r=[];if(o.validate(e,h,t,r)){var s,a=o.derToOid(t.publicKeyOid);if(a!==c.oids.rsaEncryption)throw(s=new Error("Cannot read public key. Unknown OID.")).oid=a,s;e=t.rsaPublicKey}if(r=[],!o.validate(e,f,t,r))throw(s=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=r,s;var u=i.util.createBuffer(t.publicKeyModulus).toHex(),l=i.util.createBuffer(t.publicKeyExponent).toHex();return c.setRsaPublicKey(new n(u,16),new n(l,16))},c.publicKeyToAsn1=c.publicKeyToSubjectPublicKeyInfo=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(c.oids.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.BITSTRING,!1,[c.publicKeyToRSAPublicKey(e)])])},c.publicKeyToRSAPublicKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(e.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,v(e.e))])}},{"./forge":"4OuPD","./asn1":"bcsXQ","./jsbn":"eeS3U","./oids":"7VPL4","./pkcs1":"2vXck","./prime":"ZaXlg","./random":"3tULm","./util":"df43p",crypto:"lHksA"}],eeS3U:[function(e,t,r){var i,n=e("./forge");t.exports=n.jsbn=n.jsbn||{};function s(e,t,r){this.data=[],null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function o(){return new s(null)}function a(e,t,r,i,n,s){for(var o=16383&t,a=t>>14;--s>=0;){var c=16383&this.data[e],u=this.data[e++]>>14,l=a*c+u*o;n=((c=o*c+((16383&l)<<14)+r.data[i]+n)>>28)+(l>>14)+a*u,r.data[i++]=268435455&c}return n}n.jsbn.BigInteger=s,"undefined"==typeof navigator?(s.prototype.am=a,i=28):"Microsoft Internet Explorer"==navigator.appName?(s.prototype.am=function(e,t,r,i,n,s){for(var o=32767&t,a=t>>15;--s>=0;){var c=32767&this.data[e],u=this.data[e++]>>15,l=a*c+u*o;n=((c=o*c+((32767&l)<<15)+r.data[i]+(1073741823&n))>>>30)+(l>>>15)+a*u+(n>>>30),r.data[i++]=1073741823&c}return n},i=30):"Netscape"!=navigator.appName?(s.prototype.am=function(e,t,r,i,n,s){for(;--s>=0;){var o=t*this.data[e++]+r.data[i]+n;n=Math.floor(o/67108864),r.data[i++]=67108863&o}return n},i=26):(s.prototype.am=a,i=28),s.prototype.DB=i,s.prototype.DM=(1<>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function g(e){this.m=e}function y(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function E(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function S(){}function T(e){return e}function A(e){this.r2=o(),this.q3=o(),s.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}g.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},g.prototype.revert=function(e){return e},g.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},g.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},g.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},y.prototype.convert=function(e){var t=o();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(s.ZERO)>0&&this.m.subTo(t,t),t},y.prototype.revert=function(e){var t=o();return e.copyTo(t),this.reduce(t),t},y.prototype.reduce=function(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e.data[r]+=this.m.am(0,i,e,t,0,this.m.t);e.data[r]>=e.DV;)e.data[r]-=e.DV,e.data[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},y.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},y.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},s.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s},s.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0},s.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var i=e.length,n=!1,o=0;--i>=0;){var a=8==r?255&e[i]:f(e,i);a<0?"-"==e.charAt(i)&&(n=!0):(n=!1,0==o?this.data[this.t++]=a:o+r>this.DB?(this.data[this.t-1]|=(a&(1<>this.DB-o):this.data[this.t-1]|=a<=this.DB&&(o-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,o>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==e;)--this.t},s.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t.data[r+e]=this.data[r];for(r=e-1;r>=0;--r)t.data[r]=0;t.t=this.t+e,t.s=this.s},s.prototype.drShiftTo=function(e,t){for(var r=e;r=0;--r)t.data[r+o+1]=this.data[r]>>n|a,a=(this.data[r]&s)<=0;--r)t.data[r]=0;t.data[o]=a,t.t=this.t+o+1,t.s=this.s,t.clamp()},s.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var i=e%this.DB,n=this.DB-i,s=(1<>i;for(var o=r+1;o>i;i>0&&(t.data[this.t-r-1]|=(this.s&s)<>=this.DB;if(e.t>=this.DB;i+=this.s}else{for(i+=this.s;r>=this.DB;i-=e.s}t.s=i<0?-1:0,i<-1?t.data[r++]=this.DV+i:i>0&&(t.data[r++]=i),t.t=r,t.clamp()},s.prototype.multiplyTo=function(e,t){var r=this.abs(),i=e.abs(),n=r.t;for(t.t=n+i.t;--n>=0;)t.data[n]=0;for(n=0;n=0;)e.data[r]=0;for(r=0;r=t.DV&&(e.data[r+t.t]-=t.DV,e.data[r+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(r,t.data[r],e,2*r,0,1)),e.s=0,e.clamp()},s.prototype.divRemTo=function(e,t,r){var i=e.abs();if(!(i.t<=0)){var n=this.abs();if(n.t0?(i.lShiftTo(l,a),n.lShiftTo(l,r)):(i.copyTo(a),n.copyTo(r));var d=a.t,f=a.data[d-1];if(0!=f){var h=f*(1<1?a.data[d-2]>>this.F2:0),g=this.FV/h,y=(1<=0&&(r.data[r.t++]=1,r.subTo(w,r)),s.ONE.dlShiftTo(d,w),w.subTo(a,a);a.t=0;){var _=r.data[--b]==f?this.DM:Math.floor(r.data[b]*g+(r.data[b-1]+m)*y);if((r.data[b]+=a.am(0,_,r,v,0,d))<_)for(a.dlShiftTo(v,w),r.subTo(w,r);r.data[b]<--_;)r.subTo(w,r)}null!=t&&(r.drShiftTo(d,t),c!=u&&s.ZERO.subTo(t,t)),r.t=d,r.clamp(),l>0&&r.rShiftTo(l,r),c<0&&s.ZERO.subTo(r,r)}}},s.prototype.invDigit=function(){if(this.t<1)return 0;var e=this.data[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},s.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},s.prototype.exp=function(e,t){if(e>4294967295||e<1)return s.ONE;var r=o(),i=o(),n=t.convert(this),a=p(e)-1;for(n.copyTo(r);--a>=0;)if(t.sqrTo(r,i),(e&1<0)t.mulTo(i,n,r);else{var c=r;r=i,i=c}return t.revert(r)},s.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,i=(1<0)for(a>a)>0&&(n=!0,s=d(r));o>=0;)a>(a+=this.DB-t)):(r=this.data[o]>>(a-=t)&i,a<=0&&(a+=this.DB,--o)),r>0&&(n=!0),n&&(s+=d(r));return n?s:"0"},s.prototype.negate=function(){var e=o();return s.ZERO.subTo(this,e),e},s.prototype.abs=function(){return this.s<0?this.negate():this},s.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this.data[r]-e.data[r]))return t;return 0},s.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+p(this.data[this.t-1]^this.s&this.DM)},s.prototype.mod=function(e){var t=o();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(s.ZERO)>0&&e.subTo(t,t),t},s.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new g(t):new y(t),this.exp(e,r)},s.ZERO=h(0),s.ONE=h(1),S.prototype.convert=T,S.prototype.revert=T,S.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},S.prototype.sqrTo=function(e,t){e.squareTo(t)},A.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=o();return e.copyTo(t),this.reduce(t),t},A.prototype.revert=function(e){return e},A.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},A.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},A.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var k=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],I=67108864/k[k.length-1];s.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},s.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),i=h(r),n=o(),s=o(),a="";for(this.divRemTo(i,n,s);n.signum()>0;)a=(r+s.intValue()).toString(e).substr(1)+a,n.divRemTo(i,n,s);return s.intValue().toString(e)+a},s.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),i=Math.pow(t,r),n=!1,o=0,a=0,c=0;c=r&&(this.dMultiply(i),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(t,o)),this.dAddOffset(a,0)),n&&s.ZERO.subTo(this,this)},s.prototype.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(s.ONE.shiftLeft(e-1),b,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(s.ONE.shiftLeft(e-1),this);else{var i=new Array,n=7&e;i.length=1+(e>>3),t.nextBytes(i),n>0?i[0]&=(1<>=this.DB;if(e.t>=this.DB;i+=this.s}else{for(i+=this.s;r>=this.DB;i+=e.s}t.s=i<0?-1:0,i>0?t.data[r++]=i:i<-1&&(t.data[r++]=this.DV+i),t.t=r,t.clamp()},s.prototype.dMultiply=function(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},s.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}},s.prototype.multiplyLowerTo=function(e,t,r){var i,n=Math.min(this.t+e.t,t);for(r.s=0,r.t=n;n>0;)r.data[--n]=0;for(i=r.t-this.t;n=0;)r.data[i]=0;for(i=Math.max(t-this.t,0);i0)if(0==t)r=this.data[0]%e;else for(var i=this.t-1;i>=0;--i)r=(t*r+this.data[i])%e;return r},s.prototype.millerRabin=function(e){var t=this.subtract(s.ONE),r=t.getLowestSetBit();if(r<=0)return!1;for(var i,n=t.shiftRight(r),o={nextBytes:function(e){for(var t=0;t=0);var c=i.modPow(n,this);if(0!=c.compareTo(s.ONE)&&0!=c.compareTo(t)){for(var u=1;u++>24},s.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},s.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},s.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,i=this.DB-e*this.DB%8,n=0;if(e-- >0)for(i>i)!=(this.s&this.DM)>>i&&(t[n++]=r|this.s<=0;)i<8?(r=(this.data[e]&(1<>(i+=this.DB-8)):(r=this.data[e]>>(i-=8)&255,i<=0&&(i+=this.DB,--e)),0!=(128&r)&&(r|=-256),0==n&&(128&this.s)!=(128&r)&&++n,(n>0||r!=this.s)&&(t[n++]=r);return t},s.prototype.equals=function(e){return 0==this.compareTo(e)},s.prototype.min=function(e){return this.compareTo(e)<0?this:e},s.prototype.max=function(e){return this.compareTo(e)>0?this:e},s.prototype.and=function(e){var t=o();return this.bitwiseTo(e,m,t),t},s.prototype.or=function(e){var t=o();return this.bitwiseTo(e,b,t),t},s.prototype.xor=function(e){var t=o();return this.bitwiseTo(e,v,t),t},s.prototype.andNot=function(e){var t=o();return this.bitwiseTo(e,w,t),t},s.prototype.not=function(){for(var e=o(),t=0;t=this.t?0!=this.s:0!=(this.data[t]&1<1){var d=o();for(i.sqrTo(a[1],d);c<=l;)a[c]=o(),i.mulTo(d,a[c-2],a[c]),c+=2}var f,m,b=e.t-1,v=!0,w=o();for(n=p(e.data[b])-1;b>=0;){for(n>=u?f=e.data[b]>>n-u&l:(f=(e.data[b]&(1<0&&(f|=e.data[b-1]>>this.DB+n-u)),c=r;0==(1&f);)f>>=1,--c;if((n-=c)<0&&(n+=this.DB,--b),v)a[f].copyTo(s),v=!1;else{for(;c>1;)i.sqrTo(s,w),i.sqrTo(w,s),c-=2;c>0?i.sqrTo(s,w):(m=s,s=w,w=m),i.mulTo(w,a[f],s)}for(;b>=0&&0==(e.data[b]&1<=0?(r.subTo(i,r),t&&n.subTo(a,n),o.subTo(c,o)):(i.subTo(r,i),t&&a.subTo(n,a),c.subTo(o,c))}return 0!=i.compareTo(s.ONE)?s.ZERO:c.compareTo(e)>=0?c.subtract(e):c.signum()<0?(c.addTo(e,c),c.signum()<0?c.add(e):c):c},s.prototype.pow=function(e){return this.exp(e,new S)},s.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var i=t;t=r,r=i}var n=t.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return t;for(n0&&(t.rShiftTo(s,t),r.rShiftTo(s,r));t.signum()>0;)(n=t.getLowestSetBit())>0&&t.rShiftTo(n,t),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},s.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r.data[0]<=k[k.length-1]){for(t=0;t>24&255,o>>16&255,o>>8&255,255&o);r.start(),r.update(e+a),n+=r.digest().getBytes()}return n.substring(0,t)}n.encode_rsa_oaep=function(e,t,r){var n,o,a,c;"string"==typeof r?(n=r,o=arguments[3]||void 0,a=arguments[4]||void 0):r&&(n=r.label||void 0,o=r.seed||void 0,a=r.md||void 0,r.mgf1&&r.mgf1.md&&(c=r.mgf1.md)),a?a.start():a=i.md.sha1.create(),c||(c=a);var u=Math.ceil(e.n.bitLength()/8),l=u-2*a.digestLength-2;if(t.length>l)throw(y=new Error("RSAES-OAEP input message length is too long.")).length=t.length,y.maxLength=l,y;n||(n=""),a.update(n,"raw");for(var d=a.digest(),f="",h=l-t.length,p=0;p>>0,c>>>0];for(var u=n.fullMessageLength.length-1;u>=0;--u)n.fullMessageLength[u]+=c[1],c[1]=c[0]+(n.fullMessageLength[u]/4294967296>>>0),n.fullMessageLength[u]=n.fullMessageLength[u]>>>0,c[0]=c[1]/4294967296>>>0;return t.putBytes(s),a(e,r,t),(t.read>2048||0===t.length())&&t.compact(),n},n.digest=function(){var o=i.util.createBuffer();o.putBytes(t.bytes());var c,u=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize&n.blockLength-1;o.putBytes(s.substr(0,n.blockLength-u));for(var l=8*n.fullMessageLength[0],d=0;d>>0,o.putInt32(l>>>0),l=c>>>0;o.putInt32(l);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};a(f,r,o);var h=i.util.createBuffer();return h.putInt32(f.h0),h.putInt32(f.h1),h.putInt32(f.h2),h.putInt32(f.h3),h.putInt32(f.h4),h},n};var s=null,o=!1;function a(e,t,r){for(var i,n,s,o,a,c,u,l=r.length();l>=64;){for(n=e.h0,s=e.h1,o=e.h2,a=e.h3,c=e.h4,u=0;u<16;++u)i=r.getInt32(),t[u]=i,i=(n<<5|n>>>27)+(a^s&(o^a))+c+1518500249+i,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=n,n=i;for(;u<20;++u)i=(i=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|i>>>31,t[u]=i,i=(n<<5|n>>>27)+(a^s&(o^a))+c+1518500249+i,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=n,n=i;for(;u<32;++u)i=(i=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|i>>>31,t[u]=i,i=(n<<5|n>>>27)+(s^o^a)+c+1859775393+i,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=n,n=i;for(;u<40;++u)i=(i=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|i>>>30,t[u]=i,i=(n<<5|n>>>27)+(s^o^a)+c+1859775393+i,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=n,n=i;for(;u<60;++u)i=(i=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|i>>>30,t[u]=i,i=(n<<5|n>>>27)+(s&o|a&(s^o))+c+2400959708+i,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=n,n=i;for(;u<80;++u)i=(i=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|i>>>30,t[u]=i,i=(n<<5|n>>>27)+(s^o^a)+c+3395469782+i,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=n,n=i;e.h0=e.h0+n|0,e.h1=e.h1+s|0,e.h2=e.h2+o|0,e.h3=e.h3+a|0,e.h4=e.h4+c|0,l-=64}}},{"./forge":"4OuPD","./md":"fYbz5","./util":"df43p"}],ZaXlg:[function(e,t,r){var i=e("./forge");e("./util"),e("./jsbn"),e("./random"),function(){if(i.prime)t.exports=i.prime;else{var e=t.exports=i.prime=i.prime||{},r=i.jsbn.BigInteger,n=[6,4,2,4,2,4,6,2],s=new r(null);s.fromInt(30);var o=function(e,t){return e|t};e.generateProbablePrime=function(e,t,n){"function"==typeof t&&(n=t,t={});var s=(t=t||{}).algorithm||"PRIMEINC";"string"==typeof s&&(s={name:s}),s.options=s.options||{};var o=t.prng||i.random,c={nextBytes:function(e){for(var t=o.getBytesSync(e.length),r=0;re&&(o=u(e,t));var h=o.toString(16);n.target.postMessage({hex:h,workLoad:l}),o.dAddOffset(d,0)}}}h()}(e,t,n,s):a(e,t,n,s)}(e,c,s.options,n);throw new Error("Invalid prime generation algorithm: "+s.name)}}function a(e,t,r,i){var n=u(e,t),s=function(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}(n.bitLength());"millerRabinTests"in r&&(s=r.millerRabinTests);var o=10;"maxBlockTime"in r&&(o=r.maxBlockTime),c(n,e,t,0,s,o,i)}function c(e,t,r,s,o,a,l){var d=+new Date;do{if(e.bitLength()>t&&(e=u(t,r)),e.isProbablePrime(o))return l(null,e);e.dAddOffset(n[s++%8],0)}while(a<0||+new Date-d{const t=e.crypto||e.msCrypto;if(!t||!t.subtle)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p-crypto/blob/master/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return t}},{}],"1sbpX":[function(e,t,r){"use strict";const{sha256:i}=e("multiformats/hashes/sha2"),n=e("err-code"),{equals:s}=e("uint8arrays/equals"),{toString:o}=e("uint8arrays/to-string");e("node-forge/lib/sha512"),e("node-forge/lib/ed25519");const a=e("node-forge/lib/forge"),c=e("./rsa"),u=e("./keys"),l=e("./exporter");class d{constructor(e){this._key=e}async verify(e,t){return c.hashAndVerify(this._key,t,e)}marshal(){return c.utils.jwkToPkix(this._key)}get bytes(){return u.PublicKey.encode({Type:u.KeyType.RSA,Data:this.marshal()}).finish()}encrypt(e){return c.encrypt(this._key,e)}equals(e){return s(this.bytes,e.bytes)}async hash(){const{bytes:e}=await i.digest(this.bytes);return e}}class f{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return c.getRandomValues(16)}async sign(e){return c.hashAndSign(this._key,e)}get public(){if(!this._publicKey)throw n(new Error("public key not provided"),"ERR_PUBKEY_NOT_PROVIDED");return new d(this._publicKey)}decrypt(e){return c.decrypt(this._key,e)}marshal(){return c.utils.jwkToPkcs1(this._key)}get bytes(){return u.PrivateKey.encode({Type:u.KeyType.RSA,Data:this.marshal()}).finish()}equals(e){return s(this.bytes,e.bytes)}async hash(){const{bytes:e}=await i.digest(this.bytes);return e}async id(){const e=await this.public.hash();return o(e,"base58btc")}async export(e,t="pkcs-8"){if("pkcs-8"===t){const t=new a.util.ByteBuffer(this.marshal()),r=a.asn1.fromDer(t),i=a.pki.privateKeyFromAsn1(r),n={algorithm:"aes256",count:1e4,saltSize:16,prfAlgorithm:"sha512"};return a.pki.encryptRsaPrivateKey(i,e,n)}if("libp2p-key"===t)return l.export(this.bytes,e);throw n(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")}}t.exports={RsaPublicKey:d,RsaPrivateKey:f,unmarshalRsaPublicKey:function(e){const t=c.utils.pkixToJwk(e);return new d(t)},unmarshalRsaPrivateKey:async function(e){const t=c.utils.pkcs1ToJwk(e),r=await c.unmarshalPrivateKey(t);return new f(r.privateKey,r.publicKey)},generateKeyPair:async function(e){const t=await c.generateKey(e);return new f(t.privateKey,t.publicKey)},fromJwk:async function(e){const t=await c.unmarshalPrivateKey(e);return new f(t.privateKey,t.publicKey)}}},{"multiformats/hashes/sha2":"7i9MT","err-code":"chZjB","uint8arrays/equals":"eY3cX","uint8arrays/to-string":"hC8JB","node-forge/lib/sha512":"9XKJ9","node-forge/lib/ed25519":"9HAE7","node-forge/lib/forge":"4OuPD","./rsa":"5a3He","./keys":"jWSTZ","./exporter":"8qVel"}],"9XKJ9":[function(e,t,r){var i=e("./forge");e("./md"),e("./util");var n=t.exports=i.sha512=i.sha512||{};i.md.sha512=i.md.algorithms.sha512=n;var s=i.sha384=i.sha512.sha384=i.sha512.sha384||{};s.create=function(){return n.create("SHA-384")},i.md.sha384=i.md.algorithms.sha384=s,i.sha512.sha256=i.sha512.sha256||{create:function(){return n.create("SHA-512/256")}},i.md["sha512/256"]=i.md.algorithms["sha512/256"]=i.sha512.sha256,i.sha512.sha224=i.sha512.sha224||{create:function(){return n.create("SHA-512/224")}},i.md["sha512/224"]=i.md.algorithms["sha512/224"]=i.sha512.sha224,n.create=function(e){if(a||(o=String.fromCharCode(128),o+=i.util.fillString(String.fromCharCode(0),128),c=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],(u={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],u["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],u["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],u["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],a=!0),void 0===e&&(e="SHA-512"),!(e in u))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=u[e],r=null,n=i.util.createBuffer(),s=new Array(80),d=0;d<80;++d)s[d]=new Array(2);var f=64;switch(e){case"SHA-384":f=48;break;case"SHA-512/256":f=32;break;case"SHA-512/224":f=28}var h={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:f,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){h.messageLength=0,h.fullMessageLength=h.messageLength128=[];for(var e=h.messageLengthSize/4,s=0;s>>0,o>>>0];for(var a=h.fullMessageLength.length-1;a>=0;--a)h.fullMessageLength[a]+=o[1],o[1]=o[0]+(h.fullMessageLength[a]/4294967296>>>0),h.fullMessageLength[a]=h.fullMessageLength[a]>>>0,o[0]=o[1]/4294967296>>>0;return n.putBytes(e),l(r,s,n),(n.read>2048||0===n.length())&&n.compact(),h},h.digest=function(){var t=i.util.createBuffer();t.putBytes(n.bytes());var a,c=h.fullMessageLength[h.fullMessageLength.length-1]+h.messageLengthSize&h.blockLength-1;t.putBytes(o.substr(0,h.blockLength-c));for(var u=8*h.fullMessageLength[0],d=0;d>>0,t.putInt32(u>>>0),u=a>>>0;t.putInt32(u);var f=new Array(r.length);for(d=0;d=128;){for(O=0;O<16;++O)t[O][0]=r.getInt32()>>>0,t[O][1]=r.getInt32()>>>0;for(;O<80;++O)i=(((C=(D=t[O-2])[0])>>>19|(j=D[1])<<13)^(j>>>29|C<<3)^C>>>6)>>>0,n=((C<<13|j>>>19)^(j<<3|C>>>29)^(C<<26|j>>>6))>>>0,s=(((C=(x=t[O-15])[0])>>>1|(j=x[1])<<31)^(C>>>8|j<<24)^C>>>7)>>>0,o=((C<<31|j>>>1)^(C<<24|j>>>8)^(C<<25|j>>>7))>>>0,M=t[O-7],B=t[O-16],j=n+M[1]+o+B[1],t[O][0]=i+M[0]+s+B[0]+(j/4294967296>>>0)>>>0,t[O][1]=j>>>0;for(p=e[0][0],g=e[0][1],y=e[1][0],m=e[1][1],b=e[2][0],v=e[2][1],w=e[3][0],_=e[3][1],E=e[4][0],S=e[4][1],T=e[5][0],A=e[5][1],k=e[6][0],I=e[6][1],R=e[7][0],P=e[7][1],O=0;O<80;++O)l=((E>>>14|S<<18)^(E>>>18|S<<14)^(S>>>9|E<<23))>>>0,d=(k^E&(T^k))>>>0,a=((p>>>28|g<<4)^(g>>>2|p<<30)^(g>>>7|p<<25))>>>0,u=((p<<4|g>>>28)^(g<<30|p>>>2)^(g<<25|p>>>7))>>>0,f=(p&y|b&(p^y))>>>0,h=(g&m|v&(g^m))>>>0,j=P+(((E<<18|S>>>14)^(E<<14|S>>>18)^(S<<23|E>>>9))>>>0)+((I^S&(A^I))>>>0)+c[O][1]+t[O][1],i=R+l+d+c[O][0]+t[O][0]+(j/4294967296>>>0)>>>0,n=j>>>0,s=a+f+((j=u+h)/4294967296>>>0)>>>0,o=j>>>0,R=k,P=I,k=T,I=A,T=E,A=S,E=w+i+((j=_+n)/4294967296>>>0)>>>0,S=j>>>0,w=b,_=v,b=y,v=m,y=p,m=g,p=i+s+((j=n+o)/4294967296>>>0)>>>0,g=j>>>0;j=e[0][1]+g,e[0][0]=e[0][0]+p+(j/4294967296>>>0)>>>0,e[0][1]=j>>>0,j=e[1][1]+m,e[1][0]=e[1][0]+y+(j/4294967296>>>0)>>>0,e[1][1]=j>>>0,j=e[2][1]+v,e[2][0]=e[2][0]+b+(j/4294967296>>>0)>>>0,e[2][1]=j>>>0,j=e[3][1]+_,e[3][0]=e[3][0]+w+(j/4294967296>>>0)>>>0,e[3][1]=j>>>0,j=e[4][1]+S,e[4][0]=e[4][0]+E+(j/4294967296>>>0)>>>0,e[4][1]=j>>>0,j=e[5][1]+A,e[5][0]=e[5][0]+T+(j/4294967296>>>0)>>>0,e[5][1]=j>>>0,j=e[6][1]+I,e[6][0]=e[6][0]+k+(j/4294967296>>>0)>>>0,e[6][1]=j>>>0,j=e[7][1]+P,e[7][0]=e[7][0]+R+(j/4294967296>>>0)>>>0,e[7][1]=j>>>0,L-=128}}},{"./forge":"4OuPD","./md":"fYbz5","./util":"df43p"}],"9HAE7":[function(e,t,r){var i=e("buffer").Buffer,n=e("./forge");e("./jsbn"),e("./random"),e("./sha512"),e("./util");var s=e("./asn1-validator"),o=s.publicKeyValidator,a=s.privateKeyValidator;if(void 0===c)var c=n.jsbn.BigInteger;var u=n.util.ByteBuffer,l=void 0===i?Uint8Array:i;n.pki=n.pki||{},t.exports=n.pki.ed25519=n.ed25519=n.ed25519||{};var d=n.ed25519;function f(e){var t=e.message;if(t instanceof Uint8Array||t instanceof l)return t;var r=e.encoding;if(void 0===t){if(!e.md)throw new TypeError('"options.message" or "options.md" not specified.');t=e.md.digest().getBytes(),r="binary"}if("string"==typeof t&&!r)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if("string"==typeof t){if(void 0!==i)return i.from(t,r);t=new u(t,r)}else if(!(t instanceof u))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var n=new l(t.length()),s=0;s=0;--r)U(i,i),1!==r&&F(i,i,t);for(r=0;r<16;++r)e[r]=i[r]}(r,r),F(r,r,n),F(r,r,s),F(r,r,s),F(e[0],r,s),U(i,e[0]),F(i,i,s),R(i,n)&&F(e[0],e[0],w);if(U(i,e[0]),F(i,i,s),R(i,n))return-1;O(e[0])===t[31]>>7&&N(e[0],h,e[0]);return F(e[3],e[0],e[1]),0}(a,i))return-1;for(n=0;n=0};var h=B(),p=B([1]),g=B([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),y=B([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),m=B([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),b=B([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),v=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),w=B([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function _(e,t){var r=n.md.sha512.create(),s=new u(e);r.update(s.getBytes(t),"binary");var o=r.digest().getBytes();if(void 0!==i)return i.from(o,"binary");for(var a=new l(d.constants.HASH_BYTE_LENGTH),c=0;c<64;++c)a[c]=o.charCodeAt(c);return a}function E(e,t){var r,i,n,s;for(i=63;i>=32;--i){for(r=0,n=i-32,s=i-12;n>8,t[n]-=256*r;t[n]+=r,t[i]=0}for(r=0,n=0;n<32;++n)t[n]+=r-(t[31]>>4)*v[n],r=t[n]>>8,t[n]&=255;for(n=0;n<32;++n)t[n]-=r*v[n];for(i=0;i<32;++i)t[i+1]+=t[i]>>8,e[i]=255&t[i]}function S(e){for(var t=new Float64Array(64),r=0;r<64;++r)t[r]=e[r],e[r]=0;E(e,t)}function T(e,t){var r=B(),i=B(),n=B(),s=B(),o=B(),a=B(),c=B(),u=B(),l=B();N(r,e[1],e[0]),N(l,t[1],t[0]),F(r,r,l),L(i,e[0],e[1]),L(l,t[0],t[1]),F(i,i,l),F(n,e[3],t[3]),F(n,n,y),F(s,e[2],t[2]),L(s,s,s),N(o,i,r),N(a,s,n),L(c,s,n),L(u,i,r),F(e[0],o,a),F(e[1],u,c),F(e[2],c,a),F(e[3],o,u)}function A(e,t,r){for(var i=0;i<4;++i)x(e[i],t[i],r)}function k(e,t){var r=B(),i=B(),n=B();!function(e,t){var r,i=B();for(r=0;r<16;++r)i[r]=t[r];for(r=253;r>=0;--r)U(i,i),2!==r&&4!==r&&F(i,i,t);for(r=0;r<16;++r)e[r]=i[r]}(n,t[2]),F(r,t[0],n),F(i,t[1],n),I(e,i),e[31]^=O(r)<<7}function I(e,t){var r,i,n,s=B(),o=B();for(r=0;r<16;++r)o[r]=t[r];for(M(o),M(o),M(o),i=0;i<2;++i){for(s[0]=o[0]-65517,r=1;r<15;++r)s[r]=o[r]-65535-(s[r-1]>>16&1),s[r-1]&=65535;s[15]=o[15]-32767-(s[14]>>16&1),n=s[15]>>16&1,s[14]&=65535,x(o,s,1-n)}for(r=0;r<16;r++)e[2*r]=255&o[r],e[2*r+1]=o[r]>>8}function R(e,t){var r=new l(32),i=new l(32);return I(r,e),I(i,t),P(r,0,i,0)}function P(e,t,r,i){return function(e,t,r,i,n){var s,o=0;for(s=0;s>>8)-1}(e,t,r,i,32)}function O(e){var t=new l(32);return I(t,e),1&t[0]}function C(e,t,r){var i,n;for(D(e[0],h),D(e[1],p),D(e[2],p),D(e[3],h),n=255;n>=0;--n)A(e,t,i=r[n/8|0]>>(7&n)&1),T(t,e),T(e,e),A(e,t,i)}function j(e,t){var r=[B(),B(),B(),B()];D(r[0],m),D(r[1],b),D(r[2],p),F(r[3],m,b),C(e,r,t)}function D(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function M(e){var t,r,i=1;for(t=0;t<16;++t)r=e[t]+i+65535,i=Math.floor(r/65536),e[t]=r-65536*i;e[0]+=i-1+37*(i-1)}function x(e,t,r){for(var i,n=~(r-1),s=0;s<16;++s)i=n&(e[s]^t[s]),e[s]^=i,t[s]^=i}function B(e){var t,r=new Float64Array(16);if(e)for(t=0;tt.encrypt(e)))},r.decrypt=function(e,t){return l(e,!1,t,((e,t)=>t.decrypt(e)))}},{"../webcrypto":"i99ng","../random-bytes":"gsnuW","uint8arrays/to-string":"hC8JB","uint8arrays/from-string":"dF7Y4","./rsa-utils":"3gF4s","./jwk2pem":"4kPkh"}],gsnuW:[function(e,t,r){"use strict";const i=e("iso-random-stream/src/random"),n=e("err-code");t.exports=function(e){if(isNaN(e)||e<=0)throw n(new Error("random bytes length must be a Number bigger than 0"),"ERR_INVALID_LENGTH");return i(e)}},{"iso-random-stream/src/random":"bIbEo","err-code":"chZjB"}],bIbEo:[function(e,t,r){"use strict";const i=65536;t.exports=function(e){const t=new Uint8Array(e);let r=0;if(e>0)if(e>i)for(;re?(crypto.getRandomValues(t.subarray(r,r+(e-r))),r+=e-r):(crypto.getRandomValues(t.subarray(r,r+i)),r+=i);else crypto.getRandomValues(t);return t}},{}],"3gF4s":[function(e,t,r){"use strict";e("node-forge/lib/asn1"),e("node-forge/lib/rsa");const i=e("node-forge/lib/forge"),{bigIntegerToUintBase64url:n,base64urlToBigInteger:s}=e("./../util"),{fromString:o}=e("uint8arrays/from-string"),{toString:a}=e("uint8arrays/to-string");r.pkcs1ToJwk=function(e){const t=i.asn1.fromDer(a(e,"ascii")),r=i.pki.privateKeyFromAsn1(t);return{kty:"RSA",n:n(r.n),e:n(r.e),d:n(r.d),p:n(r.p),q:n(r.q),dp:n(r.dP),dq:n(r.dQ),qi:n(r.qInv),alg:"RS256",kid:"2011-04-29"}},r.jwkToPkcs1=function(e){const t=i.pki.privateKeyToAsn1({n:s(e.n),e:s(e.e),d:s(e.d),p:s(e.p),q:s(e.q),dP:s(e.dp),dQ:s(e.dq),qInv:s(e.qi)});return o(i.asn1.toDer(t).getBytes(),"ascii")},r.pkixToJwk=function(e){const t=i.asn1.fromDer(a(e,"ascii")),r=i.pki.publicKeyFromAsn1(t);return{kty:"RSA",n:n(r.n),e:n(r.e),alg:"RS256",kid:"2011-04-29"}},r.jwkToPkix=function(e){const t=i.pki.publicKeyToAsn1({n:s(e.n),e:s(e.e)});return o(i.asn1.toDer(t).getBytes(),"ascii")}},{"node-forge/lib/asn1":"bcsXQ","node-forge/lib/rsa":"9ROH2","node-forge/lib/forge":"4OuPD","./../util":"ffmp6","uint8arrays/from-string":"dF7Y4","uint8arrays/to-string":"hC8JB"}],ffmp6:[function(e,t,r){"use strict";e("node-forge/lib/util"),e("node-forge/lib/jsbn");const i=e("node-forge/lib/forge"),{fromString:n}=e("uint8arrays/from-string"),{toString:s}=e("uint8arrays/to-string"),{concat:o}=e("uint8arrays/concat");r.bigIntegerToUintBase64url=(e,t)=>{let r=Uint8Array.from(e.abs().toByteArray());if(r=0===r[0]?r.slice(1):r,null!=t){if(r.length>t)throw new Error("byte array longer than desired length");r=o([new Uint8Array(t-r.length),r])}return s(r,"base64url")},r.base64urlToBigInteger=e=>{const t=r.base64urlToBuffer(e);return new i.jsbn.BigInteger(s(t,"base16"),16)},r.base64urlToBuffer=(e,t)=>{let r=n(e,"base64urlpad");if(null!=t){if(r.length>t)throw new Error("byte array longer than desired length");r=o([new Uint8Array(t-r.length),r])}return r}},{"node-forge/lib/util":"df43p","node-forge/lib/jsbn":"eeS3U","node-forge/lib/forge":"4OuPD","uint8arrays/from-string":"dF7Y4","uint8arrays/to-string":"hC8JB","uint8arrays/concat":"4EBjG"}],"4kPkh":[function(e,t,r){"use strict";e("node-forge/lib/rsa");const i=e("node-forge/lib/forge"),{base64urlToBigInteger:n}=e("../util");function s(e,t){return t.map((t=>n(e[t])))}t.exports={jwk2pub:function(e){return i.pki.setRsaPublicKey(...s(e,["n","e"]))},jwk2priv:function(e){return i.pki.setRsaPrivateKey(...s(e,["n","e","d","p","q","dp","dq","qi"]))}}},{"node-forge/lib/rsa":"9ROH2","node-forge/lib/forge":"4OuPD","../util":"ffmp6"}],"8qVel":[function(e,t,r){"use strict";const{base64:i}=e("multiformats/bases/base64"),n=e("../ciphers/aes-gcm");t.exports={export:async function(e,t){const r=n.create(),s=await r.encrypt(e,t);return i.encode(s)}}},{"multiformats/bases/base64":"gaFBW","../ciphers/aes-gcm":"92UH6"}],dh3ng:[function(e,t,r){"use strict";const i=e("err-code"),{equals:n}=e("uint8arrays/equals"),{sha256:s}=e("multiformats/hashes/sha2"),{base58btc:o}=e("multiformats/bases/base58"),{identity:a}=e("multiformats/hashes/identity"),c=e("./ed25519"),u=e("./keys"),l=e("./exporter");class d{constructor(e){this._key=h(e,c.publicKeyLength)}async verify(e,t){return c.hashAndVerify(this._key,t,e)}marshal(){return this._key}get bytes(){return u.PublicKey.encode({Type:u.KeyType.Ed25519,Data:this.marshal()}).finish()}equals(e){return n(this.bytes,e.bytes)}async hash(){const{bytes:e}=await s.digest(this.bytes);return e}}class f{constructor(e,t){this._key=h(e,c.privateKeyLength),this._publicKey=h(t,c.publicKeyLength)}async sign(e){return c.hashAndSign(this._key,e)}get public(){return new d(this._publicKey)}marshal(){return this._key}get bytes(){return u.PrivateKey.encode({Type:u.KeyType.Ed25519,Data:this.marshal()}).finish()}equals(e){return n(this.bytes,e.bytes)}async hash(){const{bytes:e}=await s.digest(this.bytes);return e}async id(){const e=await a.digest(this.public.bytes);return o.encode(e.bytes).substring(1)}async export(e,t="libp2p-key"){if("libp2p-key"===t)return l.export(this.bytes,e);throw i(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")}}function h(e,t){if((e=Uint8Array.from(e||[])).length!==t)throw i(new Error(`Key must be a Uint8Array of length ${t}, got ${e.length}`),"ERR_INVALID_KEY_TYPE");return e}t.exports={Ed25519PublicKey:d,Ed25519PrivateKey:f,unmarshalEd25519PrivateKey:function(e){if(e.length>c.privateKeyLength){const t=(e=h(e,c.privateKeyLength+c.publicKeyLength)).slice(0,c.privateKeyLength),r=e.slice(c.privateKeyLength,e.length);return new f(t,r)}const t=(e=h(e,c.privateKeyLength)).slice(0,c.privateKeyLength),r=e.slice(c.publicKeyLength);return new f(t,r)},unmarshalEd25519PublicKey:function(e){return e=h(e,c.publicKeyLength),new d(e)},generateKeyPair:async function(){const{privateKey:e,publicKey:t}=await c.generateKey();return new f(e,t)},generateKeyPairFromSeed:async function(e){const{privateKey:t,publicKey:r}=await c.generateKeyFromSeed(e);return new f(t,r)}}},{"err-code":"chZjB","uint8arrays/equals":"eY3cX","multiformats/hashes/sha2":"7i9MT","multiformats/bases/base58":"4n7mA","multiformats/hashes/identity":"eYCZn","./ed25519":"8jlvB","./keys":"jWSTZ","./exporter":"8qVel"}],"8jlvB":[function(e,t,r){"use strict";e("node-forge/lib/ed25519");const i=e("node-forge/lib/forge");r.publicKeyLength=i.pki.ed25519.constants.PUBLIC_KEY_BYTE_LENGTH,r.privateKeyLength=i.pki.ed25519.constants.PRIVATE_KEY_BYTE_LENGTH,r.generateKey=async function(){return i.pki.ed25519.generateKeyPair()},r.generateKeyFromSeed=async function(e){return i.pki.ed25519.generateKeyPair({seed:e})},r.hashAndSign=async function(e,t){return i.pki.ed25519.sign({message:t,privateKey:e})},r.hashAndVerify=async function(e,t,r){return i.pki.ed25519.verify({signature:t,message:r,publicKey:e})}},{"node-forge/lib/ed25519":"9HAE7","node-forge/lib/forge":"4OuPD"}],jXCAP:[function(e,t,r){"use strict";const{sha256:i}=e("multiformats/hashes/sha2"),n=e("err-code"),{equals:s}=e("uint8arrays/equals"),{toString:o}=e("uint8arrays/to-string"),a=e("./exporter");t.exports=(t,r,c)=>{c=c||e("./secp256k1")(r);class u{constructor(e){c.validatePublicKey(e),this._key=e}verify(e,t){return c.hashAndVerify(this._key,t,e)}marshal(){return c.compressPublicKey(this._key)}get bytes(){return t.PublicKey.encode({Type:t.KeyType.Secp256k1,Data:this.marshal()}).finish()}equals(e){return s(this.bytes,e.bytes)}async hash(){const{bytes:e}=await i.digest(this.bytes);return e}}class l{constructor(e,t){this._key=e,this._publicKey=t||c.computePublicKey(e),c.validatePrivateKey(this._key),c.validatePublicKey(this._publicKey)}sign(e){return c.hashAndSign(this._key,e)}get public(){return new u(this._publicKey)}marshal(){return this._key}get bytes(){return t.PrivateKey.encode({Type:t.KeyType.Secp256k1,Data:this.marshal()}).finish()}equals(e){return s(this.bytes,e.bytes)}async hash(){const{bytes:e}=await i.digest(this.bytes);return e}async id(){const e=await this.public.hash();return o(e,"base58btc")}async export(e,t="libp2p-key"){if("libp2p-key"===t)return a.export(this.bytes,e);throw n(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")}}return{Secp256k1PublicKey:u,Secp256k1PrivateKey:l,unmarshalSecp256k1PrivateKey:function(e){return new l(e)},unmarshalSecp256k1PublicKey:function(e){return new u(e)},generateKeyPair:async function(){const e=await c.generateKey();return new l(e)}}}},{"multiformats/hashes/sha2":"7i9MT","err-code":"chZjB","uint8arrays/equals":"eY3cX","uint8arrays/to-string":"hC8JB","./exporter":"8qVel","./secp256k1":"e9sAH"}],e9sAH:[function(e,t,r){"use strict";const i=e("secp256k1"),{sha256:n}=e("multiformats/hashes/sha2");t.exports=e=>{function t(e){if(!i.privateKeyVerify(e))throw new Error("Invalid private key")}return{generateKey:function(){let t;do{t=e(32)}while(!i.privateKeyVerify(t));return t},privateKeyLength:32,hashAndSign:async function(e,t){const{digest:r}=await n.digest(t),s=i.ecdsaSign(r,e);return i.signatureExport(s.signature)},hashAndVerify:async function(e,t,r){const{digest:s}=await n.digest(r);return t=i.signatureImport(t),i.ecdsaVerify(t,s,e)},compressPublicKey:function(e){if(!i.publicKeyVerify(e))throw new Error("Invalid public key");return i.publicKeyConvert(e,!0)},decompressPublicKey:function(e){return i.publicKeyConvert(e,!1)},validatePrivateKey:t,validatePublicKey:function(e){if(!i.publicKeyVerify(e))throw new Error("Invalid public key")},computePublicKey:function(e){return t(e),i.publicKeyCreate(e)}}}},{secp256k1:"5e78P","multiformats/hashes/sha2":"7i9MT"}],"5e78P":[function(e,t,r){t.exports=e("./lib")(e("./lib/elliptic"))},{"./lib":"f9Aan","./lib/elliptic":"7HHQM"}],f9Aan:[function(e,t,r){const i="Impossible case. Please create issue.",n="The tweak was out of range or the resulted private key is invalid",s="The tweak was out of range or equal to zero",o="Unknow error on context randomization",a="Private Key is invalid",c="Public Key could not be parsed",u="Public Key serialization error",l="The sum of the public keys is not valid",d="Signature could not be parsed",f="The nonce generation function failed, or the private key was invalid",h="Public key could not be recover",p="Scalar was invalid (zero or overflow)";function g(e,t){if(!e)throw new Error(t)}function y(e,t,r){if(g(t instanceof Uint8Array,`Expected ${e} to be an Uint8Array`),void 0!==r)if(Array.isArray(r)){const i=`Expected ${e} to be an Uint8Array with length [${r.join(", ")}]`;g(r.includes(t.length),i)}else{const i=`Expected ${e} to be an Uint8Array with length ${r}`;g(t.length===r,i)}}function m(e){g("Boolean"===v(e),"Expected compressed to be a Boolean")}function b(e=(e=>new Uint8Array(e)),t){return"function"==typeof e&&(e=e(t)),y("output",e,t),e}function v(e){return Object.prototype.toString.call(e).slice(8,-1)}t.exports=e=>({contextRandomize(t){if(g(null===t||t instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),null!==t&&y("seed",t,32),1===e.contextRandomize(t))throw new Error(o)},privateKeyVerify:t=>(y("private key",t,32),0===e.privateKeyVerify(t)),privateKeyNegate(t){switch(y("private key",t,32),e.privateKeyNegate(t)){case 0:return t;case 1:throw new Error(i)}},privateKeyTweakAdd(t,r){switch(y("private key",t,32),y("tweak",r,32),e.privateKeyTweakAdd(t,r)){case 0:return t;case 1:throw new Error(n)}},privateKeyTweakMul(t,r){switch(y("private key",t,32),y("tweak",r,32),e.privateKeyTweakMul(t,r)){case 0:return t;case 1:throw new Error(s)}},publicKeyVerify:t=>(y("public key",t,[33,65]),0===e.publicKeyVerify(t)),publicKeyCreate(t,r=!0,i){switch(y("private key",t,32),m(r),i=b(i,r?33:65),e.publicKeyCreate(i,t)){case 0:return i;case 1:throw new Error(a);case 2:throw new Error(u)}},publicKeyConvert(t,r=!0,i){switch(y("public key",t,[33,65]),m(r),i=b(i,r?33:65),e.publicKeyConvert(i,t)){case 0:return i;case 1:throw new Error(c);case 2:throw new Error(u)}},publicKeyNegate(t,r=!0,n){switch(y("public key",t,[33,65]),m(r),n=b(n,r?33:65),e.publicKeyNegate(n,t)){case 0:return n;case 1:throw new Error(c);case 2:throw new Error(i);case 3:throw new Error(u)}},publicKeyCombine(t,r=!0,i){g(Array.isArray(t),"Expected public keys to be an Array"),g(t.length>0,"Expected public keys array will have more than zero items");for(const e of t)y("public key",e,[33,65]);switch(m(r),i=b(i,r?33:65),e.publicKeyCombine(i,t)){case 0:return i;case 1:throw new Error(c);case 2:throw new Error(l);case 3:throw new Error(u)}},publicKeyTweakAdd(t,r,i=!0,s){switch(y("public key",t,[33,65]),y("tweak",r,32),m(i),s=b(s,i?33:65),e.publicKeyTweakAdd(s,t,r)){case 0:return s;case 1:throw new Error(c);case 2:throw new Error(n)}},publicKeyTweakMul(t,r,i=!0,n){switch(y("public key",t,[33,65]),y("tweak",r,32),m(i),n=b(n,i?33:65),e.publicKeyTweakMul(n,t,r)){case 0:return n;case 1:throw new Error(c);case 2:throw new Error(s)}},signatureNormalize(t){switch(y("signature",t,64),e.signatureNormalize(t)){case 0:return t;case 1:throw new Error(d)}},signatureExport(t,r){y("signature",t,64);const n={output:r=b(r,72),outputlen:72};switch(e.signatureExport(n,t)){case 0:return r.slice(0,n.outputlen);case 1:throw new Error(d);case 2:throw new Error(i)}},signatureImport(t,r){switch(y("signature",t),r=b(r,64),e.signatureImport(r,t)){case 0:return r;case 1:throw new Error(d);case 2:throw new Error(i)}},ecdsaSign(t,r,n={},s){y("message",t,32),y("private key",r,32),g("Object"===v(n),"Expected options to be an Object"),void 0!==n.data&&y("options.data",n.data),void 0!==n.noncefn&&g("Function"===v(n.noncefn),"Expected options.noncefn to be a Function");const o={signature:s=b(s,64),recid:null};switch(e.ecdsaSign(o,t,r,n.data,n.noncefn)){case 0:return o;case 1:throw new Error(f);case 2:throw new Error(i)}},ecdsaVerify(t,r,i){switch(y("signature",t,64),y("message",r,32),y("public key",i,[33,65]),e.ecdsaVerify(t,r,i)){case 0:return!0;case 3:return!1;case 1:throw new Error(d);case 2:throw new Error(c)}},ecdsaRecover(t,r,n,s=!0,o){switch(y("signature",t,64),g("Number"===v(r)&&r>=0&&r<=3,"Expected recovery id to be a Number within interval [0, 3]"),y("message",n,32),m(s),o=b(o,s?33:65),e.ecdsaRecover(o,t,r,n)){case 0:return o;case 1:throw new Error(d);case 2:throw new Error(h);case 3:throw new Error(i)}},ecdh(t,r,i={},n){switch(y("public key",t,[33,65]),y("private key",r,32),g("Object"===v(i),"Expected options to be an Object"),void 0!==i.data&&y("options.data",i.data),void 0!==i.hashfn?(g("Function"===v(i.hashfn),"Expected options.hashfn to be a Function"),void 0!==i.xbuf&&y("options.xbuf",i.xbuf,32),void 0!==i.ybuf&&y("options.ybuf",i.ybuf,32),y("output",n)):n=b(n,32),e.ecdh(n,t,r,i.data,i.hashfn,i.xbuf,i.ybuf)){case 0:return n;case 1:throw new Error(c);case 2:throw new Error(p)}}})},{}],"7HHQM":[function(e,t,r){const i=new(0,e("elliptic").ec)("secp256k1"),n=i.curve,s=n.n.constructor;function o(e){const t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){let r=new s(t);if(r.cmp(n.p)>=0)return null;r=r.toRed(n.red);let o=r.redSqr().redIMul(r).redIAdd(n.b).redSqrt();return 3===e!==o.isOdd()&&(o=o.redNeg()),i.keyPair({pub:{x:r,y:o}})}(t,e.subarray(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){let o=new s(t),a=new s(r);if(o.cmp(n.p)>=0||a.cmp(n.p)>=0)return null;if(o=o.toRed(n.red),a=a.toRed(n.red),(6===e||7===e)&&a.isOdd()!==(7===e))return null;const c=o.redSqr().redIMul(o);return a.redSqr().redISub(c.redIAdd(n.b)).isZero()?i.keyPair({pub:{x:o,y:a}}):null}(t,e.subarray(1,33),e.subarray(33,65));default:return null}}function a(e,t){const r=t.encode(null,33===e.length);for(let t=0;t0,privateKeyVerify(e){const t=new s(e);return t.cmp(n.n)<0&&!t.isZero()?0:1},privateKeyNegate(e){const t=new s(e),r=n.n.sub(t).umod(n.n).toArrayLike(Uint8Array,"be",32);return e.set(r),0},privateKeyTweakAdd(e,t){const r=new s(t);if(r.cmp(n.n)>=0)return 1;if(r.iadd(new s(e)),r.cmp(n.n)>=0&&r.isub(n.n),r.isZero())return 1;const i=r.toArrayLike(Uint8Array,"be",32);return e.set(i),0},privateKeyTweakMul(e,t){let r=new s(t);if(r.cmp(n.n)>=0||r.isZero())return 1;r.imul(new s(e)),r.cmp(n.n)>=0&&(r=r.umod(n.n));const i=r.toArrayLike(Uint8Array,"be",32);return e.set(i),0},publicKeyVerify:e=>null===o(e)?1:0,publicKeyCreate(e,t){const r=new s(t);if(r.cmp(n.n)>=0||r.isZero())return 1;return a(e,i.keyFromPrivate(t).getPublic()),0},publicKeyConvert(e,t){const r=o(t);if(null===r)return 1;return a(e,r.getPublic()),0},publicKeyNegate(e,t){const r=o(t);if(null===r)return 1;const i=r.getPublic();return i.y=i.y.redNeg(),a(e,i),0},publicKeyCombine(e,t){const r=new Array(t.length);for(let e=0;e=0)return 2;const c=i.getPublic().add(n.g.mul(r));return c.isInfinity()?2:(a(e,c),0)},publicKeyTweakMul(e,t,r){const i=o(t);if(null===i)return 1;if((r=new s(r)).cmp(n.n)>=0||r.isZero())return 2;return a(e,i.getPublic().mul(r)),0},signatureNormalize(e){const t=new s(e.subarray(0,32)),r=new s(e.subarray(32,64));return t.cmp(n.n)>=0||r.cmp(n.n)>=0?1:(1===r.cmp(i.nh)&&e.set(n.n.sub(r).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(e,t){const r=t.subarray(0,32),i=t.subarray(32,64);if(new s(r).cmp(n.n)>=0)return 1;if(new s(i).cmp(n.n)>=0)return 1;const{output:o}=e;let a=o.subarray(4,37);a[0]=0,a.set(r,1);let c=33,u=0;for(;c>1&&0===a[u]&&!(128&a[u+1]);--c,++u);if(a=a.subarray(u),128&a[0])return 1;if(c>1&&0===a[0]&&!(128&a[1]))return 1;let l=o.subarray(39,72);l[0]=0,l.set(i,1);let d=33,f=0;for(;d>1&&0===l[f]&&!(128&l[f+1]);--d,++f);return l=l.subarray(f),128&l[0]||d>1&&0===l[0]&&!(128&l[1])?1:(e.outputlen=6+c+d,o[0]=48,o[1]=e.outputlen-2,o[2]=2,o[3]=a.length,o.set(a,4),o[4+c]=2,o[5+c]=l.length,o.set(l,6+c),0)},signatureImport(e,t){if(t.length<8)return 1;if(t.length>72)return 1;if(48!==t[0])return 1;if(t[1]!==t.length-2)return 1;if(2!==t[2])return 1;const r=t[3];if(0===r)return 1;if(5+r>=t.length)return 1;if(2!==t[4+r])return 1;const i=t[5+r];if(0===i)return 1;if(6+r+i!==t.length)return 1;if(128&t[4])return 1;if(r>1&&0===t[4]&&!(128&t[5]))return 1;if(128&t[r+6])return 1;if(i>1&&0===t[r+6]&&!(128&t[r+7]))return 1;let o=t.subarray(4,4+r);if(33===o.length&&0===o[0]&&(o=o.subarray(1)),o.length>32)return 1;let a=t.subarray(6+r);if(33===a.length&&0===a[0]&&(a=a.slice(1)),a.length>32)throw new Error("S length is too long");let c=new s(o);c.cmp(n.n)>=0&&(c=new s(0));let u=new s(t.subarray(6+r));return u.cmp(n.n)>=0&&(u=new s(0)),e.set(c.toArrayLike(Uint8Array,"be",32),0),e.set(u.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(e,t,r,o,a){if(a){const e=a;a=i=>{const n=e(t,r,null,o,i);if(!(n instanceof Uint8Array&&32===n.length))throw new Error("This is the way");return new s(n)}}const c=new s(r);if(c.cmp(n.n)>=0||c.isZero())return 1;let u;try{u=i.sign(t,r,{canonical:!0,k:a,pers:o})}catch(e){return 1}return e.signature.set(u.r.toArrayLike(Uint8Array,"be",32),0),e.signature.set(u.s.toArrayLike(Uint8Array,"be",32),32),e.recid=u.recoveryParam,0},ecdsaVerify(e,t,r){const a={r:e.subarray(0,32),s:e.subarray(32,64)},c=new s(a.r),u=new s(a.s);if(c.cmp(n.n)>=0||u.cmp(n.n)>=0)return 1;if(1===u.cmp(i.nh)||c.isZero()||u.isZero())return 3;const l=o(r);if(null===l)return 2;const d=l.getPublic();return i.verify(t,a,d)?0:3},ecdsaRecover(e,t,r,o){const c={r:t.slice(0,32),s:t.slice(32,64)},u=new s(c.r),l=new s(c.s);if(u.cmp(n.n)>=0||l.cmp(n.n)>=0)return 1;if(u.isZero()||l.isZero())return 2;let d;try{d=i.recoverPubKey(o,c,r)}catch(e){return 2}return a(e,d),0},ecdh(e,t,r,a,c,u,l){const d=o(t);if(null===d)return 1;const f=new s(r);if(f.cmp(n.n)>=0||f.isZero())return 2;const h=d.getPublic().mul(f);if(void 0===c){const t=h.encode(null,!0),r=i.hash().update(t).digest();for(let t=0;t<32;++t)e[t]=r[t]}else{u||(u=new Uint8Array(32));const t=h.getX().toArray("be",32);for(let e=0;e<32;++e)u[e]=t[e];l||(l=new Uint8Array(32));const r=h.getY().toArray("be",32);for(let e=0;e<32;++e)l[e]=r[e];const i=c(u,l,a);if(!(i instanceof Uint8Array&&i.length===e.length))return 2;e.set(i)}return 0}}},{elliptic:"g2Vtb"}],g2Vtb:[function(e,t,r){"use strict";var i=r;i.version=e("../package.json").version,i.utils=e("./elliptic/utils"),i.rand=e("brorand"),i.curve=e("./elliptic/curve"),i.curves=e("./elliptic/curves"),i.ec=e("./elliptic/ec"),i.eddsa=e("./elliptic/eddsa")},{"../package.json":"ejBaf","./elliptic/utils":"959xT",brorand:"P54o1","./elliptic/curve":"byDyH","./elliptic/curves":"4unkA","./elliptic/ec":"5AnhI","./elliptic/eddsa":"j2H5w"}],ejBaf:[function(e,t,r){t.exports=JSON.parse('{"name":"elliptic","version":"6.5.4","description":"EC cryptography","main":"lib/elliptic.js","files":["lib"],"scripts":{"lint":"eslint lib test","lint:fix":"npm run lint -- --fix","unit":"istanbul test _mocha --reporter=spec test/index.js","test":"npm run lint && npm run unit","version":"grunt dist && git add dist/"},"repository":{"type":"git","url":"git@github.com:indutny/elliptic"},"keywords":["EC","Elliptic","curve","Cryptography"],"author":"Fedor Indutny ","license":"MIT","bugs":{"url":"https://github.com/indutny/elliptic/issues"},"homepage":"https://github.com/indutny/elliptic","devDependencies":{"brfs":"^2.0.2","coveralls":"^3.1.0","eslint":"^7.6.0","grunt":"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1","istanbul":"^0.4.5","mocha":"^8.0.1"},"dependencies":{"bn.js":"^4.11.9","brorand":"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1","inherits":"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}')},{}],"959xT":[function(e,t,r){"use strict";var i=r,n=e("bn.js"),s=e("minimalistic-assert"),o=e("minimalistic-crypto-utils");i.assert=s,i.toArray=o.toArray,i.zero2=o.zero2,i.toHex=o.toHex,i.encode=o.encode,i.getNAF=function(e,t,r){var i=new Array(Math.max(e.bitLength(),r)+1);i.fill(0);for(var n=1<(n>>1)-1?(n>>1)-c:c,s.isubn(a)):a=0,i[o]=a,s.iushrn(1)}return i},i.getJSF=function(e,t){var r=[[],[]];e=e.clone(),t=t.clone();for(var i,n=0,s=0;e.cmpn(-n)>0||t.cmpn(-s)>0;){var o,a,c=e.andln(3)+n&3,u=t.andln(3)+s&3;3===c&&(c=-1),3===u&&(u=-1),o=0==(1&c)?0:3!==(i=e.andln(7)+n&7)&&5!==i||2!==u?c:-c,r[0].push(o),a=0==(1&u)?0:3!==(i=t.andln(7)+s&7)&&5!==i||2!==c?u:-u,r[1].push(a),2*n===o+1&&(n=1-n),2*s===a+1&&(s=1-s),e.iushrn(1),t.iushrn(1)}return r},i.cachedProperty=function(e,t,r){var i="_"+t;e.prototype[t]=function(){return void 0!==this[i]?this[i]:this[i]=r.call(this)}},i.parseBytes=function(e){return"string"==typeof e?i.toArray(e,"hex"):e},i.intFromLE=function(e){return new n(e,"hex","le")}},{"bn.js":"c8Lvi","minimalistic-assert":"1GrVu","minimalistic-crypto-utils":"3MGAl"}],c8Lvi:[function(e,t,r){!function(t,r){function i(e,t){if(!e)throw new Error(t||"Assertion failed")}function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function s(e,t,r){if(s.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var o;"object"==typeof t?t.exports=s:r.BN=s,s.BN=s,s.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:e("buffer").Buffer}catch(e){}function a(e,t){var r=e.charCodeAt(t);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function c(e,t,r){var i=a(e,r);return r-1>=t&&(i|=a(e,r-1)<<4),i}function u(e,t,r,i){for(var n=0,s=Math.min(e.length,r),o=t;o=49?a-49+10:a>=17?a-17+10:a}return n}s.isBN=function(e){return e instanceof s||null!==e&&"object"==typeof e&&e.constructor.wordSize===s.wordSize&&Array.isArray(e.words)},s.max=function(e,t){return e.cmp(t)>0?e:t},s.min=function(e,t){return e.cmp(t)<0?e:t},s.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),i(t===(0|t)&&t>=2&&t<=36);var n=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n=0;n-=3)o=e[n]|e[n-1]<<8|e[n-2]<<16,this.words[s]|=o<>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===r)for(n=0,s=0;n>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this.strip()},s.prototype._parseHex=function(e,t,r){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var i=0;i=t;i-=2)n=c(e,t,i)<=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;else for(i=(e.length-t)%2==0?t+1:t;i=18?(s-=18,o+=1,this.words[o]|=n>>>26):s+=8;this.strip()},s.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=t)i++;i--,n=n/t|0;for(var s=e.length-r,o=s%i,a=Math.min(s,s-o)+r,c=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?""};var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function h(e,t,r){r.negative=t.negative^e.negative;var i=e.length+t.length|0;r.length=i,i=i-1|0;var n=0|e.words[0],s=0|t.words[0],o=n*s,a=67108863&o,c=o/67108864|0;r.words[0]=a;for(var u=1;u>>26,d=67108863&c,f=Math.min(u,t.length-1),h=Math.max(0,u-e.length+1);h<=f;h++){var p=u-h|0;l+=(o=(n=0|e.words[p])*(s=0|t.words[h])+d)/67108864|0,d=67108863&o}r.words[u]=0|d,c=0|l}return 0!==c?r.words[u]=0|c:r.length--,r.strip()}s.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var n=0,s=0,o=0;o>>24-n&16777215)||o!==this.length-1?l[6-c.length]+c+r:c+r,(n+=2)>=26&&(n-=26,o--)}for(0!==s&&(r=s.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var u=d[e],h=f[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var g=p.modn(h).toString(e);r=(p=p.idivn(h)).isZero()?g+r:l[u-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(e,t){return i(void 0!==o),this.toArrayLike(o,e,t)},s.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},s.prototype.toArrayLike=function(e,t,r){var n=this.byteLength(),s=r||Math.max(1,n);i(n<=s,"byte array longer than desired length"),i(s>0,"Requested array length <= 0"),this.strip();var o,a,c="le"===t,u=new e(s),l=this.clone();if(c){for(a=0;!l.isZero();a++)o=l.andln(255),l.iushrn(8),u[a]=o;for(;a=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},s.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},s.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},s.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},s.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},s.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},s.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var i=0;ie.length?this.clone().ixor(e):e.clone().ixor(this)},s.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},s.prototype.inotn=function(e){i("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var n=0;n0&&(this.words[n]=~this.words[n]&67108863>>26-r),this.strip()},s.prototype.notn=function(e){return this.clone().inotn(e)},s.prototype.setn=function(e,t){i("number"==typeof e&&e>=0);var r=e/26|0,n=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,i=e):(r=e,i=this);for(var n=0,s=0;s>>26;for(;0!==n&&s>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;se.length?this.clone().iadd(e):e.clone().iadd(this)},s.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,i,n=this.cmp(e);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=e):(r=e,i=this);for(var s=0,o=0;o>26,this.words[o]=67108863&t;for(;0!==s&&o>26,this.words[o]=67108863&t;if(0===s&&o>>13,h=0|o[1],p=8191&h,g=h>>>13,y=0|o[2],m=8191&y,b=y>>>13,v=0|o[3],w=8191&v,_=v>>>13,E=0|o[4],S=8191&E,T=E>>>13,A=0|o[5],k=8191&A,I=A>>>13,R=0|o[6],P=8191&R,O=R>>>13,C=0|o[7],j=8191&C,D=C>>>13,M=0|o[8],x=8191&M,B=M>>>13,L=0|o[9],N=8191&L,U=L>>>13,F=0|a[0],K=8191&F,z=F>>>13,V=0|a[1],q=8191&V,G=V>>>13,H=0|a[2],$=8191&H,W=H>>>13,Y=0|a[3],X=8191&Y,Z=Y>>>13,Q=0|a[4],J=8191&Q,ee=Q>>>13,te=0|a[5],re=8191&te,ie=te>>>13,ne=0|a[6],se=8191&ne,oe=ne>>>13,ae=0|a[7],ce=8191&ae,ue=ae>>>13,le=0|a[8],de=8191&le,fe=le>>>13,he=0|a[9],pe=8191&he,ge=he>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(u+(i=Math.imul(d,K))|0)+((8191&(n=(n=Math.imul(d,z))+Math.imul(f,K)|0))<<13)|0;u=((s=Math.imul(f,z))+(n>>>13)|0)+(ye>>>26)|0,ye&=67108863,i=Math.imul(p,K),n=(n=Math.imul(p,z))+Math.imul(g,K)|0,s=Math.imul(g,z);var me=(u+(i=i+Math.imul(d,q)|0)|0)+((8191&(n=(n=n+Math.imul(d,G)|0)+Math.imul(f,q)|0))<<13)|0;u=((s=s+Math.imul(f,G)|0)+(n>>>13)|0)+(me>>>26)|0,me&=67108863,i=Math.imul(m,K),n=(n=Math.imul(m,z))+Math.imul(b,K)|0,s=Math.imul(b,z),i=i+Math.imul(p,q)|0,n=(n=n+Math.imul(p,G)|0)+Math.imul(g,q)|0,s=s+Math.imul(g,G)|0;var be=(u+(i=i+Math.imul(d,$)|0)|0)+((8191&(n=(n=n+Math.imul(d,W)|0)+Math.imul(f,$)|0))<<13)|0;u=((s=s+Math.imul(f,W)|0)+(n>>>13)|0)+(be>>>26)|0,be&=67108863,i=Math.imul(w,K),n=(n=Math.imul(w,z))+Math.imul(_,K)|0,s=Math.imul(_,z),i=i+Math.imul(m,q)|0,n=(n=n+Math.imul(m,G)|0)+Math.imul(b,q)|0,s=s+Math.imul(b,G)|0,i=i+Math.imul(p,$)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(g,$)|0,s=s+Math.imul(g,W)|0;var ve=(u+(i=i+Math.imul(d,X)|0)|0)+((8191&(n=(n=n+Math.imul(d,Z)|0)+Math.imul(f,X)|0))<<13)|0;u=((s=s+Math.imul(f,Z)|0)+(n>>>13)|0)+(ve>>>26)|0,ve&=67108863,i=Math.imul(S,K),n=(n=Math.imul(S,z))+Math.imul(T,K)|0,s=Math.imul(T,z),i=i+Math.imul(w,q)|0,n=(n=n+Math.imul(w,G)|0)+Math.imul(_,q)|0,s=s+Math.imul(_,G)|0,i=i+Math.imul(m,$)|0,n=(n=n+Math.imul(m,W)|0)+Math.imul(b,$)|0,s=s+Math.imul(b,W)|0,i=i+Math.imul(p,X)|0,n=(n=n+Math.imul(p,Z)|0)+Math.imul(g,X)|0,s=s+Math.imul(g,Z)|0;var we=(u+(i=i+Math.imul(d,J)|0)|0)+((8191&(n=(n=n+Math.imul(d,ee)|0)+Math.imul(f,J)|0))<<13)|0;u=((s=s+Math.imul(f,ee)|0)+(n>>>13)|0)+(we>>>26)|0,we&=67108863,i=Math.imul(k,K),n=(n=Math.imul(k,z))+Math.imul(I,K)|0,s=Math.imul(I,z),i=i+Math.imul(S,q)|0,n=(n=n+Math.imul(S,G)|0)+Math.imul(T,q)|0,s=s+Math.imul(T,G)|0,i=i+Math.imul(w,$)|0,n=(n=n+Math.imul(w,W)|0)+Math.imul(_,$)|0,s=s+Math.imul(_,W)|0,i=i+Math.imul(m,X)|0,n=(n=n+Math.imul(m,Z)|0)+Math.imul(b,X)|0,s=s+Math.imul(b,Z)|0,i=i+Math.imul(p,J)|0,n=(n=n+Math.imul(p,ee)|0)+Math.imul(g,J)|0,s=s+Math.imul(g,ee)|0;var _e=(u+(i=i+Math.imul(d,re)|0)|0)+((8191&(n=(n=n+Math.imul(d,ie)|0)+Math.imul(f,re)|0))<<13)|0;u=((s=s+Math.imul(f,ie)|0)+(n>>>13)|0)+(_e>>>26)|0,_e&=67108863,i=Math.imul(P,K),n=(n=Math.imul(P,z))+Math.imul(O,K)|0,s=Math.imul(O,z),i=i+Math.imul(k,q)|0,n=(n=n+Math.imul(k,G)|0)+Math.imul(I,q)|0,s=s+Math.imul(I,G)|0,i=i+Math.imul(S,$)|0,n=(n=n+Math.imul(S,W)|0)+Math.imul(T,$)|0,s=s+Math.imul(T,W)|0,i=i+Math.imul(w,X)|0,n=(n=n+Math.imul(w,Z)|0)+Math.imul(_,X)|0,s=s+Math.imul(_,Z)|0,i=i+Math.imul(m,J)|0,n=(n=n+Math.imul(m,ee)|0)+Math.imul(b,J)|0,s=s+Math.imul(b,ee)|0,i=i+Math.imul(p,re)|0,n=(n=n+Math.imul(p,ie)|0)+Math.imul(g,re)|0,s=s+Math.imul(g,ie)|0;var Ee=(u+(i=i+Math.imul(d,se)|0)|0)+((8191&(n=(n=n+Math.imul(d,oe)|0)+Math.imul(f,se)|0))<<13)|0;u=((s=s+Math.imul(f,oe)|0)+(n>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,i=Math.imul(j,K),n=(n=Math.imul(j,z))+Math.imul(D,K)|0,s=Math.imul(D,z),i=i+Math.imul(P,q)|0,n=(n=n+Math.imul(P,G)|0)+Math.imul(O,q)|0,s=s+Math.imul(O,G)|0,i=i+Math.imul(k,$)|0,n=(n=n+Math.imul(k,W)|0)+Math.imul(I,$)|0,s=s+Math.imul(I,W)|0,i=i+Math.imul(S,X)|0,n=(n=n+Math.imul(S,Z)|0)+Math.imul(T,X)|0,s=s+Math.imul(T,Z)|0,i=i+Math.imul(w,J)|0,n=(n=n+Math.imul(w,ee)|0)+Math.imul(_,J)|0,s=s+Math.imul(_,ee)|0,i=i+Math.imul(m,re)|0,n=(n=n+Math.imul(m,ie)|0)+Math.imul(b,re)|0,s=s+Math.imul(b,ie)|0,i=i+Math.imul(p,se)|0,n=(n=n+Math.imul(p,oe)|0)+Math.imul(g,se)|0,s=s+Math.imul(g,oe)|0;var Se=(u+(i=i+Math.imul(d,ce)|0)|0)+((8191&(n=(n=n+Math.imul(d,ue)|0)+Math.imul(f,ce)|0))<<13)|0;u=((s=s+Math.imul(f,ue)|0)+(n>>>13)|0)+(Se>>>26)|0,Se&=67108863,i=Math.imul(x,K),n=(n=Math.imul(x,z))+Math.imul(B,K)|0,s=Math.imul(B,z),i=i+Math.imul(j,q)|0,n=(n=n+Math.imul(j,G)|0)+Math.imul(D,q)|0,s=s+Math.imul(D,G)|0,i=i+Math.imul(P,$)|0,n=(n=n+Math.imul(P,W)|0)+Math.imul(O,$)|0,s=s+Math.imul(O,W)|0,i=i+Math.imul(k,X)|0,n=(n=n+Math.imul(k,Z)|0)+Math.imul(I,X)|0,s=s+Math.imul(I,Z)|0,i=i+Math.imul(S,J)|0,n=(n=n+Math.imul(S,ee)|0)+Math.imul(T,J)|0,s=s+Math.imul(T,ee)|0,i=i+Math.imul(w,re)|0,n=(n=n+Math.imul(w,ie)|0)+Math.imul(_,re)|0,s=s+Math.imul(_,ie)|0,i=i+Math.imul(m,se)|0,n=(n=n+Math.imul(m,oe)|0)+Math.imul(b,se)|0,s=s+Math.imul(b,oe)|0,i=i+Math.imul(p,ce)|0,n=(n=n+Math.imul(p,ue)|0)+Math.imul(g,ce)|0,s=s+Math.imul(g,ue)|0;var Te=(u+(i=i+Math.imul(d,de)|0)|0)+((8191&(n=(n=n+Math.imul(d,fe)|0)+Math.imul(f,de)|0))<<13)|0;u=((s=s+Math.imul(f,fe)|0)+(n>>>13)|0)+(Te>>>26)|0,Te&=67108863,i=Math.imul(N,K),n=(n=Math.imul(N,z))+Math.imul(U,K)|0,s=Math.imul(U,z),i=i+Math.imul(x,q)|0,n=(n=n+Math.imul(x,G)|0)+Math.imul(B,q)|0,s=s+Math.imul(B,G)|0,i=i+Math.imul(j,$)|0,n=(n=n+Math.imul(j,W)|0)+Math.imul(D,$)|0,s=s+Math.imul(D,W)|0,i=i+Math.imul(P,X)|0,n=(n=n+Math.imul(P,Z)|0)+Math.imul(O,X)|0,s=s+Math.imul(O,Z)|0,i=i+Math.imul(k,J)|0,n=(n=n+Math.imul(k,ee)|0)+Math.imul(I,J)|0,s=s+Math.imul(I,ee)|0,i=i+Math.imul(S,re)|0,n=(n=n+Math.imul(S,ie)|0)+Math.imul(T,re)|0,s=s+Math.imul(T,ie)|0,i=i+Math.imul(w,se)|0,n=(n=n+Math.imul(w,oe)|0)+Math.imul(_,se)|0,s=s+Math.imul(_,oe)|0,i=i+Math.imul(m,ce)|0,n=(n=n+Math.imul(m,ue)|0)+Math.imul(b,ce)|0,s=s+Math.imul(b,ue)|0,i=i+Math.imul(p,de)|0,n=(n=n+Math.imul(p,fe)|0)+Math.imul(g,de)|0,s=s+Math.imul(g,fe)|0;var Ae=(u+(i=i+Math.imul(d,pe)|0)|0)+((8191&(n=(n=n+Math.imul(d,ge)|0)+Math.imul(f,pe)|0))<<13)|0;u=((s=s+Math.imul(f,ge)|0)+(n>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,i=Math.imul(N,q),n=(n=Math.imul(N,G))+Math.imul(U,q)|0,s=Math.imul(U,G),i=i+Math.imul(x,$)|0,n=(n=n+Math.imul(x,W)|0)+Math.imul(B,$)|0,s=s+Math.imul(B,W)|0,i=i+Math.imul(j,X)|0,n=(n=n+Math.imul(j,Z)|0)+Math.imul(D,X)|0,s=s+Math.imul(D,Z)|0,i=i+Math.imul(P,J)|0,n=(n=n+Math.imul(P,ee)|0)+Math.imul(O,J)|0,s=s+Math.imul(O,ee)|0,i=i+Math.imul(k,re)|0,n=(n=n+Math.imul(k,ie)|0)+Math.imul(I,re)|0,s=s+Math.imul(I,ie)|0,i=i+Math.imul(S,se)|0,n=(n=n+Math.imul(S,oe)|0)+Math.imul(T,se)|0,s=s+Math.imul(T,oe)|0,i=i+Math.imul(w,ce)|0,n=(n=n+Math.imul(w,ue)|0)+Math.imul(_,ce)|0,s=s+Math.imul(_,ue)|0,i=i+Math.imul(m,de)|0,n=(n=n+Math.imul(m,fe)|0)+Math.imul(b,de)|0,s=s+Math.imul(b,fe)|0;var ke=(u+(i=i+Math.imul(p,pe)|0)|0)+((8191&(n=(n=n+Math.imul(p,ge)|0)+Math.imul(g,pe)|0))<<13)|0;u=((s=s+Math.imul(g,ge)|0)+(n>>>13)|0)+(ke>>>26)|0,ke&=67108863,i=Math.imul(N,$),n=(n=Math.imul(N,W))+Math.imul(U,$)|0,s=Math.imul(U,W),i=i+Math.imul(x,X)|0,n=(n=n+Math.imul(x,Z)|0)+Math.imul(B,X)|0,s=s+Math.imul(B,Z)|0,i=i+Math.imul(j,J)|0,n=(n=n+Math.imul(j,ee)|0)+Math.imul(D,J)|0,s=s+Math.imul(D,ee)|0,i=i+Math.imul(P,re)|0,n=(n=n+Math.imul(P,ie)|0)+Math.imul(O,re)|0,s=s+Math.imul(O,ie)|0,i=i+Math.imul(k,se)|0,n=(n=n+Math.imul(k,oe)|0)+Math.imul(I,se)|0,s=s+Math.imul(I,oe)|0,i=i+Math.imul(S,ce)|0,n=(n=n+Math.imul(S,ue)|0)+Math.imul(T,ce)|0,s=s+Math.imul(T,ue)|0,i=i+Math.imul(w,de)|0,n=(n=n+Math.imul(w,fe)|0)+Math.imul(_,de)|0,s=s+Math.imul(_,fe)|0;var Ie=(u+(i=i+Math.imul(m,pe)|0)|0)+((8191&(n=(n=n+Math.imul(m,ge)|0)+Math.imul(b,pe)|0))<<13)|0;u=((s=s+Math.imul(b,ge)|0)+(n>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,i=Math.imul(N,X),n=(n=Math.imul(N,Z))+Math.imul(U,X)|0,s=Math.imul(U,Z),i=i+Math.imul(x,J)|0,n=(n=n+Math.imul(x,ee)|0)+Math.imul(B,J)|0,s=s+Math.imul(B,ee)|0,i=i+Math.imul(j,re)|0,n=(n=n+Math.imul(j,ie)|0)+Math.imul(D,re)|0,s=s+Math.imul(D,ie)|0,i=i+Math.imul(P,se)|0,n=(n=n+Math.imul(P,oe)|0)+Math.imul(O,se)|0,s=s+Math.imul(O,oe)|0,i=i+Math.imul(k,ce)|0,n=(n=n+Math.imul(k,ue)|0)+Math.imul(I,ce)|0,s=s+Math.imul(I,ue)|0,i=i+Math.imul(S,de)|0,n=(n=n+Math.imul(S,fe)|0)+Math.imul(T,de)|0,s=s+Math.imul(T,fe)|0;var Re=(u+(i=i+Math.imul(w,pe)|0)|0)+((8191&(n=(n=n+Math.imul(w,ge)|0)+Math.imul(_,pe)|0))<<13)|0;u=((s=s+Math.imul(_,ge)|0)+(n>>>13)|0)+(Re>>>26)|0,Re&=67108863,i=Math.imul(N,J),n=(n=Math.imul(N,ee))+Math.imul(U,J)|0,s=Math.imul(U,ee),i=i+Math.imul(x,re)|0,n=(n=n+Math.imul(x,ie)|0)+Math.imul(B,re)|0,s=s+Math.imul(B,ie)|0,i=i+Math.imul(j,se)|0,n=(n=n+Math.imul(j,oe)|0)+Math.imul(D,se)|0,s=s+Math.imul(D,oe)|0,i=i+Math.imul(P,ce)|0,n=(n=n+Math.imul(P,ue)|0)+Math.imul(O,ce)|0,s=s+Math.imul(O,ue)|0,i=i+Math.imul(k,de)|0,n=(n=n+Math.imul(k,fe)|0)+Math.imul(I,de)|0,s=s+Math.imul(I,fe)|0;var Pe=(u+(i=i+Math.imul(S,pe)|0)|0)+((8191&(n=(n=n+Math.imul(S,ge)|0)+Math.imul(T,pe)|0))<<13)|0;u=((s=s+Math.imul(T,ge)|0)+(n>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,i=Math.imul(N,re),n=(n=Math.imul(N,ie))+Math.imul(U,re)|0,s=Math.imul(U,ie),i=i+Math.imul(x,se)|0,n=(n=n+Math.imul(x,oe)|0)+Math.imul(B,se)|0,s=s+Math.imul(B,oe)|0,i=i+Math.imul(j,ce)|0,n=(n=n+Math.imul(j,ue)|0)+Math.imul(D,ce)|0,s=s+Math.imul(D,ue)|0,i=i+Math.imul(P,de)|0,n=(n=n+Math.imul(P,fe)|0)+Math.imul(O,de)|0,s=s+Math.imul(O,fe)|0;var Oe=(u+(i=i+Math.imul(k,pe)|0)|0)+((8191&(n=(n=n+Math.imul(k,ge)|0)+Math.imul(I,pe)|0))<<13)|0;u=((s=s+Math.imul(I,ge)|0)+(n>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,i=Math.imul(N,se),n=(n=Math.imul(N,oe))+Math.imul(U,se)|0,s=Math.imul(U,oe),i=i+Math.imul(x,ce)|0,n=(n=n+Math.imul(x,ue)|0)+Math.imul(B,ce)|0,s=s+Math.imul(B,ue)|0,i=i+Math.imul(j,de)|0,n=(n=n+Math.imul(j,fe)|0)+Math.imul(D,de)|0,s=s+Math.imul(D,fe)|0;var Ce=(u+(i=i+Math.imul(P,pe)|0)|0)+((8191&(n=(n=n+Math.imul(P,ge)|0)+Math.imul(O,pe)|0))<<13)|0;u=((s=s+Math.imul(O,ge)|0)+(n>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,i=Math.imul(N,ce),n=(n=Math.imul(N,ue))+Math.imul(U,ce)|0,s=Math.imul(U,ue),i=i+Math.imul(x,de)|0,n=(n=n+Math.imul(x,fe)|0)+Math.imul(B,de)|0,s=s+Math.imul(B,fe)|0;var je=(u+(i=i+Math.imul(j,pe)|0)|0)+((8191&(n=(n=n+Math.imul(j,ge)|0)+Math.imul(D,pe)|0))<<13)|0;u=((s=s+Math.imul(D,ge)|0)+(n>>>13)|0)+(je>>>26)|0,je&=67108863,i=Math.imul(N,de),n=(n=Math.imul(N,fe))+Math.imul(U,de)|0,s=Math.imul(U,fe);var De=(u+(i=i+Math.imul(x,pe)|0)|0)+((8191&(n=(n=n+Math.imul(x,ge)|0)+Math.imul(B,pe)|0))<<13)|0;u=((s=s+Math.imul(B,ge)|0)+(n>>>13)|0)+(De>>>26)|0,De&=67108863;var Me=(u+(i=Math.imul(N,pe))|0)+((8191&(n=(n=Math.imul(N,ge))+Math.imul(U,pe)|0))<<13)|0;return u=((s=Math.imul(U,ge))+(n>>>13)|0)+(Me>>>26)|0,Me&=67108863,c[0]=ye,c[1]=me,c[2]=be,c[3]=ve,c[4]=we,c[5]=_e,c[6]=Ee,c[7]=Se,c[8]=Te,c[9]=Ae,c[10]=ke,c[11]=Ie,c[12]=Re,c[13]=Pe,c[14]=Oe,c[15]=Ce,c[16]=je,c[17]=De,c[18]=Me,0!==u&&(c[19]=u,r.length++),r};function g(e,t,r){return(new y).mulp(e,t,r)}function y(e,t){this.x=e,this.y=t}Math.imul||(p=h),s.prototype.mulTo=function(e,t){var r,i=this.length+e.length;return r=10===this.length&&10===e.length?p(this,e,t):i<63?h(this,e,t):i<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var i=0,n=0,s=0;s>>26)|0)>>>26,o&=67108863}r.words[s]=a,i=o,o=n}return 0!==i?r.words[s]=i:r.length--,r.strip()}(this,e,t):g(this,e,t),r},y.prototype.makeRBT=function(e){for(var t=new Array(e),r=s.prototype._countBits(e)-1,i=0;i>=1;return i},y.prototype.permute=function(e,t,r,i,n,s){for(var o=0;o>>=1)n++;return 1<>>=13,r[2*o+1]=8191&s,s>>>=13;for(o=2*t;o>=26,t+=n/67108864|0,t+=s>>>26,this.words[r]=67108863&s}return 0!==t&&(this.words[r]=t,this.length++),this},s.prototype.muln=function(e){return this.clone().imuln(e)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>n}return t}(e);if(0===t.length)return new s(1);for(var r=this,i=0;i=0);var t,r=e%26,n=(e-r)/26,s=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(t=0;t>>26-r}o&&(this.words[t]=o,this.length++)}if(0!==n){for(t=this.length-1;t>=0;t--)this.words[t+n]=this.words[t];for(t=0;t=0),n=t?(t-t%26)/26:0;var s=e%26,o=Math.min((e-s)/26,this.length),a=67108863^67108863>>>s<o)for(this.length-=o,u=0;u=0&&(0!==l||u>=n);u--){var d=0|this.words[u];this.words[u]=l<<26-s|d>>>s,l=d&a}return c&&0!==l&&(c.words[c.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(e,t,r){return i(0===this.negative),this.iushrn(e,t,r)},s.prototype.shln=function(e){return this.clone().ishln(e)},s.prototype.ushln=function(e){return this.clone().iushln(e)},s.prototype.shrn=function(e){return this.clone().ishrn(e)},s.prototype.ushrn=function(e){return this.clone().iushrn(e)},s.prototype.testn=function(e){i("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,n=1<=0);var t=e%26,r=(e-t)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var n=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},s.prototype.isubn=function(e){if(i("number"==typeof e),i(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(c/67108864|0),this.words[n+r]=67108863&s}for(;n>26,this.words[n+r]=67108863&s;if(0===a)return this.strip();for(i(-1===a),a=0,n=0;n>26,this.words[n]=67108863&s;return this.negative=1,this.strip()},s.prototype._wordDiv=function(e,t){var r=(this.length,e.length),i=this.clone(),n=e,o=0|n.words[n.length-1];0!==(r=26-this._countBits(o))&&(n=n.ushln(r),i.iushln(r),o=0|n.words[n.length-1]);var a,c=i.length-n.length;if("mod"!==t){(a=new s(null)).length=c+1,a.words=new Array(a.length);for(var u=0;u=0;d--){var f=67108864*(0|i.words[n.length+d])+(0|i.words[n.length+d-1]);for(f=Math.min(f/o|0,67108863),i._ishlnsubmul(n,f,d);0!==i.negative;)f--,i.negative=0,i._ishlnsubmul(n,1,d),i.isZero()||(i.negative^=1);a&&(a.words[d]=f)}return a&&a.strip(),i.strip(),"div"!==t&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},s.prototype.divmod=function(e,t,r){return i(!e.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(n=a.div.neg()),"div"!==t&&(o=a.mod.neg(),r&&0!==o.negative&&o.iadd(e)),{div:n,mod:o}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(n=a.div.neg()),{div:n,mod:a.mod}):0!=(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(o=a.mod.neg(),r&&0!==o.negative&&o.isub(e)),{div:a.div,mod:o}):e.length>this.length||this.cmp(e)<0?{div:new s(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new s(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new s(this.modn(e.words[0]))}:this._wordDiv(e,t);var n,o,a},s.prototype.div=function(e){return this.divmod(e,"div",!1).div},s.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},s.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},s.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,i=e.ushrn(1),n=e.andln(1),s=r.cmp(i);return s<0||1===n&&0===s?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},s.prototype.modn=function(e){i(e<=67108863);for(var t=67108864%e,r=0,n=this.length-1;n>=0;n--)r=(t*r+(0|this.words[n]))%e;return r},s.prototype.idivn=function(e){i(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var n=(0|this.words[r])+67108864*t;this.words[r]=n/e|0,t=n%e}return this.strip()},s.prototype.divn=function(e){return this.clone().idivn(e)},s.prototype.egcd=function(e){i(0===e.negative),i(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var n=new s(1),o=new s(0),a=new s(0),c=new s(1),u=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++u;for(var l=r.clone(),d=t.clone();!t.isZero();){for(var f=0,h=1;0==(t.words[0]&h)&&f<26;++f,h<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(n.isOdd()||o.isOdd())&&(n.iadd(l),o.isub(d)),n.iushrn(1),o.iushrn(1);for(var p=0,g=1;0==(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(l),c.isub(d)),a.iushrn(1),c.iushrn(1);t.cmp(r)>=0?(t.isub(r),n.isub(a),o.isub(c)):(r.isub(t),a.isub(n),c.isub(o))}return{a:a,b:c,gcd:r.iushln(u)}},s.prototype._invmp=function(e){i(0===e.negative),i(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var n,o=new s(1),a=new s(0),c=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var u=0,l=1;0==(t.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(t.iushrn(u);u-- >0;)o.isOdd()&&o.iadd(c),o.iushrn(1);for(var d=0,f=1;0==(r.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(r.iushrn(d);d-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);t.cmp(r)>=0?(t.isub(r),o.isub(a)):(r.isub(t),a.isub(o))}return(n=0===t.cmpn(1)?o:a).cmpn(0)<0&&n.iadd(e),n},s.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var i=0;t.isEven()&&r.isEven();i++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=t.cmp(r);if(n<0){var s=t;t=r,r=s}else if(0===n||0===r.cmpn(1))break;t.isub(r)}return r.iushln(i)},s.prototype.invm=function(e){return this.egcd(e).a.umod(e)},s.prototype.isEven=function(){return 0==(1&this.words[0])},s.prototype.isOdd=function(){return 1==(1&this.words[0])},s.prototype.andln=function(e){return this.words[0]&e},s.prototype.bincn=function(e){i("number"==typeof e);var t=e%26,r=(e-t)/26,n=1<>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),i(e<=67108863,"Number is too big");var n=0|this.words[0];t=n===e?0:ne.length)return 1;if(this.length=0;r--){var i=0|this.words[r],n=0|e.words[r];if(i!==n){in&&(t=1);break}}return t},s.prototype.gtn=function(e){return 1===this.cmpn(e)},s.prototype.gt=function(e){return 1===this.cmp(e)},s.prototype.gten=function(e){return this.cmpn(e)>=0},s.prototype.gte=function(e){return this.cmp(e)>=0},s.prototype.ltn=function(e){return-1===this.cmpn(e)},s.prototype.lt=function(e){return-1===this.cmp(e)},s.prototype.lten=function(e){return this.cmpn(e)<=0},s.prototype.lte=function(e){return this.cmp(e)<=0},s.prototype.eqn=function(e){return 0===this.cmpn(e)},s.prototype.eq=function(e){return 0===this.cmp(e)},s.red=function(e){return new S(e)},s.prototype.toRed=function(e){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(e){return this.red=e,this},s.prototype.forceRed=function(e){return i(!this.red,"Already a number in reduction context"),this._forceRed(e)},s.prototype.redAdd=function(e){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},s.prototype.redIAdd=function(e){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},s.prototype.redSub=function(e){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},s.prototype.redISub=function(e){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},s.prototype.redShl=function(e){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},s.prototype.redMul=function(e){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},s.prototype.redIMul=function(e){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(e){return i(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var m={k256:null,p224:null,p192:null,p25519:null};function b(e,t){this.name=e,this.p=new s(t,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){b.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){b.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function _(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(e){if("string"==typeof e){var t=s._prime(e);this.m=t.p,this.prime=t}else i(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function T(e){S.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}b.prototype._tmp=function(){var e=new s(null);return e.words=new Array(Math.ceil(this.n/13)),e},b.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var i=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},b.prototype.split=function(e,t){e.iushrn(this.n,0,t)},b.prototype.imulK=function(e){return e.imul(this.k)},n(v,b),v.prototype.split=function(e,t){for(var r=4194303,i=Math.min(e.length,9),n=0;n>>22,s=o}s>>>=22,e.words[n-10]=s,0===s&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=n,t=i}return 0!==t&&(e.words[e.length++]=t),e},s._prime=function(e){if(m[e])return m[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new w;else if("p192"===e)t=new _;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new E}return m[e]=t,t},S.prototype._verify1=function(e){i(0===e.negative,"red works only with positives"),i(e.red,"red works only with red numbers")},S.prototype._verify2=function(e,t){i(0==(e.negative|t.negative),"red works only with positives"),i(e.red&&e.red===t.red,"red works only with red numbers")},S.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},S.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},S.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},S.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},S.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},S.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},S.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},S.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},S.prototype.isqr=function(e){return this.imul(e,e.clone())},S.prototype.sqr=function(e){return this.mul(e,e)},S.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(i(t%2==1),3===t){var r=this.m.add(new s(1)).iushrn(2);return this.pow(e,r)}for(var n=this.m.subn(1),o=0;!n.isZero()&&0===n.andln(1);)o++,n.iushrn(1);i(!n.isZero());var a=new s(1).toRed(this),c=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new s(2*l*l).toRed(this);0!==this.pow(l,u).cmp(c);)l.redIAdd(c);for(var d=this.pow(l,n),f=this.pow(e,n.addn(1).iushrn(1)),h=this.pow(e,n),p=o;0!==h.cmp(a);){for(var g=h,y=0;0!==g.cmp(a);y++)g=g.redSqr();i(y=0;i--){for(var u=t.words[i],l=c-1;l>=0;l--){var d=u>>l&1;n!==r[0]&&(n=this.sqr(n)),0!==d||0!==o?(o<<=1,o|=d,(4===++a||0===i&&0===l)&&(n=this.mul(n,r[o]),a=0,o=0)):a=0}c=26}return n},S.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},S.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},s.mont=function(e){return new T(e)},n(T,S),T.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},T.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},T.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),s=n;return n.cmp(this.m)>=0?s=n.isub(this.m):n.cmpn(0)<0&&(s=n.iadd(this.m)),s._forceRed(this)},T.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new s(0)._forceRed(this);var r=e.mul(t),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},T.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:"lHksA"}],"1GrVu":[function(e,t,r){function i(e,t){if(!e)throw new Error(t||"Assertion failed")}t.exports=i,i.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)}},{}],"3MGAl":[function(e,t,r){"use strict";var i=r;function n(e){return 1===e.length?"0"+e:e}function s(e){for(var t="",r=0;r>8,o=255&n;s?r.push(s,o):r.push(o)}return r},i.zero2=n,i.toHex=s,i.encode=function(e,t){return"hex"===t?s(e):e}},{}],P54o1:[function(e,t,r){var i;function n(e){this.rand=e}if(t.exports=function(e){return i||(i=new n(null)),i.generate(e)},t.exports.Rand=n,n.prototype.generate=function(e){return this._rand(e)},n.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function u(e,t){this.curve=e,this.type=t,this.precomputed=null}t.exports=c,c.prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(e,t){a(e.precomputed);var r=e._getDoubles(),i=s(t,1,this._bitLength),n=(1<=o;l--)c=(c<<1)+i[l];u.push(c)}for(var d=this.jpoint(null,null,null),f=this.jpoint(null,null,null),h=n;h>0;h--){for(o=0;o=0;u--){for(var l=0;u>=0&&0===o[u];u--)l++;if(u>=0&&l++,c=c.dblp(l),u<0)break;var d=o[u];a(0!==d),c="affine"===e.type?d>0?c.mixedAdd(n[d-1>>1]):c.mixedAdd(n[-d-1>>1].neg()):d>0?c.add(n[d-1>>1]):c.add(n[-d-1>>1].neg())}return"affine"===e.type?c.toP():c},c.prototype._wnafMulAdd=function(e,t,r,i,n){var a,c,u,l=this._wnafT1,d=this._wnafT2,f=this._wnafT3,h=0;for(a=0;a=1;a-=2){var g=a-1,y=a;if(1===l[g]&&1===l[y]){var m=[t[g],null,null,t[y]];0===t[g].y.cmp(t[y].y)?(m[1]=t[g].add(t[y]),m[2]=t[g].toJ().mixedAdd(t[y].neg())):0===t[g].y.cmp(t[y].y.redNeg())?(m[1]=t[g].toJ().mixedAdd(t[y]),m[2]=t[g].add(t[y].neg())):(m[1]=t[g].toJ().mixedAdd(t[y]),m[2]=t[g].toJ().mixedAdd(t[y].neg()));var b=[-3,-1,-5,-7,0,7,5,1,3],v=o(r[g],r[y]);for(h=Math.max(v[0].length,h),f[g]=new Array(h),f[y]=new Array(h),c=0;c=0;a--){for(var T=0;a>=0;){var A=!0;for(c=0;c=0&&T++,E=E.dblp(T),a<0)break;for(c=0;c0?u=d[c][k-1>>1]:k<0&&(u=d[c][-k-1>>1].neg()),E="affine"===u.type?E.mixedAdd(u):E.add(u))}}for(a=0;a=Math.ceil((e.bitLength()+1)/t.step)},u.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],i=this,n=0;n=0&&(o=t,a=r),i.negative&&(i=i.neg(),s=s.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:i,b:s},{a:o,b:a}]},c.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],i=t[1],n=i.b.mul(e).divRound(this.n),s=r.b.neg().mul(e).divRound(this.n),o=n.mul(r.a),a=s.mul(i.a),c=n.mul(r.b),u=s.mul(i.b);return{k1:e.sub(o).sub(a),k2:c.add(u).neg()}},c.prototype.pointFromX=function(e,t){(e=new n(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),i=r.redSqrt();if(0!==i.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var s=i.fromRed().isOdd();return(t&&!s||!t&&s)&&(i=i.redNeg()),this.point(e,i)},c.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,i=this.a.redMul(t),n=t.redSqr().redMul(t).redIAdd(i).redIAdd(this.b);return 0===r.redSqr().redISub(n).cmpn(0)},c.prototype._endoWnafMulAdd=function(e,t,r){for(var i=this._endoWnafT1,n=this._endoWnafT2,s=0;s":""},u.prototype.isInfinity=function(){return this.inf},u.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),i=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,i)},u.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),i=e.redInvm(),n=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(i),s=n.redSqr().redISub(this.x.redAdd(this.x)),o=n.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},u.prototype.getX=function(){return this.x.fromRed()},u.prototype.getY=function(){return this.y.fromRed()},u.prototype.mul=function(e){return e=new n(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},u.prototype.mulAdd=function(e,t,r){var i=[this,t],n=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n):this.curve._wnafMulAdd(1,i,n,2)},u.prototype.jmulAdd=function(e,t,r){var i=[this,t],n=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(i,n,!0):this.curve._wnafMulAdd(1,i,n,2,!0)},u.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},u.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,i=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(i)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(i)}}}return t},u.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},s(l,o.BasePoint),c.prototype.jpoint=function(e,t,r){return new l(this,e,t,r)},l.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),i=this.y.redMul(t).redMul(e);return this.curve.point(r,i)},l.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},l.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),i=this.x.redMul(t),n=e.x.redMul(r),s=this.y.redMul(t.redMul(e.z)),o=e.y.redMul(r.redMul(this.z)),a=i.redSub(n),c=s.redSub(o);if(0===a.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),l=u.redMul(a),d=i.redMul(u),f=c.redSqr().redIAdd(l).redISub(d).redISub(d),h=c.redMul(d.redISub(f)).redISub(s.redMul(l)),p=this.z.redMul(e.z).redMul(a);return this.curve.jpoint(f,h,p)},l.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,i=e.x.redMul(t),n=this.y,s=e.y.redMul(t).redMul(this.z),o=r.redSub(i),a=n.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=o.redSqr(),u=c.redMul(o),l=r.redMul(c),d=a.redSqr().redIAdd(u).redISub(l).redISub(l),f=a.redMul(l.redISub(d)).redISub(n.redMul(u)),h=this.z.redMul(o);return this.curve.jpoint(d,f,h)},l.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var r=this;for(t=0;t=0)return!1;if(r.redIAdd(n),0===this.x.cmp(r))return!0}},l.prototype.inspect=function(){return this.isInfinity()?"":""},l.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../utils":"959xT","bn.js":"c8Lvi",inherits:"j5plK","./base":"joYZE"}],j5plK:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},{}],exiKb:[function(e,t,r){"use strict";var i=e("bn.js"),n=e("inherits"),s=e("./base"),o=e("../utils");function a(e){s.call(this,"mont",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.i4=new i(4).toRed(this.red).redInvm(),this.two=new i(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,r){s.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new i(t,16),this.z=new i(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}n(a,s),t.exports=a,a.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),i=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===i.redSqrt().redSqr().cmp(i)},n(c,s.BasePoint),a.prototype.decodePoint=function(e,t){return this.point(o.toArray(e,t),1)},a.prototype.point=function(e,t){return new c(this,e,t)},a.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(e,t){return new c(e,t[0],t[1]||e.one)},c.prototype.inspect=function(){return this.isInfinity()?"":""},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),i=e.redMul(t),n=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(i,n)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),i=this.x.redSub(this.z),n=e.x.redAdd(e.z),s=e.x.redSub(e.z).redMul(r),o=n.redMul(i),a=t.z.redMul(s.redAdd(o).redSqr()),c=t.x.redMul(s.redISub(o).redSqr());return this.curve.point(a,c)},c.prototype.mul=function(e){for(var t=e.clone(),r=this,i=this.curve.point(null,null),n=[];0!==t.cmpn(0);t.iushrn(1))n.push(t.andln(1));for(var s=n.length-1;s>=0;s--)0===n[s]?(r=r.diffAdd(i,this),i=i.dbl()):(i=r.diffAdd(i,this),r=r.dbl());return i},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},{"bn.js":"c8Lvi",inherits:"j5plK","./base":"joYZE","../utils":"959xT"}],d2B4t:[function(e,t,r){"use strict";var i=e("../utils"),n=e("bn.js"),s=e("inherits"),o=e("./base"),a=i.assert;function c(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,o.call(this,"edwards",e),this.a=new n(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new n(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new n(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),a(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function u(e,t,r,i,s){o.BasePoint.call(this,e,"projective"),null===t&&null===r&&null===i?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new n(t,16),this.y=new n(r,16),this.z=i?new n(i,16):this.curve.one,this.t=s&&new n(s,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}s(c,o),t.exports=c,c.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},c.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},c.prototype.jpoint=function(e,t,r,i){return this.point(e,t,r,i)},c.prototype.pointFromX=function(e,t){(e=new n(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),i=this.c2.redSub(this.a.redMul(r)),s=this.one.redSub(this.c2.redMul(this.d).redMul(r)),o=i.redMul(s.redInvm()),a=o.redSqrt();if(0!==a.redSqr().redSub(o).cmp(this.zero))throw new Error("invalid point");var c=a.fromRed().isOdd();return(t&&!c||!t&&c)&&(a=a.redNeg()),this.point(e,a)},c.prototype.pointFromY=function(e,t){(e=new n(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),i=r.redSub(this.c2),s=r.redMul(this.d).redMul(this.c2).redSub(this.a),o=i.redMul(s.redInvm());if(0===o.cmp(this.zero)){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var a=o.redSqrt();if(0!==a.redSqr().redSub(o).cmp(this.zero))throw new Error("invalid point");return a.fromRed().isOdd()!==t&&(a=a.redNeg()),this.point(a,e)},c.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),r=e.y.redSqr(),i=t.redMul(this.a).redAdd(r),n=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(r)));return 0===i.cmp(n)},s(u,o.BasePoint),c.prototype.pointFromJSON=function(e){return u.fromJSON(this,e)},c.prototype.point=function(e,t,r,i){return new u(this,e,t,r,i)},u.fromJSON=function(e,t){return new u(e,t[0],t[1],t[2])},u.prototype.inspect=function(){return this.isInfinity()?"":""},u.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},u.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var i=this.curve._mulA(e),n=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),s=i.redAdd(t),o=s.redSub(r),a=i.redSub(t),c=n.redMul(o),u=s.redMul(a),l=n.redMul(a),d=o.redMul(s);return this.curve.point(c,u,d,l)},u.prototype._projDbl=function(){var e,t,r,i,n,s,o=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),c=this.y.redSqr();if(this.curve.twisted){var u=(i=this.curve._mulA(a)).redAdd(c);this.zOne?(e=o.redSub(a).redSub(c).redMul(u.redSub(this.curve.two)),t=u.redMul(i.redSub(c)),r=u.redSqr().redSub(u).redSub(u)):(n=this.z.redSqr(),s=u.redSub(n).redISub(n),e=o.redSub(a).redISub(c).redMul(s),t=u.redMul(i.redSub(c)),r=u.redMul(s))}else i=a.redAdd(c),n=this.curve._mulC(this.z).redSqr(),s=i.redSub(n).redSub(n),e=this.curve._mulC(o.redISub(i)).redMul(s),t=this.curve._mulC(i).redMul(a.redISub(c)),r=i.redMul(s);return this.curve.point(e,t,r)},u.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},u.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),i=this.t.redMul(this.curve.dd).redMul(e.t),n=this.z.redMul(e.z.redAdd(e.z)),s=r.redSub(t),o=n.redSub(i),a=n.redAdd(i),c=r.redAdd(t),u=s.redMul(o),l=a.redMul(c),d=s.redMul(c),f=o.redMul(a);return this.curve.point(u,l,f,d)},u.prototype._projAdd=function(e){var t,r,i=this.z.redMul(e.z),n=i.redSqr(),s=this.x.redMul(e.x),o=this.y.redMul(e.y),a=this.curve.d.redMul(s).redMul(o),c=n.redSub(a),u=n.redAdd(a),l=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(s).redISub(o),d=i.redMul(c).redMul(l);return this.curve.twisted?(t=i.redMul(u).redMul(o.redSub(this.curve._mulA(s))),r=c.redMul(u)):(t=i.redMul(u).redMul(o.redSub(s)),r=this.curve._mulC(c).redMul(u)),this.curve.point(d,t,r)},u.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},u.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},u.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},u.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},u.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},u.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()},u.prototype.getY=function(){return this.normalize(),this.y.fromRed()},u.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},u.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),i=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(i),0===this.x.cmp(t))return!0}},u.prototype.toP=u.prototype.normalize,u.prototype.mixedAdd=u.prototype.add},{"../utils":"959xT","bn.js":"c8Lvi",inherits:"j5plK","./base":"joYZE"}],"4unkA":[function(e,t,r){"use strict";var i,n=r,s=e("hash.js"),o=e("./curve"),a=e("./utils").assert;function c(e){"short"===e.type?this.curve=new o.short(e):"edwards"===e.type?this.curve=new o.edwards(e):this.curve=new o.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function u(e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){var r=new c(t);return Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=c,u("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:s.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),u("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:s.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),u("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:s.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),u("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:s.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),u("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:s.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),u("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:s.sha256,gRed:!1,g:["9"]}),u("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:s.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{i=e("./precomputed/secp256k1")}catch(e){i=void 0}u("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:s.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",i]})},{"hash.js":"8UgFw","./curve":"byDyH","./utils":"959xT","./precomputed/secp256k1":"0oQdV"}],"8UgFw":[function(e,t,r){var i=r;i.utils=e("./hash/utils"),i.common=e("./hash/common"),i.sha=e("./hash/sha"),i.ripemd=e("./hash/ripemd"),i.hmac=e("./hash/hmac"),i.sha1=i.sha.sha1,i.sha256=i.sha.sha256,i.sha224=i.sha.sha224,i.sha384=i.sha.sha384,i.sha512=i.sha.sha512,i.ripemd160=i.ripemd.ripemd160},{"./hash/utils":"fs59i","./hash/common":"bUDg4","./hash/sha":"allnM","./hash/ripemd":"11wsf","./hash/hmac":"7ZuTN"}],fs59i:[function(e,t,r){"use strict";var i=e("minimalistic-assert"),n=e("inherits");function s(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function o(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function c(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}r.inherits=n,r.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>6|192,r[i++]=63&o|128):s(e,n)?(o=65536+((1023&o)<<10)+(1023&e.charCodeAt(++n)),r[i++]=o>>18|240,r[i++]=o>>12&63|128,r[i++]=o>>6&63|128,r[i++]=63&o|128):(r[i++]=o>>12|224,r[i++]=o>>6&63|128,r[i++]=63&o|128)}else for(n=0;n>>0}return o},r.split32=function(e,t){for(var r=new Array(4*e.length),i=0,n=0;i>>24,r[n+1]=s>>>16&255,r[n+2]=s>>>8&255,r[n+3]=255&s):(r[n+3]=s>>>24,r[n+2]=s>>>16&255,r[n+1]=s>>>8&255,r[n]=255&s)}return r},r.rotr32=function(e,t){return e>>>t|e<<32-t},r.rotl32=function(e,t){return e<>>32-t},r.sum32=function(e,t){return e+t>>>0},r.sum32_3=function(e,t,r){return e+t+r>>>0},r.sum32_4=function(e,t,r,i){return e+t+r+i>>>0},r.sum32_5=function(e,t,r,i,n){return e+t+r+i+n>>>0},r.sum64=function(e,t,r,i){var n=e[t],s=i+e[t+1]>>>0,o=(s>>0,e[t+1]=s},r.sum64_hi=function(e,t,r,i){return(t+i>>>0>>0},r.sum64_lo=function(e,t,r,i){return t+i>>>0},r.sum64_4_hi=function(e,t,r,i,n,s,o,a){var c=0,u=t;return c+=(u=u+i>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(e,t,r,i,n,s,o,a){return t+i+s+a>>>0},r.sum64_5_hi=function(e,t,r,i,n,s,o,a,c,u){var l=0,d=t;return l+=(d=d+i>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(e,t,r,i,n,s,o,a,c,u){return t+i+s+a+u>>>0},r.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},r.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},r.shr64_hi=function(e,t,r){return e>>>r},r.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},{"minimalistic-assert":"1GrVu",inherits:"j5plK"}],bUDg4:[function(e,t,r){"use strict";var i=e("./utils"),n=e("minimalistic-assert");function s(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=s,s.prototype.update=function(e,t){if(e=i.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=i.join32(e,0,e.length-r,this.endian);for(var n=0;n>>24&255,i[n++]=e>>>16&255,i[n++]=e>>>8&255,i[n++]=255&e}else for(i[n++]=255&e,i[n++]=e>>>8&255,i[n++]=e>>>16&255,i[n++]=e>>>24&255,i[n++]=0,i[n++]=0,i[n++]=0,i[n++]=0,s=8;s>>3},r.g1_256=function(e){return i(e,17)^i(e,19)^e>>>10}},{"../utils":"fs59i"}],"5p3po":[function(e,t,r){"use strict";var i=e("../utils"),n=e("./256");function s(){if(!(this instanceof s))return new s;n.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}i.inherits(s,n),t.exports=s,s.blockSize=512,s.outSize=224,s.hmacStrength=192,s.padLength=64,s.prototype._digest=function(e){return"hex"===e?i.toHex32(this.h.slice(0,7),"big"):i.split32(this.h.slice(0,7),"big")}},{"../utils":"fs59i","./256":"kwXkv"}],kwXkv:[function(e,t,r){"use strict";var i=e("../utils"),n=e("../common"),s=e("./common"),o=e("minimalistic-assert"),a=i.sum32,c=i.sum32_4,u=i.sum32_5,l=s.ch32,d=s.maj32,f=s.s0_256,h=s.s1_256,p=s.g0_256,g=s.g1_256,y=n.BlockHash,m=[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];function b(){if(!(this instanceof b))return new b;y.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=m,this.W=new Array(64)}i.inherits(b,y),t.exports=b,b.blockSize=512,b.outSize=256,b.hmacStrength=192,b.padLength=64,b.prototype._update=function(e,t){for(var r=this.W,i=0;i<16;i++)r[i]=e[t+i];for(;ithis.blockSize&&(e=(new this.Hash).update(e).digest()),n(e.length<=this.blockSize);for(var t=e.length;t0))return o.iaddn(1),this.keyFromPrivate(o)}},d.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},d.prototype.sign=function(e,t,r,s){"object"==typeof r&&(s=r,r=null),s||(s={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new i(e,16));for(var o=this.n.byteLength(),a=t.getPrivate().toArray("be",o),c=e.toArray("be",o),u=new n({hash:this.hash,entropy:a,nonce:c,pers:s.pers,persEnc:s.persEnc||"utf8"}),d=this.n.sub(new i(1)),f=0;;f++){var h=s.k?s.k(f):new i(u.generate(this.n.byteLength()));if(!((h=this._truncateToN(h,!0)).cmpn(1)<=0||h.cmp(d)>=0)){var p=this.g.mul(h);if(!p.isInfinity()){var g=p.getX(),y=g.umod(this.n);if(0!==y.cmpn(0)){var m=h.invm(this.n).mul(y.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var b=(p.getY().isOdd()?1:0)|(0!==g.cmp(y)?2:0);return s.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),b^=1),new l({r:y,s:m,recoveryParam:b})}}}}}},d.prototype.verify=function(e,t,r,n){e=this._truncateToN(new i(e,16)),r=this.keyFromPublic(r,n);var s=(t=new l(t,"hex")).r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,c=o.invm(this.n),u=c.mul(e).umod(this.n),d=c.mul(s).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(u,r.getPublic(),d)).isInfinity()&&a.eqXToP(s):!(a=this.g.mulAdd(u,r.getPublic(),d)).isInfinity()&&0===a.getX().umod(this.n).cmp(s)},d.prototype.recoverPubKey=function(e,t,r,n){c((3&r)===r,"The recovery param is more than two bits"),t=new l(t,n);var s=this.n,o=new i(e),a=t.r,u=t.s,d=1&r,f=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&f)throw new Error("Unable to find sencond key candinate");a=f?this.curve.pointFromX(a.add(this.curve.n),d):this.curve.pointFromX(a,d);var h=t.r.invm(s),p=s.sub(o).mul(h).umod(s),g=u.mul(h).umod(s);return this.g.mulAdd(p,a,g)},d.prototype.getKeyRecoveryParam=function(e,t,r,i){if(null!==(t=new l(t,i)).recoveryParam)return t.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(e,t,n)}catch(e){continue}if(s.eq(r))return n}throw new Error("Unable to find valid recovery factor")}},{"bn.js":"c8Lvi","hmac-drbg":"iPkoP","../utils":"959xT","../curves":"4unkA",brorand:"P54o1","./key":"9sGQ9","./signature":"hmVaw"}],iPkoP:[function(e,t,r){"use strict";var i=e("hash.js"),n=e("minimalistic-crypto-utils"),s=e("minimalistic-assert");function o(e){if(!(this instanceof o))return new o(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=n.toArray(e.entropy,e.entropyEnc||"hex"),r=n.toArray(e.nonce,e.nonceEnc||"hex"),i=n.toArray(e.pers,e.persEnc||"hex");s(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,i)}t.exports=o,o.prototype._init=function(e,t,r){var i=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var n=0;n=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},o.prototype.generate=function(e,t,r,i){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(i=r,r=t,t=null),r&&(r=n.toArray(r,i||"hex"),this._update(r));for(var s=[];s.length"}},{"bn.js":"c8Lvi","../utils":"959xT"}],hmVaw:[function(e,t,r){"use strict";var i=e("bn.js"),n=e("../utils"),s=n.assert;function o(e,t){if(e instanceof o)return e;this._importDER(e,t)||(s(e.r&&e.s,"Signature without r or s"),this.r=new i(e.r,16),this.s=new i(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function a(){this.place=0}function c(e,t){var r=e[t.place++];if(!(128&r))return r;var i=15&r;if(0===i||i>4)return!1;for(var n=0,s=0,o=t.place;s>>=0;return!(n<=127)&&(t.place=o,n)}function u(e){for(var t=0,r=e.length-1;!e[t]&&!(128&e[t+1])&&t>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}t.exports=o,o.prototype._importDER=function(e,t){e=n.toArray(e,t);var r=new a;if(48!==e[r.place++])return!1;var s=c(e,r);if(!1===s)return!1;if(s+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var o=c(e,r);if(!1===o)return!1;var u=e.slice(r.place,o+r.place);if(r.place+=o,2!==e[r.place++])return!1;var l=c(e,r);if(!1===l)return!1;if(e.length!==l+r.place)return!1;var d=e.slice(r.place,l+r.place);if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}if(0===d[0]){if(!(128&d[1]))return!1;d=d.slice(1)}return this.r=new i(u),this.s=new i(d),this.recoveryParam=null,!0},o.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=u(t),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var i=[2];l(i,t.length),(i=i.concat(t)).push(2),l(i,r.length);var s=i.concat(r),o=[48];return l(o,s.length),o=o.concat(s),n.encode(o,e)}},{"bn.js":"c8Lvi","../utils":"959xT"}],j2H5w:[function(e,t,r){"use strict";var i=e("hash.js"),n=e("../curves"),s=e("../utils"),o=s.assert,a=s.parseBytes,c=e("./key"),u=e("./signature");function l(e){if(o("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof l))return new l(e);e=n[e].curve,this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=i.sha512}t.exports=l,l.prototype.sign=function(e,t){e=a(e);var r=this.keyFromSecret(t),i=this.hashInt(r.messagePrefix(),e),n=this.g.mul(i),s=this.encodePoint(n),o=this.hashInt(s,r.pubBytes(),e).mul(r.priv()),c=i.add(o).umod(this.curve.n);return this.makeSignature({R:n,S:c,Rencoded:s})},l.prototype.verify=function(e,t,r){e=a(e),t=this.makeSignature(t);var i=this.keyFromPublic(r),n=this.hashInt(t.Rencoded(),i.pubBytes(),e),s=this.g.mul(t.S());return t.R().add(i.pub().mul(n)).eq(s)},l.prototype.hashInt=function(){for(var e=this.hash(),t=0;t{const c=a[e];if(!c){const t=Object.keys(a).join(" / ");throw i(new Error(`unknown cipher type '${e}'. Must be ${t}`),"ERR_INVALID_CIPHER_TYPE")}if(!t)throw i(new Error("missing hash type"),"ERR_MISSING_HASH_TYPE");const u=c.keySize,l=c.ivSize,d=s("key expansion"),f=2*(l+u+20),h=await o.create(t,r);let p=await h.digest(d);const g=[];let y=0;for(;yf&&(t=f-y),g.push(e),y+=t,p=await h.digest(p)}const m=f/2,b=n(g),v=b.slice(0,m),w=b.slice(m,f),_=e=>({iv:e.slice(0,l),cipherKey:e.slice(l,l+u),macKey:e.slice(l+u)});return{k1:_(v),k2:_(w)}}},{"err-code":"chZjB","uint8arrays/concat":"4EBjG","uint8arrays/from-string":"dF7Y4","../hmac":"JUsR3"}],JUsR3:[function(e,t,r){"use strict";const i=e("../webcrypto"),n=e("./lengths"),s={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"};r.create=async function(e,t){const r=s[e],o=await i.get().subtle.importKey("raw",t,{name:"HMAC",hash:{name:r}},!1,["sign"]);return{digest:async e=>(async(e,t)=>{const r=await i.get().subtle.sign({name:"HMAC"},e,t);return new Uint8Array(r,r.byteOffset,r.byteLength)})(o,e),length:n[e]}}},{"../webcrypto":"i99ng","./lengths":"8g8ed"}],"8g8ed":[function(e,t,r){"use strict";t.exports={SHA1:20,SHA256:32,SHA512:64}},{}],ds3K5:[function(e,t,r){"use strict";const i=e("./ecdh");t.exports=async e=>i.generateEphmeralKeyPair(e)},{"./ecdh":"bSsHl"}],bSsHl:[function(e,t,r){"use strict";const i=e("err-code"),n=e("../webcrypto"),{base64urlToBuffer:s}=e("../util"),o=e("./validate-curve-type"),{toString:a}=e("uint8arrays/to-string"),{concat:c}=e("uint8arrays/concat"),{equals:u}=e("uint8arrays/equals"),l={"P-256":256,"P-384":384,"P-521":521};r.generateEphmeralKeyPair=async function(e){o(Object.keys(l),e);const t=await n.get().subtle.generateKey({name:"ECDH",namedCurve:e},!0,["deriveBits"]);return{key:f(await n.get().subtle.exportKey("jwk",t.publicKey)),genSharedKey:async(r,i)=>{let s;s=i?await n.get().subtle.importKey("jwk",p(e,i),{name:"ECDH",namedCurve:e},!1,["deriveBits"]):t.privateKey;const o=[await n.get().subtle.importKey("jwk",h(e,r),{name:"ECDH",namedCurve:e},!1,[]),s],a=await n.get().subtle.deriveBits({name:"ECDH",namedCurve:e,public:o[0]},o[1],l[e]);return new Uint8Array(a,a.byteOffset,a.byteLength)}}};const d={"P-256":32,"P-384":48,"P-521":66};function f(e){const t=d[e.crv];return c([Uint8Array.from([4]),s(e.x,t),s(e.y,t)],1+2*t)}function h(e,t){const r=d[e];if(u(!t.slice(0,1),Uint8Array.from([4])))throw i(new Error("Cannot unmarshal public key - invalid key format"),"ERR_INVALID_KEY_FORMAT");return{kty:"EC",crv:e,x:a(t.slice(1,r+1),"base64url"),y:a(t.slice(1+r),"base64url"),ext:!0}}const p=(e,t)=>({...h(e,t.public),d:a(t.private,"base64url")})},{"err-code":"chZjB","../webcrypto":"i99ng","../util":"ffmp6","./validate-curve-type":"8CFUR","uint8arrays/to-string":"hC8JB","uint8arrays/concat":"4EBjG","uint8arrays/equals":"eY3cX"}],"8CFUR":[function(e,t,r){"use strict";const i=e("err-code");t.exports=function(e,t){if(!e.includes(t)){const r=e.join(" / ");throw i(new Error(`Unknown curve: ${t}. Must be ${r}`),"ERR_INVALID_CURVE")}}},{"err-code":"chZjB"}],gx31A:[function(e,t,r){"use strict";t.exports=function(e,{className:t,symbolName:r}){const i=Symbol.for(r),n={[t]:class extends e{constructor(...e){super(...e),Object.defineProperty(this,i,{value:!0})}get[Symbol.toStringTag](){return t}}}[t];return n[`is${t}`]=e=>!(!e||!e[i]),n},t.exports.proto=function(e,{className:t,symbolName:r,withoutNew:i}){const n=Symbol.for(r),s={[t]:function(...t){if(i&&!(this instanceof s))return new s(...t);const r=e.call(this,...t)||this;return r&&!r[n]&&Object.defineProperty(r,n,{value:!0}),r}}[t];return s.prototype=Object.create(e.prototype),s.prototype.constructor=s,Object.defineProperty(s.prototype,Symbol.toStringTag,{get:()=>t}),s[`is${t}`]=e=>!(!e||!e[n]),s}},{}],c0IJt:[function(e,t,r){"use strict";var i=e("protobufjs/minimal"),n=i.Reader,s=i.Writer,o=i.util,a=i.roots["libp2p-peer-id"]||(i.roots["libp2p-peer-id"]={});a.PeerIdProto=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:i.id=e.bytes();break;case 2:i.pubKey=e.bytes();break;case 3:i.privKey=e.bytes();break;default:e.skipType(7&s)}}if(!i.hasOwnProperty("id"))throw o.ProtocolError("missing required 'id'",{instance:i});return i},e.fromObject=function(e){if(e instanceof a.PeerIdProto)return e;var t=new a.PeerIdProto;return null!=e.id&&("string"==typeof e.id?o.base64.decode(e.id,t.id=o.newBuffer(o.base64.length(e.id)),0):e.id.length&&(t.id=e.id)),null!=e.pubKey&&("string"==typeof e.pubKey?o.base64.decode(e.pubKey,t.pubKey=o.newBuffer(o.base64.length(e.pubKey)),0):e.pubKey.length&&(t.pubKey=e.pubKey)),null!=e.privKey&&("string"==typeof e.privKey?o.base64.decode(e.privKey,t.privKey=o.newBuffer(o.base64.length(e.privKey)),0):e.privKey.length&&(t.privKey=e.privKey)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.id="":(r.id=[],t.bytes!==Array&&(r.id=o.newBuffer(r.id))),t.bytes===String?r.pubKey="":(r.pubKey=[],t.bytes!==Array&&(r.pubKey=o.newBuffer(r.pubKey))),t.bytes===String?r.privKey="":(r.privKey=[],t.bytes!==Array&&(r.privKey=o.newBuffer(r.privKey)))),null!=e.id&&e.hasOwnProperty("id")&&(r.id=t.bytes===String?o.base64.encode(e.id,0,e.id.length):t.bytes===Array?Array.prototype.slice.call(e.id):e.id),null!=e.pubKey&&e.hasOwnProperty("pubKey")&&(r.pubKey=t.bytes===String?o.base64.encode(e.pubKey,0,e.pubKey.length):t.bytes===Array?Array.prototype.slice.call(e.pubKey):e.pubKey),null!=e.privKey&&e.hasOwnProperty("privKey")&&(r.privKey=t.bytes===String?o.base64.encode(e.privKey,0,e.privKey.length):t.bytes===Array?Array.prototype.slice.call(e.privKey):e.privKey),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e}(),t.exports=a},{"protobufjs/minimal":"grAXL"}],hDUM1:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./add.js"),n=e("./add-all.js"),s=e("./ls.js"),o=e("./rm.js"),a=e("./rm-all.js");r.PinAPI=class{constructor({codecs:e,repo:t}){const r=n.createAddAll({codecs:e,repo:t});this.addAll=r,this.add=i.createAdd({addAll:r});const c=a.createRmAll({codecs:e,repo:t});this.rmAll=c,this.rm=o.createRm({rmAll:c}),this.ls=s.createLs({codecs:e,repo:t}),this.remote={add:(e,t={})=>Promise.reject(new Error("Not implemented")),ls:async function*(e,t={}){return Promise.reject(new Error("Not implemented"))},rm:(e,t={})=>Promise.reject(new Error("Not implemented")),rmAll:(e,t={})=>Promise.reject(new Error("Not implemented")),service:{add:(e,t)=>Promise.reject(new Error("Not implemented")),rm:(e,t={})=>Promise.reject(new Error("Not implemented")),ls:(e={})=>Promise.reject(new Error("Not implemented"))}}}}},{"./add.js":"lM2k0","./add-all.js":"5qgaX","./ls.js":"hVzUN","./rm.js":"khHqn","./rm-all.js":"5GWqa"}],lM2k0:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("it-last"),n=e("multiformats/cid");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=s(i);r.createAdd=function({addAll:e}){return(t,r={})=>{let i;const s=n.CID.asCID(t);return i=e(s?[{cid:s,...r}]:[{path:t.toString(),...r}],r),o.default(i)}}},{"it-last":"cSXX9","multiformats/cid":"9ooAY"}],cSXX9:[function(e,t,r){"use strict";t.exports=async e=>{let t;for await(const r of e)t=r;return t}},{}],"5qgaX":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../../utils.js"),n=e("ipfs-core-utils/with-timeout-option"),s=e("ipfs-core-utils/pins/normalise-input"),o=e("ipfs-repo/pin-types");r.createAddAll=function({repo:e,codecs:t}){return n.withTimeoutOption((async function*(r,n={}){const a=async function*(){for await(const{path:n,recursive:a,metadata:c}of s.normaliseInput(r)){const{cid:r}=await i.resolvePath(e,t,n),{reason:s}=await e.pins.isPinnedWithType(r,[o.PinTypes.recursive,o.PinTypes.direct]);if("recursive"===s&&!a)throw new Error(`${r} already pinned recursively`);a?await e.pins.pinRecursively(r,{metadata:c}):await e.pins.pinDirectly(r,{metadata:c}),yield r}};if(!Boolean(n.lock))return void(yield*a());const c=await e.gcLock.readLock();try{yield*a()}finally{c()}}))}},{"../../utils.js":"cT4uN","ipfs-core-utils/with-timeout-option":"j29MK","ipfs-core-utils/pins/normalise-input":"4NDJq","ipfs-repo/pin-types":"uek22"}],"4NDJq":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("err-code"),n=e("multiformats/cid");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=s(i);function a(e){const t=e.cid||`${e.path}`;if(!t)throw o.default(new Error("Unexpected input: Please path either a CID or an IPFS path"),"ERR_UNEXPECTED_INPUT");const r={path:t,recursive:!1!==e.recursive};return null!=e.metadata&&(r.metadata=e.metadata),r}r.normaliseInput=async function*(e){if(null==e)throw o.default(new Error(`Unexpected input: ${e}`),"ERR_UNEXPECTED_INPUT");const t=n.CID.asCID(e);if(t)yield a({cid:t});else{if(!(e instanceof String||"string"==typeof e)){if(null!=e.cid||null!=e.path)return yield a(e);if(Symbol.iterator in e){const t=e[Symbol.iterator](),r=t.next();if(r.done)return t;if(n.CID.asCID(r.value)||r.value instanceof String||"string"==typeof r.value){yield a({cid:r.value});for(const e of t)yield a({cid:e});return}if(null!=r.value.cid||null!=r.value.path){yield a(r.value);for(const e of t)yield a(e);return}throw o.default(new Error("Unexpected input: "+typeof e),"ERR_UNEXPECTED_INPUT")}if(Symbol.asyncIterator in e){const t=e[Symbol.asyncIterator](),r=await t.next();if(r.done)return t;if(n.CID.asCID(r.value)||r.value instanceof String||"string"==typeof r.value){yield a({cid:r.value});for await(const e of t)yield a({cid:e});return}if(null!=r.value.cid||null!=r.value.path){yield a(r.value);for await(const e of t)yield a(e);return}throw o.default(new Error("Unexpected input: "+typeof e),"ERR_UNEXPECTED_INPUT")}throw o.default(new Error("Unexpected input: "+typeof e),"ERR_UNEXPECTED_INPUT")}yield a({path:e})}}},{"err-code":"chZjB","multiformats/cid":"9ooAY"}],uek22:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.PinTypes={direct:"direct",recursive:"recursive",indirect:"indirect",all:"all"}},{}],hVzUN:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/pins/normalise-input"),n=e("../../utils.js"),s=e("ipfs-core-utils/with-timeout-option"),o=e("err-code"),a=e("ipfs-repo/pin-types");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(o);function l(e,t,r){const i={type:e,cid:t};return r&&(i.metadata=r),i}r.createLs=function({repo:e,codecs:t}){return s.withTimeoutOption((async function*(r={}){let s=a.PinTypes.all;if(r.type&&(s=r.type,!Object.keys(a.PinTypes).includes(s)))throw u.default(new Error("Invalid pin type"),"ERR_INVALID_PIN_TYPE");if(r.paths){let o=!1;for await(const{path:c}of i.normaliseInput(r.paths)){const{cid:r}=await n.resolvePath(e,t,c),{reason:i,pinned:d,parent:f,metadata:h}=await e.pins.isPinnedWithType(r,s);if(!d)throw u.default(new Error(`path '${c}' is not pinned`),"ERR_NOT_PINNED");switch(i){case a.PinTypes.direct:case a.PinTypes.recursive:o=!0,yield l(i,r,h);break;default:o=!0,yield l(`${a.PinTypes.indirect} through ${f}`,r,h)}}if(!o)throw new Error("No match found")}else{if(s===a.PinTypes.recursive||s===a.PinTypes.all)for await(const{cid:t,metadata:r}of e.pins.recursiveKeys())yield l(a.PinTypes.recursive,t,r);if(s===a.PinTypes.indirect||s===a.PinTypes.all)for await(const t of e.pins.indirectKeys(r))yield l(a.PinTypes.indirect,t);if(s===a.PinTypes.direct||s===a.PinTypes.all)for await(const{cid:t,metadata:r}of e.pins.directKeys())yield l(a.PinTypes.direct,t,r)}}))}},{"ipfs-core-utils/pins/normalise-input":"4NDJq","../../utils.js":"cT4uN","ipfs-core-utils/with-timeout-option":"j29MK","err-code":"chZjB","ipfs-repo/pin-types":"uek22"}],khHqn:[function(e,t,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(r,"__esModule",{value:!0});var n=i(e("it-last"));r.createRm=function({rmAll:e}){return async function(t,r={}){const i=await n.default(e([{path:t,...r}],r));if(!i)throw new Error("CID expected");return i}}},{"it-last":"cSXX9"}],"5GWqa":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/pins/normalise-input"),n=e("../../utils.js"),s=e("ipfs-core-utils/with-timeout-option"),o=e("ipfs-repo/pin-types");r.createRmAll=function({repo:e,codecs:t}){return s.withTimeoutOption((async function*(r,s={}){const a=await e.gcLock.readLock();try{for await(const{path:s,recursive:a}of i.normaliseInput(r)){const{cid:r}=await n.resolvePath(e,t,s),{pinned:i,reason:c}=await e.pins.isPinnedWithType(r,o.PinTypes.all);if(!i)throw new Error(`${r} is not pinned`);switch(c){case o.PinTypes.recursive:if(!a)throw new Error(`${r} is pinned recursively`);await e.pins.unpin(r),yield r;break;case o.PinTypes.direct:await e.pins.unpin(r),yield r;break;default:throw new Error(`${r} is pinned indirectly under ${c}`)}}}finally{a()}}))}},{"ipfs-core-utils/pins/normalise-input":"4NDJq","../../utils.js":"cT4uN","ipfs-core-utils/with-timeout-option":"j29MK","ipfs-repo/pin-types":"uek22"}],fTgTV:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../ipns/index.js"),n=e("../ipns/routing/config.js"),s=e("../ipns/routing/offline-datastore.js"),o=e("../errors.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const c=a(e("debug")).default("ipfs:components:ipns");r.IPNSAPI=class{constructor(e={pass:""}){this.options=e,this.offline=null,this.online=null}getIPNS(){const e=this.online||this.offline;if(e)return e;throw new o.NotInitializedError}get routing(){return this.getIPNS().routing}startOffline({repo:e,peerId:t,keychain:r}){if(null!=this.offline)throw new o.AlreadyInitializedError;c("initializing IPNS keyspace");const n=new s.OfflineDatastore(e),a=new i.IPNS(n,e.datastore,t,r,this.options);this.offline=a}async startOnline({libp2p:e,repo:t,peerId:r,keychain:s}){if(null!=this.online)throw new o.AlreadyInitializedError;const a=n.createRouting({libp2p:e,repo:t,peerId:r,options:this.options}),c=new i.IPNS(a,t.datastore,r,s,this.options);await c.republisher.start(),this.online=c}async stop(){const e=this.online;e&&(await e.republisher.stop(),this.online=null)}publish(e,t,r){return this.getIPNS().publish(e,t,r)}resolve(e,t){return this.getIPNS().resolve(e,t)}initializeKeyspace(e,t){return this.getIPNS().initializeKeyspace(e,t)}}},{"../ipns/index.js":"KNAGK","../ipns/routing/config.js":"bU4x4","../ipns/routing/offline-datastore.js":"a4pYc","../errors.js":"j69o8",debug:"bO5wM"}],KNAGK:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("peer-id"),n=e("err-code"),s=e("debug"),o=e("./publisher.js"),a=e("./republisher.js"),c=e("./resolver.js"),u=e("../utils/tlru.js"),l=e("uint8arrays/to-string");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=d(n),h=d(s);const p=Object.assign(h.default("ipfs:ipns"),{error:h.default("ipfs:ipns:error")});r.IPNS=class{constructor(e,t,r,i,n){this.publisher=new o.IpnsPublisher(e,t),this.republisher=new a.IpnsRepublisher(this.publisher,t,r,i,n),this.resolver=new c.IpnsResolver(e),this.cache=new u.TLRU(1e3),this.routing=e}async publish(e,t,r=o.IpnsPublisher.defaultRecordLifetime){try{const n=await i.createFromPrivKey(e.bytes);await this.publisher.publishWithEOL(e,t,r),p(`IPNS value ${l.toString(t,"base32")} was published correctly`);const s=n.toB58String(),o=parseFloat(r),a=o<6e4?o:6e4;return this.cache.set(s,t,a),p(`IPNS value ${l.toString(t,"base32")} was cached correctly`),{name:s,value:t}}catch(e){throw p.error(e),e}}async resolve(e,t={}){if("string"!=typeof e)throw f.default(new Error("name received is not valid"),"ERR_INVALID_NAME");if(!t.nocache&&!t.recursive){const t=e.split("/")[2],r=this.cache.get(t);if(r)return r}try{const r=await this.resolver.resolve(e,t);return p(`IPNS record from ${e} was resolved correctly`),r}catch(e){throw p.error(e),e}}async initializeKeyspace(e,t){return this.publish(e,t,o.IpnsPublisher.defaultRecordLifetime)}}},{"peer-id":"8Bdb3","err-code":"chZjB",debug:"bO5wM","./publisher.js":"5jkXx","./republisher.js":"hoedq","./resolver.js":"gifOE","../utils/tlru.js":"lQE1u","uint8arrays/to-string":"hC8JB"}],"5jkXx":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("peer-id"),n=e("interface-datastore/key"),s=e("datastore-core/errors"),o=e("err-code"),a=e("debug"),c=e("uint8arrays/to-string"),u=e("uint8arrays/equals"),l=e("ipns");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function f(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var h=d(i),p=d(o),g=d(a),y=f(l);const m=Object.assign(g.default("ipfs:ipns:publisher"),{error:g.default("ipfs:ipns:publisher:error")}),b=s.notFoundError().code,v=36e5;class w{constructor(e,t){this._routing=e,this._datastore=t}async publishWithEOL(e,t,r){if(!e||!e.bytes)throw p.default(new Error("invalid private key"),"ERR_INVALID_PRIVATE_KEY");const i=await h.default.createFromPrivKey(e.bytes),n=await this._updateOrCreateRecord(e,t,r,i);return this._putRecordToRouting(n,i)}publish(e,t){return this.publishWithEOL(e,t,v)}async _putRecordToRouting(e,t){if(!h.default.isPeerId(t)){const e="peerId received is not valid";throw m.error(e),p.default(new Error(e),"ERR_INVALID_PEER_ID")}const r=t._pubKey,i=await y.embedPublicKey(r,e),n=y.getIdKeys(t.toBytes());return await this._publishEntry(n.routingKey,i||e),await this._publishPublicKey(n.routingPubKey,r),i||e}async _publishEntry(e,t){const r=n.Key.asKey(e);if(!r){const e="datastore key does not have a valid format";throw m.error(e),p.default(new Error(e),"ERR_INVALID_DATASTORE_KEY")}let i;try{i=y.marshal(t)}catch(e){throw m.error(e),e}try{const e=await this._routing.put(r.uint8Array(),i);return m(`ipns record for ${c.toString(r.uint8Array(),"base64")} was stored in the routing`),e}catch(e){const t=`ipns record for ${c.toString(r.uint8Array(),"base64")} could not be stored in the routing`;throw m.error(t),m.error(e),p.default(new Error(t),"ERR_PUTTING_TO_ROUTING")}}async _publishPublicKey(e,t){const r=n.Key.asKey(e);if(!r){const e="datastore key does not have a valid format";throw m.error(e),p.default(new Error(e),"ERR_INVALID_DATASTORE_KEY")}if(!t||!t.bytes){const e="one or more of the provided parameters are not defined";throw m.error(e),p.default(new Error(e),"ERR_UNDEFINED_PARAMETER")}try{const e=await this._routing.put(r.uint8Array(),t.bytes);return m(`public key for ${c.toString(r.uint8Array(),"base64")} was stored in the routing`),e}catch(e){const t=`public key for ${c.toString(r.uint8Array(),"base64")} could not be stored in the routing`;throw m.error(t),m.error(e),p.default(new Error(t),"ERR_PUTTING_TO_ROUTING")}}async _getPublished(e,t={}){if(!h.default.isPeerId(e)){const e="peerId received is not valid";throw m.error(e),p.default(new Error(e),"ERR_INVALID_PEER_ID")}const r=!1!==t.checkRouting;try{const t=await this._datastore.get(y.getLocalKey(e.id));return this._unmarshalData(t)}catch(t){if(t.code!==b){const t=`unexpected error getting the ipns record ${e.id} from datastore`;throw m.error(t),p.default(new Error(t),"ERR_UNEXPECTED_DATASTORE_RESPONSE")}if(!r)throw p.default(t,"ERR_NOT_FOUND_AND_CHECK_ROUTING_NOT_ENABLED");try{const t=y.getIdKeys(e.toBytes()),r=await this._routing.get(t.routingKey.uint8Array());return this._unmarshalData(r)}catch(e){throw m.error(e),e}}}_unmarshalData(e){try{return y.unmarshal(e)}catch(e){throw p.default(e,"ERR_INVALID_RECORD_DATA")}}async _updateOrCreateRecord(e,t,r,i){if(!h.default.isPeerId(i)){const e="peerId received is not valid";throw m.error(e),p.default(new Error(e),"ERR_INVALID_PEER_ID")}const n={checkRouting:!0};let s;try{s=await this._getPublished(i,n)}catch(e){if(e.code!==b){const t=`unexpected error when determining the last published IPNS record for ${i.id} ${e.stack}`;throw m.error(t),p.default(new Error(t),"ERR_DETERMINING_PUBLISHED_RECORD")}}let o,a=0;s&&void 0!==s.sequence&&(a=u.equals(s.value,t)?BigInt(s.sequence):BigInt(s.sequence)+BigInt(1));try{o=await y.create(e,t,a,r)}catch(e){const r=`ipns record for ${t} could not be created`;throw m.error(e),p.default(new Error(r),"ERR_CREATING_IPNS_RECORD")}try{const e=y.marshal(o);return await this._datastore.put(y.getLocalKey(i.id),e),m(`ipns record for ${c.toString(t,"base32")} was stored in the datastore`),o}catch(e){const r=`ipns record for ${t} could not be stored in the datastore`;throw m.error(r),p.default(new Error(r),"ERR_STORING_IN_DATASTORE")}}}w.defaultRecordLifetime=v,r.IpnsPublisher=w},{"peer-id":"8Bdb3","interface-datastore/key":"9hGOz","datastore-core/errors":"65M4b","err-code":"chZjB",debug:"bO5wM","uint8arrays/to-string":"hC8JB","uint8arrays/equals":"eY3cX",ipns:"7rNAT"}],"65M4b":[function(e,t,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(r,"__esModule",{value:!0});var n=i(e("err-code"));r.abortedError=function(e){return e=e||new Error("Aborted"),n.default(e,"ERR_ABORTED")},r.dbDeleteFailedError=function(e){return e=e||new Error("Delete failed"),n.default(e,"ERR_DB_DELETE_FAILED")},r.dbOpenFailedError=function(e){return e=e||new Error("Cannot open database"),n.default(e,"ERR_DB_OPEN_FAILED")},r.dbWriteFailedError=function(e){return e=e||new Error("Write failed"),n.default(e,"ERR_DB_WRITE_FAILED")},r.notFoundError=function(e){return e=e||new Error("Not Found"),n.default(e,"ERR_NOT_FOUND")}},{"err-code":"chZjB"}],"7rNAT":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("timestamp-nano"),n=e("interface-datastore/key"),s=e("libp2p-crypto"),o=e("peer-id"),a=e("multiformats/hashes/digest"),c=e("multiformats/hashes/identity"),u=e("err-code"),l=e("multiformats/bases/base32"),d=e("uint8arrays/from-string"),f=e("uint8arrays/to-string"),h=e("uint8arrays/concat"),p=e("uint8arrays/equals"),g=e("cborg"),y=e("long"),m=e("debug"),b=e("./pb/ipns.js"),v=e("./utils.js"),w=e("./errors.js");function _(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function E(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var S=_(i),T=_(s),A=_(o),k=E(a),I=_(u),R=E(g),P=_(y),O=_(m);const C=Object.assign(O.default("jsipns"),{error:O.default("jsipns:error")}),j=c.identity.code,D=d.fromString("/ipns/"),M="/ipns/",x=M.length,B=async(e,t,r,i,n,s)=>{r=BigInt(r);const o=d.fromString(n.toString()),a=await z(e,t,i,o),c=L(t,o,i,r,s),u=q(c),l={value:t,signature:a,validityType:i,validity:o,sequence:r,ttl:s,signatureV2:await e.sign(u),data:c};return C(`ipns entry for ${t} created`),l},L=(e,t,r,i,n)=>{const s={Value:e,Validity:t,ValidityType:r,Sequence:i,TTL:n};return R.encode(s)},N=async(e,t)=>{const{value:r,validityType:i,validity:n}=t;let s,o,a;t.signatureV2&&t.data?(o=t.signatureV2,s=q(t.data),U(t)):(o=t.signature,s=V(r,i,n));try{a=await e.verify(s,o)}catch(e){a=!1}if(!a)throw C.error("record signature verification failed"),I.default(new Error("record signature verification failed"),w.ERR_SIGNATURE_VERIFICATION);if(i===b.IpnsEntry.ValidityType.EOL){let e;try{e=v.parseRFC3339(f.toString(n))}catch(e){throw C.error("unrecognized validity format (not an rfc3339 format)"),I.default(new Error("unrecognized validity format (not an rfc3339 format)"),w.ERR_UNRECOGNIZED_FORMAT)}if(e.getTime(){if(!e.data)throw I.default(new Error("Record data is missing"),w.ERR_INVALID_RECORD_DATA);const t=R.decode(e.data);if(Number.isInteger(t.Sequence)&&(t.Sequence=BigInt(t.Sequence)),Number.isInteger(t.TTL)&&(t.TTL=BigInt(t.TTL)),!p.equals(t.Value,e.value))throw I.default(new Error('Field "value" did not match between protobuf and CBOR'),w.ERR_SIGNATURE_VERIFICATION);if(!p.equals(t.Validity,e.validity))throw I.default(new Error('Field "validity" did not match between protobuf and CBOR'),w.ERR_SIGNATURE_VERIFICATION);if(t.ValidityType!==e.validityType)throw I.default(new Error('Field "validityType" did not match between protobuf and CBOR'),w.ERR_SIGNATURE_VERIFICATION);if(t.Sequence!==e.sequence)throw I.default(new Error('Field "sequence" did not match between protobuf and CBOR'),w.ERR_SIGNATURE_VERIFICATION);if(t.TTL!==e.ttl)throw I.default(new Error('Field "ttl" did not match between protobuf and CBOR'),w.ERR_SIGNATURE_VERIFICATION)},F=async(e,t)=>{if(!t||!e){const e=new Error("one or more of the provided parameters are not defined");throw C.error(e),I.default(e,w.ERR_UNDEFINED_PARAMETER)}let r;if(t.pubKey){try{r=T.default.keys.unmarshalPublicKey(t.pubKey)}catch(e){throw C.error(e),e}if(!(await A.default.createFromPubKey(t.pubKey)).equals(e))throw I.default(new Error("Embedded public key did not match PeerID"),w.ERR_INVALID_EMBEDDED_KEY)}else e.pubKey&&(r=e.pubKey);if(r)return r;throw I.default(new Error("no public key is available"),w.ERR_UNDEFINED_PARAMETER)},K=e=>l.base32upper.encode(e).slice(1),z=(e,t,r,i)=>{try{const n=V(t,r,i);return e.sign(n)}catch(e){throw C.error("record signature creation failed"),I.default(new Error("record signature creation failed: "+e.message),w.ERR_SIGNATURE_CREATION)}},V=(e,t,r)=>{const i=d.fromString((e=>{if("0"===e.toString())return"EOL";const t=new Error(`unrecognized validity type ${e.toString()}`);throw C.error(t),I.default(t,w.ERR_UNRECOGNIZED_VALIDITY)})(t));return h.concat([e,r,i])},q=e=>{const t=d.fromString("ipns-signature:");return h.concat([t,e])},G=e=>{const t=k.decode(e.id);return t.code!==j?null:T.default.keys.unmarshalPublicKey(t.digest)},H=e=>{const t=b.IpnsEntry.decode(e),r=b.IpnsEntry.toObject(t,{defaults:!1,arrays:!0,objects:!1});return{value:r.value,signature:r.signature,validityType:r.validityType,validity:r.validity,sequence:Object.hasOwnProperty.call(r,"sequence")?BigInt(`${r.sequence}`):0,pubKey:r.pubKey,ttl:Object.hasOwnProperty.call(r,"ttl")?BigInt(`${r.ttl}`):void 0,signatureV2:r.signatureV2,data:r.data}},$={validate:async(e,t)=>{const r=H(e),i=t.slice(D.length),n=A.default.createFromBytes(i),s=await F(n,r);await N(s,r)},select:(e,t)=>{const r=H(e),i=H(t);if(r.signatureV2&&!i.signatureV2)return 0;if(i.signatureV2&&!r.signatureV2)return 1;if(r.sequence>i.sequence)return 0;if(r.sequencen.getTime()?1:0}};r.create=(e,t,r,i)=>{const n=new S.default(Date.now()+Number(i)),s=b.IpnsEntry.ValidityType.EOL,[o,a]=i.toString().split("."),c=BigInt(o)*BigInt(1e5)+BigInt(a||0);return B(e,t,r,s,n,c)},r.createWithExpiration=(e,t,r,i)=>{const n=S.default.fromString(i),s=b.IpnsEntry.ValidityType.EOL,o=n.toDate().getTime()-Date.now(),a=BigInt(o)*BigInt(1e5)+BigInt(n.getNano());return B(e,t,r,s,n,a)},r.embedPublicKey=async(e,t)=>{if(!e||!e.bytes||!t){const e=new Error("one or more of the provided parameters are not defined");throw C.error(e),I.default(e,w.ERR_UNDEFINED_PARAMETER)}let r,i;try{r=await A.default.createFromPubKey(e.bytes)}catch(e){throw I.default(e,w.ERR_PEER_ID_FROM_PUBLIC_KEY)}try{i=G(r)}catch(e){throw C.error(e),I.default(e,w.ERR_PUBLIC_KEY_FROM_ID)}if(i)return null;try{t.pubKey=T.default.keys.marshalPublicKey(e)}catch(e){throw C.error(e),e}return t},r.extractPublicKey=F,r.getIdKeys=e=>{const t=d.fromString("/pk/"),r=d.fromString("/ipns/");return{routingPubKey:new n.Key(h.concat([t,e]),!1),pkKey:new n.Key(K(h.concat([t,e]))),routingKey:new n.Key(h.concat([r,e]),!1),ipnsKey:new n.Key(K(h.concat([r,e])))}},r.getLocalKey=e=>new n.Key(`/ipns/${K(e)}`),r.marshal=e=>b.IpnsEntry.encode({...e,sequence:P.default.fromString(e.sequence.toString()),ttl:null==e.ttl?void 0:P.default.fromString(e.ttl.toString())}).finish(),r.namespace=M,r.namespaceLength=x,r.unmarshal=H,r.validate=N,r.validator=$},{"timestamp-nano":"7gA2O","interface-datastore/key":"9hGOz","libp2p-crypto":"bb1cb","peer-id":"8Bdb3","multiformats/hashes/digest":"kpRBg","multiformats/hashes/identity":"eYCZn","err-code":"chZjB","multiformats/bases/base32":"5k9Tu","uint8arrays/from-string":"dF7Y4","uint8arrays/to-string":"hC8JB","uint8arrays/concat":"4EBjG","uint8arrays/equals":"eY3cX",cborg:"iZrkE",long:"lyrB6",debug:"bO5wM","./pb/ipns.js":"ayx1q","./utils.js":"kYcWW","./errors.js":"jtlhd"}],"7gA2O":[function(e,t,r){ /** * Timestamp for 64-bit time_t, nanosecond precision and strftime * * @author Yusuke Kawasaki * @license MIT * @see https://github.com/kawanet/timestamp-nano */ !function(){void 0!==t&&(t.exports=y);var e=86400,r=3200,i=1168776,n=100982246400,s=1e3*n,o=864e13,a=4294967296,c=1e6,u=1e9,l="000000000",d=Math.trunc||function(e){var t=e-e%1;return 0===t&&(e<0||0===e&&1/e!=1/0)?-0:t},f=y.prototype;y.fromDate=function(e){return new y(+e)},y.fromInt64BE=_(0,1,2,3,0,4),y.fromInt64LE=_(3,2,1,0,4,0),y.fromString=function(e){var t,r=new y,i=(e+="").replace(/^\s*[+\-]?\d+/,(function(e){var t=+e,i=1970+(t-1970)%400;return r.year=t-i,i})).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,(function(e,r,i){return r<0&&(i*=-1),t=6e4*(60*+r+ +i),""})).replace(/\.\d+$/,(function(e){return r.nano=+(e+l).substr(1,9),""})).split(/\D+/);i.length>1?i[1]--:i[1]=0;if(r.time=t=Date.UTC.apply(Date,i)-(t||0),isNaN(t))throw new TypeError("Invalid Date");return m(r)},y.fromTimeT=function(e){return v(e,0)},f.year=0,f.time=0,f.nano=0,f.addNano=function(e){return this.nano+=+e||0,this},f.getNano=function(){var e=m(this);return(e.time%1e3*c+ +e.nano+u)%u},f.getTimeT=function(){var t=m(this),n=Math.floor(t.time/1e3),s=t.year;s&&(n+=s*i*e/r);return n},f.getYear=function(){return this.toDate().getUTCFullYear()+this.year},f.toDate=function(){return b(m(this).time)},f.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},f.toString=function(e){var t=this,r=t.toDate(),i={H:function(){return S(r.getUTCHours())},L:function(){return T(r.getUTCMilliseconds(),3)},M:function(){return S(r.getUTCMinutes())},N:function(){return T(t.getNano(),9)},S:function(){return S(r.getUTCSeconds())},Y:function(){var e=t.getYear();return e>999999?"+"+e:e>9999?"+"+T(e,6):e>=0?T(e,4):e>=-999999?"-"+T(-e,6):e},a:function(){return p[r.getUTCDay()]},b:function(){return h[r.getUTCMonth()]},d:function(){return S(r.getUTCDate())},e:function(){return e=r.getUTCDate(),(e>9?"":" ")+(0|e);var e},m:function(){return S(r.getUTCMonth()+1)}};return function e(t){return t.replace(/%./g,(function(t){var r=t[1],n=g[r],s=i[r];return n?e(n):s?s():t}))}(e||"%Y-%m-%dT%H:%M:%S.%NZ")},f.writeInt64BE=w(0,1,2,3,0,4),f.writeInt64LE=w(3,2,1,0,4,0);var h=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],p=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],g={"%":"%",F:"%Y-%m-%d",n:"\n",R:"%H:%M",T:"%H:%M:%S",t:"\t",X:"%T",Z:"GMT",z:"+0000"};function y(e,t,r){var i=this;if(!(i instanceof y))return new y(e,t,r);i.time=+e||0,i.nano=+t||0,i.year=+r||0,m(i)}function m(e){var t,i,n=e.year,a=e.time,u=e.nano;if(u<0||c<=u){var l=Math.floor(u/c);u-=l*c,a+=l,t=1}var f=n%r;if(a<-o||o>24&255,n[s+t]=o>>16&255,n[s+r]=o>>8&255,n[s+i]=255&o}}function _(e,t,r,i,n,s){return function(e,t){E(e,t|=0);var r=o(e,t+n);return v(o(e,t+s),r)};function o(n,s){return 16777216*n[s+e]+(n[s+t]<<16|n[s+r]<<8|n[s+i])}}function E(e,t){var r=e&&e.length;if(null==r)throw new TypeError("Invalid Buffer");if(r9?"":"0")+(0|e)}function T(e,t){return(l+(0|e)).substr(-t)}}()},{}],bb1cb:[function(e,t,r){"use strict";const i=e("./hmac"),n=e("./aes"),s=e("./keys");r.aes=n,r.hmac=i,r.keys=s,r.randomBytes=e("./random-bytes"),r.pbkdf2=e("./pbkdf2")},{"./hmac":"JUsR3","./aes":"haaCU","./keys":"kWJWg","./random-bytes":"gsnuW","./pbkdf2":"jWCQX"}],haaCU:[function(e,t,r){"use strict";const i=e("./ciphers"),n=e("./cipher-mode");r.create=async function(e,t){const r=n(e),s=i.createCipheriv(r,e,t),o=i.createDecipheriv(r,e,t);return{encrypt:async e=>s.update(e),decrypt:async e=>o.update(e)}}},{"./ciphers":"dBWnA","./cipher-mode":"aT0PA"}],dBWnA:[function(e,t,r){"use strict";e("node-forge/lib/aes");const i=e("node-forge/lib/forge"),{toString:n}=e("uint8arrays/to-string"),{fromString:s}=e("uint8arrays/from-string");t.exports={createCipheriv:(e,t,r)=>{const o=i.cipher.createCipher("AES-CTR",n(t,"ascii"));return o.start({iv:n(r,"ascii")}),{update:e=>(o.update(i.util.createBuffer(n(e,"ascii"))),s(o.output.getBytes(),"ascii"))}},createDecipheriv:(e,t,r)=>{const o=i.cipher.createDecipher("AES-CTR",n(t,"ascii"));return o.start({iv:n(r,"ascii")}),{update:e=>(o.update(i.util.createBuffer(n(e,"ascii"))),s(o.output.getBytes(),"ascii"))}}}},{"node-forge/lib/aes":"1SAd7","node-forge/lib/forge":"4OuPD","uint8arrays/to-string":"hC8JB","uint8arrays/from-string":"dF7Y4"}],aT0PA:[function(e,t,r){"use strict";const i=e("err-code"),n={16:"aes-128-ctr",32:"aes-256-ctr"};t.exports=function(e){const t=n[e.length];if(!t){const t=Object.entries(n).map((([e,t])=>`${e} (${t})`)).join(" / ");throw i(new Error(`Invalid key length ${e.length} bytes. Must be ${t}`),"ERR_INVALID_KEY_LENGTH")}return t}},{"err-code":"chZjB"}],jWCQX:[function(e,t,r){"use strict";const i=e("node-forge/lib/pbkdf2"),n=e("node-forge/lib/util"),s=e("err-code"),o={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};t.exports=function(e,t,r,a,c){const u=o[c];if(!u){const e=Object.keys(o).join(" / ");throw s(new Error(`Hash '${c}' is unknown or not supported. Must be ${e}`),"ERR_UNSUPPORTED_HASH_TYPE")}const l=i(e,t,r,a,u);return n.encode64(l)}},{"node-forge/lib/pbkdf2":"j1TyX","node-forge/lib/util":"df43p","err-code":"chZjB"}],lyrB6:[function(e,t,r){t.exports=n;var i=null;try{i=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(e){}function n(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}function s(e){return!0===(e&&e.__isLong__)}n.prototype.__isLong__,Object.defineProperty(n.prototype,"__isLong__",{value:!0}),n.isLong=s;var o={},a={};function c(e,t){var r,i,n;return t?(n=0<=(e>>>=0)&&e<256)&&(i=a[e])?i:(r=l(e,(0|e)<0?-1:0,!0),n&&(a[e]=r),r):(n=-128<=(e|=0)&&e<128)&&(i=o[e])?i:(r=l(e,e<0?-1:0,!1),n&&(o[e]=r),r)}function u(e,t){if(isNaN(e))return t?v:b;if(t){if(e<0)return v;if(e>=g)return T}else{if(e<=-y)return A;if(e+1>=y)return S}return e<0?u(-e,t).neg():l(e%p|0,e/p|0,t)}function l(e,t,r){return new n(e,t,r)}n.fromInt=c,n.fromNumber=u,n.fromBits=l;var d=Math.pow;function f(e,t,r){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return b;if("number"==typeof t?(r=t,t=!1):t=!!t,(r=r||10)<2||360)throw Error("interior hyphen");if(0===i)return f(e.substring(1),t,r).neg();for(var n=u(d(r,8)),s=b,o=0;o>>0:this.low},k.toNumber=function(){return this.unsigned?(this.high>>>0)*p+(this.low>>>0):this.high*p+(this.low>>>0)},k.toString=function(e){if((e=e||10)<2||36>>0).toString(e);if((s=a).isZero())return c+o;for(;c.length<6;)c="0"+c;o=""+c+o}},k.getHighBits=function(){return this.high},k.getHighBitsUnsigned=function(){return this.high>>>0},k.getLowBits=function(){return this.low},k.getLowBitsUnsigned=function(){return this.low>>>0},k.getNumBitsAbs=function(){if(this.isNegative())return this.eq(A)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<=0},k.isOdd=function(){return 1==(1&this.low)},k.isEven=function(){return 0==(1&this.low)},k.equals=function(e){return s(e)||(e=h(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},k.eq=k.equals,k.notEquals=function(e){return!this.eq(e)},k.neq=k.notEquals,k.ne=k.notEquals,k.lessThan=function(e){return this.comp(e)<0},k.lt=k.lessThan,k.lessThanOrEqual=function(e){return this.comp(e)<=0},k.lte=k.lessThanOrEqual,k.le=k.lessThanOrEqual,k.greaterThan=function(e){return this.comp(e)>0},k.gt=k.greaterThan,k.greaterThanOrEqual=function(e){return this.comp(e)>=0},k.gte=k.greaterThanOrEqual,k.ge=k.greaterThanOrEqual,k.compare=function(e){if(s(e)||(e=h(e)),this.eq(e))return 0;var t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},k.comp=k.compare,k.negate=function(){return!this.unsigned&&this.eq(A)?A:this.not().add(w)},k.neg=k.negate,k.add=function(e){s(e)||(e=h(e));var t=this.high>>>16,r=65535&this.high,i=this.low>>>16,n=65535&this.low,o=e.high>>>16,a=65535&e.high,c=e.low>>>16,u=0,d=0,f=0,p=0;return f+=(p+=n+(65535&e.low))>>>16,d+=(f+=i+c)>>>16,u+=(d+=r+a)>>>16,u+=t+o,l((f&=65535)<<16|(p&=65535),(u&=65535)<<16|(d&=65535),this.unsigned)},k.subtract=function(e){return s(e)||(e=h(e)),this.add(e.neg())},k.sub=k.subtract,k.multiply=function(e){if(this.isZero())return b;if(s(e)||(e=h(e)),i)return l(i.mul(this.low,this.high,e.low,e.high),i.get_high(),this.unsigned);if(e.isZero())return b;if(this.eq(A))return e.isOdd()?A:b;if(e.eq(A))return this.isOdd()?A:b;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(m)&&e.lt(m))return u(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,r=65535&this.high,n=this.low>>>16,o=65535&this.low,a=e.high>>>16,c=65535&e.high,d=e.low>>>16,f=65535&e.low,p=0,g=0,y=0,v=0;return y+=(v+=o*f)>>>16,g+=(y+=n*f)>>>16,y&=65535,g+=(y+=o*d)>>>16,p+=(g+=r*f)>>>16,g&=65535,p+=(g+=n*d)>>>16,g&=65535,p+=(g+=o*c)>>>16,p+=t*f+r*d+n*c+o*a,l((y&=65535)<<16|(v&=65535),(p&=65535)<<16|(g&=65535),this.unsigned)},k.mul=k.multiply,k.divide=function(e){if(s(e)||(e=h(e)),e.isZero())throw Error("division by zero");var t,r,n;if(i)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?l((this.unsigned?i.div_u:i.div_s)(this.low,this.high,e.low,e.high),i.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?v:b;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return v;if(e.gt(this.shru(1)))return _;n=v}else{if(this.eq(A))return e.eq(w)||e.eq(E)?A:e.eq(A)?w:(t=this.shr(1).div(e).shl(1)).eq(b)?e.isNegative()?w:E:(r=this.sub(e.mul(t)),n=t.add(r.div(e)));if(e.eq(A))return this.unsigned?v:b;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();n=b}for(r=this;r.gte(e);){t=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var o=Math.ceil(Math.log(t)/Math.LN2),a=o<=48?1:d(2,o-48),c=u(t),f=c.mul(e);f.isNegative()||f.gt(r);)f=(c=u(t-=a,this.unsigned)).mul(e);c.isZero()&&(c=w),n=n.add(c),r=r.sub(f)}return n},k.div=k.divide,k.modulo=function(e){return s(e)||(e=h(e)),i?l((this.unsigned?i.rem_u:i.rem_s)(this.low,this.high,e.low,e.high),i.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},k.mod=k.modulo,k.rem=k.modulo,k.not=function(){return l(~this.low,~this.high,this.unsigned)},k.and=function(e){return s(e)||(e=h(e)),l(this.low&e.low,this.high&e.high,this.unsigned)},k.or=function(e){return s(e)||(e=h(e)),l(this.low|e.low,this.high|e.high,this.unsigned)},k.xor=function(e){return s(e)||(e=h(e)),l(this.low^e.low,this.high^e.high,this.unsigned)},k.shiftLeft=function(e){return s(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?l(this.low<>>32-e,this.unsigned):l(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):l(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},k.shr=k.shiftRight,k.shiftRightUnsigned=function(e){if(s(e)&&(e=e.toInt()),0===(e&=63))return this;var t=this.high;return e<32?l(this.low>>>e|t<<32-e,t>>>e,this.unsigned):l(32===e?t:t>>>e-32,0,this.unsigned)},k.shru=k.shiftRightUnsigned,k.shr_u=k.shiftRightUnsigned,k.toSigned=function(){return this.unsigned?l(this.low,this.high,!1):this},k.toUnsigned=function(){return this.unsigned?this:l(this.low,this.high,!0)},k.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},k.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},k.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},n.fromBytes=function(e,t,r){return r?n.fromBytesLE(e,t):n.fromBytesBE(e,t)},n.fromBytesLE=function(e,t){return new n(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},n.fromBytesBE=function(e,t){return new n(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}},{}],ayx1q:[function(e,t,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(r,"__esModule",{value:!0});var n=i(e("protobufjs/minimal.js"));const s=n.default.Reader,o=n.default.Writer,a=n.default.util,c=n.default.roots["ipfs-ipns"]||(n.default.roots["ipfs-ipns"]={}),u=c.IpnsEntry=(()=>{function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:i.value=e.bytes();break;case 2:i.signature=e.bytes();break;case 3:i.validityType=e.int32();break;case 4:i.validity=e.bytes();break;case 5:i.sequence=e.uint64();break;case 6:i.ttl=e.uint64();break;case 7:i.pubKey=e.bytes();break;case 8:i.signatureV2=e.bytes();break;case 9:i.data=e.bytes();break;default:e.skipType(7&n)}}return i},e.fromObject=function(e){if(e instanceof c.IpnsEntry)return e;var t=new c.IpnsEntry;switch(null!=e.value&&("string"==typeof e.value?a.base64.decode(e.value,t.value=a.newBuffer(a.base64.length(e.value)),0):e.value.length&&(t.value=e.value)),null!=e.signature&&("string"==typeof e.signature?a.base64.decode(e.signature,t.signature=a.newBuffer(a.base64.length(e.signature)),0):e.signature.length&&(t.signature=e.signature)),e.validityType){case"EOL":case 0:t.validityType=0}return null!=e.validity&&("string"==typeof e.validity?a.base64.decode(e.validity,t.validity=a.newBuffer(a.base64.length(e.validity)),0):e.validity.length&&(t.validity=e.validity)),null!=e.sequence&&(a.Long?(t.sequence=a.Long.fromValue(e.sequence)).unsigned=!0:"string"==typeof e.sequence?t.sequence=parseInt(e.sequence,10):"number"==typeof e.sequence?t.sequence=e.sequence:"object"==typeof e.sequence&&(t.sequence=new a.LongBits(e.sequence.low>>>0,e.sequence.high>>>0).toNumber(!0))),null!=e.ttl&&(a.Long?(t.ttl=a.Long.fromValue(e.ttl)).unsigned=!0:"string"==typeof e.ttl?t.ttl=parseInt(e.ttl,10):"number"==typeof e.ttl?t.ttl=e.ttl:"object"==typeof e.ttl&&(t.ttl=new a.LongBits(e.ttl.low>>>0,e.ttl.high>>>0).toNumber(!0))),null!=e.pubKey&&("string"==typeof e.pubKey?a.base64.decode(e.pubKey,t.pubKey=a.newBuffer(a.base64.length(e.pubKey)),0):e.pubKey.length&&(t.pubKey=e.pubKey)),null!=e.signatureV2&&("string"==typeof e.signatureV2?a.base64.decode(e.signatureV2,t.signatureV2=a.newBuffer(a.base64.length(e.signatureV2)),0):e.signatureV2.length&&(t.signatureV2=e.signatureV2)),null!=e.data&&("string"==typeof e.data?a.base64.decode(e.data,t.data=a.newBuffer(a.base64.length(e.data)),0):e.data.length&&(t.data=e.data)),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults){if(t.bytes===String?r.value="":(r.value=[],t.bytes!==Array&&(r.value=a.newBuffer(r.value))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=a.newBuffer(r.signature))),r.validityType=t.enums===String?"EOL":0,t.bytes===String?r.validity="":(r.validity=[],t.bytes!==Array&&(r.validity=a.newBuffer(r.validity))),a.Long){var i=new a.Long(0,0,!0);r.sequence=t.longs===String?i.toString():t.longs===Number?i.toNumber():i}else r.sequence=t.longs===String?"0":0;if(a.Long){i=new a.Long(0,0,!0);r.ttl=t.longs===String?i.toString():t.longs===Number?i.toNumber():i}else r.ttl=t.longs===String?"0":0;t.bytes===String?r.pubKey="":(r.pubKey=[],t.bytes!==Array&&(r.pubKey=a.newBuffer(r.pubKey))),t.bytes===String?r.signatureV2="":(r.signatureV2=[],t.bytes!==Array&&(r.signatureV2=a.newBuffer(r.signatureV2))),t.bytes===String?r.data="":(r.data=[],t.bytes!==Array&&(r.data=a.newBuffer(r.data)))}return null!=e.value&&e.hasOwnProperty("value")&&(r.value=t.bytes===String?a.base64.encode(e.value,0,e.value.length):t.bytes===Array?Array.prototype.slice.call(e.value):e.value),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?a.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),null!=e.validityType&&e.hasOwnProperty("validityType")&&(r.validityType=t.enums===String?c.IpnsEntry.ValidityType[e.validityType]:e.validityType),null!=e.validity&&e.hasOwnProperty("validity")&&(r.validity=t.bytes===String?a.base64.encode(e.validity,0,e.validity.length):t.bytes===Array?Array.prototype.slice.call(e.validity):e.validity),null!=e.sequence&&e.hasOwnProperty("sequence")&&("number"==typeof e.sequence?r.sequence=t.longs===String?String(e.sequence):e.sequence:r.sequence=t.longs===String?a.Long.prototype.toString.call(e.sequence):t.longs===Number?new a.LongBits(e.sequence.low>>>0,e.sequence.high>>>0).toNumber(!0):e.sequence),null!=e.ttl&&e.hasOwnProperty("ttl")&&("number"==typeof e.ttl?r.ttl=t.longs===String?String(e.ttl):e.ttl:r.ttl=t.longs===String?a.Long.prototype.toString.call(e.ttl):t.longs===Number?new a.LongBits(e.ttl.low>>>0,e.ttl.high>>>0).toNumber(!0):e.ttl),null!=e.pubKey&&e.hasOwnProperty("pubKey")&&(r.pubKey=t.bytes===String?a.base64.encode(e.pubKey,0,e.pubKey.length):t.bytes===Array?Array.prototype.slice.call(e.pubKey):e.pubKey),null!=e.signatureV2&&e.hasOwnProperty("signatureV2")&&(r.signatureV2=t.bytes===String?a.base64.encode(e.signatureV2,0,e.signatureV2.length):t.bytes===Array?Array.prototype.slice.call(e.signatureV2):e.signatureV2),null!=e.data&&e.hasOwnProperty("data")&&(r.data=t.bytes===String?a.base64.encode(e.data,0,e.data.length):t.bytes===Array?Array.prototype.slice.call(e.data):e.data),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,n.default.util.toJSONOptions)},e.ValidityType=function(){const e={},t=Object.create(e);return t[e[0]="EOL"]=0,t}(),e})();r.IpnsEntry=u,r.default=c},{"protobufjs/minimal.js":"grAXL"}],kYcWW:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.parseRFC3339=function(e){const t=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),r=String(e).trim().match(t);if(!r)throw new Error("Invalid format");const i=parseInt(r[1],10),n=parseInt(r[2],10)-1,s=parseInt(r[3],10),o=parseInt(r[4],10),a=parseInt(r[5],10),c=parseInt(r[6],10),u=parseInt(r[7].slice(0,-6),10);return new Date(Date.UTC(i,n,s,o,a,c,u))},r.toRFC3339=function(e){return`${e.getUTCFullYear()}-${String(e.getUTCMonth()+1).padStart(2,"0")}-${String(e.getUTCDate()).padStart(2,"0")}T${String(e.getUTCHours()).padStart(2,"0")}:${String(e.getUTCMinutes()).padStart(2,"0")}:${String(e.getUTCSeconds()).padStart(2,"0")}.${1e6*e.getUTCMilliseconds()}Z`}},{}],jtlhd:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.ERR_INVALID_EMBEDDED_KEY="ERR_INVALID_EMBEDDED_KEY",r.ERR_INVALID_RECORD_DATA="ERR_INVALID_RECORD_DATA",r.ERR_IPNS_EXPIRED_RECORD="ERR_IPNS_EXPIRED_RECORD",r.ERR_PEER_ID_FROM_PUBLIC_KEY="ERR_PEER_ID_FROM_PUBLIC_KEY",r.ERR_PUBLIC_KEY_FROM_ID="ERR_PUBLIC_KEY_FROM_ID",r.ERR_SIGNATURE_CREATION="ERR_SIGNATURE_CREATION",r.ERR_SIGNATURE_VERIFICATION="ERR_SIGNATURE_VERIFICATION",r.ERR_UNDEFINED_PARAMETER="ERR_UNDEFINED_PARAMETER",r.ERR_UNRECOGNIZED_FORMAT="ERR_UNRECOGNIZED_FORMAT",r.ERR_UNRECOGNIZED_VALIDITY="ERR_UNRECOGNIZED_VALIDITY"},{}],hoedq:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipns"),n=e("libp2p-crypto"),s=e("peer-id"),o=e("err-code"),a=e("debug");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function u(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var l=u(i),d=c(n),f=c(s),h=c(o),p=c(a);const g=Object.assign(p.default("ipfs:ipns:republisher"),{error:p.default("ipfs:ipns:republisher:error")});r.IpnsRepublisher=class{constructor(e,t,r,i,n={pass:""}){this._publisher=e,this._datastore=t,this._peerId=r,this._keychain=i,this._options=n,this._republishHandle=null}async start(){if(this._republishHandle)throw h.default(new Error("republisher is already running"),"ERR_REPUBLISH_ALREADY_RUNNING");const e={_task:null,_inflightTask:null,_timeoutId:null,runPeriodically:t=>{e._timeoutId=setTimeout((async()=>{e._timeoutId=null;try{e._inflightTask=e._task(),await e._inflightTask,e._task&&e.runPeriodically(t)}catch(e){g.error(e)}}),t())},cancel:async()=>{null!=e._timeoutId&&clearTimeout(e._timeoutId),e._task=null,await e._inflightTask}},{privKey:t}=this._peerId,{pass:r}=this._options;let i=!0;e._task=()=>this._republishEntries(t,r),e.runPeriodically((()=>i?(i=!1,this._options.initialBroadcastInterval||6e4):this._options.broadcastInterval||144e5)),this._republishHandle=e}async stop(){const e=this._republishHandle;if(!e)throw h.default(new Error("republisher is not running"),"ERR_REPUBLISH_NOT_RUNNING");this._republishHandle=null,await e.cancel()}async _republishEntries(e,t){try{await this._republishEntry(e)}catch(e){const t="cannot republish entry for the node's private key";return void g.error(t)}if(t)try{const e=await this._keychain.listKeys();for(const r of e){if("self"===r.name)continue;const e=await this._keychain.exportKey(r.name,t),i=await d.default.keys.import(e,t);await this._republishEntry(i)}}catch(e){g.error(e)}}async _republishEntry(e){if(!e||!e.bytes)throw h.default(new Error("invalid private key"),"ERR_INVALID_PRIVATE_KEY");try{const t=await f.default.createFromPrivKey(e.bytes),r=await this._getPreviousValue(t);await this._publisher.publishWithEOL(e,r,864e5)}catch(e){if("ERR_NO_ENTRY_FOUND"===e.code)return;throw e}}async _getPreviousValue(e){if(!f.default.isPeerId(e))throw h.default(new Error("invalid peer ID"),"ERR_INVALID_PEER_ID");try{const t=await this._datastore.get(l.getLocalKey(e.id));if(!(t instanceof Uint8Array))throw h.default(new Error("found ipns record that we couldn't process"),"ERR_INVALID_IPNS_RECORD");try{return l.unmarshal(t).value}catch(e){throw g.error(e),h.default(new Error("found ipns record that we couldn't convert to a value"),"ERR_INVALID_IPNS_RECORD")}}catch(t){if(t&&t.notFound)throw h.default(new Error(`no previous entry for record with id: ${e.id}`),"ERR_NO_ENTRY_FOUND");throw t}}}},{ipns:"7rNAT","libp2p-crypto":"bb1cb","peer-id":"8Bdb3","err-code":"chZjB",debug:"bO5wM"}],gifOE:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipns"),n=e("peer-id"),s=e("err-code"),o=e("debug"),a=e("uint8arrays/to-string"),c=e("datastore-core/errors");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var d=l(i),f=u(n),h=u(s),p=u(o),g=l(c);const y=Object.assign(p.default("ipfs:ipns:resolver"),{error:p.default("ipfs:ipns:resolver:error")}),m=g.notFoundError().code;r.IpnsResolver=class{constructor(e){this._routing=e}async resolve(e,t={}){if("string"!=typeof e)throw h.default(new Error("invalid name"),"ERR_INVALID_NAME");const r=t.recursive&&"true"===t.recursive.toString(),i=e.split("/");if(3!==i.length||""!==i[0])throw h.default(new Error("invalid name"),"ERR_INVALID_NAME");const n=i[2];let s=1/0;r&&(s=32);const o=await this.resolver(n,s);return y(`${e} was locally resolved correctly`),o}async resolver(e,t){if(0===t){const e="could not resolve name (recursion limit of 32 exceeded)";throw y.error(e),h.default(new Error(e),"ERR_RESOLVE_RECURSION_LIMIT")}const r=await this._resolveName(e),i=r.split("/");return"ipfs"!==i[1]&&t?this.resolver(i[2],t-1):r}async _resolveName(e){const t=f.default.parse(e),{routingKey:r}=d.getIdKeys(t.toBytes());let i,n;try{i=await this._routing.get(r.uint8Array())}catch(r){if(y.error("could not get record from routing",r),r.code===m)throw h.default(new Error(`record requested for ${e} was not found in the network`),"ERR_NO_RECORD_FOUND");throw h.default(new Error(`unexpected error getting the ipns record ${t.toString()}`),"ERR_UNEXPECTED_ERROR_GETTING_RECORD")}try{n=d.unmarshal(i)}catch(e){throw y.error("could not unmarshal record",e),h.default(new Error("found ipns record that we couldn't convert to a value"),"ERR_INVALID_RECORD_RECEIVED")}return this._validateRecord(t,n)}async _validateRecord(e,t){const r=await d.extractPublicKey(e,t);return await d.validate(r,t),a.toString(t.value)}}},{ipns:"7rNAT","peer-id":"8Bdb3","err-code":"chZjB",debug:"bO5wM","uint8arrays/to-string":"hC8JB","datastore-core/errors":"65M4b"}],lQE1u:[function(e,t,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(r,"__esModule",{value:!0});var n=i(e("hashlru"));r.TLRU=class{constructor(e){this.lru=n.default(e)}get(e){const t=this.lru.get(e);if(t)return t.expire&&t.expiree.open())))}catch(e){throw n.dbOpenFailedError()}}async put(e,t){try{await Promise.all(this.stores.map((r=>r.put(e,t))))}catch(e){throw n.dbWriteFailedError()}}async get(e,t){for(const r of this.stores)try{const i=await r.get(e,t);if(i)return i}catch(e){f(e)}throw n.notFoundError()}async has(e,t){for(const r of this.stores)if(await r.has(e,t))return!0;return!1}async delete(e,t){try{await Promise.all(this.stores.map((r=>r.delete(e,t))))}catch(e){throw n.dbDeleteFailedError()}}async*putMany(e,t={}){let r;const i=this.stores.map((e=>{const i=l.default();return d.default(e.putMany(i,t)).catch((e=>{r=e})),i}));try{for await(const t of e){if(r)throw r;i.forEach((e=>e.push(t))),yield t}}finally{i.forEach((e=>e.end()))}}async*deleteMany(e,t={}){let r;const i=this.stores.map((e=>{const i=l.default();return d.default(e.deleteMany(i,t)).catch((e=>{r=e})),i}));try{for await(const t of e){if(r)throw r;i.forEach((e=>e.push(t))),yield t}}finally{i.forEach((e=>e.end()))}}async close(){await Promise.all(this.stores.map((e=>e.close())))}batch(){const e=this.stores.map((e=>e.batch()));return{put:(t,r)=>{e.forEach((e=>e.put(t,r)))},delete:t=>{e.forEach((e=>e.delete(t)))},commit:async t=>{for(const r of e)await r.commit(t)}}}query(e,t){return this.stores[this.stores.length-1].query(e,t)}queryKeys(e,t){return this.stores[this.stores.length-1].queryKeys(e,t)}}r.TieredDatastore=h},{"./base.js":"b5lsk","./errors.js":"65M4b",debug:"bO5wM","it-pushable":"bnpei","it-drain":"dKYhO"}],b5lsk:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./utils.js"),n=e("it-drain"),s=e("it-filter"),o=e("it-take");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=a(n),u=a(s),l=a(o);r.BaseDatastore=class{open(){return Promise.reject(new Error(".open is not implemented"))}close(){return Promise.reject(new Error(".close is not implemented"))}put(e,t,r){return Promise.reject(new Error(".put is not implemented"))}get(e,t){return Promise.reject(new Error(".get is not implemented"))}has(e,t){return Promise.reject(new Error(".has is not implemented"))}delete(e,t){return Promise.reject(new Error(".delete is not implemented"))}async*putMany(e,t={}){for await(const{key:r,value:i}of e)await this.put(r,i,t),yield{key:r,value:i}}async*getMany(e,t={}){for await(const r of e)yield this.get(r,t)}async*deleteMany(e,t={}){for await(const r of e)await this.delete(r,t),yield r}batch(){let e=[],t=[];return{put(t,r){e.push({key:t,value:r})},delete(e){t.push(e)},commit:async r=>{await c.default(this.putMany(e,r)),e=[],await c.default(this.deleteMany(t,r)),t=[]}}}async*_all(e,t){throw new Error("._all is not implemented")}async*_allKeys(e,t){throw new Error("._allKeys is not implemented")}query(e,t){let r=this._all(e,t);if(null!=e.prefix&&(r=u.default(r,(t=>t.key.toString().startsWith(e.prefix)))),Array.isArray(e.filters)&&(r=e.filters.reduce(((e,t)=>u.default(e,t)),r)),Array.isArray(e.orders)&&(r=e.orders.reduce(((e,t)=>i.sortAll(e,t)),r)),null!=e.offset){let t=0;r=u.default(r,(()=>t++>=e.offset))}return null!=e.limit&&(r=l.default(r,e.limit)),r}queryKeys(e,t){let r=this._allKeys(e,t);if(null!=e.prefix&&(r=u.default(r,(t=>t.toString().startsWith(e.prefix)))),Array.isArray(e.filters)&&(r=e.filters.reduce(((e,t)=>u.default(e,t)),r)),Array.isArray(e.orders)&&(r=e.orders.reduce(((e,t)=>i.sortAll(e,t)),r)),null!=e.offset){let t=0;r=u.default(r,(()=>t++>=e.offset))}return null!=e.limit&&(r=l.default(r,e.limit)),r}}},{"./utils.js":"hJ8tG","it-drain":"dKYhO","it-filter":"5LCTL","it-take":"gxr1t"}],hJ8tG:[function(e,t,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(r,"__esModule",{value:!0});var n=i(e("it-all"));r.replaceStartWith=(e,t)=>{const r=new RegExp("^"+t);return e.replace(r,"")},r.sortAll=(e,t)=>async function*(){const r=await n.default(e);yield*r.sort(t)}()},{"it-all":"iCXBu"}],iCXBu:[function(e,t,r){"use strict";t.exports=async e=>{const t=[];for await(const r of e)t.push(r);return t}},{}],dKYhO:[function(e,t,r){"use strict";t.exports=async e=>{for await(const t of e);}},{}],"5LCTL":[function(e,t,r){"use strict";t.exports=async function*(e,t){for await(const r of e)await t(r)&&(yield r)}},{}],gxr1t:[function(e,t,r){"use strict";t.exports=async function*(e,t){let r=0;if(!(t<1))for await(const i of e)if(yield i,r++,r===t)return}},{}],bnpei:[function(e,t,r){const i=e("fast-fifo");t.exports=e=>{let t;"function"==typeof(e=e||{})?(t=e,e={}):t=e.onEnd;let r,n,s,o=new i;const a=e=>n?n(e):(o.push(e),r),c=e=>s?r:a({done:!1,value:e}),u=e=>s?r:(s=!0,e?(e=>(o=new i,n?n({error:e}):(o.push({error:e}),r)))(e):a({done:!0}));if(r={[Symbol.asyncIterator](){return this},next:()=>{if(!o.isEmpty()){if(e.writev){let e;const t=[];for(;!o.isEmpty();){if(e=o.shift(),e.error)throw e.error;t.push(e.value)}return{done:e.done,value:t}}const t=o.shift();if(t.error)throw t.error;return t}return s?{done:!0}:new Promise(((t,i)=>{n=s=>(n=null,s.error?i(s.error):e.writev&&!s.done?t({done:s.done,value:[s.value]}):t(s),r)}))},return:()=>(o=new i,u(),{done:!0}),throw:e=>(u(e),{done:!0}),push:c,end:u},!t)return r;const l=r;return r={[Symbol.asyncIterator](){return this},next:()=>l.next(),throw:e=>(l.throw(e),t&&(t(e),t=null),{done:!0}),return:()=>(l.return(),t&&(t(),t=null),{done:!0}),push:c,end:e=>(l.end(e),t&&(t(e),t=null),r)},r}},{"fast-fifo":"8Ws5O"}],"8Ws5O":[function(e,t,r){const i=e("./fixed-size");t.exports=class{constructor(e){this.hwm=e||16,this.head=new i(this.hwm),this.tail=this.head}push(e){if(!this.head.push(e)){const t=this.head;this.head=t.next=new i(2*this.head.buffer.length),this.head.push(e)}}shift(){const e=this.tail.shift();if(void 0===e&&this.tail.next){const e=this.tail.next;return this.tail.next=null,this.tail=e,this.tail.shift()}return e}isEmpty(){return this.head.isEmpty()}}},{"./fixed-size":"2lgNg"}],"2lgNg":[function(e,t,r){t.exports=class{constructor(e){if(!(e>0)||0!=(e-1&e))throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){const e=this.buffer[this.btm];if(void 0!==e)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return void 0===this.buffer[this.btm]}}},{}],hp0pQ:[function(e,t,r){var i;i=this,"object"==typeof r&&void 0!==t?t.exports=function(e,t,r,i,n){for(t=t.split?t.split("."):t,i=0;i`${f.namespace}${e}`))}async cancel(e){if("string"!=typeof e)throw h.default(new Error("invalid subscription name"),"ERR_INVALID_SUBSCRIPTION_NAME");e.startsWith(f.namespace)&&(e=e.substring(f.namespaceLength));const t=Object.keys(this._subscriptions).find((t=>this._subscriptions[t]===e));if(!t)return{canceled:!1};const r=o.fromString(t);return this._pubsubDs.unsubscribe(r),delete this._subscriptions[t],g(`unsubscribed pubsub ${t}: ${e}`),{canceled:!0}}}},{ipns:"7rNAT","multiformats/bases/base58":"4n7mA","datastore-pubsub":"12I4Q","uint8arrays/from-string":"dF7Y4","uint8arrays/to-string":"hC8JB","err-code":"chZjB",debug:"bO5wM"}],"12I4Q":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("interface-datastore"),n=e("datastore-core"),s=e("./utils.js"),o=e("uint8arrays/equals"),a=e("err-code"),c=e("debug");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=u(a),d=u(c);const f=Object.assign(d.default("datastore-pubsub:publisher"),{error:d.default("datastore-pubsub:publisher:error")});class h extends n.BaseDatastore{constructor(e,t,r,i,n){if(super(),!i)throw l.default(new TypeError("missing validator"),"ERR_INVALID_PARAMETERS");if("function"!=typeof i.validate)throw l.default(new TypeError("missing validate function"),"ERR_INVALID_PARAMETERS");if("function"!=typeof i.select)throw l.default(new TypeError("missing select function"),"ERR_INVALID_PARAMETERS");if(n&&"function"!=typeof n)throw l.default(new TypeError("invalid subscriptionKeyFn received"),"ERR_INVALID_PARAMETERS");this._pubsub=e,this._datastore=t,this._peerId=r,this._validator=i,this._handleSubscriptionKeyFn=n,this._onMessage=this._onMessage.bind(this)}async put(e,t){if(!(e instanceof Uint8Array)){const e="datastore key does not have a valid format";throw f.error(e),l.default(new Error(e),"ERR_INVALID_DATASTORE_KEY")}if(!(t instanceof Uint8Array)){const e="received value is not a Uint8Array";throw f.error(e),l.default(new Error(e),"ERR_INVALID_VALUE_RECEIVED")}const r=s.keyToTopic(e);f(`publish value for topic ${r}`),await this._pubsub.publish(r,t)}async get(e){if(!(e instanceof Uint8Array)){const e="datastore key does not have a valid format";throw f.error(e),l.default(new Error(e),"ERR_INVALID_DATASTORE_KEY")}const t=s.keyToTopic(e),r=await this._pubsub.getTopics();if(r&&Array.isArray(r)&&r.indexOf(t)>-1)return this._getLocal(e);try{this._pubsub.on(t,this._onMessage),await this._pubsub.subscribe(t)}catch(e){const r=`cannot subscribe topic ${t}`;throw f.error(r),l.default(new Error(r),"ERR_SUBSCRIBING_TOPIC")}return f(`subscribed values for key ${t}`),this._getLocal(e)}unsubscribe(e){const t=s.keyToTopic(e);return this._pubsub.removeListener(t,this._onMessage),this._pubsub.unsubscribe(t)}async _getLocal(e){const t=new i.Key("/"+s.encodeBase32(e),!1);let r;try{r=await this._datastore.get(t)}catch(e){if("ERR_NOT_FOUND"!==e.code){const e=`unexpected error getting the ipns record for ${t.toString()}`;throw f.error(e),l.default(new Error(e),"ERR_UNEXPECTED_ERROR_GETTING_RECORD")}const r=`local record requested was not found for ${t.toString()}`;throw f.error(r),l.default(new Error(r),"ERR_NOT_FOUND")}if(!(r instanceof Uint8Array)){const e="found record that we couldn't convert to a value";throw f.error(e),l.default(new Error(e),"ERR_INVALID_RECORD_RECEIVED")}return r}async _onMessage(e){const{data:t,from:r,topicIDs:i}=e;let n;try{n=s.topicToKey(i[0])}catch(e){return void f.error(e)}if(f(`message received for topic ${i[0]}`),r!==this._peerId.toB58String()){if(this._handleSubscriptionKeyFn){let e;try{e=await this._handleSubscriptionKeyFn(n)}catch(e){return void f.error("message discarded by the subscriptionKeyFn")}n=e}try{await this._storeIfSubscriptionIsBetter(n,t)}catch(e){f.error(e)}}else f("message discarded as it is from the same peer")}async _storeIfSubscriptionIsBetter(e,t){let r=!1;try{r=await this._isBetter(e,t)}catch(e){if("ERR_NOT_VALID_RECORD"!==e.code)throw e}r&&await this._storeRecord(e,t)}async _validateRecord(e,t){return this._validator.validate(e,t)}async _selectRecord(e,t){return 0===await this._validator.select(e,t)}async _isBetter(e,t){try{await this._validateRecord(t,e)}catch(e){const t="record received through pubsub is not valid";throw f.error(t),l.default(new Error(t),"ERR_NOT_VALID_RECORD")}const r=new i.Key(e);let n;try{n=await this._getLocal(r.uint8Array())}catch(e){return!0}return!o.equals(n,t)&&this._selectRecord(e,[n,t])}async _storeRecord(e,t){const r=new i.Key("/"+s.encodeBase32(e),!1);await this._datastore.put(r,t),f(`record for ${s.keyToTopic(e)} was stored in the datastore`)}}r.PubsubDatastore=h},{"interface-datastore":"1Ax6d","datastore-core":"bBniO","./utils.js":"gknfF","uint8arrays/equals":"eY3cX","err-code":"chZjB",debug:"bO5wM"}],"1Ax6d":[function(e,t,r){t.exports=e("./cjs/src/index.js")},{"./cjs/src/index.js":"Pvsek"}],Pvsek:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./key.js");r.Key=i.Key},{"./key.js":"9hGOz"}],bBniO:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./errors.js"),n=e("./shard.js"),s=e("./base.js"),o=e("./memory.js"),a=e("./keytransform.js"),c=e("./sharding.js"),u=e("./mount.js"),l=e("./tiered.js"),d=e("./namespace.js");const f={...i},h={...n};r.BaseDatastore=s.BaseDatastore,r.MemoryDatastore=o.MemoryDatastore,r.KeyTransformDatastore=a.KeyTransformDatastore,r.ShardingDatastore=c.ShardingDatastore,r.MountDatastore=u.MountDatastore,r.TieredDatastore=l.TieredDatastore,r.NamespaceDatastore=d.NamespaceDatastore,r.Errors=f,r.shard=h},{"./errors.js":"65M4b","./shard.js":"8UhNG","./base.js":"b5lsk","./memory.js":"farQr","./keytransform.js":"ipyDT","./sharding.js":"4n2YO","./mount.js":"bR1T2","./tiered.js":"5GeC7","./namespace.js":"ehQtO"}],"8UhNG":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("interface-datastore/key"),n=e("./shard-readme.js");const s="/repo/flatfs/shard/",o="SHARDING";class a{constructor(e){this.param=e,this.name="base",this._padding=""}fun(e){return"implement me"}toString(){return`${s}v1/${this.name}/${this.param}`}}class c extends a{constructor(e){super(e),this._padding="".padStart(e,"_"),this.name="prefix"}fun(e){return(e+this._padding).slice(0,this.param)}}class u extends a{constructor(e){super(e),this._padding="".padStart(e,"_"),this.name="suffix"}fun(e){const t=this._padding+e;return t.slice(t.length-this.param)}}class l extends a{constructor(e){super(e),this._padding="".padStart(e+1,"_"),this.name="next-to-last"}fun(e){const t=this._padding+e,r=t.length-this.param-1;return t.slice(r,r+this.param)}}function d(e){if(0===(e=e.trim()).length)throw new Error("empty shard string");if(!e.startsWith(s))throw new Error(`invalid or no path prefix: ${e}`);const t=e.slice(s.length).split("/"),r=t[0];if("v1"!==r)throw new Error(`expect 'v1' version, got '${r}'`);const i=t[1];if(!t[2])throw new Error("missing param");const n=parseInt(t[2],10);switch(i){case"prefix":return new c(n);case"suffix":return new u(n);case"next-to-last":return new l(n);default:throw new Error(`unkown sharding function: ${i}`)}}r.readme=n,r.NextToLast=l,r.PREFIX=s,r.Prefix=c,r.README_FN="_README",r.SHARDING_FN=o,r.ShardBase=a,r.Suffix=u,r.parseShardFun=d,r.readShardFun=async(e,t)=>{const r=new i.Key(e).child(new i.Key(o)),n="function"==typeof t.getRaw?t.getRaw.bind(t):t.get.bind(t),s=await n(r);return d((new TextDecoder).decode(s||"").trim())}},{"interface-datastore/key":"9hGOz","./shard-readme.js":"hm1kE"}],hm1kE:[function(e,t,r){"use strict";t.exports="This is a repository of IPLD objects. Each IPLD object is in a single file,\nnamed .data. Where is the\n\"base32\" encoding of the CID (as specified in\nhttps://github.com/multiformats/multibase) without the 'B' prefix.\nAll the object files are placed in a tree of directories, based on a\nfunction of the CID. This is a form of sharding similar to\nthe objects directory in git repositories. Previously, we used\nprefixes, we now use the next-to-last two charters.\n func NextToLast(base32cid string) {\n nextToLastLen := 2\n offset := len(base32cid) - nextToLastLen - 1\n return str[offset : offset+nextToLastLen]\n }\nFor example, an object with a base58 CIDv1 of\n zb2rhYSxw4ZjuzgCnWSt19Q94ERaeFhu9uSqRgjSdx9bsgM6f\nhas a base32 CIDv1 of\n BAFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA\nand will be placed at\n SC/AFKREIA22FLID5AJ2KU7URG47MDLROZIH6YF2KALU2PWEFPVI37YLKRSCA.data\nwith 'SC' being the last-to-next two characters and the 'B' at the\nbeginning of the CIDv1 string is the multibase prefix that is not\nstored in the filename.\n"},{}],farQr:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./base.js"),n=e("interface-datastore/key"),s=e("./errors.js");class o extends i.BaseDatastore{constructor(){super(),this.data={}}open(){return Promise.resolve()}close(){return Promise.resolve()}async put(e,t){this.data[e.toString()]=t}async get(e){if(!await this.has(e))throw s.notFoundError();return this.data[e.toString()]}async has(e){return void 0!==this.data[e.toString()]}async delete(e){delete this.data[e.toString()]}async*_all(){yield*Object.entries(this.data).map((([e,t])=>({key:new n.Key(e),value:t})))}async*_allKeys(){yield*Object.entries(this.data).map((([e])=>new n.Key(e)))}}r.MemoryDatastore=o},{"./base.js":"b5lsk","interface-datastore/key":"9hGOz","./errors.js":"65M4b"}],ipyDT:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./base.js"),n=e("it-map"),s=e("it-pipe");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(n);class c extends i.BaseDatastore{constructor(e,t){super(),this.child=e,this.transform=t}open(){return this.child.open()}put(e,t,r){return this.child.put(this.transform.convert(e),t,r)}get(e,t){return this.child.get(this.transform.convert(e),t)}has(e,t){return this.child.has(this.transform.convert(e),t)}delete(e,t){return this.child.delete(this.transform.convert(e),t)}async*putMany(e,t={}){const r=this.transform,i=this.child;yield*s.pipe(e,(async function*(e){yield*a.default(e,(({key:e,value:t})=>({key:r.convert(e),value:t})))}),(async function*(e){yield*i.putMany(e,t)}),(async function*(e){yield*a.default(e,(({key:e,value:t})=>({key:r.invert(e),value:t})))}))}async*getMany(e,t={}){const r=this.transform,i=this.child;yield*s.pipe(e,(async function*(e){yield*a.default(e,(e=>r.convert(e)))}),(async function*(e){yield*i.getMany(e,t)}))}async*deleteMany(e,t={}){const r=this.transform,i=this.child;yield*s.pipe(e,(async function*(e){yield*a.default(e,(e=>r.convert(e)))}),(async function*(e){yield*i.deleteMany(e,t)}),(async function*(e){yield*a.default(e,(e=>r.invert(e)))}))}batch(){const e=this.child.batch();return{put:(t,r)=>{e.put(this.transform.convert(t),r)},delete:t=>{e.delete(this.transform.convert(t))},commit:t=>e.commit(t)}}query(e,t){return a.default(this.child.query(e,t),(({key:e,value:t})=>({key:this.transform.invert(e),value:t})))}queryKeys(e,t){return a.default(this.child.queryKeys(e,t),(e=>this.transform.invert(e)))}close(){return this.child.close()}}r.KeyTransformDatastore=c},{"./base.js":"b5lsk","it-map":"eeqPk","it-pipe":"giKBQ"}],eeqPk:[function(e,t,r){"use strict";t.exports=async function*(e,t){for await(const r of e)yield t(r)}},{}],giKBQ:[function(e,t,r){const i=(...e)=>{let t;for(;e.length;)t=e.shift()(t);return t},n=e=>e&&("function"==typeof e[Symbol.asyncIterator]||"function"==typeof e[Symbol.iterator]||"function"==typeof e.next),s=e=>e&&"function"==typeof e.sink&&n(e.source),o=e=>t=>(e.sink(t),e.source),a=(...e)=>{if(s(e[0])){const t=e[0];e[0]=()=>t.source}else if(n(e[0])){const t=e[0];e[0]=()=>t}if(e.length>1&&s(e[e.length-1])&&(e[e.length-1]=e[e.length-1].sink),e.length>2)for(let t=1;te.key.toString()!==u.toString(),e=>e.key.toString()!==l.toString()]},{prefix:i}=e;if(null!=i&&r.filters.push((e=>this._invertKey(e.key).toString().startsWith(i))),null!=e.filters){const t=e.filters.map((e=>({key:t,value:r})=>e({key:this._invertKey(t),value:r})));r.filters=r.filters.concat(t)}return null!=e.orders&&(r.orders=e.orders.map((e=>(t,r)=>e({key:this._invertKey(t.key),value:t.value},{key:this._invertKey(r.key),value:r.value})))),this.child.query(r,t)}queryKeys(e,t){const r={offset:e.offset,limit:e.limit,orders:[],filters:[e=>e.toString()!==u.toString(),e=>e.toString()!==l.toString()]},{prefix:i}=e;if(null!=i&&r.filters.push((e=>this._invertKey(e).toString().startsWith(i))),null!=e.filters){const t=e.filters.map((e=>t=>e(this._invertKey(t))));r.filters=r.filters.concat(t)}return null!=e.orders&&(r.orders=e.orders.map((e=>(t,r)=>e(this._invertKey(t),this._invertKey(r))))),this.child.queryKeys(r,t)}close(){return this.child.close()}}r.ShardingDatastore=d},{"interface-datastore":"1Ax6d","./shard.js":"8UhNG","./base.js":"b5lsk","./keytransform.js":"ipyDT","./errors.js":"65M4b","./shard-readme.js":"hm1kE"}],bR1T2:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("it-filter"),n=e("it-take"),s=e("it-merge"),o=e("./base.js"),a=e("./keytransform.js"),c=e("./errors.js"),u=e("./utils.js"),l=e("interface-datastore/key");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=d(i),h=d(n),p=d(s);class g extends o.BaseDatastore{constructor(e){super(),this.mounts=e.slice()}async open(){await Promise.all(this.mounts.map((e=>e.datastore.open())))}_lookup(e){for(const t of this.mounts)if(t.prefix.toString()===e.toString()||t.prefix.isAncestorOf(e)){const r=u.replaceStartWith(e.toString(),t.prefix.toString());return{datastore:t.datastore,mountpoint:t.prefix,rest:new l.Key(r)}}}put(e,t,r){const i=this._lookup(e);if(null==i)throw c.dbWriteFailedError(new Error("No datastore mounted for this key"));return i.datastore.put(i.rest,t,r)}get(e,t){const r=this._lookup(e);if(null==r)throw c.notFoundError(new Error("No datastore mounted for this key"));return r.datastore.get(r.rest,t)}has(e,t){const r=this._lookup(e);return null==r?Promise.resolve(!1):r.datastore.has(r.rest,t)}delete(e,t){const r=this._lookup(e);if(null==r)throw c.dbDeleteFailedError(new Error("No datastore mounted for this key"));return r.datastore.delete(r.rest,t)}async close(){await Promise.all(this.mounts.map((e=>e.datastore.close())))}batch(){const e={},t=t=>{const r=this._lookup(t);if(null==r)throw new Error("No datastore mounted for this key");const i=r.mountpoint.toString();return null==e[i]&&(e[i]=r.datastore.batch()),{batch:e[i],rest:r.rest}};return{put:(e,r)=>{const i=t(e);i.batch.put(i.rest,r)},delete:e=>{const r=t(e);r.batch.delete(r.rest)},commit:async t=>{await Promise.all(Object.keys(e).map((r=>e[r].commit(t))))}}}query(e,t){const r=this.mounts.map((r=>{const i=new a.KeyTransformDatastore(r.datastore,{convert:e=>{throw new Error("should never be called")},invert:e=>r.prefix.child(e)});let n;return null!=e.prefix&&(n=u.replaceStartWith(e.prefix,r.prefix.toString())),i.query({prefix:n,filters:e.filters},t)}));let i=p.default(...r);if(e.filters&&e.filters.forEach((e=>{i=f.default(i,e)})),e.orders&&e.orders.forEach((e=>{i=u.sortAll(i,e)})),null!=e.offset){let t=0;i=f.default(i,(()=>t++>=e.offset))}return null!=e.limit&&(i=h.default(i,e.limit)),i}queryKeys(e,t){const r=this.mounts.map((r=>{const i=new a.KeyTransformDatastore(r.datastore,{convert:e=>{throw new Error("should never be called")},invert:e=>r.prefix.child(e)});let n;return null!=e.prefix&&(n=u.replaceStartWith(e.prefix,r.prefix.toString())),i.queryKeys({prefix:n,filters:e.filters},t)}));let i=p.default(...r);if(e.filters&&e.filters.forEach((e=>{i=f.default(i,e)})),e.orders&&e.orders.forEach((e=>{i=u.sortAll(i,e)})),null!=e.offset){let t=0;i=f.default(i,(()=>t++>=e.offset))}return null!=e.limit&&(i=h.default(i,e.limit)),i}}r.MountDatastore=g},{"it-filter":"5LCTL","it-take":"gxr1t","it-merge":"cPFu3","./base.js":"b5lsk","./keytransform.js":"ipyDT","./errors.js":"65M4b","./utils.js":"hJ8tG","interface-datastore/key":"9hGOz"}],cPFu3:[function(e,t,r){"use strict";const i=e("it-pushable");t.exports=async function*(...e){const t=i();setTimeout((async()=>{try{await Promise.all(e.map((async e=>{for await(const r of e)t.push(r)}))),t.end()}catch(e){t.end(e)}}),0),yield*t}},{"it-pushable":"bnpei"}],ehQtO:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("interface-datastore"),n=e("./keytransform.js");class s extends n.KeyTransformDatastore{constructor(e,t){super(e,{convert:e=>t.child(e),invert(e){if("/"===t.toString())return e;if(!t.isAncestorOf(e))throw new Error(`Expected prefix: (${t.toString()}) in key: ${e.toString()}`);return new i.Key(e.toString().slice(t.toString().length),!1)}}),this.prefix=t}query(e,t){return e.prefix&&"/"!==this.prefix.toString()?super.query(Object.assign({},e,{prefix:this.prefix.child(new i.Key(e.prefix)).toString()})):super.query(e,t)}queryKeys(e,t){return e.prefix&&"/"!==this.prefix.toString()?super.queryKeys(Object.assign({},e,{prefix:this.prefix.child(new i.Key(e.prefix)).toString()})):super.queryKeys(e,t)}}r.NamespaceDatastore=s},{"interface-datastore":"1Ax6d","./keytransform.js":"ipyDT"}],gknfF:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("err-code"),n=e("uint8arrays/to-string"),s=e("uint8arrays/from-string");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(i);const c="/record/";r.encodeBase32=function(e){return n.toString(e,"base32")},r.keyToTopic=function(e){return("string"==typeof e||e instanceof String)&&(e=s.fromString(e.toString())),`/record/${n.toString(e,"base64url")}`},r.topicToKey=function(e){if(e.substring(0,c.length)!==c)throw a.default(new Error("topic received is not from a record"),"ERR_TOPIC_IS_NOT_FROM_RECORD_NAMESPACE");const t=e.substring(c.length);return s.fromString(t,"base64url")}},{"err-code":"chZjB","uint8arrays/to-string":"hC8JB","uint8arrays/from-string":"dF7Y4"}],a4pYc:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("interface-datastore/key"),n=e("libp2p-record"),s=e("err-code"),o=e("debug"),a=e("uint8arrays/to-string");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(s),l=c(o);const d=Object.assign(l.default("ipfs:ipns:offline-datastore"),{error:l.default("ipfs:ipns:offline-datastore:error")});r.OfflineDatastore=class{constructor(e){this._repo=e,this.stores=[]}async put(e,t){if(!(e instanceof Uint8Array))throw u.default(new Error("Offline datastore key must be a Uint8Array"),"ERR_INVALID_KEY");if(!(t instanceof Uint8Array))throw u.default(new Error("Offline datastore value must be a Uint8Array"),"ERR_INVALID_VALUE");let r;try{r=this._routingKey(e)}catch(e){throw d.error(e),u.default(new Error("Not possible to generate the routing key"),"ERR_GENERATING_ROUTING_KEY")}const i=new n.Record(e,t);return this._repo.datastore.put(r,i.serialize())}async get(e){if(!(e instanceof Uint8Array))throw u.default(new Error("Offline datastore key must be a Uint8Array"),"ERR_INVALID_KEY");let t;try{t=this._routingKey(e)}catch(e){throw d.error(e),u.default(new Error("Not possible to generate the routing key"),"ERR_GENERATING_ROUTING_KEY")}const r=await this._repo.datastore.get(t);let i;try{i=n.Record.deserialize(r)}catch(e){throw d.error(e),e}return i.value}_routingKey(e){return new i.Key("/"+a.toString(e,"base32upper"),!1)}}},{"interface-datastore/key":"9hGOz","libp2p-record":"h5gPS","err-code":"chZjB",debug:"bO5wM","uint8arrays/to-string":"hC8JB"}],h5gPS:[function(e,t,r){"use strict";t.exports={Record:e("./record"),validator:e("./validator"),selection:e("./selection")}},{"./record":"f8iqI","./validator":"kylm1","./selection":"3s68T"}],f8iqI:[function(e,t,r){"use strict";const{Record:i}=e("./record"),n=e("../utils");class s{constructor(e,t,r){if(!(e instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(t instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=e,this.value=t,this.timeReceived=r}serialize(){return i.encode(this.prepareSerialize()).finish()}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:this.timeReceived&&n.toRFC3339(this.timeReceived)}}static deserialize(e){const t=i.decode(e);return s.fromDeserialized(i.toObject(t,{defaults:!1,arrays:!0,longs:Number,objects:!1}))}static fromDeserialized(e){let t;e.timeReceived&&(t=n.parseRFC3339(e.timeReceived));return new s(e.key,e.value,t)}}t.exports=s},{"./record":"gqFCN","../utils":"fHufu"}],gqFCN:[function(e,t,r){"use strict";var i=e("protobufjs/minimal"),n=i.Reader,s=i.Writer,o=i.util,a=i.roots["libp2p-record"]||(i.roots["libp2p-record"]={});a.Record=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:i.key=e.bytes();break;case 2:i.value=e.bytes();break;case 5:i.timeReceived=e.string();break;default:e.skipType(7&s)}}return i},e.fromObject=function(e){if(e instanceof a.Record)return e;var t=new a.Record;return null!=e.key&&("string"==typeof e.key?o.base64.decode(e.key,t.key=o.newBuffer(o.base64.length(e.key)),0):e.key.length&&(t.key=e.key)),null!=e.value&&("string"==typeof e.value?o.base64.decode(e.value,t.value=o.newBuffer(o.base64.length(e.value)),0):e.value.length&&(t.value=e.value)),null!=e.timeReceived&&(t.timeReceived=String(e.timeReceived)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.key="":(r.key=[],t.bytes!==Array&&(r.key=o.newBuffer(r.key))),t.bytes===String?r.value="":(r.value=[],t.bytes!==Array&&(r.value=o.newBuffer(r.value))),r.timeReceived=""),null!=e.key&&e.hasOwnProperty("key")&&(r.key=t.bytes===String?o.base64.encode(e.key,0,e.key.length):t.bytes===Array?Array.prototype.slice.call(e.key):e.key),null!=e.value&&e.hasOwnProperty("value")&&(r.value=t.bytes===String?o.base64.encode(e.value,0,e.value.length):t.bytes===Array?Array.prototype.slice.call(e.value):e.value),null!=e.timeReceived&&e.hasOwnProperty("timeReceived")&&(r.timeReceived=e.timeReceived),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e}(),t.exports=a},{"protobufjs/minimal":"grAXL"}],fHufu:[function(e,t,r){"use strict";t.exports.toRFC3339=e=>`${e.getUTCFullYear()}-${String(e.getUTCMonth()+1).padStart(2,"0")}-${String(e.getUTCDate()).padStart(2,"0")}T${String(e.getUTCHours()).padStart(2,"0")}:${String(e.getUTCMinutes()).padStart(2,"0")}:${String(e.getUTCSeconds()).padStart(2,"0")}.${1e6*e.getUTCMilliseconds()}Z`,t.exports.parseRFC3339=e=>{const t=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),r=String(e).trim().match(t);if(!r)throw new Error("Invalid format");const i=parseInt(r[1],10),n=parseInt(r[2],10)-1,s=parseInt(r[3],10),o=parseInt(r[4],10),a=parseInt(r[5],10),c=parseInt(r[6],10),u=parseInt(r[7].slice(0,-6),10);return new Date(Date.UTC(i,n,s,o,a,c,u))}},{}],kylm1:[function(e,t,r){"use strict";const i=e("err-code"),{toString:n}=e("uint8arrays/to-string");t.exports={verifyRecord:(e,t)=>{const r=t.key,s=n(r).split("/");if(s.length<3)return;const o=e[s[1].toString()];if(!o){throw i(new Error("Invalid record keytype"),"ERR_INVALID_RECORD_KEY_TYPE")}return o.func(r,t.value)},validators:e("./validators")}},{"err-code":"chZjB","uint8arrays/to-string":"hC8JB","./validators":"ga6xf"}],ga6xf:[function(e,t,r){"use strict";t.exports={pk:e("./public-key")}},{"./public-key":"dJySP"}],dJySP:[function(e,t,r){"use strict";const{sha256:i}=e("multiformats/hashes/sha2"),n=e("err-code"),{toString:s}=e("uint8arrays/to-string"),{equals:o}=e("uint8arrays/equals");t.exports={func:async(e,t)=>{if(!(e instanceof Uint8Array))throw n(new Error('"key" must be a Uint8Array'),"ERR_INVALID_RECORD_KEY_NOT_BUFFER");if(e.byteLength<5)throw n(new Error("invalid public key record"),"ERR_INVALID_RECORD_KEY_TOO_SHORT");if("/pk/"!==s(e.subarray(0,4)))throw n(new Error("key was not prefixed with /pk/"),"ERR_INVALID_RECORD_KEY_BAD_PREFIX");const r=e.slice(4),a=await i.digest(t);if(!o(r,a.bytes))throw n(new Error("public key does not match passed in key"),"ERR_INVALID_RECORD_HASH_MISMATCH")},sign:!1}},{"multiformats/hashes/sha2":"7i9MT","err-code":"chZjB","uint8arrays/to-string":"hC8JB","uint8arrays/equals":"eY3cX"}],"3s68T":[function(e,t,r){"use strict";const i=e("err-code"),{toString:n}=e("uint8arrays/to-string");t.exports={bestRecord:(e,t,r)=>{if(0===r.length){throw i(new Error("No records given"),"ERR_NO_RECORDS_RECEIVED")}const s=n(t).split("/");if(s.length<3){throw i(new Error("Record key does not have a selector function"),"ERR_NO_SELECTOR_FUNCTION_FOR_RECORD_KEY")}const o=e[s[1].toString()];if(!o){const e=`Unrecognized key prefix: ${s[1]}`;throw i(new Error(e),"ERR_UNRECOGNIZED_KEY_PREFIX")}return 1===r.length?0:o(t,r)},selectors:e("./selectors")}},{"err-code":"chZjB","uint8arrays/to-string":"hC8JB","./selectors":"haGf8"}],haGf8:[function(e,t,r){"use strict";t.exports={pk:e("./public-key")}},{"./public-key":"19IEy"}],"19IEy":[function(e,t,r){"use strict";t.exports=(e,t)=>0},{}],u6g6o:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./publish.js"),n=e("./resolve.js"),s=e("./pubsub/index.js");r.NameAPI=class{constructor({dns:e,ipns:t,repo:r,codecs:o,peerId:a,isOnline:c,keychain:u,options:l}){this.publish=i.createPublish({ipns:t,repo:r,codecs:o,peerId:a,isOnline:c,keychain:u}),this.resolve=n.createResolve({dns:e,ipns:t,peerId:a,isOnline:c,options:l}),this.pubsub=new s.PubSubAPI({ipns:t,options:l})}}},{"./publish.js":"dpWDc","./resolve.js":"cm25d","./pubsub/index.js":"bgTzj"}],dpWDc:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("debug"),n=e("parse-duration"),s=e("libp2p-crypto"),o=e("err-code"),a=e("uint8arrays/from-string"),c=e("uint8arrays/to-string"),u=e("../../utils.js"),l=e("ipfs-core-utils/with-timeout-option"),d=e("./utils.js");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=f(i),p=f(n),g=f(s),y=f(o);const m=Object.assign(h.default("ipfs:name:publish"),{error:h.default("ipfs:name:publish:error")});r.createPublish=function({ipns:e,repo:t,codecs:r,peerId:i,isOnline:n,keychain:s}){const o=async e=>{if("self"===e)return i.privKey;try{const t=await s.exportKey(e,"temp");return await g.default.keys.import(t,"temp")}catch(e){throw m.error(e),y.default(e,"ERR_CANNOT_GET_KEY")}};return l.withTimeoutOption((async function(i,s={}){const l=!(!1===s.resolve),f=s.lifetime||"24h",h=s.key||"self";if(!n())throw y.default(new Error(u.OFFLINE_ERROR),"OFFLINE_ERROR");try{i=u.normalizePath(i)}catch(e){throw m.error(e),e}let g=0;try{g=p.default(f)||0,g=parseFloat(g.toFixed(6))}catch(e){throw m.error(e),e}const b=await Promise.all([o(h),l?d.resolvePath({ipns:e,repo:t,codecs:r},i):Promise.resolve()]),v=a.fromString(i),w=await e.publish(b[0],v,g);return{name:w.name,value:c.toString(w.value)}}))}},{debug:"bO5wM","parse-duration":"fGYtw","libp2p-crypto":"bb1cb","err-code":"chZjB","uint8arrays/from-string":"dF7Y4","uint8arrays/to-string":"hC8JB","../../utils.js":"cT4uN","ipfs-core-utils/with-timeout-option":"j29MK","./utils.js":"3TaO8"}],"3TaO8":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("is-ipfs"),n=e("ipfs-core-utils/to-cid-and-path"),s=e("it-drain"),o=e("../../utils.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=a(i),u=a(s);r.resolvePath=async function({ipns:e,repo:t,codecs:r},i,s){if(c.default.ipnsPath(i))return e.resolve(i);const{cid:a,path:l}=n.toCidAndPath(i);await u.default(o.resolve(a,l||"",r,t,s))}},{"is-ipfs":"40iuV","ipfs-core-utils/to-cid-and-path":"jN5CZ","it-drain":"dKYhO","../../utils.js":"cT4uN"}],cm25d:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("debug"),n=e("err-code"),s=e("merge-options"),o=e("multiformats/cid"),a=e("peer-id"),c=e("is-domain-name"),u=e("uint8arrays/to-string"),l=e("../../utils.js"),d=e("ipfs-core-utils/with-timeout-option");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=f(i),p=f(n),g=f(s),y=f(a),m=f(c);const b=g.default.bind({ignoreUndefined:!0}),v=Object.assign(h.default("ipfs:name:resolve"),{error:h.default("ipfs:name:resolve:error")}),w=(e,t)=>t.length>0?e+"/"+t.join("/"):e;r.createResolve=function({dns:e,ipns:t,peerId:r,isOnline:i,options:{offline:n}}){return d.withTimeoutOption((async function*(s,a={}){if(a=b({nocache:!1,recursive:!0},a),n&&a&&a.nocache)throw p.default(new Error("cannot specify both offline and nocache"),"ERR_NOCACHE_AND_OFFLINE");s||(s=r.toB58String()),s.startsWith("/ipns/")||(s=`/ipns/${s}`);const[c,d,...f]=s.slice(1).split("/");try{"1"===d.substring(0,1)?y.default.parse(d):o.CID.parse(d)}catch(t){if(m.default(d))return void(yield w(await e(d,a),f));throw v.error(t),p.default(new Error("Invalid IPNS name"),"ERR_IPNS_INVALID_NAME")}if(!i()&&!n)throw p.default(new Error(l.OFFLINE_ERROR),"OFFLINE_ERROR");const h=await t.resolve(`/${c}/${d}`,a);yield w(h instanceof Uint8Array?u.toString(h):h,f)}))}},{debug:"bO5wM","err-code":"chZjB","merge-options":"fupyv","multiformats/cid":"9ooAY","peer-id":"8Bdb3","is-domain-name":"4dpQa","uint8arrays/to-string":"hC8JB","../../utils.js":"cT4uN","ipfs-core-utils/with-timeout-option":"j29MK"}],"4dpQa":[function(e,t,r){"use strict";var i=/^(?:[a-z0-9](?:[a-z0-9\-]{0,61}[a-z0-9])?\.){0,126}(?:[a-z0-9](?:[a-z0-9\-]{0,61}[a-z0-9]))\.?$/i;t.exports=function(e,t){if(null==t&&(t=!1),e.length<2)return!1;if(e.length>255)return!1;var r=e[e.length-1];if(t){if("."!==r)return!1}else if("."===r)return!1;return i.test(e)}},{}],bgTzj:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./cancel.js"),n=e("./state.js"),s=e("./subs.js");r.PubSubAPI=class{constructor({ipns:e,options:t}){this.cancel=i.createCancel({ipns:e,options:t}),this.state=n.createState({ipns:e,options:t}),this.subs=s.createSubs({ipns:e,options:t})}}},{"./cancel.js":"hASEG","./state.js":"fAkSl","./subs.js":"ctElw"}],hASEG:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./utils.js"),n=e("ipfs-core-utils/with-timeout-option");r.createCancel=function({ipns:e,options:t}){const r=t.EXPERIMENTAL;return n.withTimeoutOption((async function(t,n={}){return i.getPubsubRouting(e,r).cancel(t,n)}))}},{"./utils.js":"aACl9","ipfs-core-utils/with-timeout-option":"j29MK"}],aACl9:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../../../ipns/routing/pubsub-datastore.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=n(e("err-code"));r.getPubsubRouting=function(e,t){if(!e||!t||!t.ipnsPubsub)throw s.default(new Error("IPNS pubsub subsystem is not enabled"),"ERR_IPNS_PUBSUB_NOT_ENABLED");if(e.routing instanceof i.IpnsPubsubDatastore)return e.routing;const r=(e.routing.stores||[]).find((e=>e instanceof i.IpnsPubsubDatastore));if(!r)throw s.default(new Error("IPNS pubsub datastore not found"),"ERR_PUBSUB_DATASTORE_NOT_FOUND");return r}},{"../../../ipns/routing/pubsub-datastore.js":"3XRQz","err-code":"chZjB"}],fAkSl:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./utils.js"),n=e("ipfs-core-utils/with-timeout-option");r.createState=function({ipns:e,options:t}){const r=t.EXPERIMENTAL;return n.withTimeoutOption((async function(t={}){try{return{enabled:Boolean(i.getPubsubRouting(e,r))}}catch(e){return{enabled:!1}}}))}},{"./utils.js":"aACl9","ipfs-core-utils/with-timeout-option":"j29MK"}],ctElw:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./utils.js"),n=e("ipfs-core-utils/with-timeout-option");r.createSubs=function({ipns:e,options:t}){const r=t.EXPERIMENTAL;return n.withTimeoutOption((async function(t={}){return i.getPubsubRouting(e,r).getSubscriptions(t)}))}},{"./utils.js":"aACl9","ipfs-core-utils/with-timeout-option":"j29MK"}],"9Y9Id":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("@ipld/dag-pb"),n=e("datastore-core/errors"),s=e("ipfs-core-utils/to-cid-and-path"),o=e("multiformats/cid"),a=e("timeout-abort-controller"),c=e("any-signal");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var d=l(i),f=u(a);const h=n.notFoundError().code,p={default:"",edges:" -> "};async function*g(e,t,r,i,n){const o=await e(i,n),{cid:a}=s.toCidAndPath(o),c=null!=n.maxDepth?n.maxDepth:1/0,u=n.unique||!1;for await(const e of async function*(e,t,r,i,n,s){const o=new Set;async function*a(r,c){const u=c+1;if(!(u>i))try{for await(const i of async function*(e,t,r,i){const n=await e.blocks.get(r,i),s=(await t.getCodec(r.code)).decode(n),o=r.code===d.code,a=[];for(const[e,t]of m(s,a)){if(o){const r=e.match(/^Links\/(\d+)\/Hash$/);if(r){const e=Number(r[1]);if(e/g,e.toString());return n=n.replace(//g,t.toString()),n=n.replace(//g,r),n}const m=function*(e,t){if(null!=e&&!(e instanceof Uint8Array)){for(const[r,i]of Object.entries(e)){const e=[...t,r];if(null!=i&&"object"==typeof i)if(Array.isArray(i))for(const[t,r]of i.entries()){const i=[...e,t],n=o.CID.asCID(r);n?yield[i.join("/"),n]:"object"==typeof r&&(yield*m(r,i))}else{const t=o.CID.asCID(i);t?yield[e.join("/"),t]:yield*m(i,e)}}return[]}};r.Format=p,r.createRefs=function({repo:e,codecs:t,resolve:r,preload:i}){return async function*(n,o={}){if(0===o.maxDepth)return;if(o.edges&&o.format&&o.format!==p.default)throw new Error("Cannot set edges to true and also specify format");if(o.format=o.edges?p.edges:o.format,"number"!=typeof o.maxDepth&&(o.maxDepth=o.recursive?1/0:1),o.timeout){const e=new f.default(o.timeout);o.signal=c.anySignal([o.signal,e.signal])}const a=(Array.isArray(n)?n:[n]).map((e=>function(e,t,r){const{cid:i,path:n}=s.toCidAndPath(t);!1!==r.preload&&e(i);return`/ipfs/${i}${n||""}`}(i,e,o)));for(const i of a)try{yield*g(r,e,t,i,o)}catch(e){yield{ref:"",err:e.message}}}}},{"@ipld/dag-pb":"i2cdx","datastore-core/errors":"65M4b","ipfs-core-utils/to-cid-and-path":"jN5CZ","multiformats/cid":"9ooAY","timeout-abort-controller":"hzClg","any-signal":"kXgRR"}],lEaxs:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option");r.createLocal=function({repo:e}){return i.withTimeoutOption((async function*(t={}){for await(const r of e.blocks.queryKeys({},{signal:t.signal}))yield{ref:r.toString()}}))}},{"ipfs-core-utils/with-timeout-option":"j29MK"}],lGDjO:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./wantlist.js"),n=e("./wantlist-for-peer.js"),s=e("./unwant.js"),o=e("./stat.js");r.BitswapAPI=class{constructor({network:e}){this.wantlist=i.createWantlist({network:e}),this.wantlistForPeer=n.createWantlistForPeer({network:e}),this.unwant=s.createUnwant({network:e}),this.stat=o.createStat({network:e})}}},{"./wantlist.js":"1ob69","./wantlist-for-peer.js":"7Z7Yb","./unwant.js":"iRgR3","./stat.js":"aHPBA"}],"1ob69":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option");r.createWantlist=function({network:e}){return i.withTimeoutOption((async function(t={}){const{bitswap:r}=await e.use(t),i=r.getWantlist();return Array.from(i).map((e=>e[1].cid))}))}},{"ipfs-core-utils/with-timeout-option":"j29MK"}],"7Z7Yb":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("peer-id"),n=e("ipfs-core-utils/with-timeout-option");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=s(i);r.createWantlistForPeer=function({network:e}){return n.withTimeoutOption((async function(t,r={}){const{bitswap:i}=await e.use(r),n=i.wantlistForPeer(o.default.createFromB58String(t));return Array.from(n).map((e=>e[1].cid))}))}},{"peer-id":"8Bdb3","ipfs-core-utils/with-timeout-option":"j29MK"}],iRgR3:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option");r.createUnwant=function({network:e}){return i.withTimeoutOption((async function(t,r={}){const{bitswap:i}=await e.use(r);return Array.isArray(t)||(t=[t]),i.unwant(t)}))}},{"ipfs-core-utils/with-timeout-option":"j29MK"}],aHPBA:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option");r.createStat=function({network:e}){return i.withTimeoutOption((async function(t={}){const r=(await e.use(t)).bitswap,i=r.stat().snapshot;return{provideBufLen:parseInt(i.providesBufferLength.toString()),blocksReceived:BigInt(i.blocksReceived.toString()),wantlist:Array.from(r.getWantlist()).map((e=>e[1].cid)),peers:r.peers().map((e=>e.toB58String())),dupBlksReceived:BigInt(i.dupBlksReceived.toString()),dupDataReceived:BigInt(i.dupDataReceived.toString()),dataReceived:BigInt(i.dataReceived.toString()),blocksSent:BigInt(i.blocksSent.toString()),dataSent:BigInt(i.dataSent.toString())}}))}},{"ipfs-core-utils/with-timeout-option":"j29MK"}],dh9oy:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./add.js"),n=e("./clear.js"),s=e("./list.js"),o=e("./reset.js"),a=e("./rm.js");r.BootstrapAPI=class{constructor({repo:e}){this.add=i.createAdd({repo:e}),this.list=s.createList({repo:e}),this.rm=a.createRm({repo:e}),this.clear=n.createClear({repo:e}),this.reset=o.createReset({repo:e})}}},{"./add.js":"8FDCZ","./clear.js":"jEuP0","./list.js":"gZN1y","./reset.js":"1bIlT","./rm.js":"kncM8"}],"8FDCZ":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./utils.js"),n=e("ipfs-core-utils/with-timeout-option");r.createAdd=function({repo:e}){return n.withTimeoutOption((async function(t,r={}){if(!i.isValidMultiaddr(t))throw new Error(`${t} is not a valid Multiaddr`);const n=await e.config.getAll(r),s=n.Bootstrap||[];return s.push(t.toString()),n.Bootstrap=Array.from(new Set(s)).sort(((e,t)=>e.localeCompare(t))),await e.config.replace(n),{Peers:[t]}}))}},{"./utils.js":"60F3o","ipfs-core-utils/with-timeout-option":"j29MK"}],"60F3o":[function(e,t,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(r,"__esModule",{value:!0});var n=i(e("mafmt"));r.isValidMultiaddr=function(e){try{return n.default.IPFS.matches(e)}catch(e){return!1}}},{mafmt:"l1lok"}],jEuP0:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option"),n=e("multiaddr");r.createClear=function({repo:e}){return i.withTimeoutOption((async function(t={}){const r=await e.config.getAll(t),i=r.Bootstrap||[];return r.Bootstrap=[],await e.config.replace(r),{Peers:i.map((e=>new n.Multiaddr(e)))}}))}},{"ipfs-core-utils/with-timeout-option":"j29MK",multiaddr:"8Mu1u"}],gZN1y:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option"),n=e("multiaddr");r.createList=function({repo:e}){return i.withTimeoutOption((async function(t={}){return{Peers:(await e.config.get("Bootstrap",t)||[]).map((e=>new n.Multiaddr(e)))}}))}},{"ipfs-core-utils/with-timeout-option":"j29MK",multiaddr:"8Mu1u"}],"1bIlT":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-config/config"),n=e("ipfs-core-utils/with-timeout-option"),s=e("multiaddr");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(i);r.createReset=function({repo:e}){return n.withTimeoutOption((async function(t={}){const r=await e.config.getAll(t);return r.Bootstrap=a.default().Bootstrap,await e.config.replace(r),{Peers:a.default().Bootstrap.map((e=>new s.Multiaddr(e)))}}))}},{"ipfs-core-config/config":"ejWbz","ipfs-core-utils/with-timeout-option":"j29MK",multiaddr:"8Mu1u"}],ejWbz:[function(e,t,r){"use strict";t.exports=()=>({Addresses:{Swarm:[],Announce:[],NoAnnounce:[],API:"",Gateway:"",RPC:"",Delegates:["/dns4/node0.delegate.ipfs.io/tcp/443/https","/dns4/node1.delegate.ipfs.io/tcp/443/https","/dns4/node2.delegate.ipfs.io/tcp/443/https","/dns4/node3.delegate.ipfs.io/tcp/443/https"]},Discovery:{MDNS:{Enabled:!1,Interval:10},webRTCStar:{Enabled:!0}},Bootstrap:["/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN","/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb","/dnsaddr/bootstrap.libp2p.io/p2p/QmZa1sAxajnQjVM8WjWXoMbmPd7NsWhfKsPkErzpm9wGkp","/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa","/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt","/dns4/node0.preload.ipfs.io/tcp/443/wss/p2p/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic","/dns4/node1.preload.ipfs.io/tcp/443/wss/p2p/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6","/dns4/node2.preload.ipfs.io/tcp/443/wss/p2p/QmV7gnbW5VTcJ3oyM2Xk1rdFBJ3kTkvxc87UFGsun29STS","/dns4/node3.preload.ipfs.io/tcp/443/wss/p2p/QmY7JB6MQXhxHvq7dBDh4HpbH29v4yE9JRadAVpndvzySN"],Pubsub:{Enabled:!0},Swarm:{ConnMgr:{LowWater:200,HighWater:500},DisableNatPortMap:!0},Routing:{Type:"none"}})},{}],kncM8:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./utils.js"),n=e("ipfs-core-utils/with-timeout-option");r.createRm=function({repo:e}){return n.withTimeoutOption((async function(t,r={}){if(!i.isValidMultiaddr(t))throw new Error(`${t} is not a valid Multiaddr`);const n=await e.config.getAll(r);return n.Bootstrap=(n.Bootstrap||[]).filter((e=>e.toString()!==t.toString())),await e.config.replace(n),{Peers:[t]}}))}},{"./utils.js":"60F3o","ipfs-core-utils/with-timeout-option":"j29MK"}],jcbA3:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./get.js"),n=e("./put.js"),s=e("./rm.js"),o=e("./stat.js");r.BlockAPI=class{constructor({codecs:e,hashers:t,preload:r,repo:a}){this.get=i.createGet({preload:r,repo:a}),this.put=n.createPut({codecs:e,hashers:t,preload:r,repo:a}),this.rm=s.createRm({repo:a}),this.stat=o.createStat({preload:r,repo:a})}}},{"./get.js":"3sAXc","./put.js":"3xSKb","./rm.js":"eTPrA","./stat.js":"ij9fZ"}],"3sAXc":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option");r.createGet=function({preload:e,repo:t}){return i.withTimeoutOption((async function(r,i={}){return!1!==i.preload&&e(r),t.blocks.get(r,i)}))}},{"ipfs-core-utils/with-timeout-option":"j29MK"}],"3xSKb":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("ipfs-core-utils/with-timeout-option");r.createPut=function({codecs:e,hashers:t,repo:r,preload:s}){return n.withTimeoutOption((async function(n,o={}){const a=o.pin?await r.gcLock.readLock():null;try{const c=null!=o.version?o.version:0,u=o.format||(0===c?"dag-pb":"raw"),l=await t.getHasher(o.mhtype||"sha2-256"),d=await l.digest(n),f=await e.getCodec(u),h=i.CID.create(c,f.code,d);return await r.blocks.put(h,n,{signal:o.signal}),!1!==o.preload&&s(h),!0===o.pin&&await r.pins.pinRecursively(h,{signal:o.signal}),h}finally{a&&a()}}))}},{"multiformats/cid":"9ooAY","ipfs-core-utils/with-timeout-option":"j29MK"}],eTPrA:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("err-code"),n=e("it-parallel"),s=e("it-map"),o=e("it-filter"),a=e("it-pipe"),c=e("./utils.js"),u=e("ipfs-core-utils/with-timeout-option");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=l(i),f=l(n),h=l(s),p=l(o);r.createRm=function({repo:e}){return u.withTimeoutOption((async function*(t,r={}){Array.isArray(t)||(t=[t]);const i=await e.gcLock.writeLock();try{yield*a.pipe(t,(t=>h.default(t,(t=>async()=>{const i={cid:t=c.cleanCid(t)};try{if(!await e.blocks.has(t))throw d.default(new Error("block not found"),"ERR_BLOCK_NOT_FOUND");await e.blocks.delete(t)}catch(e){r.force||(e.message=`cannot remove ${t}: ${e.message}`,i.error=e)}return i}))),(e=>f.default(e,8)),(e=>p.default(e,(()=>!r.quiet))))}finally{i()}}))}},{"err-code":"chZjB","it-parallel":"fNsT1","it-map":"eeqPk","it-filter":"5LCTL","it-pipe":"giKBQ","./utils.js":"iASYn","ipfs-core-utils/with-timeout-option":"j29MK"}],fNsT1:[function(e,t,r){"use strict";const i=e("p-defer"),n=e("events").EventEmitter;t.exports=async function*(e,t=1){t<1&&(t=1);const r=new n,s=[];let o=i(),a=!1,c=i();for(r.on("task-complete",(()=>{c.resolve(),c=i()})),Promise.resolve().then((async()=>{try{for await(const i of e){s.length===t&&await o.promise;const e={done:!1};s.push(e),i().then((t=>{e.done=!0,e.ok=!0,e.value=t,r.emit("task-complete")}),(t=>{e.done=!0,e.err=t,r.emit("task-complete")}))}a=!0}catch(e){r.emit("task-complete")}}));;){for(await c.promise;s.length&&s[0].done;){const e=s[0];if(s.shift(),!e.ok)throw e.err;yield e.value,o.resolve(),o=i()}if(a&&0===s.length)break}}},{"p-defer":"5rKSv",events:"g82pp"}],"5rKSv":[function(e,t,r){"use strict";t.exports=()=>{const e={};return e.promise=new Promise(((t,r)=>{e.resolve=t,e.reject=r})),e}},{}],g82pp:[function(e,t,r){"use strict";var i,n="object"==typeof Reflect?Reflect:null,s=n&&"function"==typeof n.apply?n.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};i=n&&"function"==typeof n.ownKeys?n.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 a(){a.init.call(this)}t.exports=a,t.exports.once=function(e,t){return new Promise((function(r,i){function n(r){e.removeListener(t,s),i(r)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",n),r([].slice.call(arguments))}m(e,t,s,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&m(e,"error",t,r)}(e,n,{once:!0})}))},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var c=10;function u(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?a.defaultMaxListeners:e._maxListeners}function d(e,t,r,i){var n,s,o,a;if(u(r),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]),void 0===o)o=s[t]=r,++e._eventsCount;else if("function"==typeof o?o=s[t]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(n=l(e))>0&&o.length>n&&!o.warned){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=o.length,a=c,console&&console.warn&&console.warn(a)}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 i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},n=f.bind(i);return n.listener=r,i.wrapFn=n,n}function p(e,t,r){var i=e._events;if(void 0===i)return[];var n=i[t];return void 0===n?[]:"function"==typeof n?r?[n.listener||n]:[n]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=n[e];if(void 0===c)return!1;if("function"==typeof c)s(c,this,t);else{var u=c.length,l=y(c,u);for(r=0;r=0;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,n=s;break}if(n<0)return this;0===n?r.shift():function(e,t){for(;t+1=0;i--)this.removeListener(e,t[i]);return this},a.prototype.listeners=function(e){return p(this,e,!0)},a.prototype.rawListeners=function(e){return p(this,e,!1)},a.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):g.call(e,t)},a.prototype.listenerCount=g,a.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]}},{}],iASYn:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid");r.cleanCid=function(e){return e instanceof Uint8Array?i.CID.decode(e):i.CID.parse(e.toString())}},{"multiformats/cid":"9ooAY"}],ij9fZ:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./utils.js"),n=e("ipfs-core-utils/with-timeout-option");r.createStat=function({repo:e,preload:t}){return n.withTimeoutOption((async function(r,n={}){return r=i.cleanCid(r),!1!==n.preload&&t(r),{cid:r,size:(await e.blocks.get(r)).length}}))}},{"./utils.js":"iASYn","ipfs-core-utils/with-timeout-option":"j29MK"}],"3wOOx":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./add.js"),n=e("./add-all/index.js"),s=e("./cat.js"),o=e("./get.js"),a=e("./ls.js");r.RootAPI=class{constructor({preload:e,repo:t,options:r}){const c=n.createAddAll({preload:e,repo:t,options:r});this.addAll=c,this.add=i.createAdd({addAll:c}),this.cat=s.createCat({repo:t,preload:e}),this.get=o.createGet({repo:t,preload:e}),this.ls=a.createLs({repo:t,preload:e})}}},{"./add.js":"b7djo","./add-all/index.js":"g1OzM","./cat.js":"dOhzw","./get.js":"3pEGl","./ls.js":"lCq4W"}],b7djo:[function(e,t,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(r,"__esModule",{value:!0});var n=i(e("it-last"));r.createAdd=function({addAll:e}){return async function(t,r={}){const i=await n.default(e(t,r));if(null==i)throw Error("Failed to add a file, if you see this please report a bug");return i}}},{"it-last":"cSXX9"}],g1OzM:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-unixfs-importer"),n=e("ipfs-core-utils/files/normalise-input"),s=e("./utils.js"),o=e("it-pipe"),a=e("ipfs-core-utils/with-timeout-option");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const u=c(e("merge-options")).default.bind({ignoreUndefined:!0});r.createAddAll=function({repo:e,preload:t,options:r}){const c=r&&r.sharding;return a.withTimeoutOption((async function*(r,a={}){const l=u({shardSplitThreshold:c?1e3:1/0,strategy:"balanced"},a,{...s.parseChunkerString(a.chunker)});l.hashAlg&&"sha2-256"!==l.hashAlg&&1!==l.cidVersion&&(l.cidVersion=1),l.trickle&&(l.strategy="trickle"),"trickle"===l.strategy&&(l.leafType="raw",l.reduceSingleLeafToSelf=!1),l.cidVersion>0&&void 0===l.rawLeaves&&(l.rawLeaves=!0),void 0!==l.hashAlg&&void 0===l.rawLeaves&&(l.rawLeaves=!0),delete l.trickle;const d={};if(l.progress){const e=l.progress;l.progress=(t,r)=>{d[r]||(d[r]=0),d[r]+=t,e(d[r],r)}}const f=o.pipe(n.normaliseInput(r),(t=>i.importer(t,e.blocks,{...l,pin:!1})),function(e){async function*t(t){for await(const r of t){let t=r.cid;1===e.cidVersion&&(t=t.toV1());let i=r.path?r.path:t.toString();e.wrapWithDirectory&&!r.path&&(i=""),yield{path:i,cid:t,size:r.size,mode:r.unixfs&&r.unixfs.mode,mtime:r.unixfs&&r.unixfs.mtime}}}return t}(l),function(e,t){async function*r(r){for await(const i of r){(!i.path||t.wrapWithDirectory?""===i.path:!i.path.includes("/"))&&!t.onlyHash&&!1!==t.preload&&e(i.cid),yield i}}return r}(t,l),function(e,t){async function*r(r){for await(const i of r){const r=!(i.path&&i.path.includes("/"));(null==t.pin||t.pin)&&r&&!t.onlyHash&&await e.pins.pinRecursively(i.cid),yield i}}return r}(e,l)),h=await e.gcLock.readLock();try{for await(const e of f)delete d[e.path],yield e}finally{h()}}))}},{"ipfs-unixfs-importer":"i61x3","ipfs-core-utils/files/normalise-input":"cda37","./utils.js":"1Nm8o","it-pipe":"giKBQ","ipfs-core-utils/with-timeout-option":"j29MK","merge-options":"fupyv"}],i61x3:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("it-parallel-batch"),n=e("./options.js"),s=e("./dag-builder/index.js"),o=e("./tree-builder.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=a(i);r.importer=async function*(e,t,r={}){const i=n(r);let a,u,l;a="function"==typeof r.dagBuilder?r.dagBuilder:s,u="function"==typeof r.treeBuilder?r.treeBuilder:o,l=Symbol.asyncIterator in e||Symbol.iterator in e?e:[e];for await(const e of u(c.default(a(l,t,i),i.fileImportConcurrency),t,i))yield{cid:e.cid,path:e.path,unixfs:e.unixfs,size:e.size}}},{"it-parallel-batch":"lPBqc","./options.js":"3mq8g","./dag-builder/index.js":"adT9a","./tree-builder.js":"3sIHL"}],lPBqc:[function(e,t,r){"use strict";const i=e("it-batch");t.exports=async function*(e,t=1){for await(const r of i(e,t)){const e=r.map((e=>e().then((e=>({ok:!0,value:e})),(e=>({ok:!1,err:e})))));for(let t=0;t=t;)yield r.slice(0,t),r=r.slice(t);for(;r.length;)yield r.slice(0,t),r=r.slice(t)}},{}],"3mq8g":[function(e,t,r){"use strict";var i=e("merge-options"),n=e("multiformats/hashes/sha2"),s=e("@multiformats/murmur3");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(i);const c={chunker:"fixed",strategy:"balanced",rawLeaves:!1,onlyHash:!1,reduceSingleLeafToSelf:!0,hasher:n.sha256,leafType:"file",cidVersion:0,progress:()=>()=>{},shardSplitThreshold:1e3,fileImportConcurrency:50,blockWriteConcurrency:10,minChunkSize:262144,maxChunkSize:262144,avgChunkSize:262144,window:16,polynomial:0x3df305dfb2a804,maxChildrenPerNode:174,layerRepeat:4,wrapWithDirectory:!1,recursive:!1,hidden:!1,timeout:void 0,hamtHashFn:async function(e){return(await s.murmur3128.encode(e)).slice(0,8).reverse()},hamtHashCode:34,hamtBucketBits:8};t.exports=(e={})=>a.default.bind({ignoreUndefined:!0})(c,e)},{"merge-options":"fupyv","multiformats/hashes/sha2":"7i9MT","@multiformats/murmur3":"5DFrl"}],"5DFrl":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/hashes/hasher"),n=e("multiformats");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=s(e("murmurhash3js-revisited"));const a=i.from({name:"murmur3-32",code:35,encode:e=>function(e){const t=new Array(4);for(let r=0;r<4;r++)t[r]=255&e,e>>=8;return new Uint8Array(t)}(o.default.x86.hash32(e))}),c=i.from({name:"murmur3-128",code:34,encode:e=>n.bytes.fromHex(o.default.x64.hash128(e))});r.murmur3128=c,r.murmur332=a},{"multiformats/hashes/hasher":"5z3Qi",multiformats:"3ANyW","murmurhash3js-revisited":"bbEKq"}],bbEKq:[function(e,t,r){t.exports=e("./lib/murmurHash3js")},{"./lib/murmurHash3js":"3dhTD"}],"3dhTD":[function(e,t,r){!function(e,i){var n={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function s(e){if(!Array.isArray(e)&&!ArrayBuffer.isView(e))return!1;for(var t=0;t255)return!1;return!0}function o(e,t){return(65535&e)*t+(((e>>>16)*t&65535)<<16)}function a(e,t){return e<>>32-t}function c(e){return e=o(e^=e>>>16,2246822507),e=o(e^=e>>>13,3266489909),e^=e>>>16}function u(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var r=[0,0,0,0];return r[3]+=e[3]+t[3],r[2]+=r[3]>>>16,r[3]&=65535,r[2]+=e[2]+t[2],r[1]+=r[2]>>>16,r[2]&=65535,r[1]+=e[1]+t[1],r[0]+=r[1]>>>16,r[1]&=65535,r[0]+=e[0]+t[0],r[0]&=65535,[r[0]<<16|r[1],r[2]<<16|r[3]]}function l(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var r=[0,0,0,0];return r[3]+=e[3]*t[3],r[2]+=r[3]>>>16,r[3]&=65535,r[2]+=e[2]*t[3],r[1]+=r[2]>>>16,r[2]&=65535,r[2]+=e[3]*t[2],r[1]+=r[2]>>>16,r[2]&=65535,r[1]+=e[1]*t[3],r[0]+=r[1]>>>16,r[1]&=65535,r[1]+=e[2]*t[2],r[0]+=r[1]>>>16,r[1]&=65535,r[1]+=e[3]*t[1],r[0]+=r[1]>>>16,r[1]&=65535,r[0]+=e[0]*t[3]+e[1]*t[2]+e[2]*t[1]+e[3]*t[0],r[0]&=65535,[r[0]<<16|r[1],r[2]<<16|r[3]]}function d(e,t){return 32===(t%=64)?[e[1],e[0]]:t<32?[e[0]<>>32-t,e[1]<>>32-t]:(t-=32,[e[1]<>>32-t,e[0]<>>32-t])}function f(e,t){return 0===(t%=64)?e:t<32?[e[0]<>>32-t,e[1]<>>1]),e=h(e=l(e,[4283543511,3981806797]),[0,e[0]>>>1]),e=h(e=l(e,[3301882366,444984403]),[0,e[0]>>>1])}n.x86.hash32=function(e,t){if(n.inputValidation&&!s(e))return i;t=t||0;for(var r=e.length%4,u=e.length-r,l=t,d=0,f=3432918353,h=461845907,p=0;p>>0},n.x86.hash128=function(e,t){if(n.inputValidation&&!s(e))return i;t=t||0;for(var r=e.length%16,u=e.length-r,l=t,d=t,f=t,h=t,p=0,g=0,y=0,m=0,b=597399067,v=2869860233,w=951274213,_=2716044179,E=0;E>>0).toString(16)).slice(-8)+("00000000"+(d>>>0).toString(16)).slice(-8)+("00000000"+(f>>>0).toString(16)).slice(-8)+("00000000"+(h>>>0).toString(16)).slice(-8)},n.x64.hash128=function(e,t){if(n.inputValidation&&!s(e))return i;t=t||0;for(var r=e.length%16,o=e.length-r,a=[0,t],c=[0,t],g=[0,0],y=[0,0],m=[2277735313,289559509],b=[1291169091,658871167],v=0;v>>0).toString(16)).slice(-8)+("00000000"+(a[1]>>>0).toString(16)).slice(-8)+("00000000"+(c[0]>>>0).toString(16)).slice(-8)+("00000000"+(c[1]>>>0).toString(16)).slice(-8)},void 0!==r?(void 0!==t&&t.exports&&(r=t.exports=n),r.murmurHash3=n):"function"==typeof define&&define.amd?define([],(function(){return n})):(n._murmurHash3=e.murmurHash3,n.noConflict=function(){return e.murmurHash3=n._murmurHash3,n._murmurHash3=i,n.noConflict=i,n},e.murmurHash3=n)}(this)},{}],adT9a:[function(e,t,r){"use strict";var i=e("./dir.js"),n=e("./file/index.js"),s=e("err-code"),o=e("../chunker/rabin.js"),a=e("../chunker/fixed-size.js"),c=e("./validate-chunks.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=u(s);function d(e){try{if(e instanceof Uint8Array)return async function*(){yield e}();if(t=e,Symbol.iterator in t)return async function*(){yield*e}();if(function(e){return Symbol.asyncIterator in e}(e))return e}catch{throw l.default(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}var t;throw l.default(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}t.exports=async function*(e,t,r){for await(const s of e)if(s.path&&("./"===s.path.substring(0,2)&&(r.wrapWithDirectory=!0),s.path=s.path.split("/").filter((e=>e&&"."!==e)).join("/")),s.content){let e,i;e="function"==typeof r.chunker?r.chunker:"rabin"===r.chunker?o:a,i="function"==typeof r.chunkValidator?r.chunkValidator:c;const u={path:s.path,mtime:s.mtime,mode:s.mode,content:e(i(d(s.content),r),r)};yield()=>n(u,t,r)}else{if(!s.path)throw new Error("Import candidate must have content or path or both");{const e={path:s.path,mtime:s.mtime,mode:s.mode};yield()=>i(e,t,r)}}}},{"./dir.js":"hHI2W","./file/index.js":"cYjOH","err-code":"chZjB","../chunker/rabin.js":"i876B","../chunker/fixed-size.js":"hCl8p","./validate-chunks.js":"aCNgw"}],hHI2W:[function(e,t,r){"use strict";var i=e("ipfs-unixfs"),n=e("../utils/persist.js"),s=e("@ipld/dag-pb");t.exports=async(e,t,r)=>{const o=new i.UnixFS({type:"directory",mtime:e.mtime,mode:e.mode}),a=s.encode(s.prepare({Data:o.marshal()}));return{cid:await n(a,t,r),path:e.path,unixfs:o,size:a.length}}},{"ipfs-unixfs":"dF9VO","../utils/persist.js":"9mA89","@ipld/dag-pb":"i2cdx"}],"9mA89":[function(e,t,r){"use strict";var i=e("multiformats/cid"),n=e("@ipld/dag-pb"),s=e("multiformats/hashes/sha2");function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var a=o(n);t.exports=async(e,t,r)=>{r.codec||(r.codec=a),r.hasher||(r.hasher=s.sha256),void 0===r.cidVersion&&(r.cidVersion=1),r.codec===a&&r.hasher!==s.sha256&&(r.cidVersion=1);const n=await r.hasher.digest(e),o=i.CID.create(r.cidVersion,r.codec.code,n);return r.onlyHash||await t.put(o,e,{signal:r.signal}),o}},{"multiformats/cid":"9ooAY","@ipld/dag-pb":"i2cdx","multiformats/hashes/sha2":"7i9MT"}],cYjOH:[function(e,t,r){"use strict";var i=e("err-code"),n=e("ipfs-unixfs"),s=e("../../utils/persist.js"),o=e("@ipld/dag-pb"),a=e("it-parallel-batch"),c=e("multiformats/codecs/raw"),u=e("./flat.js"),l=e("./balanced.js"),d=e("./trickle.js"),f=e("./buffer-importer.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function p(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var g=h(i),y=p(o),m=h(a),b=p(c);const v={flat:u,balanced:l,trickle:d};t.exports=function(e,t,r){const i=v[r.strategy];if(!i)throw g.default(new Error(`Unknown importer build strategy name: ${r.strategy}`),"ERR_BAD_STRATEGY");return i(async function*(e,t,r){let i,n,s=-1;n="function"==typeof r.bufferImporter?r.bufferImporter:f;for await(const o of m.default(n(e,t,r),r.blockWriteConcurrency))s++,0!==s?(1===s&&i&&(yield i,i=null),yield o):i=o;i&&(i.single=!0,yield i)}(e,t,r),((e,t,r)=>async function(i){if(1===i.length&&i[0].single&&r.reduceSingleLeafToSelf){const a=i[0];if(a.cid.code===b.code&&(void 0!==e.mtime||void 0!==e.mode)){let i=await t.get(a.cid);a.unixfs=new n.UnixFS({type:"file",mtime:e.mtime,mode:e.mode,data:i}),i=o.encode(o.prepare({Data:a.unixfs.marshal()})),a.cid=await s(i,t,{...r,codec:y,hasher:r.hasher,cidVersion:r.cidVersion}),a.size=i.length}return{cid:a.cid,path:e.path,unixfs:a.unixfs,size:a.size}}const a=new n.UnixFS({type:"file",mtime:e.mtime,mode:e.mode}),c=i.filter((e=>!(e.cid.code!==b.code||!e.size)||!(!e.unixfs||e.unixfs.data||!e.unixfs.fileSize())||Boolean(e.unixfs&&e.unixfs.data&&e.unixfs.data.length))).map((e=>e.cid.code===b.code?(a.addBlockSize(e.size),{Name:"",Tsize:e.size,Hash:e.cid}):(e.unixfs&&e.unixfs.data?a.addBlockSize(e.unixfs.data.length):a.addBlockSize(e.unixfs&&e.unixfs.fileSize()||0),{Name:"",Tsize:e.size,Hash:e.cid}))),u={Data:a.marshal(),Links:c},l=o.encode(o.prepare(u));return{cid:await s(l,t,r),path:e.path,unixfs:a,size:l.length+u.Links.reduce(((e,t)=>e+t.Tsize),0)}})(e,t,r),r)}},{"err-code":"chZjB","ipfs-unixfs":"dF9VO","../../utils/persist.js":"9mA89","@ipld/dag-pb":"i2cdx","it-parallel-batch":"lPBqc","multiformats/codecs/raw":"fdfgp","./flat.js":"4ZIt7","./balanced.js":"15x1A","./trickle.js":"6UQnz","./buffer-importer.js":"duyTY"}],"4ZIt7":[function(e,t,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=i(e("it-all"));t.exports=async function(e,t){return t(await n.default(e))}},{"it-all":"iCXBu"}],"15x1A":[function(e,t,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=i(e("it-batch"));async function s(e,t,r){const i=[];for await(const s of n.default(e,r.maxChildrenPerNode))i.push(await t(s));return i.length>1?s(i,t,r):i[0]}t.exports=function(e,t,r){return s(e,t,r)}},{"it-batch":"97xIF"}],"6UQnz":[function(e,t,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=i(e("it-batch"));class s{constructor(e,t,r=0){this.maxDepth=e,this.layerRepeat=t,this.currentDepth=1,this.iteration=r,this.root=this.node=this.parent={children:[],depth:this.currentDepth,maxDepth:e,maxChildren:(this.maxDepth-this.currentDepth)*this.layerRepeat}}isFull(){if(!this.root.data)return!1;if(this.currentDepthe.data)).map((e=>this._reduce(e,t))))),t((e.data||[]).concat(r))}_findParent(e,t){const r=e.parent;if(r&&0!==r.depth)return r.children.length!==r.maxChildren&&r.maxChildren?r:this._findParent(r,t)}}class o extends s{constructor(e){super(0,e),this.root.depth=0,this.currentDepth=1}addChild(e){this.root.children.push(e)}reduce(e){return e((this.root.data||[]).concat(this.root.children))}}t.exports=async function(e,t,r){const i=new o(r.layerRepeat);let a=0,c=1,u=i;for await(const o of n.default(e,r.maxChildrenPerNode))u.isFull()&&(u!==i&&i.addChild(await u.reduce(t)),a&&a%r.layerRepeat==0&&c++,u=new s(c,r.layerRepeat,a),a++),u.append(o);return u&&u!==i&&i.addChild(await u.reduce(t)),i.reduce(t)}},{"it-batch":"97xIF"}],duyTY:[function(e,t,r){"use strict";var i=e("ipfs-unixfs"),n=e("../../utils/persist.js"),s=e("@ipld/dag-pb"),o=e("multiformats/codecs/raw");function a(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var c=a(s),u=a(o);t.exports=async function*(e,t,r){for await(let s of e.content)yield async()=>{let o;r.progress(s.length,e.path);const a={codec:c,cidVersion:r.cidVersion,hasher:r.hasher,onlyHash:r.onlyHash};return r.rawLeaves?(a.codec=u,a.cidVersion=1):(o=new i.UnixFS({type:r.leafType,data:s,mtime:e.mtime,mode:e.mode}),s=c.encode({Data:o.marshal(),Links:[]})),{cid:await n(s,t,a),unixfs:o,size:s.length}}}},{"ipfs-unixfs":"dF9VO","../../utils/persist.js":"9mA89","@ipld/dag-pb":"i2cdx","multiformats/codecs/raw":"fdfgp"}],i876B:[function(e,t,r){"use strict";var i=e("bl/BufferList.js"),n=e("rabin-wasm"),s=e("err-code");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(i),c=o(s);t.exports=async function*(e,t){let r,i,s;if(t.minChunkSize&&t.maxChunkSize&&t.avgChunkSize)s=t.avgChunkSize,r=t.minChunkSize,i=t.maxChunkSize;else{if(!t.avgChunkSize)throw c.default(new Error("please specify an average chunk size"),"ERR_INVALID_AVG_CHUNK_SIZE");s=t.avgChunkSize,r=s/3,i=s+s/2}if(r<16)throw c.default(new Error("rabin min must be greater than 16"),"ERR_INVALID_MIN_CHUNK_SIZE");ithis.length||e<0)return;const t=this._offset(e);return this._bufs[t[0]][t[1]]},s.prototype.slice=function(e,t){return"number"==typeof e&&e<0&&(e+=this.length),"number"==typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},s.prototype.copy=function(e,t,r,n){if(("number"!=typeof r||r<0)&&(r=0),("number"!=typeof n||n>this.length)&&(n=this.length),r>=this.length)return e||i.alloc(0);if(n<=0)return e||i.alloc(0);const s=!!e,o=this._offset(r),a=n-r;let c=a,u=s&&t||0,l=o[1];if(0===r&&n===this.length){if(!s)return 1===this._bufs.length?this._bufs[0]:i.concat(this._bufs,this.length);for(let t=0;tr)){this._bufs[t].copy(e,u,l,l+c),u+=r;break}this._bufs[t].copy(e,u,l),u+=r,c-=r,l&&(l=0)}return e.length>u?e.slice(0,u):e},s.prototype.shallowSlice=function(e,t){if(e=e||0,t="number"!=typeof t?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return this._new();const r=this._offset(e),i=this._offset(t),n=this._bufs.slice(r[0],i[0]+1);return 0===i[1]?n.pop():n[n.length-1]=n[n.length-1].slice(0,i[1]),0!==r[1]&&(n[0]=n[0].slice(r[1])),this._new(n)},s.prototype.toString=function(e,t,r){return this.slice(t,r).toString(e)},s.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},s.prototype.duplicate=function(){const e=this._new();for(let t=0;tthis.length?this.length:t;const n=this._offset(t);let s=n[0],o=n[1];for(;s=e.length){const r=t.indexOf(e,o);if(-1!==r)return this._reverseOffset([s,r]);o=t.length-e.length+1}else{const t=this._reverseOffset([s,o]);if(this._match(t,e))return t;o++}}o=0}return-1},s.prototype._match=function(e,t){if(this.length-e * @license MIT */"use strict";var i=e("base64-js"),n=e("ieee754"),s="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=c,r.SlowBuffer=function(e){+e!=e&&(e=0);return c.alloc(+e)},r.INSPECT_MAX_BYTES=50;var o=2147483647;function a(e){if(e>o)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return d(e)}return u(e,t,r)}function u(e,t,r){if("string"==typeof e)return function(e,t){"string"==typeof t&&""!==t||(t="utf8");if(!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|g(e,t),i=a(r),n=i.write(e,t);n!==r&&(i=i.slice(0,n));return i}(e,t);if(ArrayBuffer.isView(e))return function(e){if(K(e,Uint8Array)){var t=new Uint8Array(e);return h(t.buffer,t.byteOffset,t.byteLength)}return f(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(K(e,ArrayBuffer)||e&&K(e.buffer,ArrayBuffer))return h(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(K(e,SharedArrayBuffer)||e&&K(e.buffer,SharedArrayBuffer)))return h(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var i=e.valueOf&&e.valueOf();if(null!=i&&i!==e)return c.from(i,t,r);var n=function(e){if(c.isBuffer(e)){var t=0|p(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}if(void 0!==e.length)return"number"!=typeof e.length||z(e.length)?a(0):f(e);if("Buffer"===e.type&&Array.isArray(e.data))return f(e.data)}(e);if(n)return n;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return c.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function d(e){return l(e),a(e<0?0:0|p(e))}function f(e){for(var t=e.length<0?0:0|p(e.length),r=a(t),i=0;i=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function g(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||K(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return N(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return U(e).length;default:if(n)return i?-1:N(e).length;t=(""+t).toLowerCase(),n=!0}}function y(e,t,r){var i=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return O(this,t,r);case"utf8":case"utf-8":return k(this,t,r);case"ascii":return R(this,t,r);case"latin1":case"binary":return P(this,t,r);case"base64":return A(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),i=!0}}function m(e,t,r){var i=e[t];e[t]=e[r],e[r]=i}function b(e,t,r,i,n){if(0===e.length)return-1;if("string"==typeof r?(i=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),z(r=+r)&&(r=n?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(n)return-1;r=e.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof t&&(t=c.from(t,i)),c.isBuffer(t))return 0===t.length?-1:v(e,t,r,i,n);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):v(e,[t],r,i,n);throw new TypeError("val must be string, number or Buffer")}function v(e,t,r,i,n){var s,o=1,a=e.length,c=t.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(e.length<2||t.length<2)return-1;o=2,a/=2,c/=2,r/=2}function u(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(n){var l=-1;for(s=r;sa&&(r=a-c),s=r;s>=0;s--){for(var d=!0,f=0;fn&&(i=n):i=n;var s=t.length;i>s/2&&(i=s/2);for(var o=0;o>8,n=r%256,s.push(n),s.push(i);return s}(t,e.length-r),e,r,i)}function A(e,t,r){return 0===t&&r===e.length?i.fromByteArray(e):i.fromByteArray(e.slice(t,r))}function k(e,t,r){r=Math.min(e.length,r);for(var i=[],n=t;n239?4:u>223?3:u>191?2:1;if(n+d<=r)switch(d){case 1:u<128&&(l=u);break;case 2:128==(192&(s=e[n+1]))&&(c=(31&u)<<6|63&s)>127&&(l=c);break;case 3:s=e[n+1],o=e[n+2],128==(192&s)&&128==(192&o)&&(c=(15&u)<<12|(63&s)<<6|63&o)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:s=e[n+1],o=e[n+2],a=e[n+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(c=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,d=1):l>65535&&(l-=65536,i.push(l>>>10&1023|55296),l=56320|1023&l),i.push(l),n+=d}return function(e){var t=e.length;if(t<=I)return String.fromCharCode.apply(String,e);var r="",i=0;for(;ii.length?c.from(s).copy(i,n):Uint8Array.prototype.set.call(i,s,n);else{if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,n)}n+=s.length}return i},c.byteLength=g,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;tt&&(e+=" ... "),""},s&&(c.prototype[s]=c.prototype.inspect),c.prototype.compare=function(e,t,r,i,n){if(K(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),t<0||r>e.length||i<0||n>this.length)throw new RangeError("out of range index");if(i>=n&&t>=r)return 0;if(i>=n)return-1;if(t>=r)return 1;if(this===e)return 0;for(var s=(n>>>=0)-(i>>>=0),o=(r>>>=0)-(t>>>=0),a=Math.min(s,o),u=this.slice(i,n),l=e.slice(t,r),d=0;d>>=0,isFinite(r)?(r>>>=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}var n=this.length-t;if((void 0===r||r>n)&&(r=n),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var s=!1;;)switch(i){case"hex":return w(this,e,t,r);case"utf8":case"utf-8":return _(this,e,t,r);case"ascii":case"latin1":case"binary":return E(this,e,t,r);case"base64":return S(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function R(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;ni)&&(r=i);for(var n="",s=t;sr)throw new RangeError("Trying to access beyond buffer length")}function D(e,t,r,i,n,s){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>n||te.length)throw new RangeError("Index out of range")}function M(e,t,r,i,n,s){if(r+i>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function x(e,t,r,i,s){return t=+t,r>>>=0,s||M(e,0,r,4),n.write(e,t,r,i,23,4),r+4}function B(e,t,r,i,s){return t=+t,r>>>=0,s||M(e,0,r,8),n.write(e,t,r,i,52,8),r+8}c.prototype.slice=function(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||j(e,t,this.length);for(var i=this[e],n=1,s=0;++s>>=0,t>>>=0,r||j(e,t,this.length);for(var i=this[e+--t],n=1;t>0&&(n*=256);)i+=this[e+--t]*n;return i},c.prototype.readUint8=c.prototype.readUInt8=function(e,t){return e>>>=0,t||j(e,1,this.length),this[e]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||j(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||j(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(e,t){return e>>>=0,t||j(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(e,t){return e>>>=0,t||j(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||j(e,t,this.length);for(var i=this[e],n=1,s=0;++s=(n*=128)&&(i-=Math.pow(2,8*t)),i},c.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||j(e,t,this.length);for(var i=t,n=1,s=this[e+--i];i>0&&(n*=256);)s+=this[e+--i]*n;return s>=(n*=128)&&(s-=Math.pow(2,8*t)),s},c.prototype.readInt8=function(e,t){return e>>>=0,t||j(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){e>>>=0,t||j(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(e,t){e>>>=0,t||j(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(e,t){return e>>>=0,t||j(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return e>>>=0,t||j(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return e>>>=0,t||j(e,4,this.length),n.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||j(e,4,this.length),n.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||j(e,8,this.length),n.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||j(e,8,this.length),n.read(this,e,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(e,t,r,i){(e=+e,t>>>=0,r>>>=0,i)||D(this,e,t,r,Math.pow(2,8*r)-1,0);var n=1,s=0;for(this[t]=255&e;++s>>=0,r>>>=0,i)||D(this,e,t,r,Math.pow(2,8*r)-1,0);var n=r-1,s=1;for(this[t+n]=255&e;--n>=0&&(s*=256);)this[t+n]=e/s&255;return t+r},c.prototype.writeUint8=c.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeIntLE=function(e,t,r,i){if(e=+e,t>>>=0,!i){var n=Math.pow(2,8*r-1);D(this,e,t,r,n-1,-n)}var s=0,o=1,a=0;for(this[t]=255&e;++s>0)-a&255;return t+r},c.prototype.writeIntBE=function(e,t,r,i){if(e=+e,t>>>=0,!i){var n=Math.pow(2,8*r-1);D(this,e,t,r,n-1,-n)}var s=r-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||D(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},c.prototype.writeFloatLE=function(e,t,r){return x(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return x(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return B(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return B(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,i){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(s=t;s55295&&r<57344){if(!n){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===i){(t-=3)>-1&&s.push(239,191,189);continue}n=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&(t-=3)>-1&&s.push(239,191,189);if(n=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.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;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function U(e){return i.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(L,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function F(e,t,r,i){for(var n=0;n=t.length||n>=e.length);++n)t[n+r]=e[n];return n}function K(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function z(e){return e!=e}var V=function(){for(var e="0123456789abcdef",t=new Array(256),r=0;r<16;++r)for(var i=16*r,n=0;n<16;++n)t[i+n]=e[r]+e[n];return t}()},{"base64-js":"9DJbh",ieee754:"7sDZQ"}],"9DJbh":[function(e,t,r){"use strict";r.byteLength=function(e){var t=u(e),r=t[0],i=t[1];return 3*(r+i)/4-i},r.toByteArray=function(e){var t,r,i=u(e),o=i[0],a=i[1],c=new s(function(e,t,r){return 3*(t+r)/4-r}(0,o,a)),l=0,d=a>0?o-4:o;for(r=0;r>16&255,c[l++]=t>>8&255,c[l++]=255&t;2===a&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,c[l++]=255&t);1===a&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,c[l++]=t>>8&255,c[l++]=255&t);return c},r.fromByteArray=function(e){for(var t,r=e.length,n=r%3,s=[],o=16383,a=0,c=r-n;ac?c:a+o));1===n?(t=e[r-1],s.push(i[t>>2]+i[t<<4&63]+"==")):2===n&&(t=(e[r-2]<<8)+e[r-1],s.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+"="));return s.join("")};for(var i=[],n=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function l(e,t,r){for(var n,s,o=[],a=t;a>18&63]+i[s>>12&63]+i[s>>6&63]+i[63&s]);return o.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},{}],"7sDZQ":[function(e,t,r){ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */r.read=function(e,t,r,i,n){var s,o,a=8*n-i-1,c=(1<>1,l=-7,d=r?n-1:0,f=r?-1:1,h=e[t+d];for(d+=f,s=h&(1<<-l)-1,h>>=-l,l+=a;l>0;s=256*s+e[t+d],d+=f,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=i;l>0;o=256*o+e[t+d],d+=f,l-=8);if(0===s)s=1-u;else{if(s===c)return o?NaN:1/0*(h?-1:1);o+=Math.pow(2,i),s-=u}return(h?-1:1)*o*Math.pow(2,s-i)},r.write=function(e,t,r,i,n,s){var o,a,c,u=8*s-n-1,l=(1<>1,f=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,h=i?0:s-1,p=i?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+d>=1?f/c:f*Math.pow(2,1-d))*c>=2&&(o++,c/=2),o+d>=l?(a=0,o=l):o+d>=1?(a=(t*c-1)*Math.pow(2,n),o+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,n),o=0));n>=8;e[r+h]=255&a,h+=p,a/=256,n-=8);for(o=o<0;e[r+h]=255&o,h+=p,o/=256,u-=8);e[r+h-p]|=128*g}},{}],"6Q8Fq":[function(e,t,r){const i=e("./rabin"),n=e("../dist/rabin-wasm.node.js");t.exports={Rabin:i,create:async(e,t,r,s,o)=>{const a=await n();return new i(a,e,t,r,s,o)}}},{"./rabin":"eVeCF","../dist/rabin-wasm.node.js":"bOJoE"}],eVeCF:[function(e,t,r){t.exports=class{constructor(e,t=12,r=8192,i=32768,n=64,s){this.bits=t,this.min=r,this.max=i,this.asModule=e,this.rabin=new e.Rabin(t,r,i,n,s),this.polynomial=s}fingerprint(e){const{__retain:t,__release:r,__allocArray:i,__getInt32Array:n,Int32Array_ID:s,Uint8Array_ID:o}=this.asModule,a=t(i(s,new Int32Array(Math.ceil(e.length/this.min)))),c=t(i(o,e)),u=n(this.rabin.fingerprint(c,a));r(c),r(a);const l=u.indexOf(0);return l>=0?u.subarray(0,l):u}}},{}],bOJoE:[function(e,t,r){const{instantiate:i}=e("@assemblyscript/loader");function n(e={}){if(!n.supported)return null;var t=new Uint8Array([0,97,115,109,1,0,0,0,1,78,14,96,2,127,126,0,96,1,127,1,126,96,2,127,127,0,96,1,127,1,127,96,1,127,0,96,2,127,127,1,127,96,3,127,127,127,1,127,96,0,0,96,3,127,127,127,0,96,0,1,127,96,4,127,127,127,127,0,96,5,127,127,127,127,127,1,127,96,1,126,1,127,96,2,126,126,1,126,2,13,1,3,101,110,118,5,97,98,111,114,116,0,10,3,54,53,2,2,8,9,3,5,2,8,6,5,3,4,2,6,9,12,13,2,5,11,3,2,3,2,3,2,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,6,7,7,4,4,5,3,1,0,1,6,47,9,127,1,65,0,11,127,1,65,0,11,127,0,65,3,11,127,0,65,4,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,0,65,240,2,11,127,0,65,6,11,7,240,5,41,6,109,101,109,111,114,121,2,0,7,95,95,97,108,108,111,99,0,10,8,95,95,114,101,116,97,105,110,0,11,9,95,95,114,101,108,101,97,115,101,0,12,9,95,95,99,111,108,108,101,99,116,0,51,11,95,95,114,116,116,105,95,98,97,115,101,3,7,13,73,110,116,51,50,65,114,114,97,121,95,73,68,3,2,13,85,105,110,116,56,65,114,114,97,121,95,73,68,3,3,6,100,101,103,114,101,101,0,16,3,109,111,100,0,17,5,82,97,98,105,110,3,8,16,82,97,98,105,110,35,103,101,116,58,119,105,110,100,111,119,0,21,16,82,97,98,105,110,35,115,101,116,58,119,105,110,100,111,119,0,22,21,82,97,98,105,110,35,103,101,116,58,119,105,110,100,111,119,95,115,105,122,101,0,23,21,82,97,98,105,110,35,115,101,116,58,119,105,110,100,111,119,95,115,105,122,101,0,24,14,82,97,98,105,110,35,103,101,116,58,119,112,111,115,0,25,14,82,97,98,105,110,35,115,101,116,58,119,112,111,115,0,26,15,82,97,98,105,110,35,103,101,116,58,99,111,117,110,116,0,27,15,82,97,98,105,110,35,115,101,116,58,99,111,117,110,116,0,28,13,82,97,98,105,110,35,103,101,116,58,112,111,115,0,29,13,82,97,98,105,110,35,115,101,116,58,112,111,115,0,30,15,82,97,98,105,110,35,103,101,116,58,115,116,97,114,116,0,31,15,82,97,98,105,110,35,115,101,116,58,115,116,97,114,116,0,32,16,82,97,98,105,110,35,103,101,116,58,100,105,103,101,115,116,0,33,16,82,97,98,105,110,35,115,101,116,58,100,105,103,101,115,116,0,34,21,82,97,98,105,110,35,103,101,116,58,99,104,117,110,107,95,115,116,97,114,116,0,35,21,82,97,98,105,110,35,115,101,116,58,99,104,117,110,107,95,115,116,97,114,116,0,36,22,82,97,98,105,110,35,103,101,116,58,99,104,117,110,107,95,108,101,110,103,116,104,0,37,22,82,97,98,105,110,35,115,101,116,58,99,104,117,110,107,95,108,101,110,103,116,104,0,38,31,82,97,98,105,110,35,103,101,116,58,99,104,117,110,107,95,99,117,116,95,102,105,110,103,101,114,112,114,105,110,116,0,39,31,82,97,98,105,110,35,115,101,116,58,99,104,117,110,107,95,99,117,116,95,102,105,110,103,101,114,112,114,105,110,116,0,40,20,82,97,98,105,110,35,103,101,116,58,112,111,108,121,110,111,109,105,97,108,0,41,20,82,97,98,105,110,35,115,101,116,58,112,111,108,121,110,111,109,105,97,108,0,42,17,82,97,98,105,110,35,103,101,116,58,109,105,110,115,105,122,101,0,43,17,82,97,98,105,110,35,115,101,116,58,109,105,110,115,105,122,101,0,44,17,82,97,98,105,110,35,103,101,116,58,109,97,120,115,105,122,101,0,45,17,82,97,98,105,110,35,115,101,116,58,109,97,120,115,105,122,101,0,46,14,82,97,98,105,110,35,103,101,116,58,109,97,115,107,0,47,14,82,97,98,105,110,35,115,101,116,58,109,97,115,107,0,48,17,82,97,98,105,110,35,99,111,110,115,116,114,117,99,116,111,114,0,20,17,82,97,98,105,110,35,102,105,110,103,101,114,112,114,105,110,116,0,49,8,1,50,10,165,31,53,199,1,1,4,127,32,1,40,2,0,65,124,113,34,2,65,128,2,73,4,127,32,2,65,4,118,33,4,65,0,5,32,2,65,31,32,2,103,107,34,3,65,4,107,118,65,16,115,33,4,32,3,65,7,107,11,33,3,32,1,40,2,20,33,2,32,1,40,2,16,34,5,4,64,32,5,32,2,54,2,20,11,32,2,4,64,32,2,32,5,54,2,16,11,32,1,32,0,32,4,32,3,65,4,116,106,65,2,116,106,40,2,96,70,4,64,32,0,32,4,32,3,65,4,116,106,65,2,116,106,32,2,54,2,96,32,2,69,4,64,32,0,32,3,65,2,116,106,32,0,32,3,65,2,116,106,40,2,4,65,1,32,4,116,65,127,115,113,34,1,54,2,4,32,1,69,4,64,32,0,32,0,40,2,0,65,1,32,3,116,65,127,115,113,54,2,0,11,11,11,11,226,2,1,6,127,32,1,40,2,0,33,3,32,1,65,16,106,32,1,40,2,0,65,124,113,106,34,4,40,2,0,34,5,65,1,113,4,64,32,3,65,124,113,65,16,106,32,5,65,124,113,106,34,2,65,240,255,255,255,3,73,4,64,32,0,32,4,16,1,32,1,32,2,32,3,65,3,113,114,34,3,54,2,0,32,1,65,16,106,32,1,40,2,0,65,124,113,106,34,4,40,2,0,33,5,11,11,32,3,65,2,113,4,64,32,1,65,4,107,40,2,0,34,2,40,2,0,34,6,65,124,113,65,16,106,32,3,65,124,113,106,34,7,65,240,255,255,255,3,73,4,64,32,0,32,2,16,1,32,2,32,7,32,6,65,3,113,114,34,3,54,2,0,32,2,33,1,11,11,32,4,32,5,65,2,114,54,2,0,32,4,65,4,107,32,1,54,2,0,32,0,32,3,65,124,113,34,2,65,128,2,73,4,127,32,2,65,4,118,33,4,65,0,5,32,2,65,31,32,2,103,107,34,2,65,4,107,118,65,16,115,33,4,32,2,65,7,107,11,34,3,65,4,116,32,4,106,65,2,116,106,40,2,96,33,2,32,1,65,0,54,2,16,32,1,32,2,54,2,20,32,2,4,64,32,2,32,1,54,2,16,11,32,0,32,4,32,3,65,4,116,106,65,2,116,106,32,1,54,2,96,32,0,32,0,40,2,0,65,1,32,3,116,114,54,2,0,32,0,32,3,65,2,116,106,32,0,32,3,65,2,116,106,40,2,4,65,1,32,4,116,114,54,2,4,11,119,1,1,127,32,2,2,127,32,0,40,2,160,12,34,2,4,64,32,2,32,1,65,16,107,70,4,64,32,2,40,2,0,33,3,32,1,65,16,107,33,1,11,11,32,1,11,107,34,2,65,48,73,4,64,15,11,32,1,32,3,65,2,113,32,2,65,32,107,65,1,114,114,54,2,0,32,1,65,0,54,2,16,32,1,65,0,54,2,20,32,1,32,2,106,65,16,107,34,2,65,2,54,2,0,32,0,32,2,54,2,160,12,32,0,32,1,16,2,11,155,1,1,3,127,35,0,34,0,69,4,64,65,1,63,0,34,0,74,4,127,65,1,32,0,107,64,0,65,0,72,5,65,0,11,4,64,0,11,65,176,3,34,0,65,0,54,2,0,65,208,15,65,0,54,2,0,3,64,32,1,65,23,73,4,64,32,1,65,2,116,65,176,3,106,65,0,54,2,4,65,0,33,2,3,64,32,2,65,16,73,4,64,32,1,65,4,116,32,2,106,65,2,116,65,176,3,106,65,0,54,2,96,32,2,65,1,106,33,2,12,1,11,11,32,1,65,1,106,33,1,12,1,11,11,65,176,3,65,224,15,63,0,65,16,116,16,3,65,176,3,36,0,11,32,0,11,45,0,32,0,65,240,255,255,255,3,79,4,64,65,32,65,224,0,65,201,3,65,29,16,0,0,11,32,0,65,15,106,65,112,113,34,0,65,16,32,0,65,16,75,27,11,169,1,1,1,127,32,0,32,1,65,128,2,73,4,127,32,1,65,4,118,33,1,65,0,5,32,1,65,248,255,255,255,1,73,4,64,32,1,65,1,65,27,32,1,103,107,116,106,65,1,107,33,1,11,32,1,65,31,32,1,103,107,34,2,65,4,107,118,65,16,115,33,1,32,2,65,7,107,11,34,2,65,2,116,106,40,2,4,65,127,32,1,116,113,34,1,4,127,32,0,32,1,104,32,2,65,4,116,106,65,2,116,106,40,2,96,5,32,0,40,2,0,65,127,32,2,65,1,106,116,113,34,1,4,127,32,0,32,0,32,1,104,34,0,65,2,116,106,40,2,4,104,32,0,65,4,116,106,65,2,116,106,40,2,96,5,65,0,11,11,11,111,1,1,127,63,0,34,2,32,1,65,248,255,255,255,1,73,4,127,32,1,65,1,65,27,32,1,103,107,116,65,1,107,106,5,32,1,11,65,16,32,0,40,2,160,12,32,2,65,16,116,65,16,107,71,116,106,65,255,255,3,106,65,128,128,124,113,65,16,118,34,1,32,2,32,1,74,27,64,0,65,0,72,4,64,32,1,64,0,65,0,72,4,64,0,11,11,32,0,32,2,65,16,116,63,0,65,16,116,16,3,11,113,1,2,127,32,1,40,2,0,34,3,65,124,113,32,2,107,34,4,65,32,79,4,64,32,1,32,2,32,3,65,2,113,114,54,2,0,32,2,32,1,65,16,106,106,34,1,32,4,65,16,107,65,1,114,54,2,0,32,0,32,1,16,2,5,32,1,32,3,65,126,113,54,2,0,32,1,65,16,106,32,1,40,2,0,65,124,113,106,32,1,65,16,106,32,1,40,2,0,65,124,113,106,40,2,0,65,125,113,54,2,0,11,11,91,1,2,127,32,0,32,1,16,5,34,4,16,6,34,3,69,4,64,65,1,36,1,65,0,36,1,32,0,32,4,16,6,34,3,69,4,64,32,0,32,4,16,7,32,0,32,4,16,6,33,3,11,11,32,3,65,0,54,2,4,32,3,32,2,54,2,8,32,3,32,1,54,2,12,32,0,32,3,16,1,32,0,32,3,32,4,16,8,32,3,11,13,0,16,4,32,0,32,1,16,9,65,16,106,11,33,1,1,127,32,0,65,172,3,75,4,64,32,0,65,16,107,34,1,32,1,40,2,4,65,1,106,54,2,4,11,32,0,11,18,0,32,0,65,172,3,75,4,64,32,0,65,16,107,16,52,11,11,140,3,1,1,127,2,64,32,1,69,13,0,32,0,65,0,58,0,0,32,0,32,1,106,65,1,107,65,0,58,0,0,32,1,65,2,77,13,0,32,0,65,1,106,65,0,58,0,0,32,0,65,2,106,65,0,58,0,0,32,0,32,1,106,34,2,65,2,107,65,0,58,0,0,32,2,65,3,107,65,0,58,0,0,32,1,65,6,77,13,0,32,0,65,3,106,65,0,58,0,0,32,0,32,1,106,65,4,107,65,0,58,0,0,32,1,65,8,77,13,0,32,1,65,0,32,0,107,65,3,113,34,1,107,33,2,32,0,32,1,106,34,0,65,0,54,2,0,32,0,32,2,65,124,113,34,1,106,65,4,107,65,0,54,2,0,32,1,65,8,77,13,0,32,0,65,4,106,65,0,54,2,0,32,0,65,8,106,65,0,54,2,0,32,0,32,1,106,34,2,65,12,107,65,0,54,2,0,32,2,65,8,107,65,0,54,2,0,32,1,65,24,77,13,0,32,0,65,12,106,65,0,54,2,0,32,0,65,16,106,65,0,54,2,0,32,0,65,20,106,65,0,54,2,0,32,0,65,24,106,65,0,54,2,0,32,0,32,1,106,34,2,65,28,107,65,0,54,2,0,32,2,65,24,107,65,0,54,2,0,32,2,65,20,107,65,0,54,2,0,32,2,65,16,107,65,0,54,2,0,32,0,32,0,65,4,113,65,24,106,34,2,106,33,0,32,1,32,2,107,33,1,3,64,32,1,65,32,79,4,64,32,0,66,0,55,3,0,32,0,65,8,106,66,0,55,3,0,32,0,65,16,106,66,0,55,3,0,32,0,65,24,106,66,0,55,3,0,32,1,65,32,107,33,1,32,0,65,32,106,33,0,12,1,11,11,11,11,178,1,1,3,127,32,1,65,240,255,255,255,3,32,2,118,75,4,64,65,144,1,65,192,1,65,23,65,56,16,0,0,11,32,1,32,2,116,34,3,65,0,16,10,34,2,32,3,16,13,32,0,69,4,64,65,12,65,2,16,10,34,0,65,172,3,75,4,64,32,0,65,16,107,34,1,32,1,40,2,4,65,1,106,54,2,4,11,11,32,0,65,0,54,2,0,32,0,65,0,54,2,4,32,0,65,0,54,2,8,32,2,34,1,32,0,40,2,0,34,4,71,4,64,32,1,65,172,3,75,4,64,32,1,65,16,107,34,5,32,5,40,2,4,65,1,106,54,2,4,11,32,4,16,12,11,32,0,32,1,54,2,0,32,0,32,2,54,2,4,32,0,32,3,54,2,8,32,0,11,46,1,2,127,65,12,65,5,16,10,34,0,65,172,3,75,4,64,32,0,65,16,107,34,1,32,1,40,2,4,65,1,106,54,2,4,11,32,0,65,128,2,65,3,16,14,11,9,0,65,63,32,0,121,167,107,11,49,1,2,127,65,63,32,1,121,167,107,33,2,3,64,65,63,32,0,121,167,107,32,2,107,34,3,65,0,78,4,64,32,0,32,1,32,3,172,134,133,33,0,12,1,11,11,32,0,11,40,0,32,1,32,0,40,2,8,79,4,64,65,128,2,65,192,2,65,163,1,65,44,16,0,0,11,32,1,32,0,40,2,4,106,65,0,58,0,0,11,38,0,32,1,32,0,40,2,8,79,4,64,65,128,2,65,192,2,65,152,1,65,44,16,0,0,11,32,1,32,0,40,2,4,106,45,0,0,11,254,5,2,1,127,4,126,32,0,69,4,64,65,232,0,65,6,16,10,34,0,65,172,3,75,4,64,32,0,65,16,107,34,5,32,5,40,2,4,65,1,106,54,2,4,11,11,32,0,65,0,54,2,0,32,0,65,0,54,2,4,32,0,65,0,54,2,8,32,0,66,0,55,3,16,32,0,66,0,55,3,24,32,0,66,0,55,3,32,32,0,66,0,55,3,40,32,0,66,0,55,3,48,32,0,66,0,55,3,56,32,0,66,0,55,3,64,32,0,66,0,55,3,72,32,0,66,0,55,3,80,32,0,66,0,55,3,88,32,0,66,0,55,3,96,32,0,32,2,173,55,3,80,32,0,32,3,173,55,3,88,65,12,65,4,16,10,34,2,65,172,3,75,4,64,32,2,65,16,107,34,3,32,3,40,2,4,65,1,106,54,2,4,11,32,2,32,4,65,0,16,14,33,2,32,0,40,2,0,16,12,32,0,32,2,54,2,0,32,0,32,4,54,2,4,32,0,66,1,32,1,173,134,66,1,125,55,3,96,32,0,66,243,130,183,218,216,230,232,30,55,3,72,35,4,69,4,64,65,0,33,2,3,64,32,2,65,128,2,72,4,64,32,2,65,255,1,113,173,33,6,32,0,41,3,72,34,7,33,8,65,63,32,7,121,167,107,33,1,3,64,65,63,32,6,121,167,107,32,1,107,34,3,65,0,78,4,64,32,6,32,8,32,3,172,134,133,33,6,12,1,11,11,65,0,33,4,3,64,32,4,32,0,40,2,4,65,1,107,72,4,64,32,6,66,8,134,33,6,32,0,41,3,72,34,7,33,8,65,63,32,7,121,167,107,33,1,3,64,65,63,32,6,121,167,107,32,1,107,34,3,65,0,78,4,64,32,6,32,8,32,3,172,134,133,33,6,12,1,11,11,32,4,65,1,106,33,4,12,1,11,11,35,6,40,2,4,32,2,65,3,116,106,32,6,55,3,0,32,2,65,1,106,33,2,12,1,11,11,65,63,32,0,41,3,72,121,167,107,172,33,7,65,0,33,2,3,64,32,2,65,128,2,72,4,64,35,5,33,1,32,2,172,32,7,134,34,8,33,6,65,63,32,0,41,3,72,34,9,121,167,107,33,3,3,64,65,63,32,6,121,167,107,32,3,107,34,4,65,0,78,4,64,32,6,32,9,32,4,172,134,133,33,6,12,1,11,11,32,1,40,2,4,32,2,65,3,116,106,32,6,32,8,132,55,3,0,32,2,65,1,106,33,2,12,1,11,11,65,1,36,4,11,32,0,66,0,55,3,24,32,0,66,0,55,3,32,65,0,33,2,3,64,32,2,32,0,40,2,4,72,4,64,32,0,40,2,0,32,2,16,18,32,2,65,1,106,33,2,12,1,11,11,32,0,66,0,55,3,40,32,0,65,0,54,2,8,32,0,66,0,55,3,16,32,0,66,0,55,3,40,32,0,40,2,0,32,0,40,2,8,16,19,33,1,32,0,40,2,8,32,0,40,2,0,40,2,4,106,65,1,58,0,0,32,0,32,0,41,3,40,35,6,40,2,4,32,1,65,3,116,106,41,3,0,133,55,3,40,32,0,32,0,40,2,8,65,1,106,32,0,40,2,4,111,54,2,8,32,0,35,5,40,2,4,32,0,41,3,40,34,6,66,45,136,167,65,3,116,106,41,3,0,32,6,66,8,134,66,1,132,133,55,3,40,32,0,11,38,1,1,127,32,0,40,2,0,34,0,65,172,3,75,4,64,32,0,65,16,107,34,1,32,1,40,2,4,65,1,106,54,2,4,11,32,0,11,55,1,2,127,32,1,32,0,40,2,0,34,2,71,4,64,32,1,65,172,3,75,4,64,32,1,65,16,107,34,3,32,3,40,2,4,65,1,106,54,2,4,11,32,2,16,12,11,32,0,32,1,54,2,0,11,7,0,32,0,40,2,4,11,9,0,32,0,32,1,54,2,4,11,7,0,32,0,40,2,8,11,9,0,32,0,32,1,54,2,8,11,7,0,32,0,41,3,16,11,9,0,32,0,32,1,55,3,16,11,7,0,32,0,41,3,24,11,9,0,32,0,32,1,55,3,24,11,7,0,32,0,41,3,32,11,9,0,32,0,32,1,55,3,32,11,7,0,32,0,41,3,40,11,9,0,32,0,32,1,55,3,40,11,7,0,32,0,41,3,48,11,9,0,32,0,32,1,55,3,48,11,7,0,32,0,41,3,56,11,9,0,32,0,32,1,55,3,56,11,7,0,32,0,41,3,64,11,9,0,32,0,32,1,55,3,64,11,7,0,32,0,41,3,72,11,9,0,32,0,32,1,55,3,72,11,7,0,32,0,41,3,80,11,9,0,32,0,32,1,55,3,80,11,7,0,32,0,41,3,88,11,9,0,32,0,32,1,55,3,88,11,7,0,32,0,41,3,96,11,9,0,32,0,32,1,55,3,96,11,172,4,2,5,127,1,126,32,2,65,172,3,75,4,64,32,2,65,16,107,34,4,32,4,40,2,4,65,1,106,54,2,4,11,32,2,33,4,65,0,33,2,32,1,40,2,8,33,5,32,1,40,2,4,33,6,3,64,2,127,65,0,33,3,3,64,32,3,32,5,72,4,64,32,3,32,6,106,45,0,0,33,1,32,0,40,2,0,32,0,40,2,8,16,19,33,7,32,0,40,2,8,32,0,40,2,0,40,2,4,106,32,1,58,0,0,32,0,32,0,41,3,40,35,6,40,2,4,32,7,65,3,116,106,41,3,0,133,55,3,40,32,0,32,0,40,2,8,65,1,106,32,0,40,2,4,111,54,2,8,32,0,35,5,40,2,4,32,0,41,3,40,34,8,66,45,136,167,65,3,116,106,41,3,0,32,1,173,32,8,66,8,134,132,133,55,3,40,32,0,32,0,41,3,16,66,1,124,55,3,16,32,0,32,0,41,3,24,66,1,124,55,3,24,32,0,41,3,16,32,0,41,3,80,90,4,127,32,0,41,3,40,32,0,41,3,96,131,80,5,65,0,11,4,127,65,1,5,32,0,41,3,16,32,0,41,3,88,90,11,4,64,32,0,32,0,41,3,32,55,3,48,32,0,32,0,41,3,16,55,3,56,32,0,32,0,41,3,40,55,3,64,65,0,33,1,3,64,32,1,32,0,40,2,4,72,4,64,32,0,40,2,0,32,1,16,18,32,1,65,1,106,33,1,12,1,11,11,32,0,66,0,55,3,40,32,0,65,0,54,2,8,32,0,66,0,55,3,16,32,0,66,0,55,3,40,32,0,40,2,0,32,0,40,2,8,16,19,33,1,32,0,40,2,8,32,0,40,2,0,40,2,4,106,65,1,58,0,0,32,0,32,0,41,3,40,35,6,40,2,4,32,1,65,3,116,106,41,3,0,133,55,3,40,32,0,32,0,40,2,8,65,1,106,32,0,40,2,4,111,54,2,8,32,0,35,5,40,2,4,32,0,41,3,40,34,8,66,45,136,167,65,3,116,106,41,3,0,32,8,66,8,134,66,1,132,133,55,3,40,32,3,65,1,106,12,3,11,32,3,65,1,106,33,3,12,1,11,11,65,127,11,34,1,65,0,78,4,64,32,5,32,1,107,33,5,32,1,32,6,106,33,6,32,2,34,1,65,1,106,33,2,32,4,40,2,4,32,1,65,2,116,106,32,0,41,3,56,62,2,0,12,1,11,11,32,4,11,10,0,16,15,36,5,16,15,36,6,11,3,0,1,11,73,1,2,127,32,0,40,2,4,34,1,65,255,255,255,255,0,113,34,2,65,1,70,4,64,32,0,65,16,106,16,53,32,0,32,0,40,2,0,65,1,114,54,2,0,35,0,32,0,16,2,5,32,0,32,2,65,1,107,32,1,65,128,128,128,128,127,113,114,54,2,4,11,11,58,0,2,64,2,64,2,64,32,0,65,8,107,40,2,0,14,7,0,0,1,1,1,1,1,2,11,15,11,32,0,40,2,0,34,0,4,64,32,0,65,172,3,79,4,64,32,0,65,16,107,16,52,11,11,15,11,0,11,11,137,3,7,0,65,16,11,55,40,0,0,0,1,0,0,0,1,0,0,0,40,0,0,0,97,0,108,0,108,0,111,0,99,0,97,0,116,0,105,0,111,0,110,0,32,0,116,0,111,0,111,0,32,0,108,0,97,0,114,0,103,0,101,0,65,208,0,11,45,30,0,0,0,1,0,0,0,1,0,0,0,30,0,0,0,126,0,108,0,105,0,98,0,47,0,114,0,116,0,47,0,116,0,108,0,115,0,102,0,46,0,116,0,115,0,65,128,1,11,43,28,0,0,0,1,0,0,0,1,0,0,0,28,0,0,0,73,0,110,0,118,0,97,0,108,0,105,0,100,0,32,0,108,0,101,0,110,0,103,0,116,0,104,0,65,176,1,11,53,38,0,0,0,1,0,0,0,1,0,0,0,38,0,0,0,126,0,108,0,105,0,98,0,47,0,97,0,114,0,114,0,97,0,121,0,98,0,117,0,102,0,102,0,101,0,114,0,46,0,116,0,115,0,65,240,1,11,51,36,0,0,0,1,0,0,0,1,0,0,0,36,0,0,0,73,0,110,0,100,0,101,0,120,0,32,0,111,0,117,0,116,0,32,0,111,0,102,0,32,0,114,0,97,0,110,0,103,0,101,0,65,176,2,11,51,36,0,0,0,1,0,0,0,1,0,0,0,36,0,0,0,126,0,108,0,105,0,98,0,47,0,116,0,121,0,112,0,101,0,100,0,97,0,114,0,114,0,97,0,121,0,46,0,116,0,115,0,65,240,2,11,53,7,0,0,0,16,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,145,4,0,0,2,0,0,0,49,0,0,0,2,0,0,0,17,1,0,0,2,0,0,0,16,0,34,16,115,111,117,114,99,101,77,97,112,112,105,110,103,85,82,76,16,46,47,114,97,98,105,110,46,119,97,115,109,46,109,97,112]);return i(new Response(new Blob([t],{type:"application/wasm"})),e)}n.supported="undefined"!=typeof WebAssembly,t.exports=n},{"@assemblyscript/loader":"kAk4C"}],kAk4C:[function(e,t,r){"use strict";const i="undefined"!=typeof BigUint64Array,n=Symbol(),s=1024;function o(e,t){const r=new Uint32Array(e),i=new Uint16Array(e);var n=r[t+-4>>>2]>>>1,o=t>>>1;if(n<=s)return String.fromCharCode.apply(String,i.subarray(o,o+n));const a=[];do{const e=i[o+s-1],t=e>=55296&&e<56320?1023:s;a.push(String.fromCharCode.apply(String,i.subarray(o,o+=t))),n-=t}while(n>s);return a.join("")+String.fromCharCode.apply(String,i.subarray(o,o+n))}function a(e){const t={};function r(e,t){return e?o(e.buffer,t):""}const i=e.env=e.env||{};return i.abort=i.abort||function(e,n,s,o){const a=t.memory||i.memory;throw Error("abort: "+r(a,e)+" at "+r(a,n)+":"+s+":"+o)},i.trace=i.trace||function(e,n){const s=t.memory||i.memory;console.log("trace: "+r(s,e)+(n?" ":"")+Array.prototype.slice.call(arguments,2,2+n).join(", "))},e.Math=e.Math||Math,e.Date=e.Date||Date,t}function c(e,t){const r=t.exports,n=r.memory,s=r.table,a=r.__alloc,c=r.__retain,u=r.__rtti_base||-1;function l(e){const t=new Uint32Array(n.buffer);if((e>>>=0)>=t[u>>>2])throw Error("invalid id: "+e);return t[(u+4>>>2)+2*e]}function d(e){const t=new Uint32Array(n.buffer);if((e>>>=0)>=t[u>>>2])throw Error("invalid id: "+e);return t[(u+4>>>2)+2*e+1]}function h(e){return 31-Math.clz32(e>>>5&31)}function p(e,t,r){const i=n.buffer;if(r)switch(e){case 2:return new Float32Array(i);case 3:return new Float64Array(i)}else switch(e){case 0:return new(t?Int8Array:Uint8Array)(i);case 1:return new(t?Int16Array:Uint16Array)(i);case 2:return new(t?Int32Array:Uint32Array)(i);case 3:return new(t?BigInt64Array:BigUint64Array)(i)}throw Error("unsupported align: "+e)}function g(e){const t=new Uint32Array(n.buffer),r=t[e+-8>>>2],i=l(r);if(!(1&i))throw Error("not an array: "+r);const s=h(i);var o=t[e+4>>>2];const a=2&i?t[e+12>>>2]:t[o+-4>>>2]>>>s;return p(s,1024&i,2048&i).subarray(o>>>=s,o+a)}function y(e,t,r){return new e(m(e,t,r))}function m(e,t,r){const i=n.buffer,s=new Uint32Array(i),o=s[r+4>>>2];return new e(i,o,s[o+-4>>>2]>>>t)}return e.__allocString=function(e){const t=e.length,r=a(t<<1,1),i=new Uint16Array(n.buffer);for(var s=0,o=r>>>1;s>>2])throw Error("not a string: "+e);return o(t,e)},e.__allocArray=function(e,t){const r=l(e);if(!(3&r))throw Error("not an array: "+e+" @ "+r);const i=h(r),s=t.length,o=a(s<>>2]=c(o),d[u+4>>>2]=o,d[u+8>>>2]=s<>>2]=s);const f=p(i,1024&r,2048&r);if(8192&r)for(let e=0;e>>i)+e]=c(t[e]);else f.set(t,o>>>i);return u},e.__getArrayView=g,e.__getArray=function(e){const t=g(e),r=t.length,i=new Array(r);for(let e=0;e>>2];return t.slice(e,e+r)},e.__getInt8Array=y.bind(null,Int8Array,0),e.__getInt8ArrayView=m.bind(null,Int8Array,0),e.__getUint8Array=y.bind(null,Uint8Array,0),e.__getUint8ArrayView=m.bind(null,Uint8Array,0),e.__getUint8ClampedArray=y.bind(null,Uint8ClampedArray,0),e.__getUint8ClampedArrayView=m.bind(null,Uint8ClampedArray,0),e.__getInt16Array=y.bind(null,Int16Array,1),e.__getInt16ArrayView=m.bind(null,Int16Array,1),e.__getUint16Array=y.bind(null,Uint16Array,1),e.__getUint16ArrayView=m.bind(null,Uint16Array,1),e.__getInt32Array=y.bind(null,Int32Array,2),e.__getInt32ArrayView=m.bind(null,Int32Array,2),e.__getUint32Array=y.bind(null,Uint32Array,2),e.__getUint32ArrayView=m.bind(null,Uint32Array,2),i&&(e.__getInt64Array=y.bind(null,BigInt64Array,3),e.__getInt64ArrayView=m.bind(null,BigInt64Array,3),e.__getUint64Array=y.bind(null,BigUint64Array,3),e.__getUint64ArrayView=m.bind(null,BigUint64Array,3)),e.__getFloat32Array=y.bind(null,Float32Array,2),e.__getFloat32ArrayView=m.bind(null,Float32Array,2),e.__getFloat64Array=y.bind(null,Float64Array,3),e.__getFloat64ArrayView=m.bind(null,Float64Array,3),e.__instanceof=function(e,t){const r=new Uint32Array(n.buffer);var i=r[e+-8>>>2];if(i<=r[u>>>2])do{if(i==t)return!0}while(i=d(i));return!1},e.memory=e.memory||n,e.table=e.table||s,f(r,e)}function u(e){return"undefined"!=typeof Response&&e instanceof Response}async function l(e,t){return u(e=await e)?d(e,t):c(a(t||(t={})),await WebAssembly.instantiate(e instanceof WebAssembly.Module?e:await WebAssembly.compile(e),t))}async function d(e,t){return WebAssembly.instantiateStreaming?c(a(t||(t={})),(await WebAssembly.instantiateStreaming(e,t)).instance):l(u(e=await e)?e.arrayBuffer():e,t)}function f(e,t){var r=t?Object.create(t):{},i=e.__argumentsLength?function(t){e.__argumentsLength.value=t}:e.__setArgumentsLength||e.__setargc||function(){};for(let t in e){if(!Object.prototype.hasOwnProperty.call(e,t))continue;const s=e[t];let o=t.split("."),a=r;for(;o.length>1;){let e=o.shift();Object.prototype.hasOwnProperty.call(a,e)||(a[e]={}),a=a[e]}let c=o[0],u=c.indexOf("#");if(u>=0){let r=c.substring(0,u),o=a[r];if(void 0===o||!o.prototype){let e=function(...t){return e.wrap(e.prototype.constructor(0,...t))};e.prototype={valueOf:function(){return this[n]}},e.wrap=function(t){return Object.create(e.prototype,{[n]:{value:t,writable:!1}})},o&&Object.getOwnPropertyNames(o).forEach((t=>Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t)))),a[r]=e}if(c=c.substring(u+1),a=a[r].prototype,/^(get|set):/.test(c)){if(!Object.prototype.hasOwnProperty.call(a,c=c.substring(4))){let r=e[t.replace("set:","get:")],i=e[t.replace("get:","set:")];Object.defineProperty(a,c,{get:function(){return r(this[n])},set:function(e){i(this[n],e)},enumerable:!0})}}else"constructor"===c?(a[c]=(...e)=>(i(e.length),s(...e))).original=s:(a[c]=function(...e){return i(e.length),s(this[n],...e)}).original=s}else/^(get|set):/.test(c)?Object.prototype.hasOwnProperty.call(a,c=c.substring(4))||Object.defineProperty(a,c,{get:e[t.replace("set:","get:")],set:e[t.replace("get:","set:")],enumerable:!0}):"function"==typeof s&&s!==i?(a[c]=(...e)=>(i(e.length),s(...e))).original=s:a[c]=s}return r}r.instantiate=l,r.instantiateSync=function(e,t){return c(a(t||(t={})),new WebAssembly.Instance(e instanceof WebAssembly.Module?e:new WebAssembly.Module(e),t))},r.instantiateStreaming=d,r.demangle=f},{}],hCl8p:[function(e,t,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=i(e("bl/BufferList.js"));t.exports=async function*(e,t){let r=new n.default,i=0,s=!1;const o=t.maxChunkSize;for await(const t of e)for(r.append(t),i+=t.length;i>=o;)if(yield r.slice(0,o),s=!0,o===r.length)r=new n.default,i=0;else{const e=new n.default;e.append(r.shallowSlice(o)),r=e,i-=o}s&&!i||(yield r.slice(0,i))}},{"bl/BufferList.js":"im7j6"}],aCNgw:[function(e,t,r){"use strict";var i=e("err-code"),n=e("uint8arrays/from-string");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=s(i);t.exports=async function*(e){for await(const t of e){if(void 0===t.length)throw o.default(new Error("Content was invalid"),"ERR_INVALID_CONTENT");if("string"==typeof t||t instanceof String)yield n.fromString(t.toString());else if(Array.isArray(t))yield Uint8Array.from(t);else{if(!(t instanceof Uint8Array))throw o.default(new Error("Content was invalid"),"ERR_INVALID_CONTENT");yield t}}}},{"err-code":"chZjB","uint8arrays/from-string":"dF7Y4"}],"3sIHL":[function(e,t,r){"use strict";var i=e("./dir-flat.js"),n=e("./flat-to-shard.js"),s=e("./dir.js"),o=e("./utils/to-path-components.js");async function a(e,t,r){const a=o(e.path||""),c=a.length-1;let u=t,l="";for(let o=0;oe+(null==t.Tsize?0:t.Tsize)),0);this.cid=l,this.size=d,yield{cid:l,unixfs:a,path:this.path,size:d}}}},{"@ipld/dag-pb":"i2cdx","ipfs-unixfs":"dF9VO","./dir.js":"4gYma","./utils/persist.js":"9mA89"}],"4gYma":[function(e,t,r){"use strict";t.exports=class{constructor(e,t){this.options=t||{},this.root=e.root,this.dir=e.dir,this.path=e.path,this.dirty=e.dirty,this.flat=e.flat,this.parent=e.parent,this.parentKey=e.parentKey,this.unixfs=e.unixfs,this.mode=e.mode,this.mtime=e.mtime,this.cid=void 0,this.size=void 0}async put(e,t){}get(e){return Promise.resolve(this)}async*eachChildSeries(){}async*flush(e){}}},{}],khOkw:[function(e,t,r){"use strict";var i=e("./dir-sharded.js"),n=e("./dir-flat.js");t.exports=async function e(t,r,s,o){let a=r;r instanceof n&&r.directChildrenCount()>=s&&(a=await async function(e,t){const r=new i({root:e.root,dir:!0,parent:e.parent,parentKey:e.parentKey,path:e.path,dirty:e.dirty,flat:!1,mtime:e.mtime,mode:e.mode},t);for await(const{key:t,child:i}of e.eachChildSeries())await r.put(t,i);return r}(r,o));const c=a.parent;if(c){if(a!==r){if(t&&(t.parent=a),!a.parentKey)throw new Error("No parent key found");await c.put(a.parentKey,a)}return e(a,c,s,o)}return a}},{"./dir-sharded.js":"aobU3","./dir-flat.js":"1nsnr"}],aobU3:[function(e,t,r){"use strict";var i=e("@ipld/dag-pb"),n=e("ipfs-unixfs"),s=e("./dir.js"),o=e("./utils/persist.js"),a=e("hamt-sharding");async function*c(e,t,r,s){const u=e._children,l=[];let d=0;for(let e=0;et instanceof s?e+t.leafCount():e+1),0)}childrenCount(){return this._children.length}onlyChild(){return this._children.get(0)}*eachLeafSeries(){const e=this._children.compactArray();for(const t of e)t instanceof s?yield*t.eachLeafSeries():yield t;return[]}serialize(e,t){return t(this._children.reduce(((r,i,n)=>(i&&(i instanceof s?r.push(i.serialize(e,t)):r.push(e(i,n))),r)),[]))}asyncTransform(e,t){return u(this,e,t)}toJSON(){return this.serialize(a,c)}prettyPrint(){return JSON.stringify(this.toJSON(),null," ")}tableSize(){return Math.pow(2,this._options.bits)}async _findChild(e){const t=await this._findPlace(e),r=t.bucket._at(t.pos);if(!(r instanceof s))return r&&r.key===e?r:void 0}async _findPlace(e){const t=this._options.hash("string"==typeof e?n(e):e),r=await t.take(this._options.bits),i=this._children.get(r);return i instanceof s?i._findPlace(t):{bucket:this,pos:r,hash:t,existingChild:i}}async _findNewBucketAndPos(e){const t=await this._findPlace(e);if(t.existingChild&&t.existingChild.key!==e){const e=new s(this._options,t.bucket,t.pos);t.bucket._putObjectAt(t.pos,e);const r=await e._findPlace(t.existingChild.hash);return r.bucket._putAt(r,t.existingChild.key,t.existingChild.value),e._findNewBucketAndPos(t.hash)}return t}_putAt(e,t,r){this._putObjectAt(e.pos,{key:t,value:r,hash:e.hash})}_putObjectAt(e,t){this._children.get(e)||this._popCount++,this._children.set(e,t)}_delAt(e){if(-1===e)throw new Error("Invalid position");this._children.get(e)&&this._popCount--,this._children.unset(e),this._level()}_level(){if(this._parent&&this._popCount<=1)if(1===this._popCount){const e=this._children.find(o);if(e&&!(e instanceof s)){const t=e.hash;t.untake(this._options.bits);const r={pos:this._posAtParent,hash:t,bucket:this._parent};this._parent._putAt(r,e.key,e.value)}}else this._parent._delAt(this._posAtParent)}_at(e){return this._children.get(e)}}function o(e){return Boolean(e)}function a(e,t){return e.key}function c(e){return e}async function u(e,t,r){const i=[];for(const n of e._children.compactArray())if(n instanceof s)await u(n,t,r);else{const r=await t(n);i.push({bitField:e._children.bitField(),children:r})}return r(i)}t.exports=s},{"sparse-array":"26rb7","uint8arrays/from-string":"dF7Y4"}],"26rb7":[function(e,t,r){"use strict";function i(e,t){return e+n(t)}function n(e){let t=e;return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),16843009*(t+(t>>4)&252645135)>>24}function s(e,t){return e[0]-t[0]}function o(e){return e[1]}t.exports=class{constructor(){this._bitArrays=[],this._data=[],this._length=0,this._changedLength=!1,this._changedData=!1}set(e,t){let r=this._internalPositionFor(e,!1);if(void 0===t)-1!==r&&(this._unsetInternalPos(r),this._unsetBit(e),this._changedLength=!0,this._changedData=!0);else{let i=!1;-1===r?(r=this._data.length,this._setBit(e),this._changedData=!0):i=!0,this._setInternalPos(r,e,t,i),this._changedLength=!0}}unset(e){this.set(e,void 0)}get(e){this._sortData();const t=this._internalPositionFor(e,!0);if(-1!==t)return this._data[t][1]}push(e){return this.set(this.length,e),this.length}get length(){if(this._sortData(),this._changedLength){const e=this._data[this._data.length-1];this._length=e?e[0]+1:0,this._changedLength=!1}return this._length}forEach(e){let t=0;for(;t=this._bitArrays.length)return-1;const s=this._bitArrays[r],o=e-7*r;if(!((s&1<0))return-1;return this._bitArrays.slice(0,r).reduce(i,0)+n(s&~(4294967295<=t)n.push(s);else if(n[0][0]<=t)n.unshift(s);else{const e=Math.round(n.length/2);this._data=n.slice(0,e).concat(s).concat(n.slice(e))}else this._data.push(s);this._changedData=!0,this._changedLength=!0}}_unsetInternalPos(e){this._data.splice(e,1)}_sortData(){this._changedData&&this._data.sort(s),this._changedData=!1}bitField(){const e=[];let t,r=8,i=0,n=0;const s=this._bitArrays.slice();for(;s.length||i;){0===i&&(t=s.shift(),i=7);const o=Math.min(i,r);n|=(t&~(255<>>=o,i-=o,r-=o,r&&(i||s.length)||(e.push(n),n=0,r=8)}for(var o=e.length-1;o>0;o--){if(0!==e[o])break;e.pop()}return e}compactArray(){return this._sortData(),this._data.map(o)}}},{}],"8PIJS":[function(e,t,r){"use strict";const i=e("./consumable-buffer"),{concat:n}=e("uint8arrays/concat");class s{constructor(e,t){if(!(e instanceof Uint8Array))throw new Error("can only hash Uint8Arrays");this._value=e,this._hashFn=t,this._depth=-1,this._availableBits=0,this._currentBufferIndex=0,this._buffers=[]}async take(e){let t=e;for(;this._availableBits0;){const e=this._buffers[this._currentBufferIndex],i=Math.min(e.availableBits(),t);r=(r<0;){const e=this._buffers[this._currentBufferIndex],r=Math.min(e.totalBits()-e.availableBits(),t);e.untake(r),t-=r,this._availableBits+=r,this._currentBufferIndex>0&&e.totalBits()===e.availableBits()&&(this._depth--,this._currentBufferIndex--)}}async _produceMoreBits(){this._depth++;const e=this._depth?n([this._value,Uint8Array.from([this._depth])]):this._value,t=await this._hashFn(e),r=new i(t);this._buffers.push(r),this._availableBits+=r.availableBits()}}t.exports=function(e){return function(t){return t instanceof s?t:new s(t,e)}},t.exports.InfiniteHash=s},{"./consumable-buffer":"ip5wL","uint8arrays/concat":"4EBjG"}],ip5wL:[function(e,t,r){"use strict";const i=[255,254,252,248,240,224,192,128],n=[1,3,7,15,31,63,127,255];function s(e,t,r){const s=function(e,t){return i[e]&n[Math.min(t+e-1,7)]}(t,r);return(e&s)>>>t}t.exports=class{constructor(e){this._value=e,this._currentBytePos=e.length-1,this._currentBitPos=7}availableBits(){return this._currentBitPos+1+8*this._currentBytePos}totalBits(){return 8*this._value.length}take(e){let t=e,r=0;for(;t&&this._haveBits();){const e=this._value[this._currentBytePos],i=this._currentBitPos+1,n=Math.min(i,t);r=(r<7;)this._currentBitPos-=8,this._currentBytePos+=1}_haveBits(){return this._currentBytePos>=0}}},{}],brjB0:[function(e,t,r){"use strict";t.exports=(e="")=>(e.trim().match(/([^\\^/]|\\\/)+/g)||[]).filter(Boolean)},{}],cda37:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./normalise-content.js"),n=e("./normalise.js");r.normaliseInput=function(e){return n.normalise(e,i.normaliseContent)}},{"./normalise-content.js":"dXynQ","./normalise.js":"7hUEG"}],dXynQ:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("err-code"),n=e("uint8arrays/from-string"),s=e("browser-readablestream-to-it"),o=e("blob-to-it"),a=e("it-peekable"),c=e("it-all"),u=e("it-map"),l=e("./utils.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=d(i),h=d(s),p=d(o),g=d(a),y=d(c),m=d(u);function b(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer?new Uint8Array(e):Array.isArray(e)?Uint8Array.from(e):n.fromString(e.toString())}r.normaliseContent=async function(e){return async function*(e){if(l.isBytes(e))return void(yield b(e));if("string"==typeof e||e instanceof String)return void(yield b(e.toString()));if(l.isBlob(e))return void(yield*p.default(e));l.isReadableStream(e)&&(e=h.default(e));if(Symbol.iterator in e||Symbol.asyncIterator in e){const t=g.default(e),{value:r,done:i}=await t.peek();if(i)return void(yield*[]);if(t.push(r),Number.isInteger(r))return void(yield Uint8Array.from(await y.default(t)));if(l.isBytes(r)||"string"==typeof r||r instanceof String)return void(yield*m.default(t,b))}throw f.default(new Error(`Unexpected input: ${e}`),"ERR_UNEXPECTED_INPUT")}(e)}},{"err-code":"chZjB","uint8arrays/from-string":"dF7Y4","browser-readablestream-to-it":"aUa4D","blob-to-it":"5K8SZ","it-peekable":"bi9X1","it-all":"iCXBu","it-map":"eeqPk","./utils.js":"ded5K"}],aUa4D:[function(e,t,r){"use strict";t.exports=async function*(e,t={}){const r=e.getReader();try{for(;;){const e=await r.read();if(e.done)return;yield e.value}}finally{!0!==t.preventCancel&&r.cancel(),r.releaseLock()}}},{}],"5K8SZ":[function(e,t,r){"use strict";const i=e("browser-readablestream-to-it");t.exports=function(e){return"function"==typeof e.stream?i(e.stream()):i(new Response(e).body)}},{"browser-readablestream-to-it":"aUa4D"}],bi9X1:[function(e,t,r){"use strict";t.exports=function(e){const[t,r]=e[Symbol.asyncIterator]?[e[Symbol.asyncIterator](),Symbol.asyncIterator]:[e[Symbol.iterator](),Symbol.iterator],i=[];return{peek:()=>t.next(),push:e=>{i.push(e)},next:()=>i.length?{done:!1,value:i.shift()}:t.next(),[r](){return this}}}},{}],ded5K:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.isBlob=function(e){return e.constructor&&("Blob"===e.constructor.name||"File"===e.constructor.name)&&"function"==typeof e.stream},r.isBytes=function(e){return ArrayBuffer.isView(e)||e instanceof ArrayBuffer},r.isFileObject=function(e){return"object"==typeof e&&(e.path||e.content)},r.isReadableStream=e=>e&&"function"==typeof e.getReader},{}],"7hUEG":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("err-code"),n=e("browser-readablestream-to-it"),s=e("it-peekable"),o=e("it-map"),a=e("./utils.js"),c=e("ipfs-unixfs");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=u(i),d=u(n),f=u(s),h=u(o);async function p(e,t){const{path:r,mode:i,mtime:n,content:s}=e,o={path:r||"",mode:c.parseMode(i),mtime:c.parseMtime(n)};return s?o.content=await t(s):r||(o.content=await t(e)),o}r.normalise=async function*(e,t){if(null==e)throw l.default(new Error(`Unexpected input: ${e}`),"ERR_UNEXPECTED_INPUT");if("string"==typeof e||e instanceof String)yield p(e.toString(),t);else if(a.isBytes(e)||a.isBlob(e))yield p(e,t);else{if(a.isReadableStream(e)&&(e=d.default(e)),Symbol.iterator in e||Symbol.asyncIterator in e){const r=f.default(e),{value:i,done:n}=await r.peek();if(n)return void(yield*[]);if(r.push(i),Number.isInteger(i)||a.isBytes(i))return void(yield p(r,t));if(i._readableState)return void(yield*h.default(r,(e=>p({content:e},t))));if(a.isFileObject(i)||a.isBlob(i)||"string"==typeof i||i instanceof String)return void(yield*h.default(r,(e=>p(e,t))));if(i[Symbol.iterator]||i[Symbol.asyncIterator]||a.isReadableStream(i))return void(yield*h.default(r,(e=>p(e,t))))}if(!a.isFileObject(e))throw l.default(new Error("Unexpected input: "+typeof e),"ERR_UNEXPECTED_INPUT");yield p(e,t)}}},{"err-code":"chZjB","browser-readablestream-to-it":"aUa4D","it-peekable":"bi9X1","it-map":"eeqPk","./utils.js":"ded5K","ipfs-unixfs":"dF9VO"}],"1Nm8o":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const i=e=>{const t={},r=e.split("-");switch(r.length){case 1:t.avgChunkSize=262144;break;case 2:t.avgChunkSize=n(r[1],"avg");break;case 4:t.minChunkSize=n(r[1],"min"),t.avgChunkSize=n(r[2],"avg"),t.maxChunkSize=n(r[3],"max");break;default:throw new Error('Incorrect chunker format (expected "rabin" "rabin-[avg]" or "rabin-[min]-[avg]-[max]"')}return t},n=(e,t)=>{const r=parseInt(e);if(isNaN(r))throw new Error(`Chunker parameter ${t} must be an integer`);return r};r.parseChunkSize=n,r.parseChunkerString=e=>{if(e){if(e.startsWith("size-")){const t=e.split("-")[1],r=parseInt(t);if(isNaN(r))throw new Error("Chunker parameter size must be an integer");return{chunker:"fixed",maxChunkSize:r}}if(e.startsWith("rabin"))return{chunker:"rabin",...i(e)};throw new Error(`Unrecognized chunker option: ${e}`)}return{chunker:"fixed"}},r.parseRabinString=i},{}],dOhzw:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-unixfs-exporter"),n=e("../utils.js"),s=e("ipfs-core-utils/with-timeout-option"),o=e("multiformats/cid");r.createCat=function({repo:e,preload:t}){return s.withTimeoutOption((async function*(r,s={}){if(r=n.normalizeCidPath(r),!1!==s.preload){const e=r.split("/");t(o.CID.parse(e[0]))}const a=await i.exporter(r,e.blocks,s);if("directory"===a.type)throw new Error("this dag node is a directory");if(!a.content)throw new Error("this dag node has no content");yield*a.content(s)}))}},{"ipfs-unixfs-exporter":"BgMiX","../utils.js":"cT4uN","ipfs-core-utils/with-timeout-option":"j29MK","multiformats/cid":"9ooAY"}],BgMiX:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("err-code"),n=e("multiformats/cid"),s=e("./resolvers/index.js"),o=e("it-last");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=a(i),u=a(o);const l=e=>{if(e instanceof Uint8Array)return{cid:n.CID.decode(e),toResolve:[]};const t=n.CID.asCID(e);if(t)return{cid:t,toResolve:[]};if("string"==typeof e){0===e.indexOf("/ipfs/")&&(e=e.substring(6));const t=((e="")=>(e.trim().match(/([^\\^/]|\\\/)+/g)||[]).filter(Boolean))(e);return{cid:n.CID.parse(t[0]),toResolve:t.slice(1)}}throw c.default(new Error(`Unknown path type ${e}`),"ERR_BAD_PATH")};async function*d(e,t,r={}){let{cid:i,toResolve:n}=l(e),o=i.toString(),a=o;const u=n.length;for(;;){const l=await s(i,o,a,n,u,t,r);if(!l.entry&&!l.next)throw c.default(new Error(`Could not resolve ${e}`),"ERR_NOT_FOUND");if(l.entry&&(yield l.entry),!l.next)return;n=l.next.toResolve,i=l.next.cid,o=l.next.name,a=l.next.path}}async function f(e,t,r={}){const i=await u.default(d(e,t,r));if(!i)throw c.default(new Error(`Could not resolve ${e}`),"ERR_NOT_FOUND");return i}r.exporter=f,r.recursive=async function*(e,t,r={}){const i=await f(e,t,r);if(i&&(yield i,"directory"===i.type))for await(const e of async function*e(t,r){for await(const i of t.content(r))yield i,i instanceof Uint8Array||"directory"===i.type&&(yield*e(i,r))}(i,r))yield e},r.walkPath=d},{"err-code":"chZjB","multiformats/cid":"9ooAY","./resolvers/index.js":"9Jksl","it-last":"cSXX9"}],"9Jksl":[function(e,t,r){"use strict";var i=e("err-code"),n=e("@ipld/dag-pb"),s=e("@ipld/dag-cbor"),o=e("multiformats/codecs/raw"),a=e("multiformats/hashes/identity"),c=e("./unixfs-v1/index.js"),u=e("./raw.js"),l=e("./dag-cbor.js"),d=e("./identity.js");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function h(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var p=f(i),g=h(n),y=h(s),m=h(o);const b={[g.code]:c,[m.code]:u,[y.code]:l,[a.identity.code]:d};t.exports=function e(t,r,i,n,s,o,a){const c=b[t.code];if(!c)throw p.default(new Error(`No resolver for code ${t.code}`),"ERR_NO_RESOLVER");return c(t,r,i,n,e,s,o,a)}},{"err-code":"chZjB","@ipld/dag-pb":"i2cdx","@ipld/dag-cbor":"3498i","multiformats/codecs/raw":"fdfgp","multiformats/hashes/identity":"eYCZn","./unixfs-v1/index.js":"fnWJf","./raw.js":"7dtUh","./dag-cbor.js":"9CgTa","./identity.js":"lAVdS"}],fnWJf:[function(e,t,r){"use strict";var i=e("err-code"),n=e("ipfs-unixfs"),s=e("../../utils/find-cid-in-shard.js"),o=e("@ipld/dag-pb"),a=e("./content/file.js"),c=e("./content/directory.js"),u=e("./content/hamt-sharded-directory.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=l(i);const f={raw:a,file:a,directory:c,"hamt-sharded-directory":u,metadata:(e,t,r,i,n,s,o)=>()=>[],symlink:(e,t,r,i,n,s,o)=>()=>[]};t.exports=async(e,t,r,i,a,c,u,l)=>{const h=await u.get(e,l),p=o.decode(h);let g,y;if(t||(t=e.toString()),null==p.Data)throw d.default(new Error("no data in PBNode"),"ERR_NOT_UNIXFS");try{g=n.UnixFS.unmarshal(p.Data)}catch(e){throw d.default(e,"ERR_NOT_UNIXFS")}if(r||(r=t),i.length){let e;if(e=g&&"hamt-sharded-directory"===g.type?await s(p,i[0],u):((e,t)=>{const r=e.Links.find((e=>e.Name===t));return r&&r.Hash})(p,i[0]),!e)throw d.default(new Error("file does not exist"),"ERR_NOT_FOUND");const t=i.shift();y={cid:e,toResolve:i,name:t||"",path:`${r}/${t}`}}return{entry:{type:g.isDirectory()?"directory":"file",name:t,path:r,cid:e,content:f[g.type](e,p,g,r,a,c,u),unixfs:g,depth:c,node:p,size:g.fileSize()},next:y}}},{"err-code":"chZjB","ipfs-unixfs":"dF9VO","../../utils/find-cid-in-shard.js":"8EIYq","@ipld/dag-pb":"i2cdx","./content/file.js":"bQPcT","./content/directory.js":"kXtRz","./content/hamt-sharded-directory.js":"f7k0P"}],"8EIYq":[function(e,t,r){"use strict";var i=e("hamt-sharding"),n=e("@ipld/dag-pb"),s=e("@multiformats/murmur3");const o=async function(e){return(await s.murmur3128.encode(e)).slice(0,8).reverse()},a=e=>e.toString(16).toUpperCase().padStart(2,"0").substring(0,2),c=async(e,t,r,s,u)=>{if(!s){const e=i.createHAMT({hashFn:o});s={rootBucket:e,hamtDepth:1,lastBucket:e}}var l,d,f;await(l=e.Links,d=s.lastBucket,f=s.rootBucket,Promise.all(l.map((e=>{if(null==e.Name)throw new Error("Unexpected Link without a Name");if(2===e.Name.length){const t=parseInt(e.Name,16);return d._putObjectAt(t,new i.Bucket({hash:f._options.hash,bits:f._options.bits},d,t))}return f.put(e.Name.substring(2),!0)}))));const h=await s.rootBucket._findNewBucketAndPos(t);let p=a(h.pos);const g=(e=>{let t=e.bucket;const r=[];for(;t._parent;)r.push(t),t=t._parent;return r.push(t),r.reverse()})(h);g.length>s.hamtDepth&&(s.lastBucket=g[s.hamtDepth],p=a(s.lastBucket._posAtParent));const y=e.Links.find((e=>{if(null==e.Name)return!1;const r=e.Name.substring(0,2),i=e.Name.substring(2);return r===p&&(!i||i===t)}));if(!y)return null;if(null!=y.Name&&y.Name.substring(2)===t)return y.Hash;s.hamtDepth++;const m=await r.get(y.Hash,u);return e=n.decode(m),c(e,t,r,s,u)};t.exports=c},{"hamt-sharding":"1SDvb","@ipld/dag-pb":"i2cdx","@multiformats/murmur3":"5DFrl"}],bQPcT:[function(e,t,r){"use strict";var i=e("../../../utils/extract-data-from-block.js"),n=e("../../../utils/validate-offset-and-length.js"),s=e("ipfs-unixfs"),o=e("err-code"),a=e("@ipld/dag-pb"),c=e("@ipld/dag-cbor"),u=e("multiformats/codecs/raw");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function d(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var f=l(o),h=d(a),p=d(c),g=d(u);async function*y(e,t,r,n,o=0,a){if(t instanceof Uint8Array){const e=i(t,o,r,n);return e.length&&(yield e),o+=e.length}if(null==t.Data)throw f.default(new Error("no data in PBNode"),"ERR_NOT_UNIXFS");let c;try{c=s.UnixFS.unmarshal(t.Data)}catch(e){throw f.default(e,"ERR_NOT_UNIXFS")}if(c.data&&c.data.length){const e=i(c.data,o,r,n);e.length&&(yield e),o+=c.data.length}let u=o;for(let i=0;i=u&&ru&&n<=l||rl){const t=await e.get(s.Hash,{signal:a.signal});let i;switch(s.Hash.code){case h.code:i=await h.decode(t);break;case g.code:i=t;break;case p.code:i=await p.decode(t);break;default:throw Error(`Unsupported codec: ${s.Hash.code}`)}for await(const t of y(e,i,r,n,o,a))o+=t.length,yield t}o=l,u=l+1}}t.exports=(e,t,r,i,s,o,a)=>function(e={}){const i=r.fileSize();if(void 0===i)throw new Error("File was a directory");const{offset:s,length:o}=n(i,e.offset,e.length);return y(a,t,s,s+o,0,e)}},{"../../../utils/extract-data-from-block.js":"Trn4t","../../../utils/validate-offset-and-length.js":"gF8ya","ipfs-unixfs":"dF9VO","err-code":"chZjB","@ipld/dag-pb":"i2cdx","@ipld/dag-cbor":"3498i","multiformats/codecs/raw":"fdfgp"}],Trn4t:[function(e,t,r){"use strict";t.exports=function(e,t,r,i){const n=t+e.length;return r>=n||i=t&&i=t&&r{if(t||(t=0),t<0)throw n.default(new Error("Offset must be greater than or equal to 0"),"ERR_INVALID_PARAMS");if(t>e)throw n.default(new Error("Offset must be less than the file size"),"ERR_INVALID_PARAMS");if(r||0===r||(r=e-t),r<0)throw n.default(new Error("Length must be greater than or equal to 0"),"ERR_INVALID_PARAMS");return t+r>e&&(r=e-t),{offset:t,length:r}}},{"err-code":"chZjB"}],kXtRz:[function(e,t,r){"use strict";t.exports=(e,t,r,i,n,s,o)=>async function*(e={}){const r=e.offset||0,a=e.length||t.Links.length,c=t.Links.slice(r,a);for(const t of c){const r=await n(t.Hash,t.Name||"",`${i}/${t.Name||""}`,[],s+1,o,e);r.entry&&(yield r.entry)}}},{}],f7k0P:[function(e,t,r){"use strict";var i=e("@ipld/dag-pb");async function*n(e,t,r,s,o,a){const c=e.Links;for(const u of c){const c=null!=u.Name?u.Name.substring(2):null;if(c){const e=await r(u.Hash,c,`${t}/${c}`,[],s+1,o,a);yield e.entry}else{const c=await o.get(u.Hash);e=i.decode(c);for await(const i of n(e,t,r,s,o,a))yield i}}}t.exports=(e,t,r,i,s,o,a)=>function(e={}){return n(t,i,s,o,a,e)}},{"@ipld/dag-pb":"i2cdx"}],"7dtUh":[function(e,t,r){"use strict";var i=e("err-code"),n=e("../utils/extract-data-from-block.js"),s=e("../utils/validate-offset-and-length.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(i);t.exports=async(e,t,r,i,o,c,u,l)=>{if(i.length)throw a.default(new Error(`No link named ${r} found in raw node ${e}`),"ERR_NOT_FOUND");const d=await u.get(e,l);return{entry:{type:"raw",name:t,path:r,cid:e,content:(f=d,async function*(e={}){const{offset:t,length:r}=s(f.length,e.offset,e.length);yield n(f,0,t,t+r)}),depth:c,size:d.length,node:d}};var f}},{"err-code":"chZjB","../utils/extract-data-from-block.js":"Trn4t","../utils/validate-offset-and-length.js":"gF8ya"}],"9CgTa":[function(e,t,r){"use strict";var i=e("multiformats/cid"),n=e("err-code"),s=e("@ipld/dag-cbor");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function a(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var c=o(n),u=a(s);t.exports=async(e,t,r,n,s,o,a,l)=>{const d=await a.get(e),f=u.decode(d);let h=f,p=r;for(;n.length;){const s=n[0];if(!(s in h))throw c.default(new Error(`No property named ${s} found in cbor node ${e}`),"ERR_NO_PROP");{n.shift(),p=`${p}/${s}`;const a=i.CID.asCID(h[s]);if(a)return{entry:{type:"object",name:t,path:r,cid:e,node:d,depth:o,size:d.length,content:async function*(){yield f}},next:{cid:a,name:s,path:p,toResolve:n}};h=h[s]}}return{entry:{type:"object",name:t,path:r,cid:e,node:d,depth:o,size:d.length,content:async function*(){yield f}}}}},{"multiformats/cid":"9ooAY","err-code":"chZjB","@ipld/dag-cbor":"3498i"}],lAVdS:[function(e,t,r){"use strict";var i=e("err-code"),n=e("../utils/extract-data-from-block.js"),s=e("../utils/validate-offset-and-length.js"),o=e("multiformats/hashes/digest");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function c(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var u=a(i),l=c(o);t.exports=async(e,t,r,i,o,a,c,d)=>{if(i.length)throw u.default(new Error(`No link named ${r} found in raw node ${e}`),"ERR_NOT_FOUND");const f=await l.decode(e.multihash.bytes);return{entry:{type:"identity",name:t,path:r,cid:e,content:(h=f.digest,async function*(e={}){const{offset:t,length:r}=s(h.length,e.offset,e.length);yield n(h,0,t,t+r)}),depth:a,size:f.digest.length,node:f.digest}};var h}},{"err-code":"chZjB","../utils/extract-data-from-block.js":"Trn4t","../utils/validate-offset-and-length.js":"gF8ya","multiformats/hashes/digest":"kpRBg"}],"3pEGl":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-unixfs-exporter"),n=e("err-code"),s=e("../utils.js"),o=e("ipfs-core-utils/with-timeout-option"),a=e("multiformats/cid"),c=e("it-tar"),u=e("it-pipe"),l=e("pako"),d=e("it-map"),f=e("it-to-buffer");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=h(n),g=h(l),y=h(d),m=h(f);r.createGet=function({repo:e,preload:t}){return o.withTimeoutOption((async function*(r,n={}){if(n.compressionLevel<0||n.compressionLevel>9)throw p.default(new Error("Compression level must be between 1 and 9"),"ERR_INVALID_PARAMS");if(!1!==n.preload){let e;try{e=s.normalizeCidPath(r).split("/")}catch(e){throw p.default(e,"ERR_INVALID_PATH")}t(a.CID.parse(e[0]))}const o=a.CID.asCID(r)||r,l=await i.exporter(o,e.blocks,n);if("file"===l.type||"raw"===l.type){const e=[];return n.compress&&!0!==n.archive?e.push(l.content):e.push([{header:{name:l.path,mode:"file"===l.type&&l.unixfs.mode,mtime:"file"===l.type&&l.unixfs.mtime?new Date(1e3*l.unixfs.mtime.secs):void 0,size:l.size,type:"file"},body:l.content()}],c.pack(),(e=>y.default(e,(e=>e.slice())))),n.compress&&e.push((async function*(e){const t=await m.default(e);yield g.default.gzip(t,{level:n.compressionLevel||6})})),void(yield*u.pipe(...e))}if("directory"!==l.type)throw p.default(new Error("Not a UnixFS node"),"ERR_NOT_UNIXFS");{const t=[i.recursive(o,e.blocks,n),async function*(e){for await(const t of e){const e={header:{name:t.path,size:t.size}};if("file"===t.type)e.header.type="file",e.header.mode=null!=t.unixfs.mode?t.unixfs.mode:void 0,e.header.mtime=t.unixfs.mtime?new Date(1e3*t.unixfs.mtime.secs):void 0,e.body=t.content();else if("raw"===t.type)e.header.type="file",e.body=t.content();else{if("directory"!==t.type)throw p.default(new Error("Not a UnixFS node"),"ERR_NOT_UNIXFS");e.header.type="directory",e.header.mode=null!=t.unixfs.mode?t.unixfs.mode:void 0,e.header.mtime=t.unixfs.mtime?new Date(1e3*t.unixfs.mtime.secs):void 0}yield e}},c.pack(),e=>y.default(e,(e=>e.slice()))];if(n.compress){if(!n.archive)throw p.default(new Error("file is not regular"),"ERR_INVALID_PATH");n.compress&&t.push((async function*(e){const t=await m.default(e);yield g.default.gzip(t,{level:n.compressionLevel||6})}))}yield*u.pipe(...t)}}))}},{"ipfs-unixfs-exporter":"BgMiX","err-code":"chZjB","../utils.js":"cT4uN","ipfs-core-utils/with-timeout-option":"j29MK","multiformats/cid":"9ooAY","it-tar":"3xygI","it-pipe":"giKBQ",pako:"ibwO8","it-map":"eeqPk","it-to-buffer":"38Qf6"}],"3xygI":[function(e,t,r){r.extract=e("./extract"),r.pack=e("./pack")},{"./extract":"b9Qck","./pack":"7XvZX"}],b9Qck:[function(e,t,r){const i=e("p-defer"),n=e("./extract-headers"),s=e("./lte-reader");async function o(e,t){const r=function(e){return(e&=511)&&512-e}(t);r&&await e.next(r)}t.exports=e=>((e=e||{}).highWaterMark=e.highWaterMark||16384,t=>async function*(){const r=s(t);let a,c,u,l;try{for(;;){let t;try{const{done:e,value:i}=await r.next(512);if(e)return;t=i}catch(e){if("ERR_UNDER_READ"===e.code)return;throw e}const s=n.decode(t,e.filenameEncoding);if(!s)continue;if("gnu-long-path"===s.type){const{done:t,value:i}=await r.next(s.size);if(t)return;a=n.decodeLongPath(i,e.filenameEncoding),await o(r,s.size);continue}if("gnu-long-link-path"===s.type){const{done:t,value:i}=await r.next(s.size);if(t)return;c=n.decodeLongPath(i,e.filenameEncoding),await o(r,s.size);continue}if("pax-global-header"===s.type){const{done:t,value:i}=await r.next(s.size);if(t)return;u=n.decodePax(i,e.filenameEncoding),await o(r,s.size);continue}if("pax-header"===s.type){const{done:t,value:i}=await r.next(s.size);if(t)return;l=n.decodePax(i,e.filenameEncoding),u&&(l={...u,...l}),await o(r,s.size);continue}if(a&&(s.name=a,a=null),c&&(s.linkname=c,c=null),l&&(l.path&&(s.name=l.path),l.linkpath&&(s.linkname=l.linkpath),l.size&&(s.size=parseInt(l.size,10)),s.pax=l,l=null),!s.size||"directory"===s.type){yield{header:s,body:async function*(){}()};continue}let d=s.size;const f=i(),h=await r.nextLte(Math.min(d,e.highWaterMark));d-=h.value.length,d||f.resolve();const p=async function*(){try{for(yield h.value;d;){const{done:e,value:t}=await r.nextLte(d);if(e)return void(d=0);d-=t.length,yield t}}finally{f.resolve()}}();if(yield{header:s,body:p},await f.promise,d)for await(const e of p);await o(r,s.size)}}finally{await r.return()}}())},{"p-defer":"5rKSv","./extract-headers":"i80wA","./lte-reader":"2v3aC"}],i80wA:[function(e,t,r){const{Buffer:i}=e("buffer"),n=e("bl/BufferList"),s="0".charCodeAt(0),o=i.from("ustar\0","binary"),a=i.from("ustar ","binary"),c=i.from(" \0","binary"),u=257,l=function(e,t,r,i){for(;r0;n--){const s=e.get(n);t?i.push(s):r&&0===s?i.push(0):r?(r=!1,i.push(256-s)):i.push(255-s)}let n=0;const s=i.length;for(let e=0;e=n?n:i>=0||(i+=n)>=0?i:0);for(;ts,async next(e){if(r){let n;if(null==e||r.length===e)n=r,r=null;else if(r.length>e)n=r.shallowSlice(0,e),r=r.shallowSlice(e);else if(r.lengtht.return()};return s}},{"bl/BufferList":"im7j6","it-reader":"btxDo"}],btxDo:[function(e,t,r){const i=e("bl/BufferList");t.exports=e=>{const t=async function*(){let t=yield,r=new i;for await(const n of e)if(t)for(r.append(n);r.length>=t;){const e=r.shallowSlice(0,t);if(r.consume(t),t=yield e,!t){r.length&&(t=yield r,r=new i);break}}else t=yield r.append(n),r=new i;if(t)throw Object.assign(new Error(`stream ended before ${t} bytes became available`),{code:"ERR_UNDER_READ",buffer:r})}();return t.next(),t}},{"bl/BufferList":"im7j6"}],"7XvZX":[function(e,t,r){const{Buffer:i}=e("buffer"),n=e("bl/BufferList"),{S_IFMT:s,S_IFBLK:o,S_IFCHR:a,S_IFDIR:c,S_IFIFO:u,S_IFLNK:l}=e("iso-constants"),d=e("it-concat"),f=e("./pack-headers"),h=parseInt("755",8),p=parseInt("644",8),g=i.alloc(1024);function y(e){switch(e&s){case o:return"block-device";case a:return"character-device";case c:return"directory";case u:return"fifo";case l:return"symlink"}return"file"}function m(e){if(e&=511)return new n(g.slice(0,512-e))}function b(e){if(!e.pax){const t=f.encode(e);if(t)return t}return function(e){const t=f.encodePax({name:e.name,linkname:e.linkname,pax:e.pax}),r={name:"PaxHeader",mode:e.mode,uid:e.uid,gid:e.gid,size:t.length,mtime:e.mtime,type:"pax-header",linkname:e.linkname&&"PaxHeader",uname:e.uname,gname:e.gname,devmajor:e.devmajor,devminor:e.devminor};return new n([f.encode(r),t,m(t.length),f.encode({...r,size:e.size,type:e.type})])}(e)}t.exports=()=>async function*(e){for await(let{header:t,body:r}of e){if(t.size&&"symlink"!==t.type||(t.size=0),t.type||(t.type=y(t.mode)),t.mode||(t.mode="directory"===t.type?h:p),t.uid||(t.uid=0),t.gid||(t.gid=0),t.mtime||(t.mtime=new Date),"string"==typeof r&&(r=i.from(r)),i.isBuffer(r)||n.isBufferList(r)){t.size=r.length,yield new n([b(t),r,m(t.size)]);continue}if("symlink"===t.type&&!t.linkname){t.linkname=(await d(r)).toString(),yield b(t);continue}if(yield b(t),"file"!==t.type&&"contiguous-file"!==t.type)continue;let e=0;for await(const t of r)e+=t.length,yield n.isBufferList(t)?t:new n(t);if(e!==t.size)throw new Error("size mismatch");const s=m(t.size);s&&(yield s)}yield new n(g)}},{buffer:"etowf","bl/BufferList":"im7j6","iso-constants":"4lhZA","it-concat":"9rWFO","./pack-headers":"49ru5"}],"4lhZA":[function(e,t,r){"use strict";t.exports={RTLD_LAZY:1,RTLD_NOW:2,RTLD_GLOBAL:256,RTLD_LOCAL:0,RTLD_DEEPBIND:8,E2BIG:7,EACCES:13,EADDRINUSE:98,EADDRNOTAVAIL:99,EAFNOSUPPORT:97,EAGAIN:11,EALREADY:114,EBADF:9,EBADMSG:74,EBUSY:16,ECANCELED:125,ECHILD:10,ECONNABORTED:103,ECONNREFUSED:111,ECONNRESET:104,EDEADLK:35,EDESTADDRREQ:89,EDOM:33,EDQUOT:122,EEXIST:17,EFAULT:14,EFBIG:27,EHOSTUNREACH:113,EIDRM:43,EILSEQ:84,EINPROGRESS:115,EINTR:4,EINVAL:22,EIO:5,EISCONN:106,EISDIR:21,ELOOP:40,EMFILE:24,EMLINK:31,EMSGSIZE:90,EMULTIHOP:72,ENAMETOOLONG:36,ENETDOWN:100,ENETRESET:102,ENETUNREACH:101,ENFILE:23,ENOBUFS:105,ENODATA:61,ENODEV:19,ENOENT:2,ENOEXEC:8,ENOLCK:37,ENOLINK:67,ENOMEM:12,ENOMSG:42,ENOPROTOOPT:92,ENOSPC:28,ENOSR:63,ENOSTR:60,ENOSYS:38,ENOTCONN:107,ENOTDIR:20,ENOTEMPTY:39,ENOTSOCK:88,ENOTSUP:95,ENOTTY:25,ENXIO:6,EOPNOTSUPP:95,EOVERFLOW:75,EPERM:1,EPIPE:32,EPROTO:71,EPROTONOSUPPORT:93,EPROTOTYPE:91,ERANGE:34,EROFS:30,ESPIPE:29,ESRCH:3,ESTALE:116,ETIME:62,ETIMEDOUT:110,ETXTBSY:26,EWOULDBLOCK:11,EXDEV:18,PRIORITY_LOW:19,PRIORITY_BELOW_NORMAL:10,PRIORITY_NORMAL:0,PRIORITY_ABOVE_NORMAL:-7,PRIORITY_HIGH:-14,PRIORITY_HIGHEST:-20,SIGHUP:1,SIGINT:2,SIGQUIT:3,SIGILL:4,SIGTRAP:5,SIGABRT:6,SIGIOT:6,SIGBUS:7,SIGFPE:8,SIGKILL:9,SIGUSR1:10,SIGSEGV:11,SIGUSR2:12,SIGPIPE:13,SIGALRM:14,SIGTERM:15,SIGCHLD:17,SIGSTKFLT:16,SIGCONT:18,SIGSTOP:19,SIGTSTP:20,SIGTTIN:21,SIGTTOU:22,SIGURG:23,SIGXCPU:24,SIGXFSZ:25,SIGVTALRM:26,SIGPROF:27,SIGWINCH:28,SIGIO:29,SIGPOLL:29,SIGPWR:30,SIGSYS:31,SIGUNUSED:31,UV_FS_SYMLINK_DIR:1,UV_FS_SYMLINK_JUNCTION:2,O_RDONLY:0,O_WRONLY:1,O_RDWR:2,UV_DIRENT_UNKNOWN:0,UV_DIRENT_FILE:1,UV_DIRENT_DIR:2,UV_DIRENT_LINK:3,UV_DIRENT_FIFO:4,UV_DIRENT_SOCKET:5,UV_DIRENT_CHAR:6,UV_DIRENT_BLOCK:7,S_IFMT:61440,S_IFREG:32768,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960,S_IFSOCK:49152,O_CREAT:64,O_EXCL:128,UV_FS_O_FILEMAP:0,O_NOCTTY:256,O_TRUNC:512,O_APPEND:1024,O_DIRECTORY:65536,O_NOATIME:262144,O_NOFOLLOW:131072,O_SYNC:1052672,O_DSYNC:4096,O_DIRECT:16384,O_NONBLOCK:2048,S_IRWXU:448,S_IRUSR:256,S_IWUSR:128,S_IXUSR:64,S_IRWXG:56,S_IRGRP:32,S_IWGRP:16,S_IXGRP:8,S_IRWXO:7,S_IROTH:4,S_IWOTH:2,S_IXOTH:1,F_OK:0,R_OK:4,W_OK:2,X_OK:1,UV_FS_COPYFILE_EXCL:1,COPYFILE_EXCL:1,UV_FS_COPYFILE_FICLONE:2,COPYFILE_FICLONE:2,UV_FS_COPYFILE_FICLONE_FORCE:4,COPYFILE_FICLONE_FORCE:4,OPENSSL_VERSION_NUMBER:269488255,SSL_OP_ALL:2147485780,SSL_OP_ALLOW_NO_DHE_KEX:1024,SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION:262144,SSL_OP_CIPHER_SERVER_PREFERENCE:4194304,SSL_OP_CISCO_ANYCONNECT:32768,SSL_OP_COOKIE_EXCHANGE:8192,SSL_OP_CRYPTOPRO_TLSEXT_BUG:2147483648,SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS:2048,SSL_OP_EPHEMERAL_RSA:0,SSL_OP_LEGACY_SERVER_CONNECT:4,SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER:0,SSL_OP_MICROSOFT_SESS_ID_BUG:0,SSL_OP_MSIE_SSLV2_RSA_PADDING:0,SSL_OP_NETSCAPE_CA_DN_BUG:0,SSL_OP_NETSCAPE_CHALLENGE_BUG:0,SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG:0,SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG:0,SSL_OP_NO_COMPRESSION:131072,SSL_OP_NO_ENCRYPT_THEN_MAC:524288,SSL_OP_NO_QUERY_MTU:4096,SSL_OP_NO_RENEGOTIATION:1073741824,SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION:65536,SSL_OP_NO_SSLv2:0,SSL_OP_NO_SSLv3:33554432,SSL_OP_NO_TICKET:16384,SSL_OP_NO_TLSv1:67108864,SSL_OP_NO_TLSv1_1:268435456,SSL_OP_NO_TLSv1_2:134217728,SSL_OP_NO_TLSv1_3:536870912,SSL_OP_PKCS1_CHECK_1:0,SSL_OP_PKCS1_CHECK_2:0,SSL_OP_PRIORITIZE_CHACHA:2097152,SSL_OP_SINGLE_DH_USE:0,SSL_OP_SINGLE_ECDH_USE:0,SSL_OP_SSLEAY_080_CLIENT_DH_BUG:0,SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG:0,SSL_OP_TLS_BLOCK_PADDING_BUG:0,SSL_OP_TLS_D5_BUG:0,SSL_OP_TLS_ROLLBACK_BUG:8388608,ENGINE_METHOD_RSA:1,ENGINE_METHOD_DSA:2,ENGINE_METHOD_DH:4,ENGINE_METHOD_RAND:8,ENGINE_METHOD_EC:2048,ENGINE_METHOD_CIPHERS:64,ENGINE_METHOD_DIGESTS:128,ENGINE_METHOD_PKEY_METHS:512,ENGINE_METHOD_PKEY_ASN1_METHS:1024,ENGINE_METHOD_ALL:65535,ENGINE_METHOD_NONE:0,DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,RSA_PSS_SALTLEN_DIGEST:-1,RSA_PSS_SALTLEN_MAX_SIGN:-2,RSA_PSS_SALTLEN_AUTO:-2,defaultCoreCipherList:"TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA",TLS1_VERSION:769,TLS1_1_VERSION:770,TLS1_2_VERSION:771,TLS1_3_VERSION:772,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6}},{}],"9rWFO":[function(e,t,r){const i=e("bl/BufferList"),n={string:()=>"",buffer:()=>i()};t.exports=async(e,t)=>{if((t=t||{}).type&&!n[t.type])throw new Error(`invalid type "${t.type}"`);let r,i;for await(const s of e)r||(i=t.type||("string"==typeof s?"string":"buffer"),r=n[i]()),"string"===i?r+=s:r.append(s);return r||n[t.type||"buffer"]()}},{"bl/BufferList":"im7j6"}],"49ru5":[function(e,t,r){const{Buffer:i}=e("buffer"),n=i.alloc,s="0".charCodeAt(0),o=i.from("ustar\0","binary"),a=i.from("00","binary"),c=parseInt("7777",8),u=function(e,t){return(e=e.toString(8)).length>t?"7777777777777777777".slice(0,t)+" ":"0000000000000000000".slice(0,t-e.length)+e+" "},l=function(e){const t=i.byteLength(e);let r=Math.floor(Math.log(t)/Math.log(10))+1;return t+r>=Math.pow(10,r)&&r++,t+r+e};r.encodePax=function(e){let t="";e.name&&(t+=l(" path="+e.name+"\n")),e.linkname&&(t+=l(" linkpath="+e.linkname+"\n"));const r=e.pax;if(r)for(const e in r)t+=l(" "+e+"="+r[e]+"\n");return i.from(t)},r.encode=function(e){const t=n(512);let r=e.name,l="";if(5===e.typeflag&&"/"!==r[r.length-1]&&(r+="/"),i.byteLength(r)!==r.length)return null;for(;i.byteLength(r)>100;){const e=r.indexOf("/");if(-1===e)return null;l+=l?"/"+r.slice(0,e):r.slice(0,e),r=r.slice(e+1)}return i.byteLength(r)>100||i.byteLength(l)>155||e.linkname&&i.byteLength(e.linkname)>100?null:(t.write(r),t.write(u(e.mode&c,6),100),t.write(u(e.uid,6),108),t.write(u(e.gid,6),116),t.write(u(e.size,11),124),t.write(u(e.mtime.getTime()/1e3|0,11),136),t[156]=s+function(e){switch(e){case"file":return 0;case"link":return 1;case"symlink":return 2;case"character-device":return 3;case"block-device":return 4;case"directory":return 5;case"fifo":return 6;case"contiguous-file":return 7;case"pax-header":return 72}return 0}(e.type),e.linkname&&t.write(e.linkname,157),o.copy(t,257),a.copy(t,263),e.uname&&t.write(e.uname,265),e.gname&&t.write(e.gname,297),t.write(u(e.devmajor||0,6),329),t.write(u(e.devminor||0,6),337),l&&t.write(l,345),t.write(u(function(e){let t=256;for(let r=0;r<148;r++)t+=e[r];for(let r=156;r<512;r++)t+=e[r];return t}(t),6),148),t)}},{buffer:"etowf"}],ibwO8:[function(e,t,r){"use strict";var i={};(0,e("./lib/utils/common").assign)(i,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),t.exports=i},{"./lib/utils/common":"aI1i7","./lib/deflate":"j0x9v","./lib/inflate":"fWsHR","./lib/zlib/constants":"822Hi"}],aI1i7:[function(e,t,r){"use strict";var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var i in r)n(r,i)&&(e[i]=r[i])}}return e},r.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var s={arraySet:function(e,t,r,i,n){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+i),n);else for(var s=0;s0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new a,this.strm.avail_out=0;var r=i.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==r)throw new Error(o[r]);if(t.header&&i.deflateSetHeader(this.strm,t.header),t.dictionary){var l;if(l="string"==typeof t.dictionary?s.string2buf(t.dictionary):"[object ArrayBuffer]"===c.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(r=i.deflateSetDictionary(this.strm,l)))throw new Error(o[r]);this._dict_set=!0}}function l(e,t){var r=new u(t);if(r.push(e,!0),r.err)throw r.msg||o[r.err];return r.result}u.prototype.push=function(e,t){var r,o,a=this.strm,u=this.options.chunkSize;if(this.ended)return!1;o=t===~~t?t:!0===t?4:0,"string"==typeof e?a.input=s.string2buf(e):"[object ArrayBuffer]"===c.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new n.Buf8(u),a.next_out=0,a.avail_out=u),1!==(r=i.deflate(a,o))&&0!==r)return this.onEnd(r),this.ended=!0,!1;0!==a.avail_out&&(0!==a.avail_in||4!==o&&2!==o)||("string"===this.options.to?this.onData(s.buf2binstring(n.shrinkBuf(a.output,a.next_out))):this.onData(n.shrinkBuf(a.output,a.next_out)))}while((a.avail_in>0||0===a.avail_out)&&1!==r);return 4===o?(r=i.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,0===r):2!==o||(this.onEnd(0),a.avail_out=0,!0)},u.prototype.onData=function(e){this.chunks.push(e)},u.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},r.Deflate=u,r.deflate=l,r.deflateRaw=function(e,t){return(t=t||{}).raw=!0,l(e,t)},r.gzip=function(e,t){return(t=t||{}).gzip=!0,l(e,t)}},{"./zlib/deflate":"eWDtg","./utils/common":"aI1i7","./utils/strings":"gLcvD","./zlib/messages":"2FeB7","./zlib/zstream":"2JH5n"}],eWDtg:[function(e,t,r){"use strict";var i,n=e("../utils/common"),s=e("./trees"),o=e("./adler32"),a=e("./crc32"),c=e("./messages"),u=-2,l=258,d=262,f=103,h=113,p=666;function g(e,t){return e.msg=c[t],t}function y(e){return(e<<1)-(e>4?9:0)}function m(e){for(var t=e.length;--t>=0;)e[t]=0}function b(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(n.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function v(e,t){s._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,b(e.strm)}function w(e,t){e.pending_buf[e.pending++]=t}function _(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function E(e,t){var r,i,n=e.max_chain_length,s=e.strstart,o=e.prev_length,a=e.nice_match,c=e.strstart>e.w_size-d?e.strstart-(e.w_size-d):0,u=e.window,f=e.w_mask,h=e.prev,p=e.strstart+l,g=u[s+o-1],y=u[s+o];e.prev_length>=e.good_match&&(n>>=2),a>e.lookahead&&(a=e.lookahead);do{if(u[(r=t)+o]===y&&u[r+o-1]===g&&u[r]===u[s]&&u[++r]===u[s+1]){s+=2,r++;do{}while(u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&so){if(e.match_start=t,o=i,i>=a)break;g=u[s+o-1],y=u[s+o]}}}while((t=h[t&f])>c&&0!=--n);return o<=e.lookahead?o:e.lookahead}function S(e){var t,r,i,s,c,u,l,f,h,p,g=e.w_size;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=g+(g-d)){n.arraySet(e.window,e.window,g,g,0),e.match_start-=g,e.strstart-=g,e.block_start-=g,t=r=e.hash_size;do{i=e.head[--t],e.head[t]=i>=g?i-g:0}while(--r);t=r=g;do{i=e.prev[--t],e.prev[t]=i>=g?i-g:0}while(--r);s+=g}if(0===e.strm.avail_in)break;if(u=e.strm,l=e.window,f=e.strstart+e.lookahead,h=s,p=void 0,(p=u.avail_in)>h&&(p=h),r=0===p?0:(u.avail_in-=p,n.arraySet(l,u.input,u.next_in,p,f),1===u.state.wrap?u.adler=o(u.adler,l,p,f):2===u.state.wrap&&(u.adler=a(u.adler,l,p,f)),u.next_in+=p,u.total_in+=p,p),e.lookahead+=r,e.lookahead+e.insert>=3)for(c=e.strstart-e.insert,e.ins_h=e.window[c],e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<=3)if(i=s._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<=3&&(e.ins_h=(e.ins_h<4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-3,i=s._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=n&&(e.ins_h=(e.ins_h<15&&(a=2,i-=16),s<1||s>9||8!==r||i<8||i>15||t<0||t>9||o<0||o>4)return g(e,u);8===i&&(i=9);var c=new I;return e.state=c,c.strm=e,c.wrap=a,c.gzhead=null,c.w_bits=i,c.w_size=1<e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(S(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var i=e.block_start+r;if((0===e.strstart||e.strstart>=i)&&(e.lookahead=e.strstart-i,e.strstart=i,v(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-d&&(v(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(v(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(v(e,!1),e.strm.avail_out),1)})),new k(4,4,8,4,T),new k(4,5,16,8,T),new k(4,6,32,32,T),new k(4,4,16,16,A),new k(8,16,32,32,A),new k(8,16,128,128,A),new k(8,32,128,256,A),new k(32,128,258,1024,A),new k(32,258,258,4096,A)],r.deflateInit=function(e,t){return O(e,t,8,15,8,0)},r.deflateInit2=O,r.deflateReset=P,r.deflateResetKeep=R,r.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?u:(e.state.gzhead=t,0):u},r.deflate=function(e,t){var r,n,o,c;if(!e||!e.state||t>5||t<0)return e?g(e,u):u;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===p&&4!==t)return g(e,0===e.avail_out?-5:u);if(n.strm=e,r=n.last_flush,n.last_flush=t,42===n.status)if(2===n.wrap)e.adler=0,w(n,31),w(n,139),w(n,8),n.gzhead?(w(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),w(n,255&n.gzhead.time),w(n,n.gzhead.time>>8&255),w(n,n.gzhead.time>>16&255),w(n,n.gzhead.time>>24&255),w(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),w(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(w(n,255&n.gzhead.extra.length),w(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=a(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(w(n,0),w(n,0),w(n,0),w(n,0),w(n,0),w(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),w(n,3),n.status=h);else{var d=8+(n.w_bits-8<<4)<<8;d|=(n.strategy>=2||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(d|=32),d+=31-d%31,n.status=h,_(n,d),0!==n.strstart&&(_(n,e.adler>>>16),_(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(o=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>o&&(e.adler=a(e.adler,n.pending_buf,n.pending-o,o)),b(e),o=n.pending,n.pending!==n.pending_buf_size));)w(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>o&&(e.adler=a(e.adler,n.pending_buf,n.pending-o,o)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(e.adler=a(e.adler,n.pending_buf,n.pending-o,o)),b(e),o=n.pending,n.pending===n.pending_buf_size)){c=1;break}c=n.gzindexo&&(e.adler=a(e.adler,n.pending_buf,n.pending-o,o)),0===c&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(e.adler=a(e.adler,n.pending_buf,n.pending-o,o)),b(e),o=n.pending,n.pending===n.pending_buf_size)){c=1;break}c=n.gzindexo&&(e.adler=a(e.adler,n.pending_buf,n.pending-o,o)),0===c&&(n.status=f)}else n.status=f;if(n.status===f&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&b(e),n.pending+2<=n.pending_buf_size&&(w(n,255&e.adler),w(n,e.adler>>8&255),e.adler=0,n.status=h)):n.status=h),0!==n.pending){if(b(e),0===e.avail_out)return n.last_flush=-1,0}else if(0===e.avail_in&&y(t)<=y(r)&&4!==t)return g(e,-5);if(n.status===p&&0!==e.avail_in)return g(e,-5);if(0!==e.avail_in||0!==n.lookahead||0!==t&&n.status!==p){var E=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(S(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,r=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(v(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(v(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(v(e,!1),0===e.strm.avail_out)?1:2}(n,t):3===n.strategy?function(e,t){for(var r,i,n,o,a=e.window;;){if(e.lookahead<=l){if(S(e),e.lookahead<=l&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(i=a[n=e.strstart-1])===a[++n]&&i===a[++n]&&i===a[++n]){o=e.strstart+l;do{}while(i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&i===a[++n]&&ne.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=s._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=s._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(v(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(v(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(v(e,!1),0===e.strm.avail_out)?1:2}(n,t):i[n.level].func(n,t);if(3!==E&&4!==E||(n.status=p),1===E||3===E)return 0===e.avail_out&&(n.last_flush=-1),0;if(2===E&&(1===t?s._tr_align(n):5!==t&&(s._tr_stored_block(n,0,0,!1),3===t&&(m(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),b(e),0===e.avail_out))return n.last_flush=-1,0}return 4!==t?0:n.wrap<=0?1:(2===n.wrap?(w(n,255&e.adler),w(n,e.adler>>8&255),w(n,e.adler>>16&255),w(n,e.adler>>24&255),w(n,255&e.total_in),w(n,e.total_in>>8&255),w(n,e.total_in>>16&255),w(n,e.total_in>>24&255)):(_(n,e.adler>>>16),_(n,65535&e.adler)),b(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?0:1)},r.deflateEnd=function(e){var t;return e&&e.state?42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&t!==f&&t!==h&&t!==p?g(e,u):(e.state=null,t===h?g(e,-3):0):u},r.deflateSetDictionary=function(e,t){var r,i,s,a,c,l,d,f,h=t.length;if(!e||!e.state)return u;if(2===(a=(r=e.state).wrap)||1===a&&42!==r.status||r.lookahead)return u;for(1===a&&(e.adler=o(e.adler,t,h,0)),r.wrap=0,h>=r.w_size&&(0===a&&(m(r.head),r.strstart=0,r.block_start=0,r.insert=0),f=new n.Buf8(r.w_size),n.arraySet(f,t,h-r.w_size,r.w_size,0),t=f,h=r.w_size),c=e.avail_in,l=e.next_in,d=e.input,e.avail_in=h,e.next_in=0,e.input=t,S(r);r.lookahead>=3;){i=r.strstart,s=r.lookahead-2;do{r.ins_h=(r.ins_h<=0;)e[t]=0}var s=256,o=286,a=30,c=15,u=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],l=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],d=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],f=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],h=new Array(576);n(h);var p=new Array(60);n(p);var g=new Array(512);n(g);var y=new Array(256);n(y);var m=new Array(29);n(m);var b,v,w,_=new Array(a);function E(e,t,r,i,n){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=i,this.max_length=n,this.has_stree=e&&e.length}function S(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function T(e){return e<256?g[e]:g[256+(e>>>7)]}function A(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function k(e,t,r){e.bi_valid>16-r?(e.bi_buf|=t<>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<>>=1,r<<=1}while(--t>0);return r>>>1}function P(e,t,r){var i,n,s=new Array(16),o=0;for(i=1;i<=c;i++)s[i]=o=o+r[i-1]<<1;for(n=0;n<=t;n++){var a=e[2*n+1];0!==a&&(e[2*n]=R(s[a]++,a))}}function O(e){var t;for(t=0;t8?A(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function j(e,t,r,i){var n=2*t,s=2*r;return e[n]>1;r>=1;r--)D(e,s,r);n=u;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],D(e,s,1),i=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=i,s[2*n]=s[2*r]+s[2*i],e.depth[n]=(e.depth[r]>=e.depth[i]?e.depth[r]:e.depth[i])+1,s[2*r+1]=s[2*i+1]=n,e.heap[1]=n++,D(e,s,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,i,n,s,o,a,u=t.dyn_tree,l=t.max_code,d=t.stat_desc.static_tree,f=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,g=t.stat_desc.max_length,y=0;for(s=0;s<=c;s++)e.bl_count[s]=0;for(u[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<573;r++)(s=u[2*u[2*(i=e.heap[r])+1]+1]+1)>g&&(s=g,y++),u[2*i+1]=s,i>l||(e.bl_count[s]++,o=0,i>=p&&(o=h[i-p]),a=u[2*i],e.opt_len+=a*(s+o),f&&(e.static_len+=a*(d[2*i+1]+o)));if(0!==y){do{for(s=g-1;0===e.bl_count[s];)s--;e.bl_count[s]--,e.bl_count[s+1]+=2,e.bl_count[g]--,y-=2}while(y>0);for(s=g;0!==s;s--)for(i=e.bl_count[s];0!==i;)(n=e.heap[--r])>l||(u[2*n+1]!==s&&(e.opt_len+=(s-u[2*n+1])*u[2*n],u[2*n+1]=s),i--)}}(e,t),P(s,l,e.bl_count)}function B(e,t,r){var i,n,s=-1,o=t[1],a=0,c=7,u=4;for(0===o&&(c=138,u=3),t[2*(r+1)+1]=65535,i=0;i<=r;i++)n=o,o=t[2*(i+1)+1],++a>=7;i0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t=3&&0===e.bl_tree[2*f[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),n=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=n&&(n=o)):n=o=r+5,r+4<=n&&-1!==t?U(e,t,r,i):4===e.strategy||o===n?(k(e,2+(i?1:0),3),M(e,h,p)):(k(e,4+(i?1:0),3),function(e,t,r,i){var n;for(k(e,t-257,5),k(e,r-1,5),k(e,i-4,4),n=0;n>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(y[r]+s+1)]++,e.dyn_dtree[2*T(t)]++),e.last_lit===e.lit_bufsize-1},r._tr_align=function(e){k(e,2,3),I(e,256,h),function(e){16===e.bi_valid?(A(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":"aI1i7"}],aFgUT:[function(e,t,r){"use strict";t.exports=function(e,t,r,i){for(var n=65535&e|0,s=e>>>16&65535|0,o=0;0!==r;){r-=o=r>2e3?2e3:r;do{s=s+(n=n+t[i++]|0)|0}while(--o);n%=65521,s%=65521}return n|s<<16|0}},{}],"5TUdt":[function(e,t,r){"use strict";var i=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();t.exports=function(e,t,r,n){var s=i,o=n+r;e^=-1;for(var a=n;a>>8^s[255&(e^t[a])];return-1^e}},{}],"2FeB7":[function(e,t,r){"use strict";t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],gLcvD:[function(e,t,r){"use strict";var i=e("./common"),n=!0,s=!0;try{String.fromCharCode.apply(null,[0])}catch(e){n=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){s=!1}for(var o=new i.Buf8(256),a=0;a<256;a++)o[a]=a>=252?6:a>=248?5:a>=240?4:a>=224?3:a>=192?2:1;function c(e,t){if(t<65534&&(e.subarray&&s||!e.subarray&&n))return String.fromCharCode.apply(null,i.shrinkBuf(e,t));for(var r="",o=0;o>>6,t[o++]=128|63&r):r<65536?(t[o++]=224|r>>>12,t[o++]=128|r>>>6&63,t[o++]=128|63&r):(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63,t[o++]=128|r>>>6&63,t[o++]=128|63&r);return t},r.buf2binstring=function(e){return c(e,e.length)},r.binstring2buf=function(e){for(var t=new i.Buf8(e.length),r=0,n=t.length;r4)u[i++]=65533,r+=s-1;else{for(n&=2===s?31:3===s?15:7;s>1&&r1?u[i++]=65533:n<65536?u[i++]=n:(n-=65536,u[i++]=55296|n>>10&1023,u[i++]=56320|1023&n)}return c(u,i)},r.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+o[e[r]]>t?r:t}},{"./common":"aI1i7"}],"2JH5n":[function(e,t,r){"use strict";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],fWsHR:[function(e,t,r){"use strict";var i=e("./zlib/inflate"),n=e("./utils/common"),s=e("./utils/strings"),o=e("./zlib/constants"),a=e("./zlib/messages"),c=e("./zlib/zstream"),u=e("./zlib/gzheader"),l=Object.prototype.toString;function d(e){if(!(this instanceof d))return new d(e);this.options=n.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var r=i.inflateInit2(this.strm,t.windowBits);if(r!==o.Z_OK)throw new Error(a[r]);if(this.header=new u,i.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=s.string2buf(t.dictionary):"[object ArrayBuffer]"===l.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=i.inflateSetDictionary(this.strm,t.dictionary))!==o.Z_OK))throw new Error(a[r])}function f(e,t){var r=new d(t);if(r.push(e,!0),r.err)throw r.msg||a[r.err];return r.result}d.prototype.push=function(e,t){var r,a,c,u,d,f=this.strm,h=this.options.chunkSize,p=this.options.dictionary,g=!1;if(this.ended)return!1;a=t===~~t?t:!0===t?o.Z_FINISH:o.Z_NO_FLUSH,"string"==typeof e?f.input=s.binstring2buf(e):"[object ArrayBuffer]"===l.call(e)?f.input=new Uint8Array(e):f.input=e,f.next_in=0,f.avail_in=f.input.length;do{if(0===f.avail_out&&(f.output=new n.Buf8(h),f.next_out=0,f.avail_out=h),(r=i.inflate(f,o.Z_NO_FLUSH))===o.Z_NEED_DICT&&p&&(r=i.inflateSetDictionary(this.strm,p)),r===o.Z_BUF_ERROR&&!0===g&&(r=o.Z_OK,g=!1),r!==o.Z_STREAM_END&&r!==o.Z_OK)return this.onEnd(r),this.ended=!0,!1;f.next_out&&(0!==f.avail_out&&r!==o.Z_STREAM_END&&(0!==f.avail_in||a!==o.Z_FINISH&&a!==o.Z_SYNC_FLUSH)||("string"===this.options.to?(c=s.utf8border(f.output,f.next_out),u=f.next_out-c,d=s.buf2string(f.output,c),f.next_out=u,f.avail_out=h-u,u&&n.arraySet(f.output,f.output,c,u,0),this.onData(d)):this.onData(n.shrinkBuf(f.output,f.next_out)))),0===f.avail_in&&0===f.avail_out&&(g=!0)}while((f.avail_in>0||0===f.avail_out)&&r!==o.Z_STREAM_END);return r===o.Z_STREAM_END&&(a=o.Z_FINISH),a===o.Z_FINISH?(r=i.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===o.Z_OK):a!==o.Z_SYNC_FLUSH||(this.onEnd(o.Z_OK),f.avail_out=0,!0)},d.prototype.onData=function(e){this.chunks.push(e)},d.prototype.onEnd=function(e){e===o.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},r.Inflate=d,r.inflate=f,r.inflateRaw=function(e,t){return(t=t||{}).raw=!0,f(e,t)},r.ungzip=f},{"./zlib/inflate":"bCmNK","./utils/common":"aI1i7","./utils/strings":"gLcvD","./zlib/constants":"822Hi","./zlib/messages":"2FeB7","./zlib/zstream":"2JH5n","./zlib/gzheader":"2gJW0"}],bCmNK:[function(e,t,r){"use strict";var i=e("../utils/common"),n=e("./adler32"),s=e("./crc32"),o=e("./inffast"),a=e("./inftrees"),c=-2,u=12,l=30;function d(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function f(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function h(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new i.Buf32(852),t.distcode=t.distdyn=new i.Buf32(592),t.sane=1,t.back=-1,0):c}function p(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,h(e)):c}function g(e,t){var r,i;return e&&e.state?(i=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?c:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=r,i.wbits=t,p(e))):c}function y(e,t){var r,i;return e?(i=new f,e.state=i,i.window=null,0!==(r=g(e,t))&&(e.state=null),r):c}var m,b,v=!0;function w(e){if(v){var t;for(m=new i.Buf32(512),b=new i.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(a(1,e.lens,0,288,m,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;a(2,e.lens,0,32,b,0,e.work,{bits:5}),v=!1}e.lencode=m,e.lenbits=9,e.distcode=b,e.distbits=5}function _(e,t,r,n){var s,o=e.state;return null===o.window&&(o.wsize=1<=o.wsize?(i.arraySet(o.window,t,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((s=o.wsize-o.wnext)>n&&(s=n),i.arraySet(o.window,t,r-n,s,o.wnext),(n-=s)?(i.arraySet(o.window,t,r-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=s,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,r.check=s(r.check,N,2,0),b=0,v=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&b)<<8)+(b>>8))%31){e.msg="incorrect header check",r.mode=l;break}if(8!=(15&b)){e.msg="unknown compression method",r.mode=l;break}if(v-=4,D=8+(15&(b>>>=4)),0===r.wbits)r.wbits=D;else if(D>r.wbits){e.msg="invalid window size",r.mode=l;break}r.dmax=1<>8&1),512&r.flags&&(N[0]=255&b,N[1]=b>>>8&255,r.check=s(r.check,N,2,0)),b=0,v=0,r.mode=3;case 3:for(;v<32;){if(0===y)break e;y--,b+=f[p++]<>>8&255,N[2]=b>>>16&255,N[3]=b>>>24&255,r.check=s(r.check,N,4,0)),b=0,v=0,r.mode=4;case 4:for(;v<16;){if(0===y)break e;y--,b+=f[p++]<>8),512&r.flags&&(N[0]=255&b,N[1]=b>>>8&255,r.check=s(r.check,N,2,0)),b=0,v=0,r.mode=5;case 5:if(1024&r.flags){for(;v<16;){if(0===y)break e;y--,b+=f[p++]<>>8&255,r.check=s(r.check,N,2,0)),b=0,v=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((T=r.length)>y&&(T=y),T&&(r.head&&(D=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),i.arraySet(r.head.extra,f,p,T,D)),512&r.flags&&(r.check=s(r.check,f,T,p)),y-=T,p+=T,r.length-=T),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===y)break e;T=0;do{D=f[p+T++],r.head&&D&&r.length<65536&&(r.head.name+=String.fromCharCode(D))}while(D&&T>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=u;break;case 10:for(;v<32;){if(0===y)break e;y--,b+=f[p++]<>>=7&v,v-=7&v,r.mode=27;break}for(;v<3;){if(0===y)break e;y--,b+=f[p++]<>>=1)){case 0:r.mode=14;break;case 1:if(w(r),r.mode=20,6===t){b>>>=2,v-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=l}b>>>=2,v-=2;break;case 14:for(b>>>=7&v,v-=7&v;v<32;){if(0===y)break e;y--,b+=f[p++]<>>16^65535)){e.msg="invalid stored block lengths",r.mode=l;break}if(r.length=65535&b,b=0,v=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(T=r.length){if(T>y&&(T=y),T>m&&(T=m),0===T)break e;i.arraySet(h,f,p,T,g),y-=T,p+=T,m-=T,g+=T,r.length-=T;break}r.mode=u;break;case 17:for(;v<14;){if(0===y)break e;y--,b+=f[p++]<>>=5,v-=5,r.ndist=1+(31&b),b>>>=5,v-=5,r.ncode=4+(15&b),b>>>=4,v-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=l;break}r.have=0,r.mode=18;case 18:for(;r.have>>=3,v-=3}for(;r.have<19;)r.lens[U[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,x={bits:r.lenbits},M=a(0,r.lens,0,19,r.lencode,0,r.work,x),r.lenbits=x.bits,M){e.msg="invalid code lengths set",r.mode=l;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,P=65535&L,!((I=L>>>24)<=v);){if(0===y)break e;y--,b+=f[p++]<>>=I,v-=I,r.lens[r.have++]=P;else{if(16===P){for(B=I+2;v>>=I,v-=I,0===r.have){e.msg="invalid bit length repeat",r.mode=l;break}D=r.lens[r.have-1],T=3+(3&b),b>>>=2,v-=2}else if(17===P){for(B=I+3;v>>=I)),b>>>=3,v-=3}else{for(B=I+7;v>>=I)),b>>>=7,v-=7}if(r.have+T>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=l;break}for(;T--;)r.lens[r.have++]=D}}if(r.mode===l)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=l;break}if(r.lenbits=9,x={bits:r.lenbits},M=a(1,r.lens,0,r.nlen,r.lencode,0,r.work,x),r.lenbits=x.bits,M){e.msg="invalid literal/lengths set",r.mode=l;break}if(r.distbits=6,r.distcode=r.distdyn,x={bits:r.distbits},M=a(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,x),r.distbits=x.bits,M){e.msg="invalid distances set",r.mode=l;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(y>=6&&m>=258){e.next_out=g,e.avail_out=m,e.next_in=p,e.avail_in=y,r.hold=b,r.bits=v,o(e,S),g=e.next_out,h=e.output,m=e.avail_out,p=e.next_in,f=e.input,y=e.avail_in,b=r.hold,v=r.bits,r.mode===u&&(r.back=-1);break}for(r.back=0;R=(L=r.lencode[b&(1<>>16&255,P=65535&L,!((I=L>>>24)<=v);){if(0===y)break e;y--,b+=f[p++]<>O)])>>>16&255,P=65535&L,!(O+(I=L>>>24)<=v);){if(0===y)break e;y--,b+=f[p++]<>>=O,v-=O,r.back+=O}if(b>>>=I,v-=I,r.back+=I,r.length=P,0===R){r.mode=26;break}if(32&R){r.back=-1,r.mode=u;break}if(64&R){e.msg="invalid literal/length code",r.mode=l;break}r.extra=15&R,r.mode=22;case 22:if(r.extra){for(B=r.extra;v>>=r.extra,v-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;R=(L=r.distcode[b&(1<>>16&255,P=65535&L,!((I=L>>>24)<=v);){if(0===y)break e;y--,b+=f[p++]<>O)])>>>16&255,P=65535&L,!(O+(I=L>>>24)<=v);){if(0===y)break e;y--,b+=f[p++]<>>=O,v-=O,r.back+=O}if(b>>>=I,v-=I,r.back+=I,64&R){e.msg="invalid distance code",r.mode=l;break}r.offset=P,r.extra=15&R,r.mode=24;case 24:if(r.extra){for(B=r.extra;v>>=r.extra,v-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=l;break}r.mode=25;case 25:if(0===m)break e;if(T=S-m,r.offset>T){if((T=r.offset-T)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=l;break}T>r.wnext?(T-=r.wnext,A=r.wsize-T):A=r.wnext-T,T>r.length&&(T=r.length),k=r.window}else k=h,A=g-r.offset,T=r.length;T>m&&(T=m),m-=T,r.length-=T;do{h[g++]=k[A++]}while(--T);0===r.length&&(r.mode=21);break;case 26:if(0===m)break e;h[g++]=r.length,m--,r.mode=21;break;case 27:if(r.wrap){for(;v<32;){if(0===y)break e;y--,b|=f[p++]<>>=w=v>>>24,p-=w,0===(w=v>>>16&255))k[s++]=65535&v;else{if(!(16&w)){if(0==(64&w)){v=g[(65535&v)+(h&(1<>>=w,p-=w),p<15&&(h+=A[i++]<>>=w=v>>>24,p-=w,!(16&(w=v>>>16&255))){if(0==(64&w)){v=y[(65535&v)+(h&(1<c){e.msg="invalid distance too far back",r.mode=30;break e}if(h>>>=w,p-=w,E>(w=s-o)){if((w=E-w)>l&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(S=0,T=f,0===d){if(S+=u-w,w<_){_-=w;do{k[s++]=f[S++]}while(--w);S=s-E,T=k}}else if(d2;)k[s++]=T[S++],k[s++]=T[S++],k[s++]=T[S++],_-=3;_&&(k[s++]=T[S++],_>1&&(k[s++]=T[S++]))}else{S=s-E;do{k[s++]=k[S++],k[s++]=k[S++],k[s++]=k[S++],_-=3}while(_>2);_&&(k[s++]=k[S++],_>1&&(k[s++]=k[S++]))}break}}break}}while(i>3,h&=(1<<(p-=_<<3))-1,e.next_in=i,e.next_out=s,e.avail_in=i=1&&0===B[I];I--);if(R>I&&(R=I),0===I)return l[d++]=20971520,l[d++]=20971520,h.bits=1,0;for(k=1;k0&&(0===e||1!==I))return-1;for(L[1]=0,T=1;T852||2===e&&j>592)return 1;for(;;){w=T-O,f[A]v?(_=N[U+f[A]],E=M[x+f[A]]):(_=96,E=0),p=1<>O)+(g-=p)]=w<<24|_<<16|E|0}while(0!==g);for(p=1<>=1;if(0!==p?(D&=p-1,D+=p):D=0,A++,0==--B[T]){if(T===I)break;T=t[r+f[A]]}if(T>R&&(D&m)!==y){for(0===O&&(O=R),b+=k,C=1<<(P=T-O);P+O852||2===e&&j>592)return 1;l[y=D&m]=R<<24|P<<16|b-d|0}}return 0!==D&&(l[b+D]=T-O<<24|4194304),h.bits=R,0}},{"../utils/common":"aI1i7"}],"822Hi":[function(e,t,r){"use strict";t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],"2gJW0":[function(e,t,r){"use strict";t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],"38Qf6":[function(e,t,r){"use strict";const{concat:i}=e("uint8arrays/concat");t.exports=async function(e){let t=new Uint8Array(0);for await(const r of e)t=i([t,r],t.length+r.length);return t}},{"uint8arrays/concat":"4EBjG"}],lCq4W:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-unixfs-exporter"),n=e("err-code"),s=e("../utils.js"),o=e("ipfs-core-utils/with-timeout-option"),a=e("multiformats/cid");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(n);r.createLs=function({repo:e,preload:t}){return o.withTimeoutOption((async function*(r,n={}){const o=s.normalizeCidPath(r),c=o.split("/");!1!==n.preload&&t(a.CID.parse(c[0]));const l=a.CID.asCID(o)||o,d=await i.exporter(l,e.blocks,n);if("file"!==d.type){if("directory"!==d.type)throw u.default(new Error(`Unknown UnixFS type ${d.type}`),"ERR_UNKNOWN_UNIXFS_TYPE");for await(const e of d.content())yield s.mapFile(e)}else yield s.mapFile(d)}))}},{"ipfs-unixfs-exporter":"BgMiX","err-code":"chZjB","../utils.js":"cT4uN","ipfs-core-utils/with-timeout-option":"j29MK","multiformats/cid":"9ooAY"}],"8mBfq":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../version.js"),n=e("ipfs-core-utils/with-timeout-option");r.createVersion=function({repo:e}){return n.withTimeoutOption((async function(t={}){const r=await e.version.get();return{version:i.ipfsCore,commit:i.commit,repo:`${r}`,"ipfs-core":i.ipfsCore,"interface-ipfs-core":i.interfaceIpfsCore}}))}},{"../version.js":"cyFMr","ipfs-core-utils/with-timeout-option":"j29MK"}],cyFMr:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.commit="5ddd0c555cc6577ee15667f4ef4e7f3a3b17d04c",r.interfaceIpfsCore="^0.151.1",r.ipfsCore="0.11.1"},{}],bQa6q:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../version.js"),n=e("multiaddr"),s=e("ipfs-core-utils/with-timeout-option"),o=e("uint8arrays/to-string"),a=e("peer-id"),c=e("../errors.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=u(a);r.createId=function({peerId:e,network:t}){return s.withTimeoutOption((async function(r={}){r.peerId===e.toB58String()&&delete r.peerId;const s=t.try();if(!s){if(r.peerId)throw new c.NotStartedError;return{id:e.toB58String(),publicKey:o.toString(e.pubKey.bytes,"base64pad"),addresses:[],agentVersion:`js-ipfs/${i.ipfsCore}`,protocolVersion:"9000",protocols:[]}}const a=r.peerId?l.default.createFromB58String(r.peerId.toString()):e,{libp2p:u}=s,d=r.peerId?u.peerStore.keyBook.get(a):a.pubKey,f=r.peerId?u.peerStore.addressBook.getMultiaddrsForPeer(a):u.multiaddrs,h=r.peerId?u.peerStore.protoBook.get(a):Array.from(u.upgrader.protocols.keys()),p=o.toString(u.peerStore.metadataBook.getValue(a,"AgentVersion")||new Uint8Array),g=o.toString(u.peerStore.metadataBook.getValue(a,"ProtocolVersion")||new Uint8Array),y=a.toB58String();return{id:y,publicKey:o.toString(d.bytes,"base64pad"),addresses:(f||[]).map((e=>{const t=e.toString();return t.endsWith(`/p2p/${y}`)?t:`${t}/p2p/${y}`})).sort().map((e=>new n.Multiaddr(e))),agentVersion:p,protocolVersion:g,protocols:(h||[]).sort()}}))}},{"../version.js":"cyFMr",multiaddr:"8Mu1u","ipfs-core-utils/with-timeout-option":"j29MK","uint8arrays/to-string":"hC8JB","peer-id":"8Bdb3","../errors.js":"j69o8"}],"3uMSz":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option"),n=e("debug"),s=e("./profiles.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const a=o(n).default("ipfs:core:config");async function c(e){return Object.keys(s.profiles).map((e=>({name:e,description:s.profiles[e].description})))}r.createConfig=function({repo:e}){return{getAll:i.withTimeoutOption((async function(t={}){return e.config.getAll(t)})),get:i.withTimeoutOption((async function(t,r){return t?e.config.get(t,r):Promise.reject(new Error("key argument is required"))})),set:i.withTimeoutOption((async function(t,r,i){return e.config.set(t,r,i)})),replace:i.withTimeoutOption((async function(t,r){return e.config.replace(t,r)})),profiles:{apply:i.withTimeoutOption((async function(t,r={dryRun:!1}){const{dryRun:i}=r,n=s.profiles[t];if(!n)throw new Error(`No profile with name '${t}' exists`);try{const t=await e.config.getAll(r);let s=JSON.parse(JSON.stringify(t));return s=n.transform(s),i||await e.config.replace(s,r),delete t.Identity.PrivKey,delete s.Identity.PrivKey,{original:t,updated:s}}catch(e){throw a(e),new Error(`Could not apply profile '${t}' to config: ${e.message}`)}})),list:i.withTimeoutOption(c)}}}},{"ipfs-core-utils/with-timeout-option":"j29MK",debug:"bO5wM","./profiles.js":"f6AK7"}],f6AK7:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("just-safe-set"),n=e("ipfs-core-config/config");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=s(i),a=s(n);const c={server:{description:"Recommended for nodes with public IPv4 address (servers, VPSes, etc.), disables host and content discovery and UPnP in local networks.",transform:e=>(o.default(e,"Discovery.MDNS.Enabled",!1),o.default(e,"Discovery.webRTCStar.Enabled",!1),e.Swarm={...e.Swarm||{},DisableNatPortMap:!0},e)},"local-discovery":{description:"Sets default values to fields affected by `server` profile, enables discovery and UPnP in local networks.",transform:e=>(o.default(e,"Discovery.MDNS.Enabled",!0),o.default(e,"Discovery.webRTCStar.Enabled",!0),o.default(e,"Swarm",{...e.Swarm||{},DisableNatPortMap:!1}),e)},test:{description:"Reduces external interference, useful for running ipfs in test environments. Note that with these settings node won't be able to talk to the rest of the network without manual bootstrap.",transform:e=>{const t=a.default();return o.default(e,"Addresses.API",t.Addresses.API?"/ip4/127.0.0.1/tcp/0":""),o.default(e,"Addresses.Gateway",t.Addresses.Gateway?"/ip4/127.0.0.1/tcp/0":""),o.default(e,"Addresses.Swarm",t.Addresses.Swarm.length?["/ip4/127.0.0.1/tcp/0"]:[]),o.default(e,"Addresses.Delegates",[]),o.default(e,"Bootstrap",[]),o.default(e,"Discovery.MDNS.Enabled",!1),o.default(e,"Discovery.webRTCStar.Enabled",!1),o.default(e,"Swarm",{...e.Swarm||{},DisableNatPortMap:!0}),e}},"default-networking":{description:"Restores default network settings. Inverse profile of the `test` profile.",transform:e=>{const t=a.default();return o.default(e,"Addresses.API",t.Addresses.API),o.default(e,"Addresses.Gateway",t.Addresses.Gateway),o.default(e,"Addresses.Swarm",t.Addresses.Swarm),o.default(e,"Addresses.Delegates",t.Addresses.Delegates),o.default(e,"Bootstrap",t.Bootstrap),o.default(e,"Discovery.MDNS.Enabled",t.Discovery.MDNS.Enabled),o.default(e,"Discovery.webRTCStar.Enabled",t.Discovery.webRTCStar.Enabled),o.default(e,"Swarm",{...e.Swarm||{},DisableNatPortMap:!1}),e}},lowpower:{description:"Reduces daemon overhead on the system. May affect node functionality,performance of content discovery and data fetching may be degraded. Recommended for low power systems.",transform:e=>{const t=e.Swarm||{},r=t.ConnMgr||{};return r.LowWater=20,r.HighWater=40,t.ConnMgr=r,e.Swarm=t,e}},"default-power":{description:'Inverse of "lowpower" profile.',transform:e=>{const t=a.default();return e.Swarm=t.Swarm,e}}};r.profiles=c},{"just-safe-set":"glUwm","ipfs-core-config/config":"ejWbz"}],glUwm:[function(e,t,r){function i(e){if("__proto__"===e||"constructor"===e||"prototype"===e)throw new Error("setting of prototype values not supported")}t.exports=function(e,t,r){var n,s,o;Array.isArray(t)&&(n=t.slice(0));"string"==typeof t&&(n=t.split("."));"symbol"==typeof t&&(n=[t]);if(!Array.isArray(n))throw new Error("props arg must be an array, a string or a symbol");if(!(s=n.pop()))return!1;i(s);for(;o=n.shift();)if(i(o),void 0===e[o]&&(e[o]={}),!(e=e[o])||"object"!=typeof e)return!1;return e[s]=r,!0}},{}],"9rLzF":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./export.js"),n=e("./get.js"),s=e("./import.js"),o=e("./put.js"),a=e("./resolve.js");r.DagAPI=class{constructor({repo:e,codecs:t,hashers:r,preload:c}){this.export=i.createExport({repo:e,preload:c,codecs:t}),this.get=n.createGet({codecs:t,repo:e,preload:c}),this.import=s.createImport({repo:e}),this.resolve=a.createResolve({repo:e,codecs:t,preload:c}),this.put=o.createPut({repo:e,codecs:t,hashers:r,preload:c})}}},{"./export.js":"fGRwg","./get.js":"evp3q","./import.js":"1a905","./put.js":"d8SU0","./resolve.js":"gIL7b"}],fGRwg:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("multiformats/block"),s=e("multiformats/bases/base58"),o=e("@ipld/car/writer"),a=e("ipfs-core-utils/with-timeout-option"),c=e("debug"),u=e("multiformats/codecs/raw"),l=e("multiformats/codecs/json");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function f(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var h=d(c),p=f(u),g=f(l);const y=h.default("ipfs:components:dag:import"),m=[p.code,g.code];async function b(e,t,r,i,o,a=new Set){const c=r.toString(s.base58btc);if(a.has(c))return;const u=await async function(e,t,r,i){const s=await e.blocks.get(r,t);let o=[];const a=await i.getCodec(r.code);if(a){o=[...n.createUnsafe({bytes:s,cid:r,codec:a}).links()].map((e=>e[1]))}else if(!m.includes(r.code))throw new Error(`Can't decode links in block with codec 0x${r.code.toString(16)} to form complete DAG`);return{cid:r,bytes:s,links:o}}(e,t,r,o);y(`Adding block ${r} to car`),await i.put(u),a.add(c);for(const r of u.links)await b(e,t,r,i,o,a)}r.createExport=function({repo:e,preload:t,codecs:r}){return a.withTimeoutOption((async function*(n,s={}){!1!==s.preload&&t(n);const a=i.CID.asCID(n);if(!a)throw new Error(`Unexpected error converting CID type: ${n}`);y(`Exporting ${a} as car`);const{writer:c,out:u}=await o.CarWriter.create([a]);let l=null;(async()=>{try{await b(e,{signal:s.signal,timeout:s.timeout},a,c,r),c.close()}catch(e){l=e}})();for await(const e of u){if(l)break;yield e}if(l)throw l}))}},{"multiformats/cid":"9ooAY","multiformats/block":"i1Z6F","multiformats/bases/base58":"4n7mA","@ipld/car/writer":"7xGrH","ipfs-core-utils/with-timeout-option":"j29MK",debug:"bO5wM","multiformats/codecs/raw":"fdfgp","multiformats/codecs/json":"cRmep"}],i1Z6F:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),e("./index.js");var i=e("./cid.js"),n=e("./bytes.js");const s=({enumerable:e=!0,configurable:t=!1}={})=>({enumerable:e,configurable:t,writable:!1}),o=function*(e,t){if(null!=e&&!(e instanceof Uint8Array))for(const[r,n]of Object.entries(e)){const e=[...t,r];if(null!=n&&"object"==typeof n)if(Array.isArray(n))for(const[t,r]of n.entries()){const n=[...e,t],s=i.CID.asCID(r);s?yield[n.join("/"),s]:"object"==typeof r&&(yield*o(r,n))}else{const t=i.CID.asCID(n);t?yield[e.join("/"),t]:yield*o(n,e)}}},a=function*(e,t){if(null!=e)for(const[r,n]of Object.entries(e)){const e=[...t,r];if(yield e.join("/"),!(null==n||n instanceof Uint8Array||"object"!=typeof n||i.CID.asCID(n)))if(Array.isArray(n))for(const[t,r]of n.entries()){const n=[...e,t];yield n.join("/"),"object"!=typeof r||i.CID.asCID(r)||(yield*a(r,n))}else yield*a(n,e)}};class c{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:s(),bytes:s(),value:s(),asBlock:s()})}links(){return o(this.value,[])}tree(){return a(this.value,[])}get(e="/"){return((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 s=i.CID.asCID(r);if(s)return{value:s,remaining:t.slice(e+1).join("/")}}return{value:r}})(this.value,e.split("/").filter(Boolean))}}const u=({bytes:e,cid:t,value:r,codec:i})=>{const n=void 0!==r?r:i&&i.decode(e);if(void 0===n)throw new Error('Missing required argument, must either provide "value" or "codec"');return new c({cid:t,bytes:e,value:n})};r.Block=c,r.create=async({bytes:e,cid:t,hasher:r,codec:i})=>{if(!e)throw new Error('Missing required argument "bytes"');if(!r)throw new Error('Missing required argument "hasher"');const s=i.decode(e),o=await r.digest(e);if(!n.equals(t.multihash.bytes,o.bytes))throw new Error("CID hash does not match bytes");return u({bytes:e,cid:t,value:s,codec:i})},r.createUnsafe=u,r.decode=async({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),s=await r.digest(e),o=i.CID.create(1,t.code,s);return new c({value:n,bytes:e,cid:o})},r.encode=async({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),s=await r.digest(n),o=i.CID.create(1,t.code,s);return new c({value:e,bytes:n,cid:o})}},{"./index.js":"3ANyW","./cid.js":"9ooAY","./bytes.js":"6I0Ku"}],"7xGrH":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("./encoder.js"),s=e("./iterator-channel.js"),o=e("./decoder.js");class a{constructor(e,t){this._encoder=t,this._mutex=t.setRoots(e),this._ended=!1}async put(e){if(!(e.bytes instanceof Uint8Array&&e.cid))throw new TypeError("Can only write {cid, bytes} objects");if(this._ended)throw new Error("Already closed");const t=i.CID.asCID(e.cid);if(!t)throw new TypeError("Can only write {cid, bytes} objects");return this._mutex=this._mutex.then((()=>this._encoder.writeBlock({cid:t,bytes:e.bytes}))),this._mutex}async close(){if(this._ended)throw new Error("Already closed");return await this._mutex,this._ended=!0,this._encoder.close()}static create(e){e=function(e){if(void 0===e)return[];if(!Array.isArray(e)){const t=i.CID.asCID(e);if(!t)throw new TypeError("roots must be a single CID or an array of CIDs");return[t]}const t=[];for(const r of e){const e=i.CID.asCID(r);if(!e)throw new TypeError("roots must be a single CID or an array of CIDs");t.push(e)}return t}(e);const{encoder:t,iterator:r}=u();return{writer:new a(e,t),out:new c(r)}}static createAppender(){const{encoder:e,iterator:t}=u();e.setRoots=()=>Promise.resolve();return{writer:new a([],e),out:new c(t)}}static async updateRootsInBytes(e,t){const r=o.bytesReader(e);await o.readHeader(r);const i=n.createHeader(t);if(r.pos!==i.length)throw new Error(`updateRoots() can only overwrite a header of the same length (old header is ${r.pos} bytes, new header is ${i.length} bytes)`);return e.set(i,0),e}}class c{constructor(e){this._iterator=e}[Symbol.asyncIterator](){if(this._iterating)throw new Error("Multiple iterator not supported");return this._iterating=!0,this._iterator}}function u(){const e=s.create(),{writer:t,iterator:r}=e;return{encoder:n.createEncoder(t),iterator:r}}r.CarWriter=a,r.CarWriterOut=c,r.__browser=!0},{"multiformats/cid":"9ooAY","./encoder.js":"d1fSj","./iterator-channel.js":"9nhH8","./decoder.js":"hA2ak"}],d1fSj:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("varint"),n=e("@ipld/dag-cbor");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=s(i);function a(e){const t=n.encode({version:1,roots:e}),r=o.default.encode(t.length),i=new Uint8Array(r.length+t.length);return i.set(r,0),i.set(t,r.length),i}r.createEncoder=function(e){return{async setRoots(t){const r=a(t);await e.write(r)},async writeBlock(t){const{cid:r,bytes:i}=t;await e.write(new Uint8Array(o.default.encode(r.bytes.length+i.length))),await e.write(r.bytes),i.length&&await e.write(i)},close:async()=>e.end()}},r.createHeader=a},{varint:"aN1CO","@ipld/dag-cbor":"3498i"}],"9nhH8":[function(e,t,r){"use strict";function i(){}Object.defineProperty(r,"__esModule",{value:!0}),r.create=function(){const e=[];let t=null,r=i,n=!1,s=null,o=i;const a=()=>(t||(t=new Promise((e=>{r=()=>{t=null,r=i,e()}}))),t),c={async next(){const t=e.shift();return t?(0===e.length&&r(),{done:!1,value:t}):n?(r(),{done:!0,value:void 0}):(s||(s=new Promise((e=>{o=()=>(s=null,o=i,e(c.next()))}))),s)}};return{writer:{write(t){e.push(t);const r=a();return o(),r},async end(){n=!0;const e=a();return o(),e}},iterator:c}}},{}],hA2ak:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("varint"),n=e("multiformats/cid"),s=e("multiformats/hashes/digest"),o=e("@ipld/dag-cbor");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function c(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var u=a(i),l=c(s);const d=18,f=32,h=112;async function p(e){const t=await e.upTo(8),r=u.default.decode(t);return e.seek(u.default.decode.bytes),r}async function g(e){const t=await p(e);if(0===t)throw new Error("Invalid CAR header (zero length)");const r=await e.exactly(t);e.seek(t);const i=o.decode(r);if(null==i||Array.isArray(i)||"object"!=typeof i)throw new Error("Invalid CAR header format");if(1!==i.version){if("string"==typeof i.version)throw new Error(`Invalid CAR version: "${i.version}"`);throw new Error(`Invalid CAR version: ${i.version}`)}if(!Array.isArray(i.roots))throw new Error("Invalid CAR header format");if(Object.keys(i).filter((e=>"roots"!==e&&"version"!==e)).length)throw new Error("Invalid CAR header format");return i}async function y(e){const t=await e.exactly(2);if(t[0]===d&&t[1]===f){const t=await e.exactly(34);e.seek(34);const r=l.decode(t);return n.CID.create(0,h,r)}const r=await p(e);if(1!==r)throw new Error(`Unexpected CID version (${r})`);const i=await p(e),s=await async function(e){const t=await e.upTo(8);u.default.decode(t);const r=u.default.decode.bytes,i=u.default.decode(t.subarray(u.default.decode.bytes)),n=r+u.default.decode.bytes+i,s=await e.exactly(n);return e.seek(n),s}(e),o=l.decode(s);return n.CID.create(r,i,o)}async function m(e){const t=e.pos;let r=await p(e);if(0===r)throw new Error("Invalid CAR section (zero length)");r+=e.pos-t;return{cid:await y(e),length:r,blockLength:r-(e.pos-t)}}async function b(e){const{cid:t,blockLength:r}=await m(e),i=await e.exactly(r);return e.seek(r),{bytes:i,cid:t}}async function v(e){const t=e.pos,{cid:r,length:i,blockLength:n}=await m(e),s={cid:r,length:i,blockLength:n,offset:t,blockOffset:e.pos};return e.seek(s.blockLength),s}function w(e){let t=0,r=0,i=0,n=new Uint8Array(0);const s=async t=>{r=n.length-i;const s=[n.subarray(i)];for(;rr&&s.push(t.subarray(-r)):s.push(t),r+=t.length}n=new Uint8Array(s.reduce(((e,t)=>e+t.length),0));let o=0;for(const e of s)n.set(e,o),o+=e.length;i=0};return{upTo:async e=>(n.length-ie.subarray(t,t+Math.min(r,e.length-t)),async exactly(r){if(r>e.length-t)throw new Error("Unexpected end of data");return e.subarray(t,t+r)},seek(e){t+=e},get pos(){return t}}},r.chunkReader=w,r.createDecoder=function(e){const t=g(e);return{header:()=>t,async*blocks(){for(await t;(await e.upTo(8)).length>0;)yield await b(e)},async*blocksIndex(){for(await t;(await e.upTo(8)).length>0;)yield await v(e)}}},r.readHeader=g},{varint:"aN1CO","multiformats/cid":"9ooAY","multiformats/hashes/digest":"kpRBg","@ipld/dag-cbor":"3498i"}],evp3q:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option"),n=e("it-first"),s=e("it-last"),o=e("../../utils.js"),a=e("err-code");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(n),l=c(s),d=c(a);r.createGet=function({codecs:e,repo:t,preload:r}){return i.withTimeoutOption((async function(i,n={}){if(!1!==n.preload&&r(i),n.path){const r=n.localResolve?await u.default(o.resolve(i,n.path,e,t,n)):await l.default(o.resolve(i,n.path,e,t,n));if(!r)throw d.default(new Error("Not found"),"ERR_NOT_FOUND");return r}const s=await e.getCodec(i.code),a=await t.blocks.get(i,n);return{value:s.decode(a),remainderPath:""}}))}},{"ipfs-core-utils/with-timeout-option":"j29MK","it-first":"hBrkP","it-last":"cSXX9","../../utils.js":"cT4uN","err-code":"chZjB"}],hBrkP:[function(e,t,r){"use strict";t.exports=async e=>{for await(const t of e)return t}},{}],"1a905":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("@ipld/car/iterator"),n=e("ipfs-core-utils/with-timeout-option"),s=e("it-peekable"),o=e("it-drain"),a=e("it-map"),c=e("debug");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=u(s),d=u(o),f=u(a);const h=u(c).default("ipfs:components:dag:import");async function p(e,t,r){const n=await i.CarBlockIterator.fromIterable(r),s=await n.getRoots();return await d.default(e.blocks.putMany(f.default(n,(({cid:e,bytes:t})=>(h(`Import block ${e}`),{key:e,value:t}))),{signal:t.signal})),s}r.createImport=function({repo:e}){return n.withTimeoutOption((async function*(t,r={}){const i=await e.gcLock.readLock();try{const n={signal:r.signal,timeout:r.timeout},s=l.default(t),{value:o,done:a}=await s.peek();if(a)return;let c;o&&s.push(o),c=o instanceof Uint8Array?[s]:s;for await(const t of c){const i=await p(e,n,t);if(!1!==r.pinRoots)for(const t of i){let r="";try{await e.blocks.has(t)?(h(`Pinning root ${t}`),await e.pins.pinRecursively(t)):r="blockstore: block not found"}catch(e){r=e.message}yield{root:{cid:t,pinErrorMsg:r}}}}}finally{i()}}))}},{"@ipld/car/iterator":"e6CDb","ipfs-core-utils/with-timeout-option":"j29MK","it-peekable":"bi9X1","it-drain":"dKYhO","it-map":"eeqPk",debug:"bO5wM"}],e6CDb:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./decoder.js");class n{constructor(e,t,r){this._version=e,this._roots=t,this._iterable=r,this._decoded=!1}get version(){return this._version}async getRoots(){return this._roots}}class s extends n{[Symbol.asyncIterator](){if(this._decoded)throw new Error("Cannot decode more than once");if(!this._iterable)throw new Error("Block iterable not found");return this._decoded=!0,this._iterable[Symbol.asyncIterator]()}static async fromBytes(e){const{version:t,roots:r,iterator:i}=await a(e);return new s(t,r,i)}static async fromIterable(e){const{version:t,roots:r,iterator:i}=await c(e);return new s(t,r,i)}}class o extends n{[Symbol.asyncIterator](){if(this._decoded)throw new Error("Cannot decode more than once");if(!this._iterable)throw new Error("Block iterable not found");this._decoded=!0;const e=this._iterable[Symbol.asyncIterator]();return{async next(){const t=await e.next();return t.done?t:{done:!1,value:t.value.cid}}}}static async fromBytes(e){const{version:t,roots:r,iterator:i}=await a(e);return new o(t,r,i)}static async fromIterable(e){const{version:t,roots:r,iterator:i}=await c(e);return new o(t,r,i)}}async function a(e){if(!(e instanceof Uint8Array))throw new TypeError("fromBytes() requires a Uint8Array");return u(i.bytesReader(e))}async function c(e){if(!e||"function"!=typeof e[Symbol.asyncIterator])throw new TypeError("fromIterable() requires an async iterable");return u(i.asyncIterableReader(e))}async function u(e){const t=i.createDecoder(e),{version:r,roots:n}=await t.header();return{version:r,roots:n,iterator:t.blocks()}}r.CarBlockIterator=s,r.CarCIDIterator=o,r.CarIteratorBase=n},{"./decoder.js":"hA2ak"}],d8SU0:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("ipfs-core-utils/with-timeout-option");r.createPut=function({repo:e,codecs:t,hashers:r,preload:s}){return n.withTimeoutOption((async function(n,o={}){const a=o.pin?await e.gcLock.readLock():null;try{const c=o.format||"dag-cbor",u=null!=o.version?o.version:"dag-pb"===c?0:1,l=await t.getCodec(c);if(!l)throw new Error(`Unknown codec ${o.format}, please configure additional BlockCodecs for this IPFS instance`);const d=await r.getHasher(o.hashAlg||"sha2-256");if(!d)throw new Error(`Unknown hash algorithm ${o.hashAlg}, please configure additional MultihashHashers for this IPFS instance`);const f=l.encode(n),h=await d.digest(f),p=i.CID.create(u,l.code,h);return await e.blocks.put(p,f,{signal:o.signal}),o.pin&&await e.pins.pinRecursively(p),!1!==o.preload&&s(p),p}finally{a&&a()}}))}},{"multiformats/cid":"9ooAY","ipfs-core-utils/with-timeout-option":"j29MK"}],gIL7b:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option"),n=e("ipfs-core-utils/to-cid-and-path"),s=e("../../utils.js");r.createResolve=function({repo:e,codecs:t,preload:r}){return i.withTimeoutOption((async function(i,o={}){const{cid:a}=n.toCidAndPath(i);return!1!==o.preload&&r(a),s.resolvePath(e,t,i,o)}))}},{"ipfs-core-utils/with-timeout-option":"j29MK","ipfs-core-utils/to-cid-and-path":"jN5CZ","../../utils.js":"cT4uN"}],kBOEV:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiaddr-to-uri"),n=e("debug"),s=e("array-shuffle"),o=e("native-abort-controller"),a=e("ipfs-core-config/preload"),c=e("hashlru");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=u(i),d=u(n),f=u(s),h=u(c);const p=Object.assign(d.default("ipfs:preload"),{error:d.default("ipfs:preload:error")});r.createPreloader=function(e={}){if(e.enabled=Boolean(e.enabled),e.addresses=e.addresses||[],e.cache=e.cache||1e3,!e.enabled||!e.addresses.length){p("preload disabled");const e=()=>{};return Object.assign(e,{start:()=>{},stop:()=>{}})}let t=!0,r=[];const i=e.addresses.map(l.default),n=h.default(e.cache),s=async e=>{try{if(t)throw new Error(`preload ${e} but preloader is not started`);const s=e.toString();if(n.has(s))return;n.set(s,!0);const c=f.default(i);let u=!1;const l=Date.now();for(const e of c){if(t)throw new Error(`preload aborted for ${s}`);let i;try{i=new o.AbortController,r=r.concat(i),await a.preload(`${e}/api/v0/refs?r=true&arg=${encodeURIComponent(s)}`,{signal:i.signal}),u=!0}catch(e){"aborted"!==e.type&&p.error(e)}finally{r=r.filter((e=>e!==i))}if(u)break}p(`${u?"":"un"}successfully preloaded ${s} in ${Date.now()-l}ms`)}catch(e){p.error(e)}};return s.start=()=>{t=!1},s.stop=()=>{t=!0,p(`aborting ${r.length} pending preload request(s)`),r.forEach((e=>e.abort())),r=[]},s}},{"multiaddr-to-uri":"4PPH7",debug:"bO5wM","array-shuffle":"kUouG","native-abort-controller":"6zwoZ","ipfs-core-config/preload":"lk3b0",hashlru:"kBj5c"}],"4PPH7":[function(e,t,r){const{Multiaddr:i}=e("multiaddr"),n=(e,t)=>t,s={ip4:n,ip6:(e,t,r,i)=>1===i.length&&"ip6"===i[0].protocol?t:`[${t}]`,tcp:(e,t,r,i,n)=>i.some((e=>["http","https","ws","wss"].includes(e.protocol)))?`${e}:${t}`:((e,t,r,i)=>{if(i&&!1===i.assumeHttp)return`tcp://${e}:${t}`;let n="tcp",s=`:${t}`;return"tcp"===r[r.length-1].protocol&&(n="443"===t?"https":"http",s="443"===t||"80"===t?"":s),`${n}://${e}${s}`})(e,t,i,n),udp:(e,t)=>`udp://${e}:${t}`,dnsaddr:n,dns4:n,dns6:n,ipfs:(e,t)=>`${e}/ipfs/${t}`,p2p:(e,t)=>`${e}/p2p/${t}`,http:e=>`http://${e}`,https:e=>`https://${e}`,ws:e=>`ws://${e}`,wss:e=>`wss://${e}`,"p2p-websocket-star":e=>`${e}/p2p-websocket-star`,"p2p-webrtc-star":e=>`${e}/p2p-webrtc-star`,"p2p-webrtc-direct":e=>`${e}/p2p-webrtc-direct`};t.exports=(e,t)=>{const r=new i(e),n=e.toString().split("/").slice(1);return r.tuples().map((e=>({protocol:n.shift(),content:e[1]?n.shift():null}))).reduce(((e,r,i,n)=>{const o=s[r.protocol];if(!o)throw new Error(`Unsupported protocol ${r.protocol}`);return o(e,r.content,i,n,t)}),"")}},{multiaddr:"8Mu1u"}],kUouG:[function(e,t,r){"use strict";t.exports=e=>{if(!Array.isArray(e))throw new TypeError("Expected an array, got "+typeof e);for(let t=(e=[...e]).length-1;t>0;t--){const r=Math.floor(Math.random()*(t+1));[e[t],e[r]]=[e[r],e[t]]}return e}},{}],lk3b0:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-utils/src/http.js"),n=e("debug"),s=e("p-queue");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(i),c=o(n),u=o(s);const l=Object.assign(c.default("ipfs:preload"),{error:c.default("ipfs:preload:error")}),d=new(u.default.default?u.default.default:u.default)({concurrency:4});r.preload=function(e,t={}){return l(e),d.add((async()=>{const r=(await a.default.post(e,{signal:t.signal})).body.getReader();try{for(;;){const{done:e}=await r.read();if(e)return}}finally{r.releaseLock()}}))}},{"ipfs-utils/src/http.js":"ifXXn",debug:"bO5wM","p-queue":"biPlv"}],"7arhH":[function(e,t,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(r,"__esModule",{value:!0});var n=i(e("debug"));const s=Object.assign(n.default("ipfs:mfs-preload"),{error:n.default("ipfs:mfs-preload:error")});r.createMfsPreloader=function({preload:e,files:t,options:r={}}){if(r.interval=r.interval||3e4,!r.enabled){s("MFS preload disabled");const e=async()=>{};return{start:e,stop:e}}let i,n="";const o=async()=>{try{const a=await t.stat("/"),c=a.cid.toString();n!==c&&(s(`preloading updated MFS root ${n} -> ${a.cid}`),await e(a.cid),n=c)}catch(e){s.error("failed to preload MFS root",e)}finally{i=setTimeout(o,r.interval)}};return{async start(){const e=await t.stat("/");n=e.cid.toString(),s(`monitoring MFS root ${e.cid}`),i=setTimeout(o,r.interval)},stop(){clearTimeout(i)}}}},{debug:"bO5wM"}],"1yxa2":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./utils/create-lock.js"),n=e("is-ipfs"),s=e("./stat.js"),o=e("./chmod.js"),a=e("./cp.js"),c=e("./flush.js"),u=e("./mkdir.js"),l=e("./mv.js"),d=e("./rm.js"),f=e("./touch.js"),h=e("./read.js"),p=e("./write.js"),g=e("./ls.js");function y(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var m=y(n);const b={stat:s.createStat},v={chmod:o.createChmod,cp:a.createCp,flush:c.createFlush,mkdir:u.createMkdir,mv:l.createMv,rm:d.createRm,touch:f.createTouch},w={write:p.createWrite,read:h.createRead,ls:g.createLs},_=({options:e,mfs:t,operations:r,lock:i})=>{Object.keys(r).forEach((n=>{t[n]=i(r[n](e))}))},E={repoOwner:!0,repo:null};r.createFiles=function({repo:e,preload:t,hashers:r,options:n}){const s=function(e){const{repoOwner:t}=Object.assign({},E||{},e),r=i.createLock(t),n={};return _({options:e,mfs:n,operations:b,lock:e=>r.readLock(e)}),_({options:e,mfs:n,operations:v,lock:e=>r.writeLock(e)}),Object.keys(w).forEach((t=>{n[t]=w[t](e)})),n}({repo:e,repoOwner:Boolean(n.repoOwner),hashers:r}),o=e=>(...r)=>{const i=r.filter((e=>m.default.ipfsPath(e)||m.default.cid(e)));if(i.length){const e=r[r.length-1];e&&!1!==e.preload&&i.forEach((e=>t(e)))}return e(...r)};return{...s,chmod:s.chmod,cp:o(s.cp),mkdir:s.mkdir,stat:o(s.stat),rm:s.rm,read:o(s.read),touch:s.touch,write:s.write,mv:o(s.mv),flush:s.flush,ls:o((async function*(...e){for await(const t of s.ls(...e))yield{...t,size:t.size||0}}))}}},{"./utils/create-lock.js":"kHT2F","is-ipfs":"40iuV","./stat.js":"lCUdo","./chmod.js":"4Rlct","./cp.js":"eJoZU","./flush.js":"dFNhT","./mkdir.js":"h1mMu","./mv.js":"347nd","./rm.js":"hU9a1","./touch.js":"d4deE","./read.js":"3Dh6r","./write.js":"fQgQQ","./ls.js":"2uADA"}],kHT2F:[function(e,t,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(r,"__esModule",{value:!0});var n=i(e("mortice"));let s;r.createLock=function(e=!1){if(s)return s;const t=n.default({singleProcess:e});return s={readLock:e=>async(...r)=>{const i=await t.readLock();try{return await e.apply(null,r)}finally{i()}},writeLock:e=>async(...r)=>{const i=await t.writeLock();try{return await e.apply(null,r)}finally{i()}}},s}},{mortice:"b5y0B"}],b5y0B:[function(e,t,r){var i=arguments[3];const n=e("./node"),s=e("./browser"),{default:o}=e("p-queue"),{timeout:a}=e("promise-timeout"),c=e("observable-webworkers"),u={};let l;function d(e,t){let r;const i=new Promise((e=>{r=e}));return e.add((()=>a(new Promise((e=>{r((()=>{e()}))})),t.timeout))),i}const f=(e,t)=>{if(l.isWorker)return{readLock:l.readLock(e,t),writeLock:l.writeLock(e,t)};const r=new o({concurrency:1});let i=null;return{readLock:()=>{if(i)return d(i,t);i=new o({concurrency:t.concurrency,autoStart:!1});const e=i,n=d(i,t);return r.add((()=>(e.start(),e.onIdle().then((()=>{i===e&&(i=null)}))))),n},writeLock:()=>(i=null,d(r,t))}},h={concurrency:1/0,timeout:846e5,global:i,singleProcess:!1};t.exports=(e,t)=>(t||(t={}),"object"==typeof e&&(t=e,e="lock"),e||(e="lock"),t=Object.assign({},h,t),l||(l=n(t)||s(t),l.isWorker||(l.on("requestReadLock",((e,t)=>{u[e]&&u[e].readLock().then((e=>t().finally((()=>e()))))})),l.on("requestWriteLock",(async(e,t)=>{u[e]&&u[e].writeLock().then((e=>t().finally((()=>e()))))})))),u[e]||(u[e]=f(e,t)),u[e]),t.exports.Worker=function(e,t){let r;t=t||i.Worker;try{r=new t(e)}catch(i){i.message.includes("not a constructor")&&(r=t(e))}if(!r)throw new Error("Could not create Worker from",t);return c(r),r}},{"./node":"i9PST","./browser":"jBdTr","p-queue":"biPlv","promise-timeout":"hQpJ2","observable-webworkers":"9ZFPi"}],i9PST:[function(e,t,r){var i=e("process");const n=e("events").EventEmitter,{nanoid:s}=e("nanoid"),{WORKER_REQUEST_READ_LOCK:o,WORKER_RELEASE_READ_LOCK:a,MASTER_GRANT_READ_LOCK:c,WORKER_REQUEST_WRITE_LOCK:u,WORKER_RELEASE_WRITE_LOCK:l,MASTER_GRANT_WRITE_LOCK:d}=e("./constants");let f;const h=(e,t,r,i,n)=>(s,o)=>{o&&o.type===r&&e.emit(t,o.name,(()=>(s.send({type:n,name:o.name,identifier:o.identifier}),new Promise((e=>{const t=r=>{r&&r.type===i&&r.identifier===o.identifier&&(s.removeListener("message",t),e())};s.on("message",t)})))))},p=(e,t,r,n)=>()=>{const o=s();return i.send({type:t,identifier:o,name:e}),new Promise((t=>{const s=a=>{a&&a.type===r&&a.identifier===o&&(i.removeListener("message",s),t((()=>{i.send({type:n,identifier:o,name:e})})))};i.on("message",s)}))};t.exports=t=>{try{if(f=e("cluster"),!Object.keys(f).length)return}catch(e){return}if(f.isMaster||t.singleProcess){const e=new n;return f.on("message",h(e,"requestReadLock",o,a,c)),f.on("message",h(e,"requestWriteLock",u,l,d)),e}return{isWorker:!0,readLock:e=>p(e,o,c,a),writeLock:e=>p(e,u,d,l)}}},{process:"bjUAi",events:"g82pp",nanoid:"dmVhu","./constants":"i3YBW",cluster:"lHksA"}],i3YBW:[function(e,t,r){t.exports={WORKER_REQUEST_READ_LOCK:"lock:worker:request-read",WORKER_RELEASE_READ_LOCK:"lock:worker:release-read",MASTER_GRANT_READ_LOCK:"lock:master:grant-read",WORKER_REQUEST_WRITE_LOCK:"lock:worker:request-write",WORKER_RELEASE_WRITE_LOCK:"lock:worker:release-write",MASTER_GRANT_WRITE_LOCK:"lock:master:grant-write"}},{}],jBdTr:[function(e,t,r){const i=e("events").EventEmitter,{nanoid:n}=e("nanoid"),{WORKER_REQUEST_READ_LOCK:s,WORKER_RELEASE_READ_LOCK:o,MASTER_GRANT_READ_LOCK:a,WORKER_REQUEST_WRITE_LOCK:c,WORKER_RELEASE_WRITE_LOCK:u,MASTER_GRANT_WRITE_LOCK:l}=e("./constants"),d=e("observable-webworkers"),f=(e,t,r,i,n)=>(s,o)=>{if(!o||!o.data||o.data.type!==r)return;const a={type:o.data.type,name:o.data.name,identifier:o.data.identifier};e.emit(t,a.name,(()=>(s.postMessage({type:n,name:a.name,identifier:a.identifier}),new Promise((e=>{const t=r=>{if(!r||!r.data)return;const n={type:r.data.type,name:r.data.name,identifier:r.data.identifier};n&&n.type===i&&n.identifier===a.identifier&&(s.removeEventListener("message",t),e())};s.addEventListener("message",t)})))))},h=(e,t,r,i)=>()=>{const s=n();return globalThis.postMessage({type:t,identifier:s,name:e}),new Promise((t=>{const n=o=>{if(!o||!o.data)return;const a={type:o.data.type,identifier:o.data.identifier};a&&a.type===r&&a.identifier===s&&(globalThis.removeEventListener("message",n),t((()=>{globalThis.postMessage({type:i,identifier:s,name:e})})))};globalThis.addEventListener("message",n)}))},p={singleProcess:!1};t.exports=e=>{e=Object.assign({},p,e);if(!!globalThis.document||e.singleProcess){const e=new i;return d.addEventListener("message",f(e,"requestReadLock",s,o,a)),d.addEventListener("message",f(e,"requestWriteLock",c,u,l)),e}return{isWorker:!0,readLock:e=>h(e,s,a,o),writeLock:e=>h(e,c,l,u)}}},{events:"g82pp",nanoid:"dmVhu","./constants":"i3YBW","observable-webworkers":"9ZFPi"}],"9ZFPi":[function(e,t,r){const i={},n=e=>{e.addEventListener("message",(t=>{n.dispatchEvent("message",e,t)})),e.port&&e.port.addEventListener("message",(t=>{n.dispatchEvent("message",e,t)}))};n.addEventListener=(e,t)=>{i[e]||(i[e]=[]),i[e].push(t)},n.removeEventListener=(e,t)=>{i[e]&&(i[e]=i[e].filter((e=>e===t)))},n.dispatchEvent=function(){const e=Array.prototype.slice.call(arguments),t=e.shift();i[t]&&i[t].forEach((t=>t.apply(null,e)))},t.exports=n},{}],hQpJ2:[function(e,t,r){"use strict";var i;t.exports.timeout=function(e,t){var r,n=new i;return Promise.race([e,new Promise((function(e,i){r=setTimeout((function(){i(n)}),t)}))]).then((function(e){return clearTimeout(r),e}),(function(e){throw clearTimeout(r),e}))};(i=t.exports.TimeoutError=function(){Error.call(this),this.stack=Error().stack,this.message="Timeout"}).prototype=Object.create(Error.prototype),i.prototype.name="TimeoutError"},{}],lCUdo:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("merge-options"),n=e("./utils/to-mfs-path.js"),s=e("ipfs-unixfs-exporter"),o=e("debug"),a=e("err-code"),c=e("ipfs-core-utils/with-timeout-option"),u=e("@ipld/dag-pb");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function d(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var f=l(i),h=l(o),p=l(a),g=d(u);const y=f.default.bind({ignoreUndefined:!0}),m=h.default("ipfs:mfs:stat"),b={withLocal:!1};const v={raw:e=>({cid:e.cid,size:e.node.length,cumulativeSize:e.node.length,blocks:0,type:"file",local:void 0,sizeLocal:void 0,withLocality:!1}),file:e=>{const t={cid:e.cid,type:"file",size:e.unixfs.fileSize(),cumulativeSize:g.encode(e.node).length+(e.node.Links||[]).reduce(((e,t)=>e+(t.Tsize||0)),0),blocks:e.unixfs.blockSizes.length,local:void 0,sizeLocal:void 0,withLocality:!1,mode:e.unixfs.mode};return e.unixfs.mtime&&(t.mtime=e.unixfs.mtime),t},directory:e=>{const t={cid:e.cid,type:"directory",size:0,cumulativeSize:g.encode(e.node).length+(e.node.Links||[]).reduce(((e,t)=>e+(t.Tsize||0)),0),blocks:e.node.Links.length,local:void 0,sizeLocal:void 0,withLocality:!1,mode:e.unixfs.mode};return e.unixfs.mtime&&(t.mtime=e.unixfs.mtime),t},object:e=>({cid:e.cid,size:e.node.length,cumulativeSize:e.node.length,type:"file",blocks:0,local:void 0,sizeLocal:void 0,withLocality:!1}),identity:e=>({cid:e.cid,size:e.node.length,cumulativeSize:e.node.length,blocks:0,type:"file",local:void 0,sizeLocal:void 0,withLocality:!1})};r.createStat=function(e){return c.withTimeoutOption((async function(t,r={}){r=y(b,r),m(`Fetching stats for ${t}`);const{type:i,cid:o,mfsPath:a}=await n.toMfsPath(e,t,r),c="ipfs"===i&&o?o:a;let u;try{u=await s.exporter(c,e.repo.blocks)}catch(e){if("ERR_NOT_FOUND"===e.code)throw p.default(new Error(`${t} does not exist`),"ERR_NOT_FOUND");throw e}if(!v[u.type])throw new Error(`Cannot stat codec ${u.cid.code}`);return v[u.type](u)}))}},{"merge-options":"fupyv","./utils/to-mfs-path.js":"gAtPl","ipfs-unixfs-exporter":"BgMiX",debug:"bO5wM","err-code":"chZjB","ipfs-core-utils/with-timeout-option":"j29MK","@ipld/dag-pb":"i2cdx"}],gAtPl:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./with-mfs-root.js"),n=e("./to-path-components.js"),s=e("ipfs-unixfs-exporter"),o=e("err-code"),a=e("multiformats/cid");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(o);const l="ipfs";r.toMfsPath=async(e,t,r)=>{const o=await i.loadMfsRoot(e,r);let c={entryType:"file"},d="";if(d=a.CID.asCID(t)?`/ipfs/${t}`:t.toString(),d=d.trim(),d=d.replace(/(\/\/+)/g,"/"),d.endsWith("/")&&d.length>1&&(d=d.substring(0,d.length-1)),!d)throw u.default(new Error("paths must not be empty"),"ERR_NO_PATH");if("/"!==d.substring(0,1))throw u.default(new Error("paths must start with a leading slash"),"ERR_INVALID_PATH");"/"===d.substring(d.length-1)&&(d=d.substring(0,d.length-1));const f=n.toPathComponents(d);if(f[0]===l){let e;e=2===f.length?`/${f.join("/")}`:`/${f.slice(0,f.length-1).join("/")}`,c={type:"ipfs",depth:f.length-2,entryType:"file",mfsPath:`/${f.join("/")}`,mfsDirectory:e,parts:f,path:`/${f.join("/")}`,name:f[f.length-1]}}else{const e=`/ipfs/${o}${f.length?"/"+f.join("/"):""}`,t=`/ipfs/${o}/${f.slice(0,f.length-1).join("/")}`;c={type:"mfs",depth:f.length,entryType:"file",mfsDirectory:t,mfsPath:e,parts:f,path:`/${f.join("/")}`,name:f[f.length-1]}}const h="mfs"===c.type?c.mfsPath:c.path;try{const t=await s.exporter(h,e.repo.blocks,r);c.cid=t.cid,c.mfsPath=`/ipfs/${t.path}`,c.entryType=t.type,c.content=t.content,"file"!==c.entryType&&"directory"!==c.entryType||"file"!==t.type&&"directory"!==t.type||(c.unixfs=t.unixfs)}catch(e){if("ERR_NOT_FOUND"!==e.code)throw e}return c.exists=Boolean(c.cid),c}},{"./with-mfs-root.js":"ho9kf","./to-path-components.js":"j9m7w","ipfs-unixfs-exporter":"BgMiX","err-code":"chZjB","multiformats/cid":"9ooAY"}],ho9kf:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("ipfs-unixfs"),s=e("@ipld/dag-pb"),o=e("multiformats/hashes/sha2"),a=e("debug"),c=e("err-code"),u=e("../../../utils.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function d(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var f=d(s),h=l(a),p=l(c);const g=h.default("ipfs:mfs:utils:with-mfs-root");r.loadMfsRoot=async function(e,t){if(t&&t.signal&&t.signal.aborted)throw p.default(new Error("Request aborted"),"ERR_ABORTED",{name:"Aborted"});let r;await e.repo.datastore.open();try{const t=await e.repo.datastore.get(u.MFS_ROOT_KEY);r=i.CID.decode(t)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s;g("Creating new MFS root");const a=f.encode({Data:new n.UnixFS({type:"directory"}).marshal(),Links:[]}),c=await o.sha256.digest(a);if(r=i.CID.createV0(c),await e.repo.blocks.put(r,a),t&&t.signal&&t.signal.aborted)throw p.default(new Error("Request aborted"),"ERR_ABORTED",{name:"Aborted"});await e.repo.datastore.put(u.MFS_ROOT_KEY,r.bytes)}return g(`Loaded MFS root /ipfs/${r}`),r}},{"multiformats/cid":"9ooAY","ipfs-unixfs":"dF9VO","@ipld/dag-pb":"i2cdx","multiformats/hashes/sha2":"7i9MT",debug:"bO5wM","err-code":"chZjB","../../../utils.js":"cT4uN"}],j9m7w:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.toPathComponents=function(e=""){return(e.trim().match(/([^\\^/]|\\\/)+/g)||[]).filter(Boolean)}},{}],"4Rlct":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("merge-options"),n=e("./utils/to-mfs-path.js"),s=e("debug"),o=e("err-code"),a=e("ipfs-unixfs"),c=e("./utils/to-trail.js"),u=e("./utils/add-link.js"),l=e("./utils/update-tree.js"),d=e("./utils/update-mfs-root.js"),f=e("@ipld/dag-pb"),h=e("multiformats/cid"),p=e("it-pipe"),g=e("ipfs-unixfs-importer"),y=e("ipfs-unixfs-exporter"),m=e("it-last"),b=e("./cp.js"),v=e("./rm.js"),w=e("./utils/persist.js"),_=e("ipfs-core-utils/with-timeout-option");function E(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function S(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var T=E(i),A=E(s),k=E(o),I=S(f),R=E(m);const P=T.default.bind({ignoreUndefined:!0}),O=A.default("ipfs:mfs:touch"),C={flush:!0,shardSplitThreshold:1e3,hashAlg:"sha2-256",cidVersion:0,recursive:!1};function j(e,t,r){t||(t=0);const i=e.match(/^(u?g?o?a?)(-?\+?=?)?(r?w?x?X?s?t?)$/);if(!i)throw new Error(`Invalid file mode: ${e}`);let[,n,s,o]=i;"a"!==n&&n||(n="ugo");let a=function(e,t,r){let i=0;return(e.includes("x")||e.includes("X")&&(r||1&t||8&t||64&t))&&(i+=1),e.includes("w")&&(i+=2),e.includes("r")&&(i+=4),i}(o,t,r);return a=function(e,t){let r=0;return e.includes("u")&&(r+=t<<6),e.includes("g")&&(r+=t<<3),e.includes("o")&&(r+=t),r}(n,a),a=function(e,t,r){return t.includes("t")&&(r+=parseInt("1000",8)),t.includes("s")&&(e.includes("u")&&(r+=parseInt("4000",8)),e.includes("g")&&(r+=parseInt("2000",8))),r}(n,o,a),"="===s?(n.includes("u")&&(t&=parseInt("7077",8),t|=a),n.includes("g")&&(t&=parseInt("7707",8),t|=a),n.includes("o")&&(t&=parseInt("7770",8),t|=a),t):"+"===s?a|t:"-"===s?a^t:t}function D(e,t){if(e instanceof String||"string"==typeof e){const r=`${e}`;e=r.match(/^\d+$/g)?parseInt(r,8):0+r.split(",").reduce(((e,r)=>j(r,e,t.isDirectory())),t.mode||0)}return e}r.createChmod=function(e){return _.withTimeoutOption((async function(t,r,i={}){const s=P(C,i);O(`Fetching stats for ${t}`);const{cid:o,mfsDirectory:f,name:m}=await n.toMfsPath(e,t,s);if(o.code!==I.code)throw k.default(new Error(`${t} was not a UnixFS node`),"ERR_NOT_UNIXFS");if(s.recursive){const i=await p.pipe((async function*(){for await(const i of y.recursive(o,e.repo.blocks)){if("file"!==i.type&&"directory"!==i.type)throw k.default(new Error(`${t} was not a UnixFS node`),"ERR_NOT_UNIXFS");i.unixfs.mode=D(r,i.unixfs);const e=I.prepare({Data:i.unixfs.marshal(),Links:i.node.Links});yield{path:i.path,content:e}}}),(t=>g.importer(t,e.repo.blocks,{...s,pin:!1,dagBuilder:async function*(e,t,r){for await(const i of e)yield async function(){const e=i.content,n=I.encode(e),s=await w.persist(n,t,r);if(!e.Data)throw k.default(new Error(`${s} had no data`),"ERR_INVALID_NODE");const o=a.UnixFS.unmarshal(e.Data);return{cid:s,size:n.length,path:i.path,unixfs:o}}}})),(e=>R.default(e)));if(!i)throw k.default(new Error(`Could not chmod ${t}`),"ERR_COULD_NOT_CHMOD");return await v.createRm(e)(t,s),void await b.createCp(e)(`/ipfs/${i.cid}`,t,s)}const _=await e.repo.blocks.get(o),E=I.decode(_);if(!E.Data)throw k.default(new Error(`${o} had no data`),"ERR_INVALID_NODE");const S=a.UnixFS.unmarshal(E.Data);S.mode=D(r,S);const T=I.encode({Data:S.marshal(),Links:E.Links}),A=s.hashAlg||C.hashAlg,j=await e.hashers.getHasher(A),M=await j.digest(T),x=h.CID.create(s.cidVersion,I.code,M);s.flush&&await e.repo.blocks.put(x,T);const B=await c.toTrail(e,f),L=B[B.length-1],N=h.CID.decode(L.cid.bytes),U=await e.repo.blocks.get(N),F=I.decode(U),K=await u.addLink(e,{parent:F,name:m,cid:x,size:T.length,flush:s.flush,hashAlg:A,cidVersion:o.version,shardSplitThreshold:1/0});L.cid=K.cid;const z=await l.updateTree(e,B,s);await d.updateMfsRoot(e,z,s)}))}},{"merge-options":"fupyv","./utils/to-mfs-path.js":"gAtPl",debug:"bO5wM","err-code":"chZjB","ipfs-unixfs":"dF9VO","./utils/to-trail.js":"crUUQ","./utils/add-link.js":"dv4f9","./utils/update-tree.js":"dvDDB","./utils/update-mfs-root.js":"lpX0i","@ipld/dag-pb":"i2cdx","multiformats/cid":"9ooAY","it-pipe":"giKBQ","ipfs-unixfs-importer":"i61x3","ipfs-unixfs-exporter":"BgMiX","it-last":"cSXX9","./cp.js":"eJoZU","./rm.js":"hU9a1","./utils/persist.js":"hc7Uz","ipfs-core-utils/with-timeout-option":"j29MK"}],crUUQ:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-unixfs-exporter");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const s=n(e("debug")).default("ipfs:mfs:utils:to-trail");r.toTrail=async function(e,t){s(`Creating trail for path ${t}`);const r=[];for await(const n of i.walkPath(t,e.repo.blocks))r.push({name:n.name,cid:n.cid,size:n.size,type:n.type});return r}},{"ipfs-unixfs-exporter":"BgMiX",debug:"bO5wM"}],dv4f9:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("@ipld/dag-pb"),n=e("multiformats/cid"),s=e("debug"),o=e("ipfs-unixfs"),a=e("./dir-sharded.js"),c=e("./hamt-utils.js"),u=e("err-code"),l=e("it-last");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function f(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var h=f(i),p=d(s),g=d(u),y=d(l);const m=p.default("ipfs:mfs:core:utils:add-link");const b=async(e,t)=>{const r=await c.createShard(e,t.parent.Links.map((e=>({name:e.Name||"",size:e.Tsize||0,cid:e.Hash}))).concat({name:t.name,size:t.size,cid:t.cid}),t);return m(`Converted directory to sharded directory ${r.cid}`),r},v=async(e,t)=>{const r=t.parent.Links.filter((e=>e.Name!==t.name));if(r.push({Name:t.name,Tsize:t.size,Hash:t.cid}),!t.parent.Data)throw g.default(new Error("Parent node with no data passed to addToDirectory"),"ERR_INVALID_PARENT");const i=o.UnixFS.unmarshal(t.parent.Data);let s;if(i.mtime){const e=Date.now(),t=Math.floor(e/1e3);i.mtime={secs:t,nsecs:1e3*(e-1e3*t)},s=i.marshal()}else s=t.parent.Data;t.parent=h.prepare({Data:s,Links:r});const a=await e.hashers.getHasher(t.hashAlg),c=h.encode(t.parent),u=await a.digest(c),l=n.CID.create(t.cidVersion,h.code,u);return t.flush&&await e.repo.blocks.put(l,c),{node:t.parent,cid:l,size:c.length}},w=async(e,t)=>{const{shard:r,path:i}=await _(e,t),n=await y.default(r.flush(e.repo.blocks));if(!n)throw new Error("No result from flushing shard");const s=await e.repo.blocks.get(n.cid),o=h.decode(s),a=t.parent.Links.filter((e=>(e.Name||"").substring(0,2)!==i[0].prefix)),u=o.Links.find((e=>(e.Name||"").substring(0,2)===i[0].prefix));if(!u)throw new Error(`No link found with prefix ${i[0].prefix}`);return a.push(u),c.updateHamtDirectory(e,a,i[0].bucket,t)},_=async(e,t)=>{const r={name:t.name,cid:t.cid,size:t.size};if(!t.parent.Data)throw g.default(new Error("Parent node with no data passed to addFileToShardedDirectory"),"ERR_INVALID_PARENT");const i=await c.recreateInitialHamtLevel(t.parent.Links),n=o.UnixFS.unmarshal(t.parent.Data),s=new a.DirSharded({root:!0,dir:!0,parent:void 0,parentKey:void 0,path:"",dirty:!0,flat:!1,mode:n.mode},t);s._bucket=i,n.mtime&&(s.mtime={secs:Math.round(Date.now()/1e3)});const u=await i._findNewBucketAndPos(r.name),l=E(u);l[0].node=t.parent;let d=0;for(;d(e.Name||"").substring(0,2)===t.prefix));if(!s){m(`Link ${t.prefix}${r.name} will be added`),d=l.length;break}if(s.Name===`${t.prefix}${r.name}`){m(`Link ${t.prefix}${r.name} will be replaced`),d=l.length;break}if((s.Name||"").length>2){m(`Link ${s.Name} ${s.Hash} will be replaced with a subshard`),d=l.length;break}m(`Found subshard ${t.prefix}`);const o=await e.repo.blocks.get(s.Hash),a=h.decode(o);if(!l[d]){m(`Loaded new subshard ${t.prefix}`),await c.recreateHamtLevel(a.Links,i,t.bucket,parseInt(t.prefix,16));const e=await i._findNewBucketAndPos(r.name);l.push({bucket:e.bucket,prefix:c.toPrefix(e.pos),node:a});break}const u=l[d];await c.addLinksToHamtBucket(a.Links,u.bucket,i),u.node=a}return await s._bucket.put(r.name,{size:r.size,cid:r.cid}),{shard:s,path:l}},E=e=>{const t=[{bucket:e.bucket,prefix:c.toPrefix(e.pos)}];let r=e.bucket._parent,i=e.bucket._posAtParent;for(;r;)t.push({bucket:r,prefix:c.toPrefix(i)}),i=r._posAtParent,r=r._parent;return t.reverse(),t};r.addLink=async function(e,t){let r=t.parent;if(t.parentCid){const i=n.CID.asCID(t.parentCid);if(null===i)throw g.default(new Error("Invalid CID passed to addLink"),"EINVALIDPARENTCID");if(i.code!==h.code)throw g.default(new Error("Unsupported codec. Only DAG-PB is supported"),"EINVALIDPARENTCID");m(`Loading parent node ${i}`);const s=await e.repo.blocks.get(i);r=h.decode(s)}if(!r)throw g.default(new Error("No parent node or CID passed to addLink"),"EINVALIDPARENT");if(!t.cid)throw g.default(new Error("No child cid passed to addLink"),"EINVALIDCHILDCID");if(!t.name)throw g.default(new Error("No child name passed to addLink"),"EINVALIDCHILDNAME");if(!t.size&&0!==t.size)throw g.default(new Error("No child size passed to addLink"),"EINVALIDCHILDSIZE");if(!r.Data)throw g.default(new Error("Parent node with no data passed to addLink"),"ERR_INVALID_PARENT");const i=o.UnixFS.unmarshal(r.Data);return"hamt-sharded-directory"===i.type?(m("Adding link to sharded directory"),w(e,{...t,parent:r})):r.Links.length>=t.shardSplitThreshold?(m("Converting directory to sharded directory"),b(e,{...t,parent:r,mtime:i.mtime,mode:i.mode})):(m(`Adding ${t.name} (${t.cid}) to regular directory`),v(e,{...t,parent:r}))}},{"@ipld/dag-pb":"i2cdx","multiformats/cid":"9ooAY",debug:"bO5wM","ipfs-unixfs":"dF9VO","./dir-sharded.js":"ixBLc","./hamt-utils.js":"gemQO","err-code":"chZjB","it-last":"cSXX9"}],ixBLc:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("@ipld/dag-pb"),n=e("ipfs-unixfs"),s=e("./persist.js"),o=e("hamt-sharding"),a=e("./hamt-constants.js");class c{constructor(e,t){this.options=t||{},this.root=e.root,this.dir=e.dir,this.path=e.path,this.dirty=e.dirty,this.flat=e.flat,this.parent=e.parent,this.parentKey=e.parentKey,this.unixfs=e.unixfs,this.mode=e.mode,this.mtime=e.mtime,this.cid=void 0,this.size=void 0}async put(e,t){}get(e){return Promise.resolve(this)}async*eachChildSeries(){}async*flush(e){}}async function*u(e,t,r,c){const l=e._children,d=[];let f=0;for(let e=0;e{r.codec||(r.codec=a),r.hasher||(r.hasher=s.sha256),void 0===r.cidVersion&&(r.cidVersion=1),r.codec===a&&r.hasher!==s.sha256&&(r.cidVersion=1);const n=await r.hasher.digest(e),o=i.CID.create(r.cidVersion,r.codec.code,n);return r.onlyHash||await t.put(o,e,{signal:r.signal}),o}},{"multiformats/cid":"9ooAY","@ipld/dag-pb":"i2cdx","multiformats/hashes/sha2":"7i9MT"}],"2jyXQ":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("@multiformats/murmur3");const n=i.murmur3128.code;r.hamtBucketBits=8,r.hamtHashCode=n,r.hamtHashFn=async function(e){return(await i.murmur3128.encode(e)).slice(0,8).reverse()}},{"@multiformats/murmur3":"5DFrl"}],gemQO:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("@ipld/dag-pb"),n=e("hamt-sharding"),s=e("./dir-sharded.js"),o=e("debug"),a=e("ipfs-unixfs"),c=e("it-last"),u=e("multiformats/cid"),l=e("./hamt-constants.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function f(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var h=f(i),p=d(o),g=d(c);const y=p.default("ipfs:mfs:core:utils:hamt-utils"),m=async(e,t,r,i)=>{const s=new n.Bucket({hash:t._options.hash,bits:t._options.bits},r,i);return r._putObjectAt(i,s),await v(e,s,t),s},b=async e=>{const t=n.createHAMT({hashFn:l.hamtHashFn,bits:l.hamtBucketBits});return await v(e,t,t),t},v=async(e,t,r)=>{await Promise.all(e.map((e=>{const i=e.Name||"";if(2===i.length){const e=parseInt(i,16);return t._putObjectAt(e,new n.Bucket({hash:r._options.hash,bits:r._options.bits},t,e)),Promise.resolve()}return r.put(i.substring(2),{size:e.Tsize,cid:e.Hash})})))},w=e=>e.toString(16).toUpperCase().padStart(2,"0").substring(0,2);r.addLinksToHamtBucket=v,r.createShard=async(e,t,r={})=>{const i=new s.DirSharded({root:!0,dir:!0,parent:void 0,parentKey:void 0,path:"",dirty:!0,flat:!1,mtime:r.mtime,mode:r.mode},r);for(let e=0;e{const i=await b(r.Links),n=await i._findNewBucketAndPos(t),s=[{bucket:n.bucket,prefix:w(n.pos)}];let o=n.bucket;for(;o!==i;)s.push({bucket:o,prefix:w(o._posAtParent)}),o=o._parent;s.reverse(),s[0].node=r;for(let r=0;r(e.Name||"").substring(0,2)===n.prefix)).pop();if(!o){y(`Link ${n.prefix}${t} will be added`);continue}if(o.Name===`${n.prefix}${t}`){y(`Link ${n.prefix}${t} will be replaced`);continue}y(`Found subshard ${n.prefix}`);const a=await e.repo.blocks.get(o.Hash),c=h.decode(a);if(!s[r+1]){y(`Loaded new subshard ${n.prefix}`),await m(c.Links,i,n.bucket,parseInt(n.prefix,16));const e=await i._findNewBucketAndPos(t);s.push({bucket:e.bucket,prefix:w(e.pos),node:c});continue}const u=s[r+1];await v(c.Links,u.bucket,i),u.node=c}return await i.put(t,!0),s.reverse(),{rootBucket:i,path:s}},r.recreateHamtLevel=m,r.recreateInitialHamtLevel=b,r.toPrefix=w,r.updateHamtDirectory=async(e,t,r,i)=>{if(!i.parent.Data)throw new Error("Could not update HAMT directory because parent had no data");const n=Uint8Array.from(r._children.bitField().reverse()),s=a.UnixFS.unmarshal(i.parent.Data),o=new a.UnixFS({type:"hamt-sharded-directory",data:n,fanout:r.tableSize(),hashType:l.hamtHashCode,mode:s.mode,mtime:s.mtime}),c=await e.hashers.getHasher(i.hashAlg),d={Data:o.marshal(),Links:t.sort(((e,t)=>(e.Name||"").localeCompare(t.Name||"")))},f=h.encode(d),p=await c.digest(f),g=u.CID.create(i.cidVersion,h.code,p);return i.flush&&await e.repo.blocks.put(g,f),{node:d,cid:g,size:t.reduce(((e,t)=>e+(t.Tsize||0)),f.length)}}},{"@ipld/dag-pb":"i2cdx","hamt-sharding":"1SDvb","./dir-sharded.js":"ixBLc",debug:"bO5wM","ipfs-unixfs":"dF9VO","it-last":"cSXX9","multiformats/cid":"9ooAY","./hamt-constants.js":"2jyXQ"}],dvDDB:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("debug"),n=e("./add-link.js"),s=e("@ipld/dag-pb");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const a=o(i).default("ipfs:mfs:utils:update-tree"),c={shardSplitThreshold:1e3};r.updateTree=async function(e,t,r){r=Object.assign({},c,r),a("Trail",t),t=t.slice().reverse();let i,o=0;for await(const a of e.repo.blocks.getMany(t.map((e=>e.cid)))){const c=s.decode(a),u=t[o].cid,l=t[o].name;if(o++,!i){i={cid:u,name:l,size:a.length};continue}const d=await n.addLink(e,{parent:c,name:i.name,cid:i.cid,size:i.size,flush:r.flush,shardSplitThreshold:r.shardSplitThreshold,hashAlg:r.hashAlg,cidVersion:r.cidVersion});i={cid:d.cid,name:l,size:d.size}}const{cid:u}=i;return a(`Final CID ${u}`),u}},{debug:"bO5wM","./add-link.js":"dv4f9","@ipld/dag-pb":"i2cdx"}],lpX0i:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("debug"),n=e("../../../utils.js"),s=e("err-code");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(i),c=o(s);const u=a.default("ipfs:mfs:utils:update-mfs-root");r.updateMfsRoot=async function(e,t,r){if(r&&r.signal&&r.signal.aborted)throw c.default(new Error("Request aborted"),"ERR_ABORTED",{name:"Aborted"});return u(`New MFS root will be ${t}`),await e.repo.datastore.put(n.MFS_ROOT_KEY,t.bytes),t}},{debug:"bO5wM","../../../utils.js":"cT4uN","err-code":"chZjB"}],eJoZU:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./mkdir.js"),n=e("./stat.js"),s=e("debug"),o=e("err-code"),a=e("./utils/update-tree.js"),c=e("./utils/update-mfs-root.js"),u=e("./utils/add-link.js"),l=e("./utils/to-mfs-path.js"),d=e("merge-options"),f=e("./utils/to-trail.js"),h=e("ipfs-core-utils/with-timeout-option");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g=p(s),y=p(o);const m=p(d).default.bind({ignoreUndefined:!0}),b=g.default("ipfs:mfs:cp"),v={parents:!1,flush:!0,hashAlg:"sha2-256",cidVersion:0,shardSplitThreshold:1e3};const w=e=>e.unixfs&&e.unixfs.type&&e.unixfs.type.includes("directory"),_=async(e,t,r,i,n)=>{let s=i.pop();if(!s)throw y.default(new Error("destination had no parent"),"ERR_INVALID_PARAMS");s=await S(e,t,r,s,n),i.push(s);const o=await a.updateTree(e,i,n);await c.updateMfsRoot(e,o,n)},E=async(e,t,r,i,n)=>{for(let i=0;i{const s=await e.repo.blocks.get(t.cid),{node:o,cid:a,size:c}=await u.addLink(e,{parentCid:i.cid,size:s.length,cid:t.cid,name:r,hashAlg:n.hashAlg,cidVersion:n.cidVersion,flush:n.flush,shardSplitThreshold:n.shardSplitThreshold});return i.node=o,i.cid=a,i.size=c,i};r.createCp=function(e){return h.withTimeoutOption((async function(t,r,s={}){const o=m(v,s);Array.isArray(t)||(t=[t]);const a=await Promise.all(t.map((t=>l.toMfsPath(e,t,o))));let c=await l.toMfsPath(e,r,o);if(!a.length||!c)throw y.default(new Error("Please supply at least one source"),"ERR_INVALID_PARAMS");const u=a.find((e=>!e.exists));if(u)throw y.default(new Error(`${u.path} does not exist`),"ERR_INVALID_PARAMS");const d=w(c);if(c.exists){if(b("Destination exists"),1===a.length&&!d)throw y.default(new Error("directory already has entry by that name"),"ERR_ALREADY_EXISTS")}else if(b("Destination does not exist"),a.length>1){if(!o.parents)throw y.default(new Error("destination did not exist, pass -p to create intermediate directories"),"ERR_INVALID_PARAMS");await i.createMkdir(e)(c.path,o),c=await l.toMfsPath(e,c.path,o)}else if(c.parts.length>1){const t=`/${c.parts.slice(0,-1).join("/")}`;try{await n.createStat(e)(t,o)}catch(r){if("ERR_NOT_FOUND"!==r.code)throw r;if(!o.parents)throw y.default(new Error("destination did not exist, pass -p to create intermediate directories"),"ERR_INVALID_PARAMS");await i.createMkdir(e)(t,o),c=await l.toMfsPath(e,c.path,o)}}const h=w(c)?c.mfsPath:c.mfsDirectory,p=await f.toTrail(e,h);if(1===a.length){const t=a.pop();if(!t)throw y.default(new Error("could not find source"),"ERR_INVALID_PARAMS");const r=d?t.name:c.name;return b(`Only one source, copying to destination ${d?"directory":"file"} ${r}`),_(e,t,r,p,o)}return b("Multiple sources, wrapping in a directory"),E(e,a,c,p,o)}))}},{"./mkdir.js":"h1mMu","./stat.js":"lCUdo",debug:"bO5wM","err-code":"chZjB","./utils/update-tree.js":"dvDDB","./utils/update-mfs-root.js":"lpX0i","./utils/add-link.js":"dv4f9","./utils/to-mfs-path.js":"gAtPl","merge-options":"fupyv","./utils/to-trail.js":"crUUQ","ipfs-core-utils/with-timeout-option":"j29MK"}],h1mMu:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("err-code"),n=e("debug"),s=e("ipfs-unixfs-exporter"),o=e("./utils/create-node.js"),a=e("./utils/to-path-components.js"),c=e("./utils/update-mfs-root.js"),u=e("./utils/update-tree.js"),l=e("./utils/add-link.js"),d=e("./utils/with-mfs-root.js"),f=e("merge-options"),h=e("ipfs-core-utils/with-timeout-option");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g=p(i),y=p(n);const m=p(f).default.bind({ignoreUndefined:!0}),b=y.default("ipfs:mfs:mkdir"),v={parents:!1,hashAlg:"sha2-256",cidVersion:0,shardSplitThreshold:1e3,flush:!0};const w=async(e,t,r,i,n,s)=>{b(`Adding empty dir called ${t} to ${i.cid}`);const o=await l.addLink(e,{parent:i.node,parentCid:i.cid,size:0,cid:r.cid,name:t,hashAlg:s.hashAlg,cidVersion:s.cidVersion,flush:s.flush,shardSplitThreshold:s.shardSplitThreshold});n[n.length-1].cid=o.cid,n.push({name:t,cid:r.cid})};r.createMkdir=function(e){return h.withTimeoutOption((async function(t,r={}){const i=m(v,r);if(!t)throw new Error("no path given to Mkdir");if("/"===(t=t.trim())){if(i.parents)return;throw g.default(new Error("cannot create directory '/': Already exists"),"ERR_INVALID_PATH")}if("/"!==t.substring(0,1))throw g.default(new Error("paths must start with a leading slash"),"ERR_INVALID_PATH");b(`Creating ${t}`);const n=a.toPathComponents(t);if("ipfs"===n[0])throw g.default(new Error("path cannot have the prefix 'ipfs'"),"ERR_INVALID_PATH");const l=await d.loadMfsRoot(e,i);let f;const h=[],p=await o.createNode(e,"directory",i);for(let r=0;r<=n.length;r++){const o=n.slice(0,r),a=`/ipfs/${l}/${o.join("/")}`;try{if(f=await s.exporter(a,e.repo.blocks),"file"!==f.type&&"directory"!==f.type)throw g.default(new Error(`${t} was not a UnixFS node`),"ERR_NOT_UNIXFS");if(r===n.length){if(i.parents)return;throw g.default(new Error("file already exists"),"ERR_ALREADY_EXISTS")}h.push({name:f.name,cid:f.cid})}catch(t){if("ERR_NOT_FOUND"!==t.code)throw t;if(r{const i=await a.toMfsPath(e,t,r),u=await c.toTrail(e,i.mfsPath),l=u[u.length-1];u.pop();const d=u[u.length-1];if(!d)throw f.default(new Error(`${t} does not exist`),"ERR_NOT_FOUND");if("directory"===l.type&&!r.recursive)throw f.default(new Error(`${t} is a directory, use -r to remove directories`),"ERR_WAS_DIR");const{cid:h}=await o.removeLink(e,{parentCid:d.cid,name:l.name,hashAlg:r.hashAlg,cidVersion:r.cidVersion,flush:r.flush,shardSplitThreshold:r.shardSplitThreshold});d.cid=h;const p=await n.updateTree(e,u,r);await s.updateMfsRoot(e,p,r)};r.createRm=function(e){return u.withTimeoutOption((async function(t,r={}){const i=h(p,r);Array.isArray(t)||(t=[t]);const n=await Promise.all(t.map((t=>a.toMfsPath(e,t,i))));if(!n.length)throw f.default(new Error("Please supply at least one path to remove"),"ERR_INVALID_PARAMS");n.forEach((e=>{if("/"===e.path)throw f.default(new Error("Cannot delete root"),"ERR_INVALID_PARAMS")}));for(const t of n)await g(e,t.path,i)}))}},{"err-code":"chZjB","./utils/update-tree.js":"dvDDB","./utils/update-mfs-root.js":"lpX0i","./utils/remove-link.js":"fAytm","./utils/to-mfs-path.js":"gAtPl","./utils/to-trail.js":"crUUQ","ipfs-core-utils/with-timeout-option":"j29MK","merge-options":"fupyv"}],fAytm:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("@ipld/dag-pb"),n=e("multiformats/cid"),s=e("debug"),o=e("ipfs-unixfs"),a=e("./hamt-utils.js"),c=e("err-code");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var d=l(i),f=u(s),h=u(c);const p=f.default("ipfs:mfs:core:utils:remove-link");const g=async(e,t)=>{t.parent.Links=t.parent.Links.filter((e=>e.Name!==t.name));const r=await d.encode(t.parent),i=await e.hashers.getHasher(t.hashAlg),s=await i.digest(r),o=n.CID.create(t.cidVersion,d.code,s);return await e.repo.blocks.put(o,r),p(`Updated regular directory ${o}`),{node:t.parent,cid:o}},y=async(e,t)=>{const{rootBucket:r,path:i}=await a.generatePath(e,t.name,t.parent);await r.del(t.name);const{node:n}=await m(e,i,t.name,t);return a.updateHamtDirectory(e,n.Links,r,t)},m=async(e,t,r,i)=>{const n=t.pop();if(!n)throw h.default(new Error("Could not find parent"),"EINVALIDPARENT");const{bucket:s,prefix:o,node:c}=n;if(!c)throw h.default(new Error("Could not find parent"),"EINVALIDPARENT");const u=c.Links.find((e=>(e.Name||"").substring(0,2)===o));if(!u)throw h.default(new Error(`No link found with prefix ${o} for file ${r}`),"ERR_NOT_FOUND");if(u.Name===`${o}${r}`){p(`Removing existing link ${u.Name}`);const t=c.Links.filter((e=>e.Name!==u.Name));return await s.del(r),a.updateHamtDirectory(e,t,s,i)}p(`Descending into sub-shard ${u.Name} for ${o}${r}`);const l=await m(e,t,r,i);let d=l.cid,f=l.size,g=o;if(1===l.node.Links.length){p(`Removing subshard for ${o}`);const e=l.node.Links[0];g=`${o}${(e.Name||"").substring(2)}`,d=e.Hash,f=e.Tsize||0}return p(`Updating shard ${o} with name ${g}`),b(e,s,c,o,g,f,d,i)},b=(e,t,r,i,n,s,o,c)=>{const u=r.Links.filter((e=>e.Name!==i));return u.push({Name:n,Tsize:s,Hash:o}),a.updateHamtDirectory(e,u,t,c)};r.removeLink=async function(e,t){let r=t.parent;if(t.parentCid){const i=n.CID.asCID(t.parentCid);if(null===i)throw h.default(new Error("Invalid CID passed to removeLink"),"EINVALIDPARENTCID");p(`Loading parent node ${i}`);const s=await e.repo.blocks.get(i);r=d.decode(s)}if(!r)throw h.default(new Error("No parent node or CID passed to removeLink"),"EINVALIDPARENT");if(!t.name)throw h.default(new Error("No child name passed to removeLink"),"EINVALIDCHILDNAME");if(!r.Data)throw h.default(new Error("Parent node had no data"),"ERR_INVALID_NODE");return"hamt-sharded-directory"===o.UnixFS.unmarshal(r.Data).type?(p(`Removing ${t.name} from sharded directory`),y(e,{...t,parent:r})):(p(`Removing link ${t.name} regular directory`),g(e,{...t,parent:r}))}},{"@ipld/dag-pb":"i2cdx","multiformats/cid":"9ooAY",debug:"bO5wM","ipfs-unixfs":"dF9VO","./hamt-utils.js":"gemQO","err-code":"chZjB"}],dFNhT:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./stat.js"),n=e("ipfs-core-utils/with-timeout-option");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const o=s(e("merge-options")).default.bind({ignoreUndefined:!0}),a={};r.createFlush=function(e){return n.withTimeoutOption((async function(t,r={}){r=o(a,r);const{cid:n}=await i.createStat(e)(t,r);return n}))}},{"./stat.js":"lCUdo","ipfs-core-utils/with-timeout-option":"j29MK","merge-options":"fupyv"}],"347nd":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./cp.js"),n=e("./rm.js"),s=e("merge-options"),o=e("ipfs-core-utils/with-timeout-option");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const c=a(s).default.bind({ignoreUndefined:!0}),u={parents:!1,flush:!0,cidVersion:0,hashAlg:"sha2-256",shardSplitThreshold:1e3};r.createMv=function(e){return o.withTimeoutOption((async function(t,r,s={}){const o=c(u,s);await i.createCp(e)(t,r,o),await n.createRm(e)(t,{...o,recursive:!0})}))}},{"./cp.js":"eJoZU","./rm.js":"hU9a1","merge-options":"fupyv","ipfs-core-utils/with-timeout-option":"j29MK"}],d4deE:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("merge-options"),n=e("./utils/to-mfs-path.js"),s=e("debug"),o=e("err-code"),a=e("ipfs-unixfs"),c=e("./utils/to-trail.js"),u=e("./utils/add-link.js"),l=e("./utils/update-tree.js"),d=e("./utils/update-mfs-root.js"),f=e("@ipld/dag-pb"),h=e("multiformats/cid"),p=e("ipfs-core-utils/with-timeout-option");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function y(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var m=g(i),b=g(s),v=g(o),w=y(f);const _=m.default.bind({ignoreUndefined:!0}),E=b.default("ipfs:mfs:touch"),S={flush:!0,shardSplitThreshold:1e3,cidVersion:0,hashAlg:"sha2-256"};r.createTouch=function(e){return p.withTimeoutOption((async function(t,r={}){const i=_(S,r);i.mtime=i.mtime||new Date,E(`Touching ${t} mtime: ${i.mtime}`);const{cid:s,mfsDirectory:o,name:f,exists:p}=await n.toMfsPath(e,t,i),g=r.hashAlg||S.hashAlg,y=await e.hashers.getHasher(g);let m,b,T=i.cidVersion;if(p){if(s.code!==w.code)throw v.default(new Error(`${t} was not a UnixFS node`),"ERR_NOT_UNIXFS");T=s.version;const r=await e.repo.blocks.get(s),n=w.decode(r);if(!n.Data)throw v.default(new Error(`${t} had no data`),"ERR_INVALID_NODE");const o=a.UnixFS.unmarshal(n.Data);o.mtime=i.mtime,m=w.encode({Data:o.marshal(),Links:n.Links});const c=await y.digest(m);b=h.CID.create(i.cidVersion,w.code,c),i.flush&&await e.repo.blocks.put(b,m)}else{const t=new a.UnixFS({type:"file",mtime:i.mtime});m=w.encode({Data:t.marshal(),Links:[]});const r=await y.digest(m);b=h.CID.create(i.cidVersion,w.code,r),i.flush&&await e.repo.blocks.put(b,m)}const A=await c.toTrail(e,o),k=A[A.length-1],I=k.cid,R=await e.repo.blocks.get(I),P=w.decode(R),O=await u.addLink(e,{parent:P,name:f,cid:b,size:m.length,flush:i.flush,shardSplitThreshold:i.shardSplitThreshold,hashAlg:i.hashAlg,cidVersion:T});k.cid=O.cid;const C=await l.updateTree(e,A,i);await d.updateMfsRoot(e,C,i)}))}},{"merge-options":"fupyv","./utils/to-mfs-path.js":"gAtPl",debug:"bO5wM","err-code":"chZjB","ipfs-unixfs":"dF9VO","./utils/to-trail.js":"crUUQ","./utils/add-link.js":"dv4f9","./utils/update-tree.js":"dvDDB","./utils/update-mfs-root.js":"lpX0i","@ipld/dag-pb":"i2cdx","multiformats/cid":"9ooAY","ipfs-core-utils/with-timeout-option":"j29MK"}],"3Dh6r":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-unixfs-exporter"),n=e("merge-options"),s=e("./utils/to-mfs-path.js"),o=e("err-code"),a=e("ipfs-core-utils/with-timeout-option");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(n),l=c(o);const d=u.default.bind({ignoreUndefined:!0}),f={offset:0,length:1/0};r.createRead=function(e){return a.withTimeoutOption((function(t,r={}){return r=d(f,r),{[Symbol.asyncIterator]:async function*(){const n=await s.toMfsPath(e,t,r),o=await i.exporter(n.mfsPath,e.repo.blocks);if("file"!==o.type)throw l.default(new Error(`${t} was not a file`),"ERR_NOT_FILE");if(!o.content)throw l.default(new Error(`Could not load content stream from ${t}`),"ERR_NO_CONTENT");for await(const e of o.content({offset:r.offset,length:r.length}))yield e}}}))}},{"ipfs-unixfs-exporter":"BgMiX","merge-options":"fupyv","./utils/to-mfs-path.js":"gAtPl","err-code":"chZjB","ipfs-core-utils/with-timeout-option":"j29MK"}],fQgQQ:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("debug"),n=e("ipfs-unixfs-importer"),s=e("@ipld/dag-pb"),o=e("multiformats/hashes/sha2"),a=e("./stat.js"),c=e("./mkdir.js"),u=e("./utils/add-link.js"),l=e("merge-options"),d=e("./utils/create-lock.js"),f=e("./utils/to-async-iterator.js"),h=e("./utils/to-mfs-path.js"),p=e("./utils/to-path-components.js"),g=e("./utils/to-trail.js"),y=e("./utils/update-tree.js"),m=e("./utils/update-mfs-root.js"),b=e("err-code"),v=e("../../utils.js"),w=e("it-last"),_=e("ipfs-core-utils/with-timeout-option"),E=e("ipfs-unixfs");function S(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var T=S(i),A=S(l),k=S(b),I=S(w);const R=A.default.bind({ignoreUndefined:!0}),P=T.default("ipfs:mfs:write"),O={offset:0,length:1/0,create:!1,truncate:!1,rawLeaves:!1,reduceSingleLeafToSelf:!1,cidVersion:0,hashAlg:"sha2-256",parents:!1,progress:(e,t)=>{},strategy:"trickle",flush:!0,leafType:"raw",shardSplitThreshold:1e3};const C=async(e,t,r,i,n)=>{const o=await j(e,r,i,n);await d.createLock().writeLock((async()=>{const r=p.toPathComponents(t),i=r.pop();if(null==i)throw k.default(new Error("source does not exist"),"ERR_NO_EXIST");let l=!1;try{await a.createStat(e)(`/${r.join("/")}`,n),l=!0}catch(e){if("ERR_NOT_FOUND"!==e.code)throw e}l||await c.createMkdir(e)(`/${r.join("/")}`,n);const d=await h.toMfsPath(e,t,n),f=await g.toTrail(e,d.mfsDirectory),b=f[f.length-1];if(!b)throw k.default(new Error("directory does not exist"),"ERR_NO_EXIST");if(!b.type||!b.type.includes("directory"))throw k.default(new Error(`cannot write to ${b.name}: Not a directory`),"ERR_NOT_A_DIRECTORY");const v=await e.repo.blocks.get(b.cid),w=s.decode(v),_=await u.addLink(e,{parent:w,name:i,cid:o.cid,size:o.size,flush:n.flush,shardSplitThreshold:n.shardSplitThreshold,hashAlg:n.hashAlg,cidVersion:n.cidVersion});b.cid=_.cid;const E=await y.updateTree(e,f,n);await m.updateMfsRoot(e,E,n)}))()},j=async(e,t,r,i)=>{r.exists?P(`Overwriting file ${r.cid} offset ${i.offset} length ${i.length}`):P(`Writing file offset ${i.offset} length ${i.length}`);const s=[];if(i.offset>0)if(r.unixfs){if(P(`Writing first ${i.offset} bytes of original file`),s.push((()=>r.content({offset:0,length:i.offset}))),r.unixfs.fileSize(){if(r.unixfs&&!i.truncate){const t=r.unixfs.fileSize();if(t>e)return P(`Writing last ${t-e} of ${t} bytes from original file starting at offset ${e}`),r.content({offset:e});P("Not writing last bytes from original file")}return{[Symbol.asyncIterator]:async function*(){}}}));let c,u,l;switch(void 0!==i.mode&&null!==i.mode?c=E.parseMode(i.mode):r&&r.unixfs&&(c=r.unixfs.mode),null!=i.mtime?u=E.parseMtime(i.mtime):r&&r.unixfs&&(u=r.unixfs.mtime),i.hashAlg){case"sha2-256":l=o.sha256;break;case"sha2-512":l=o.sha512;break;default:throw new Error(`TODO vmx 2021-03-31: Proper error message for unsupported hash algorithms like ${i.hashAlg}`)}const d=await I.default(n.importer([{content:a,mode:c,mtime:u}],e.repo.blocks,{progress:i.progress,hasher:l,cidVersion:i.cidVersion,strategy:i.strategy,rawLeaves:i.rawLeaves,reduceSingleLeafToSelf:i.reduceSingleLeafToSelf,leafType:i.leafType}));if(!d)throw k.default(new Error(`cannot write to ${parent.name}`),"ERR_COULD_NOT_WRITE");return P(`Wrote ${d.cid}`),{cid:d.cid,size:d.size}},D=(e,t)=>async function*(){let r=0;for await(const i of e){if(r+=i.length,r>t)return void(yield i.slice(0,t-r));yield i}},M=(e,t=v.MFS_MAX_CHUNK_SIZE)=>{const r=new Uint8Array(t);return D(async function*(){for(;;)yield r.slice()}(),e)},x=async function*(e){for(let t=0;t{s=await f.toAsyncIterator(r),o=await h.toMfsPath(e,t,n),a=await h.toMfsPath(e,o.mfsDirectory,n)}))(),P("Read source, destination and parent"),!n.parents&&!a.exists)throw k.default(new Error("directory does not exist"),"ERR_NO_EXIST");if(null==s)throw k.default(new Error("could not create source"),"ERR_NO_SOURCE");if(null==o)throw k.default(new Error("could not create destination"),"ERR_NO_DESTINATION");if(!n.create&&!o.exists)throw k.default(new Error("file does not exist"),"ERR_NO_EXIST");if("file"!==o.entryType)throw k.default(new Error("not a file"),"ERR_NOT_A_FILE");return C(e,t,s,o,n)}))}},{debug:"bO5wM","ipfs-unixfs-importer":"i61x3","@ipld/dag-pb":"i2cdx","multiformats/hashes/sha2":"7i9MT","./stat.js":"lCUdo","./mkdir.js":"h1mMu","./utils/add-link.js":"dv4f9","merge-options":"fupyv","./utils/create-lock.js":"kHT2F","./utils/to-async-iterator.js":"jbAGR","./utils/to-mfs-path.js":"gAtPl","./utils/to-path-components.js":"j9m7w","./utils/to-trail.js":"crUUQ","./utils/update-tree.js":"dvDDB","./utils/update-mfs-root.js":"lpX0i","err-code":"chZjB","../../utils.js":"cT4uN","it-last":"cSXX9","ipfs-core-utils/with-timeout-option":"j29MK","ipfs-unixfs":"dF9VO"}],jbAGR:[function(e,t,r){var i=arguments[3];Object.defineProperty(r,"__esModule",{value:!0});var n=e("err-code"),s=e("debug"),o=e("../../../utils.js"),a=e("uint8arrays/from-string");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(n),l=c(s);const d=l.default("ipfs:mfs:utils:to-async-iterator");function f(e){if(!e)throw u.default(new Error("paths must start with a leading slash"),"ERR_INVALID_PATH");if(("string"==typeof e||e instanceof String)&&(d("Content was a string"),e=a.fromString(e.toString())),e.length)return d("Content was array-like"),{[Symbol.asyncIterator]:function*(){yield e}};if(e[Symbol.asyncIterator])return d("Content was an async iterator"),e;if(e[Symbol.iterator])return d("Content was an iterator"),e;if(i.Blob&&e instanceof i.Blob){d("Content was an HTML5 Blob");let t=0;const r={next:()=>t>e.size?{done:!0}:new Promise(((r,n)=>{const s=e.slice(t,o.MFS_MAX_CHUNK_SIZE);t+=o.MFS_MAX_CHUNK_SIZE;const a=new i.FileReader,c=e=>{if(a.removeEventListener("loadend",c,!1),e.error)return n(e.error);r({done:!1,value:new Uint8Array(a.result)})};a.addEventListener("loadend",c),a.readAsArrayBuffer(s)}))};return{[Symbol.asyncIterator]:()=>r}}throw u.default(new Error(`Don't know how to convert ${e} into an async iterator`),"ERR_INVALID_PARAMS")}r.toAsyncIterator=f},{"err-code":"chZjB",debug:"bO5wM","../../../utils.js":"cT4uN","uint8arrays/from-string":"dF7Y4"}],"2uADA":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-unixfs-exporter"),n=e("./utils/to-mfs-path.js"),s=e("ipfs-core-utils/with-timeout-option");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(e("it-map"));const c=e=>{const t={cid:e.cid,name:e.name,type:"directory"===e.type?"directory":"file",size:e.size};return"file"!==e.type&&"directory"!==e.type||(t.mode=e.unixfs.mode,t.mtime=e.unixfs.mtime),t};r.createLs=function(e){return s.withTimeoutOption((async function*(t,r={}){const s=await n.toMfsPath(e,t,r),o=await i.exporter(s.mfsPath,e.repo.blocks);"directory"!==o.type?yield c(o):yield*a.default(o.content(r),c)}))}},{"ipfs-unixfs-exporter":"BgMiX","./utils/to-mfs-path.js":"gAtPl","ipfs-core-utils/with-timeout-option":"j29MK","it-map":"eeqPk"}],aJXOU:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./export.js"),n=e("./gen.js"),s=e("./import.js"),o=e("./info.js"),a=e("./list.js"),c=e("./rename.js"),u=e("./rm.js");r.KeyAPI=class{constructor({keychain:e}){this.gen=n.createGen({keychain:e}),this.list=a.createList({keychain:e}),this.rm=u.createRm({keychain:e}),this.rename=c.createRename({keychain:e}),this.export=i.createExport({keychain:e}),this.import=s.createImport({keychain:e}),this.info=o.createInfo({keychain:e})}}},{"./export.js":"bcIEv","./gen.js":"9dF1X","./import.js":"5TBS8","./info.js":"4SpeM","./list.js":"kkYzS","./rename.js":"idv1N","./rm.js":"iQMly"}],bcIEv:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option");r.createExport=function({keychain:e}){return i.withTimeoutOption(((t,r)=>e.exportKey(t,r)))}},{"ipfs-core-utils/with-timeout-option":"j29MK"}],"9dF1X":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option");const n="ed25519";r.createGen=function({keychain:e}){return i.withTimeoutOption(((t,r={type:n,size:2048})=>e.createKey(t,r.type||n,r.size||2048)))}},{"ipfs-core-utils/with-timeout-option":"j29MK"}],"5TBS8":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option");r.createImport=function({keychain:e}){return i.withTimeoutOption(((t,r,i)=>e.importKey(t,r,i)))}},{"ipfs-core-utils/with-timeout-option":"j29MK"}],"4SpeM":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option");r.createInfo=function({keychain:e}){return i.withTimeoutOption((t=>e.findKeyByName(t)))}},{"ipfs-core-utils/with-timeout-option":"j29MK"}],kkYzS:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option");r.createList=function({keychain:e}){return i.withTimeoutOption((()=>e.listKeys()))}},{"ipfs-core-utils/with-timeout-option":"j29MK"}],idv1N:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option");r.createRename=function({keychain:e}){return i.withTimeoutOption((async(t,r)=>{const i=await e.renameKey(t,r);return{was:t,now:i.name,id:i.id,overwrite:!1}}))}},{"ipfs-core-utils/with-timeout-option":"j29MK"}],iQMly:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option");r.createRm=function({keychain:e}){return i.withTimeoutOption((t=>e.removeKey(t)))}},{"ipfs-core-utils/with-timeout-option":"j29MK"}],kwMxL:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./data.js"),n=e("./get.js"),s=e("./links.js"),o=e("./new.js"),a=e("./put.js"),c=e("./stat.js"),u=e("./patch/index.js");r.ObjectAPI=class{constructor({repo:e,codecs:t,preload:r}){this.data=i.createData({repo:e,preload:r}),this.get=n.createGet({repo:e,preload:r}),this.links=s.createLinks({repo:e,codecs:t}),this.new=o.createNew({repo:e,preload:r}),this.put=a.createPut({repo:e,preload:r}),this.stat=c.createStat({repo:e,preload:r}),this.patch=new u.ObjectPatchAPI({repo:e,preload:r})}}},{"./data.js":"lgHu1","./get.js":"3KrcI","./links.js":"2SX04","./new.js":"fa8jR","./put.js":"2HgKS","./stat.js":"1xg5C","./patch/index.js":"ejlpO"}],lgHu1:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option"),n=e("./get.js");r.createData=function({repo:e,preload:t}){const r=n.createGet({repo:e,preload:t});return i.withTimeoutOption((async function(e,t={}){return(await r(e,t)).Data||new Uint8Array(0)}))}},{"ipfs-core-utils/with-timeout-option":"j29MK","./get.js":"3KrcI"}],"3KrcI":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("@ipld/dag-pb"),n=e("ipfs-core-utils/with-timeout-option");function s(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var o=s(i);r.createGet=function({repo:e,preload:t}){return n.withTimeoutOption((async function(r,i={}){!1!==i.preload&&t(r);const n=await e.blocks.get(r,i);return o.decode(n)}))}},{"@ipld/dag-pb":"i2cdx","ipfs-core-utils/with-timeout-option":"j29MK"}],"2SX04":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("@ipld/dag-pb"),n=e("@ipld/dag-cbor"),s=e("multiformats/codecs/raw"),o=e("multiformats/cid"),a=e("ipfs-core-utils/with-timeout-option");function c(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var u=c(i),l=c(n),d=c(s);function f(e,t=[]){for(const r in e){const i=e[r];if("/"===r&&1===Object.keys(e).length)try{t.push({Name:"",Tsize:0,Hash:o.CID.parse(i)});continue}catch(e){}const n=o.CID.asCID(i);n?t.push({Name:"",Tsize:0,Hash:n}):(Array.isArray(i)&&f(i,t),i&&"object"==typeof i&&f(i,t))}return t}r.createLinks=function({repo:e,codecs:t}){return a.withTimeoutOption((async function(r,i={}){const n=await t.getCodec(r.code),s=await e.blocks.get(r,i),o=n.decode(s);if(r.code===d.code)return[];if(r.code===u.code)return o.Links;if(r.code===l.code)return f(o);throw new Error(`Cannot resolve links from codec ${r.code}`)}))}},{"@ipld/dag-pb":"i2cdx","@ipld/dag-cbor":"3498i","multiformats/codecs/raw":"fdfgp","multiformats/cid":"9ooAY","ipfs-core-utils/with-timeout-option":"j29MK"}],fa8jR:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("@ipld/dag-pb"),n=e("multiformats/hashes/sha2"),s=e("ipfs-unixfs"),o=e("ipfs-core-utils/with-timeout-option"),a=e("multiformats/cid");function c(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var u=c(i);r.createNew=function({repo:e,preload:t}){return o.withTimeoutOption((async function(r={}){let i;if(r.template){if("unixfs-dir"!==r.template)throw new Error("unknown template");i=new s.UnixFS({type:"directory"}).marshal()}const o=u.encode({Data:i,Links:[]}),c=await n.sha256.digest(o),l=a.CID.createV0(c);return await e.blocks.put(l,o,{signal:r.signal}),!1!==r.preload&&t(l),l}))}},{"@ipld/dag-pb":"i2cdx","multiformats/hashes/sha2":"7i9MT","ipfs-unixfs":"dF9VO","ipfs-core-utils/with-timeout-option":"j29MK","multiformats/cid":"9ooAY"}],"2HgKS":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("@ipld/dag-pb"),n=e("multiformats/cid"),s=e("multiformats/hashes/sha2"),o=e("ipfs-core-utils/with-timeout-option");function a(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var c=a(i);r.createPut=function({repo:e,preload:t}){return o.withTimeoutOption((async function(r,i={}){const o=await e.gcLock.readLock();try{const a=c.encode(r),u=await s.sha256.digest(a),l=n.CID.createV0(u);return await e.blocks.put(l,a,{signal:i.signal}),!1!==i.preload&&t(l),i.pin&&await e.pins.pinRecursively(l,{signal:i.signal}),l}finally{o()}}))}},{"@ipld/dag-pb":"i2cdx","multiformats/cid":"9ooAY","multiformats/hashes/sha2":"7i9MT","ipfs-core-utils/with-timeout-option":"j29MK"}],"1xg5C":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("@ipld/dag-pb"),n=e("ipfs-core-utils/with-timeout-option"),s=e("./get.js");function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var a=o(i);r.createStat=function({repo:e,preload:t}){const r=s.createGet({repo:e,preload:t});return n.withTimeoutOption((async function(e,t={}){const i=await r(e,t),n=a.encode(i).length,s=i.Links.reduce(((e,t)=>e+(t.Tsize||0)),0);return{Hash:e,NumLinks:i.Links.length,BlockSize:n,LinksSize:n-(i.Data||[]).length,DataSize:(i.Data||[]).length,CumulativeSize:n+s}}))}},{"@ipld/dag-pb":"i2cdx","ipfs-core-utils/with-timeout-option":"j29MK","./get.js":"3KrcI"}],ejlpO:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./add-link.js"),n=e("./append-data.js"),s=e("./rm-link.js"),o=e("./set-data.js");r.ObjectPatchAPI=class{constructor({repo:e,preload:t}){this.addLink=i.createAddLink({repo:e,preload:t}),this.appendData=n.createAppendData({repo:e,preload:t}),this.rmLink=s.createRmLink({repo:e,preload:t}),this.setData=o.createSetData({repo:e,preload:t})}}},{"./add-link.js":"4oi3r","./append-data.js":"c7ABb","./rm-link.js":"f9JX7","./set-data.js":"7RZAU"}],"4oi3r":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option"),n=e("../get.js"),s=e("../put.js");r.createAddLink=function({repo:e,preload:t}){const r=n.createGet({repo:e,preload:t}),o=s.createPut({repo:e,preload:t});return i.withTimeoutOption((async function(e,t,i={}){const n=await r(e,i);return o({...n,Links:n.Links.concat([t])},i)}))}},{"ipfs-core-utils/with-timeout-option":"j29MK","../get.js":"3KrcI","../put.js":"2HgKS"}],c7ABb:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option"),n=e("uint8arrays/concat"),s=e("../get.js"),o=e("../put.js");r.createAppendData=function({repo:e,preload:t}){const r=s.createGet({repo:e,preload:t}),a=o.createPut({repo:e,preload:t});return i.withTimeoutOption((async function(e,t,i={}){const s=await r(e,i),o=n.concat([s.Data||[],t]);return a({...s,Data:o},i)}))}},{"ipfs-core-utils/with-timeout-option":"j29MK","uint8arrays/concat":"4EBjG","../get.js":"3KrcI","../put.js":"2HgKS"}],f9JX7:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option"),n=e("../get.js"),s=e("../put.js");r.createRmLink=function({repo:e,preload:t}){const r=n.createGet({repo:e,preload:t}),o=s.createPut({repo:e,preload:t});return i.withTimeoutOption((async function(e,t,i={}){const n=await r(e,i),s=("string"==typeof t?t:t.Name)||"";return n.Links=n.Links.filter((e=>e.Name!==s)),o(n,i)}))}},{"ipfs-core-utils/with-timeout-option":"j29MK","../get.js":"3KrcI","../put.js":"2HgKS"}],"7RZAU":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option"),n=e("../get.js"),s=e("../put.js");r.createSetData=function({repo:e,preload:t}){const r=n.createGet({repo:e,preload:t}),o=s.createPut({repo:e,preload:t});return i.withTimeoutOption((async function(e,t,i={}){const n=await r(e,i);return o({...n,Data:t},i)}))}},{"ipfs-core-utils/with-timeout-option":"j29MK","../get.js":"3KrcI","../put.js":"2HgKS"}],"1qDVo":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./gc.js"),n=e("./stat.js"),s=e("./version.js");r.RepoAPI=class{constructor({repo:e,hashers:t}){this.gc=i.createGc({repo:e,hashers:t}),this.stat=n.createStat({repo:e}),this.version=s.createVersion({repo:e}),this.setApiAddr=t=>e.apiAddr.set(t)}}},{"./gc.js":"gtgb5","./stat.js":"cgD5k","./version.js":"7VIBe"}],gtgb5:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("debug"),n=e("ipfs-core-utils/with-timeout-option"),s=e("../files/utils/with-mfs-root.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const a=o(i).default("ipfs:repo:gc");r.createGc=function({repo:e,hashers:t}){return n.withTimeoutOption((async function*(r={}){const i=Date.now();let n;try{n=await s.loadMfsRoot({repo:e,hashers:t},r),await e.pins.pinRecursively(n),yield*e.gc()}finally{n&&await e.pins.unpin(n)}a(`Complete (${Date.now()-i}ms)`)}))}},{debug:"bO5wM","ipfs-core-utils/with-timeout-option":"j29MK","../files/utils/with-mfs-root.js":"ho9kf"}],cgD5k:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option");r.createStat=function({repo:e}){return i.withTimeoutOption((async function(t={}){const r=await e.stat();return{numObjects:BigInt(r.numObjects.toString()),repoSize:BigInt(r.repoSize.toString()),repoPath:r.repoPath,version:`${r.version}`,storageMax:BigInt(r.storageMax.toString())}}))}},{"ipfs-core-utils/with-timeout-option":"j29MK"}],"7VIBe":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option"),n=e("ipfs-repo/constants");r.createVersion=function({repo:e}){return i.withTimeoutOption((async function(t={}){try{await e._checkInitialized(t)}catch(e){if([/Key not found in database \[\/version\]/,/ENOENT/,/repo is not initialized yet/].some((t=>t.test(e.message))))return n.repoVersion;throw e}return e.version.get()}))}},{"ipfs-core-utils/with-timeout-option":"j29MK","ipfs-repo/constants":"kDOvV"}],kDOvV:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.repoVersion=11},{}],"1NkyG":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./bw.js"),n=e("../repo/stat.js"),s=e("../bitswap/stat.js");r.StatsAPI=class{constructor({repo:e,network:t}){this.repo=n.createStat({repo:e}),this.bw=i.createBw({network:t}),this.bitswap=s.createStat({network:t})}}},{"./bw.js":"DMKGd","../repo/stat.js":"cgD5k","../bitswap/stat.js":"aHPBA"}],DMKGd:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("parse-duration"),n=e("err-code"),s=e("ipfs-core-utils/with-timeout-option");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(i),c=o(n);function u(e,t){let r;if(r=e.metrics?t.peer?e.metrics.forPeer(t.peer):t.proto?e.metrics.forProtocol(t.proto):e.metrics.global:void 0,!r)return{totalIn:BigInt(0),totalOut:BigInt(0),rateIn:0,rateOut:0};const{movingAverages:i,snapshot:n}=r;return{totalIn:BigInt(n.dataReceived.integerValue().toString()),totalOut:BigInt(n.dataSent.integerValue().toString()),rateIn:i.dataReceived[6e4].movingAverage()/60,rateOut:i.dataSent[6e4].movingAverage()/60}}r.createBw=function({network:e}){return s.withTimeoutOption((async function*(t={}){const{libp2p:r}=await e.use(t);if(!t.poll)return void(yield u(r,t));const i=t.interval||1e3;let n,s=-1;try{if(s="string"==typeof i?a.default(i)||-1:i,!s||s<0)throw new Error("invalid duration")}catch(e){throw c.default(e,"ERR_INVALID_POLL_INTERVAL")}try{for(;;)yield u(r,t),await new Promise((e=>{n=setTimeout(e,s)}))}finally{clearTimeout(n)}}))}},{"parse-duration":"fGYtw","err-code":"chZjB","ipfs-core-utils/with-timeout-option":"j29MK"}],bI63q:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("debug"),n=e("ipfs-core-config/repo"),s=e("ipfs-core-config/config"),o=e("uint8arrays/from-string"),a=e("uint8arrays/to-string"),c=e("peer-id"),u=e("merge-options"),l=e("./config/profiles.js"),d=e("../errors.js"),f=e("./libp2p.js"),h=e("ipfs-repo/errors");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g=p(i),y=p(s),m=p(c);const b=p(u).default.bind({ignoreUndefined:!0}),v=g.default("ipfs:components:peer:storage");class w{constructor(e,t,r,i,n){this.print=i,this.peerId=e,this.keychain=t,this.repo=r,this.print=i,this.isNew=n}static async start(e,t,r){const{repoAutoMigrate:i,repo:s,onMigrationProgress:o}=r,a="string"==typeof s||null==s?n.createRepo(e,t,{path:s,autoMigrate:i,onMigrationProgress:o}):s,{peerId:c,keychain:u,isNew:l}=await _(e,a,r);return new w(c,u,a,e,l)}}const _=async(e,t,r)=>{if(!t.closed)return{...await k(t,r),isNew:!1};try{return await t.open(),{...await k(t,r),isNew:!1}}catch(i){if(i.code!==h.ERR_REPO_NOT_INITIALIZED)throw i;if(r.init&&!1===r.init.allowNew)throw new d.NotEnabledError("Initialization of new repos disabled by config, pass `config.init.isNew: true` to enable it");return{...await E(e,t,r),isNew:!0}}},E=async(e,t,r)=>{const i=r.init||{},n=await t.exists();if(v("repo exists?",n),!0===n)throw new Error("repo already exists");const s=i.privateKey?await S(i.privateKey):await T(e,i),o=A(s);v("peer identity: %s",o.PeerID);const a={...b(R(y.default(),i.profiles),r.config),Identity:o};await t.init(a),await t.open(),v("repo opened");const c={pass:r.pass};try{c.dek=await t.config.get("Keychain.DEK")}catch(e){if("ERR_NOT_FOUND"!==e.code)throw e}const u=await f.createLibp2p({options:void 0,multiaddrs:void 0,peerId:s,repo:t,config:a,keychainConfig:c});return u.keychain&&u.keychain.opts&&(await u.loadKeychain(),await t.config.set("Keychain",{DEK:u.keychain.opts.dek})),{peerId:s,keychain:u.keychain}},S=e=>(v("using user-supplied private-key"),"object"==typeof e?e:m.default.createFromPrivKey(o.fromString(e,"base64pad"))),T=(e,{algorithm:t="Ed25519",bits:r=2048})=>(e("generating %s keypair...",t),m.default.create({keyType:t,bits:r})),A=e=>({PeerID:e.toB58String(),PrivKey:a.toString(e.privKey.bytes,"base64pad")}),k=async(e,t)=>{const r=t.config,i=t.init&&t.init.profiles||[],n=t.pass,s=await e.config.getAll(),o=I(R(s,i),r);if(s!==o&&await e.config.replace(o),!o.Identity||!o.Identity.PrivKey)throw new d.NotInitializedError("No private key was found in the config, please intialize the repo");const a=await m.default.createFromPrivKey(o.Identity.PrivKey),c=await f.createLibp2p({options:void 0,multiaddrs:void 0,peerId:a,repo:e,config:o,keychainConfig:{pass:n,...o.Keychain}});return c.keychain&&await c.loadKeychain(),{peerId:a,keychain:c.keychain}},I=(e,t)=>t?b(e,t):e,R=(e,t)=>(t||[]).reduce(((e,t)=>{const r=l.profiles[t];if(!r)throw new Error(`Could not find profile with name '${t}'`);return v("applying profile %s",t),r.transform(e)}),e);r.Storage=w},{debug:"bO5wM","ipfs-core-config/repo":"cPlYr","ipfs-core-config/config":"ejWbz","uint8arrays/from-string":"dF7Y4","uint8arrays/to-string":"hC8JB","peer-id":"8Bdb3","merge-options":"fupyv","./config/profiles.js":"f6AK7","../errors.js":"j69o8","./libp2p.js":"jcB2q","ipfs-repo/errors":"jDxkJ"}],cPlYr:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-repo"),n=e("datastore-level"),s=e("blockstore-datastore-adapter"),o=e("ipfs-repo/locks/memory");r.createRepo=function(e,t,r){const a=r.path||"ipfs";return i.createRepo(a,(e=>t.getCodec(e)),{root:new n.LevelDatastore(a,{prefix:"",version:2}),blocks:new s.BlockstoreDatastoreAdapter(new n.LevelDatastore(`${a}/blocks`,{prefix:"",version:2})),datastore:new n.LevelDatastore(`${a}/datastore`,{prefix:"",version:2}),keys:new n.LevelDatastore(`${a}/keys`,{prefix:"",version:2}),pins:new n.LevelDatastore(`${a}/pins`,{prefix:"",version:2})},{autoMigrate:r.autoMigrate,onMigrationProgress:r.onMigrationProgress||e,repoLock:o.MemoryLock})}},{"ipfs-repo":"c5Wg7","datastore-level":"3taGN","blockstore-datastore-adapter":"lEkQn","ipfs-repo/locks/memory":"xMQlv"}],c5Wg7:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("just-safe-get"),n=e("debug"),s=e("err-code"),o=e("ipfs-repo-migrations"),a=e("bytes"),c=e("merge-options"),u=e("./constants.js"),l=e("./version.js"),d=e("./config.js"),f=e("./spec.js"),h=e("./api-addr.js"),p=e("./idstore.js"),g=e("./default-options.js"),y=e("./default-datastore.js"),m=e("./errors.js"),b=e("./pin-manager.js"),v=e("./pinned-blockstore.js"),w=e("mortice"),_=e("./gc.js");function E(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function S(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var T=E(i),A=E(n),k=E(s),I=S(o),R=E(a),P=E(c),O=E(w);const C=A.default("ipfs:repo"),j=Number.MAX_SAFE_INTEGER;class D{constructor(e,t,r,i){if("string"!=typeof e)throw new Error("missing repo path");if("function"!=typeof t)throw new Error("missing codec loader");this.options=P.default(g,i),this.closed=!0,this.path=e,this.root=r.root,this.datastore=r.datastore,this.keys=r.keys;const n=r.blocks,s=r.pins;this.pins=new b.PinManager({pinstore:s,blockstore:n,loadCodec:t});const o=v.createPinnedBlockstore(this.pins,n);this.blocks=p.createIdStore(o),this.version=l.version(this.root),this.config=d.config(this.root),this.spec=f.spec(this.root),this.apiAddr=h.apiAddr(this.root),this.gcLock=O.default(e,{singleProcess:!1!==this.options.repoOwner}),this.gc=_.gc({gcLock:this.gcLock,pins:this.pins,blockstore:this.blocks,root:this.root,loadCodec:t})}async init(e){var t;C("initializing at: %s",this.path),await this._openRoot(),await this.config.replace((t=e,t.Datastore=Object.assign({},y,T.default(t,"datastore")),t)),await this.spec.set(function(e){const t={...y.Spec,...T.default(e,"Datastore.Spec")};return{type:t.type,mounts:t.mounts.map((e=>({mountpoint:e.mountpoint,type:e.child.type,path:e.child.path,shardFunc:e.child.shardFunc})))}}(e)),await this.version.set(u.repoVersion)}async isInitialized(){if(!this.closed)return!0;try{return await this._openRoot(),await this._checkInitialized(),await this.root.close(),!0}catch(e){return!1}}async open(){if(!this.closed)throw k.default(new Error("repo is already open"),m.ERR_REPO_ALREADY_OPEN);C("opening at: %s",this.path);try{await this._openRoot(),await this._checkInitialized(),this._lockfile=await this._openLock(),C("acquired repo.lock");if(!await this.version.check(u.repoVersion)){if(!await this._isAutoMigrationEnabled())throw new m.InvalidRepoVersionError("Incompatible repo versions. Automatic migrations disabled. Please migrate the repo manually.");await this._migrate(u.repoVersion,{root:this.root,datastore:this.datastore,pins:this.pins.pinstore,blocks:this.pins.blockstore,keys:this.keys})}C("creating datastore"),await this.datastore.open(),C("creating blocks"),await this.blocks.open(),C("creating keystore"),await this.keys.open(),C("creating pins"),await this.pins.pinstore.open(),this.closed=!1,C("all opened")}catch(e){if(this._lockfile)try{await this._closeLock(),this._lockfile=null}catch(e){C("error removing lock",e)}throw e}}async _openRoot(){try{await this.root.open()}catch(e){if("Already open"!==e.message)throw e}}async _openLock(){const e=await this.options.repoLock.lock(this.path);if("function"!=typeof e.close)throw k.default(new Error("Locks must have a close method"),"ERR_NO_CLOSE_FUNCTION");return e}_closeLock(){return this._lockfile&&this._lockfile.close()}async _checkInitialized(){let e;C("init check");try{[e]=await Promise.all([this.config.exists(),this.spec.exists(),this.version.exists()])}catch(e){if("ERR_NOT_FOUND"===e.code)throw k.default(new Error("repo is not initialized yet"),m.ERR_REPO_NOT_INITIALIZED,{path:this.path});throw e}if(!e)throw k.default(new Error("repo is not initialized yet"),m.ERR_REPO_NOT_INITIALIZED,{path:this.path})}async close(){if(this.closed)throw k.default(new Error("repo is already closed"),m.ERR_REPO_ALREADY_CLOSED);C("closing at: %s",this.path);try{await this.apiAddr.delete()}catch(e){if(e.code!==m.ERR_REPO_NOT_INITIALIZED&&!e.message.startsWith("ENOENT"))throw e}await Promise.all([this.root,this.blocks,this.keys,this.datastore,this.pins.pinstore].map((e=>e&&e.close()))),C("unlocking"),this.closed=!0,await this._closeLock()}exists(){return this.version.exists()}async stat(){if(this.datastore&&this.keys){const[e,t,r,i,n]=await Promise.all([this._storageMaxStat(),this._blockStat(),this.version.get(),M(this.datastore),M(this.keys)]),s=t.size+i+n;return{repoPath:this.path,storageMax:e,version:r,numObjects:t.count,repoSize:s}}throw k.default(new Error("repo is not initialized yet"),m.ERR_REPO_NOT_INITIALIZED,{path:this.path})}async _isAutoMigrationEnabled(){if(void 0!==this.options.autoMigrate)return this.options.autoMigrate;let e;try{e=await this.config.get("repoAutoMigrate")}catch(t){if(t.code!==m.NotFoundError.code)throw t;e=!0}return e}async _migrate(e,t){return await this.version.get()>e?(C(`reverting to version ${e}`),I.revert(this.path,t,this.options,e,{ignoreLock:!0,onProgress:this.options.onMigrationProgress})):(C(`migrating to version ${e}`),I.migrate(this.path,t,this.options,e,{ignoreLock:!0,onProgress:this.options.onMigrationProgress}))}async _storageMaxStat(){try{const e=await this.config.get("Datastore.StorageMax");return BigInt(R.default(e))}catch(e){return BigInt(j)}}async _blockStat(){let e=BigInt(0),t=BigInt(0);if(this.blocks)for await(const{key:r,value:i}of this.blocks.query({}))e+=BigInt(1),t+=BigInt(i.byteLength),t+=BigInt(r.bytes.byteLength);return{count:e,size:t}}}async function M(e){let t=BigInt(0);for await(const r of e.query({}))t+=BigInt(r.value.byteLength),t+=BigInt(r.key.uint8Array().byteLength);return t}r.createRepo=function(e,t,r,i){return new D(e,t,r,i)}},{"just-safe-get":"6M8pS",debug:"bO5wM","err-code":"chZjB","ipfs-repo-migrations":"6Vgma",bytes:"7yIGD","merge-options":"fupyv","./constants.js":"kDOvV","./version.js":"4JQCP","./config.js":"1Sgmj","./spec.js":"hVqbt","./api-addr.js":"jPLmC","./idstore.js":"4g9K0","./default-options.js":"kDkh7","./default-datastore.js":"gHTwB","./errors.js":"jDxkJ","./pin-manager.js":"byEbm","./pinned-blockstore.js":"ds9CD",mortice:"b5y0B","./gc.js":"e9PbA"}],"6M8pS":[function(e,t,r){t.exports=function(e,t,r){if(!e)return r;var i,n;Array.isArray(t)&&(i=t.slice(0));"string"==typeof t&&(i=t.split("."));"symbol"==typeof t&&(i=[t]);if(!Array.isArray(i))throw new Error("props arg must be an array, a string or a symbol");for(;i.length;){if(n=i.shift(),!e)return r;if(void 0===(e=e[n]))return r}return e}},{}],"6Vgma":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../migrations/index.js"),n=e("./repo/version.js"),s=e("./errors.js"),o=e("./utils.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const c=a(e("debug")).default("ipfs:repo:migrator");function u(e){return e=e||i,Array.isArray(e)&&0!==e.length?e[e.length-1].version:0}function l(e,t,r,i=!1){let n=0;for(const s of e){if(s.version>r)break;if(s.version>t){if(i&&!s.revert)throw new f.NonReversibleMigrationError(`It is not possible to revert to version ${t} because migration version ${s.version} is not reversible. Cancelling reversion.`);n++}}if(n!==r-t)throw new f.InvalidValueError(`The ipfs-repo-migrations package does not have all migration to migrate from version ${t} to ${r}`)}const d=n.getVersion,f=s,h=i;r.errors=f,r.getCurrentRepoVersion=d,r.getLatestMigrationVersion=u,r.migrate=async function(e,t,r,s,{ignoreLock:a=!1,onProgress:d,isDryRun:h=!1,migrations:p}){if(p=p||i,!e)throw new f.RequiredParameterError("Path argument is required!");if(!r)throw new f.RequiredParameterError("repoOptions argument is required!");if(!s)throw new f.RequiredParameterError("toVersion argument is required!");if(!Number.isInteger(s)||s<=0)throw new f.InvalidValueError("Version has to be positive integer!");t=o.wrapBackends(t);const g=await n.getVersion(t);if(g===s)return void c("Nothing to migrate.");if(g>s)throw new f.InvalidValueError(`Current repo's version (${g}) is higher then toVersion (${s}), you probably wanted to revert it?`);let y;l(p,g,s),h||a||(y=await r.repoLock.lock(e));try{for(const e of p){if(void 0!==s&&e.version>s)break;if(!(e.version<=g)){c(`Migrating version ${e.version}`);try{if(!h){let r=()=>{};d&&(r=(t,r)=>d(e.version,t.toFixed(2),r)),await e.migrate(t,r)}}catch(r){const i=e.version-1;throw c(`An exception was raised during execution of migration. Setting the repo's version to last successfully migrated version: ${i}`),await n.setVersion(i,t),new Error(`During migration to version ${e.version} exception was raised: ${r.stack||r.message||r}`)}c(`Migrating to version ${e.version} finished`)}}h||await n.setVersion(s||u(p),t),c("Repo successfully migrated",void 0!==s?`to version ${s}!`:"to latest version!")}finally{h||a||!y||await y.close()}},r.migrations=h,r.revert=async function(e,t,r,s,{ignoreLock:a=!1,onProgress:u,isDryRun:d=!1,migrations:h}){if(h=h||i,!e)throw new f.RequiredParameterError("Path argument is required!");if(!r)throw new f.RequiredParameterError("repoOptions argument is required!");if(!s)throw new f.RequiredParameterError("When reverting migrations, you have to specify to which version to revert!");if(!Number.isInteger(s)||s<=0)throw new f.InvalidValueError("Version has to be positive integer!");t=o.wrapBackends(t);const p=await n.getVersion(t);if(p===s)return void c("Nothing to revert.");if(pp)){c(`Reverting migration version ${r.version}`);try{if(!d){let e=()=>{};u&&(e=(e,t)=>u(r.version,e.toFixed(2),t)),await r.revert(t,e)}}catch(e){const i=r.version;throw c(`An exception was raised during execution of migration. Setting the repo's version to last successfully reverted version: ${i}`),await n.setVersion(i,t),e.message=`During reversion to version ${r.version} exception was raised: ${e.message}`,e}c(`Reverting to version ${r.version} finished`)}}d||await n.setVersion(s,t),c(`All migrations successfully reverted to version ${s}!`)}finally{d||a||!g||await g.close()}}},{"../migrations/index.js":"lR7UE","./repo/version.js":"h9pUV","./errors.js":"dUdRa","./utils.js":"2ugL9",debug:"bO5wM"}],lR7UE:[function(e,t,r){"use strict";var i=e("./migration-8/index.js"),n=e("./migration-9/index.js"),s=e("./migration-10/index.js"),o=e("./migration-11/index.js");const a={description:"Empty migration.",migrate:()=>{},revert:()=>{},empty:!0};var c=[Object.assign({version:1},a),Object.assign({version:2},a),Object.assign({version:3},a),Object.assign({version:4},a),Object.assign({version:5},a),Object.assign({version:6},a),Object.assign({version:7},a),i.migration,n.migration,s.migration,o.migration];t.exports=c},{"./migration-8/index.js":"iqKuU","./migration-9/index.js":"bq0Kw","./migration-10/index.js":"qHC3R","./migration-11/index.js":"5Bi4X"}],iqKuU:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("interface-datastore/key"),s=e("debug"),o=e("it-length"),a=e("multiformats/bases/base32"),c=e("multiformats/codecs/raw"),u=e("multiformats/hashes/digest");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function d(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var f=l(s),h=l(o),p=d(c),g=d(u);const y=f.default("ipfs:repo:migrator:migration-8");function m(e){return e.child?m(e.child):e}function b(e){try{const t=a.base32.decode(`b${e.toString().toLowerCase().slice(1)}`),r=i.CID.decode(t).multihash.bytes,s=a.base32.encode(r).slice(1).toUpperCase();return new n.Key(`/${s}`,!1)}catch(t){return e}}function v(e){try{const t=a.base32.decode(`b${e.toString().toLowerCase().slice(1)}`),r=g.decode(t),s=a.base32.encode(i.CID.createV1(p.code,r).bytes).slice(1);return new n.Key(`/${s.toUpperCase()}`,!1)}catch{return e}}async function w(e,t,r){const i=e.blocks;await i.open();const n=m(i),s=await h.default(n.queryKeys({filters:[e=>r(e).toString()!==e.toString()]}));try{let e=0;for await(const i of n.query({})){const o=r(i.key);o.toString()!==i.key.toString()&&(e+=1,y(`Migrating Block from ${i.key} to ${o}`,await n.has(i.key)),await n.delete(i.key),await n.put(o,i.value),t(e/s*100,`Migrated Block from ${i.key} to ${o}`))}}finally{await i.close()}}const _={version:8,description:"Transforms key names into base32 encoding and converts Block store to use bare multihashes encoded as base32",migrate:(e,t=(()=>{}))=>w(e,t,b),revert:(e,t=(()=>{}))=>w(e,t,v)};r.migration=_},{"multiformats/cid":"9ooAY","interface-datastore/key":"9hGOz",debug:"bO5wM","it-length":"6ksGI","multiformats/bases/base32":"5k9Tu","multiformats/codecs/raw":"fdfgp","multiformats/hashes/digest":"kpRBg"}],"6ksGI":[function(e,t,r){"use strict";t.exports=async e=>{let t=0;for await(const r of e)t++;return t}},{}],bq0Kw:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("@ipld/dag-pb"),s=e("cborg"),o=e("./pin-set.js"),a=e("./utils.js"),c=e("it-length"),u=e("multiformats/hashes/sha2"),l=e("multiformats/hashes/digest"),d=e("multiformats/bases/base32");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function h(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var p=h(n),g=h(s),y=f(c),m=h(l);async function b(e,t,r,n){if(!await t.has(a.PIN_DS_KEY))return;const s=await t.get(a.PIN_DS_KEY),c=i.CID.decode(s),u=await e.get(c),l=p.decode(u);let d=0;const f=await y.default(o.loadSet(e,l,a.PinTypes.recursive))+await y.default(o.loadSet(e,l,a.PinTypes.direct));for await(const t of o.loadSet(e,l,a.PinTypes.recursive)){d++;const e={depth:1/0};0!==t.version&&(e.version=t.version),t.code!==p.code&&(e.codec=t.code),await r.put(a.cidToKey(t),g.encode(e)),n(d/f*100,`Migrated recursive pin ${t}`)}for await(const t of o.loadSet(e,l,a.PinTypes.direct)){d++;const e={depth:0};0!==t.version&&(e.version=t.version),t.code!==p.code&&(e.codec=t.code),await r.put(a.cidToKey(t),g.encode(e)),n(d/f*100,`Migrated direct pin ${t}`)}await e.delete(c),await t.delete(a.PIN_DS_KEY)}async function v(e,t,r,n){const s=[],c=[];let l=0;const f=await y.default(r.queryKeys({}));for await(const{key:e,value:t}of r.query({})){l++;const r=g.decode(t),o=i.CID.create(r.version||0,r.codec||p.code,m.decode(d.base32.decode("b"+e.toString().toLowerCase().split("/").pop())));0===r.depth?(n(l/f*100,`Reverted direct pin ${o}`),c.push(o)):(n(l/f*100,`Reverted recursive pin ${o}`),s.push(o))}n(100,"Updating pin root");const h={Links:[await o.storeSet(e,a.PinTypes.direct,c),await o.storeSet(e,a.PinTypes.recursive,s)]},b=p.encode(h),v=await u.sha256.digest(b),w=i.CID.createV0(v);await e.put(w,b),await t.put(a.PIN_DS_KEY,w.bytes)}async function w(e,t,r){const i=e.blocks,n=e.datastore,s=e.pins;await i.open(),await n.open(),await s.open();try{await r(i,n,s,t)}finally{await s.close(),await n.close(),await i.close()}}const _={version:9,description:"Migrates pins to datastore",migrate:(e,t=(()=>{}))=>w(e,t,b),revert:(e,t=(()=>{}))=>w(e,t,v)};r.migration=_},{"multiformats/cid":"9ooAY","@ipld/dag-pb":"i2cdx",cborg:"iZrkE","./pin-set.js":"4k7S6","./utils.js":"iretC","it-length":"6ksGI","multiformats/hashes/sha2":"7i9MT","multiformats/hashes/digest":"kpRBg","multiformats/bases/base32":"5k9Tu"}],"4k7S6":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("./pin.js"),s=e("fnv1a"),o=e("varint"),a=e("@ipld/dag-pb"),c=e("./utils.js"),u=e("uint8arrays/concat"),l=e("uint8arrays/compare"),d=e("uint8arrays/to-string"),f=e("uint8arrays/from-string"),h=e("multiformats/hashes/sha2");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function g(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var y=p(s),m=p(o),b=g(a);const v=n.ipfs.pin.Set;async function*w(e,t){const r=function(e){const t=e.Data;if(!t)throw new Error("No data present");const r=m.default.decode(t),i=m.default.decode.bytes;if(i<=0)throw new Error("Invalid Set header length");if(i+r>t.length)throw new Error("Impossibly large set header length");const n=t.slice(i,r+i),s=v.toObject(v.decode(n),{defaults:!1,arrays:!0,longs:Number,objects:!1});if(1!==s.version)throw new Error(`Unsupported Set version: ${s.version}`);if(s.fanout>e.Links.length)throw new Error("Impossibly large fanout");return{header:s,data:t.slice(r+i)}}(t);let i=0;for(const n of t.Links){if(i({link:{Name:"",Tsize:1,Hash:e.key},data:e.data||new Uint8Array}))).sort(((e,t)=>l.compare(e.link.Hash.bytes,t.link.Hash.bytes))),t=p.concat(e.map((e=>e.link)));return{Data:u.concat([a,...e.map((e=>e.data))]),Links:t}}{const e=r.reduce(((e,t)=>{const r=function(e,t){const r=new Uint8Array(4);new DataView(r.buffer).setUint32(0,e,!0);const i=f.fromString(t.toString()),n=u.concat([r,i],r.byteLength+i.byteLength);return y.default(d.toString(n))}(n,t.key)%c.DEFAULT_FANOUT;return e[r]=r in e?e[r].concat([t]):[t],e}),[]);let i=0;for(const r of e){const e=await t(r,n+1);await g(e,i),i++}return{Data:a,Links:p}}async function g(t,r){const n=b.encode(t),s=await h.sha256.digest(n),o=i.CID.createV0(s);await e.put(o,n);const a=t.Links.reduce(((e,t)=>e+(t.Tsize||0)),0)+n.length;p[r]={Name:"",Tsize:a,Hash:o}}}(t,0)}r.loadSet=async function*(e,t,r){const i=t.Links.find((e=>e.Name===r));if(!i)throw new Error("No link found with name "+r);const n=await e.get(i.Hash),s=b.decode(n);yield*w(e,s)},r.storeSet=async function(e,t,r){const n=await _(e,r.map((e=>({key:e})))),s=b.encode(n),o=await h.sha256.digest(s),a=i.CID.createV0(o);return await e.put(a,s),{Name:t,Tsize:n.Links.reduce(((e,t)=>e+t.Tsize),0)+s.length,Hash:a}}},{"multiformats/cid":"9ooAY","./pin.js":"0pDow",fnv1a:"9l12K",varint:"aN1CO","@ipld/dag-pb":"i2cdx","./utils.js":"iretC","uint8arrays/concat":"4EBjG","uint8arrays/compare":"2xv9i","uint8arrays/to-string":"hC8JB","uint8arrays/from-string":"dF7Y4","multiformats/hashes/sha2":"7i9MT"}],"0pDow":[function(e,t,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(r,"__esModule",{value:!0});var n=i(e("protobufjs/minimal.js"));const s=n.default.Reader,o=n.default.Writer,a=(n.default.util,n.default.roots.default||(n.default.roots.default={})),c=a.ipfs=(()=>{const e={};return e.pin=function(){const e={};return e.Set=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:i.version=e.uint32();break;case 2:i.fanout=e.uint32();break;case 3:i.seed=e.fixed32();break;default:e.skipType(7&n)}}return i},e.fromObject=function(e){if(e instanceof a.ipfs.pin.Set)return e;var t=new a.ipfs.pin.Set;return null!=e.version&&(t.version=e.version>>>0),null!=e.fanout&&(t.fanout=e.fanout>>>0),null!=e.seed&&(t.seed=e.seed>>>0),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.version=0,r.fanout=0,r.seed=0),null!=e.version&&e.hasOwnProperty("version")&&(r.version=e.version),null!=e.fanout&&e.hasOwnProperty("fanout")&&(r.fanout=e.fanout),null!=e.seed&&e.hasOwnProperty("seed")&&(r.seed=e.seed),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,n.default.util.toJSONOptions)},e}(),e}(),e})();r.default=a,r.ipfs=c},{"protobufjs/minimal.js":"grAXL"}],"9l12K":[function(e,t,r){function i(e){for(var t=i.BASE,r=0,n=e.length;r>>0}i.BASE=2166136261,t.exports=i},{}],iretC:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("interface-datastore/key"),n=e("multiformats/bases/base32"),s=e("multiformats/cid");const o=new i.Key("/local/pins"),a=s.CID.parse("QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n");r.DEFAULT_FANOUT=256,r.EMPTY_KEY=a,r.MAX_ITEMS=8192,r.PIN_DS_KEY=o,r.PinTypes={direct:"direct",recursive:"recursive"},r.cidToKey=function(e){return new i.Key(`/${n.base32.encode(e.multihash.bytes).toUpperCase().substring(1)}`)}},{"interface-datastore/key":"9hGOz","multiformats/bases/base32":"5k9Tu","multiformats/cid":"9ooAY"}],"2xv9i":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.compare=function(e,t){for(let r=0;rt[r])return 1}return e.byteLength>t.byteLength?1:e.byteLength{})){const s=i.findLevelJs(t);if(!s)return void r(`${e} did not need an upgrade`);r(`Upgrading ${e}`);await d(s,((e,t)=>[{type:"del",key:e},{type:"put",key:n.fromString(e),value:t}]))}async function a(e,t,r=(()=>{})){const n=i.findLevelJs(t);if(!n)return void r(`${e} did not need a downgrade`);r(`Downgrading ${e}`);await d(n,((e,t)=>[{type:"del",key:e},{type:"put",key:s.toString(e),value:t}]))}function c(e){return e.child?c(e.child):e}async function u(e,t,r){const i=Object.entries(e).map((([e,t])=>({key:e,backend:c(t)}))).filter((({key:e,backend:t})=>"LevelDatastore"===t.constructor.name)).map((({key:e,backend:t})=>({name:e,store:t})));t(0,`Migrating ${i.length} dbs`);let n=0;const s=e=>{t(Math.round(n/i.length*100),e)};for(const{name:e,store:t}of i){await t.open();try{await r(e,t,s)}finally{n++,await t.close()}}t(100,`Migrated ${i.length} dbs`)}const l={version:10,description:"Migrates datastore-level keys to binary",migrate:(e,t=(()=>{}))=>u(e,t,o),revert:(e,t=(()=>{}))=>u(e,t,a)};function d(e,t){return new Promise(((r,i)=>{const n=e.iterator();n._deserializeKey=n._deserializeValue=e=>e,function s(){const o=(o,a,c)=>{if(o||void 0===a){const e=e=>{e?i(e):r()};n.end(e)}else!function(t,r){const i=e.store("readwrite"),n=i.transaction;let s,o=0;n.onabort=()=>r(s||n.error||new Error("aborted by user")),n.oncomplete=()=>r(),function e(){const r=t[o++],a=r.key;let c;try{c="del"===r.type?i.delete(a):i.put(r.value,a)}catch(e){return s=e,void n.abort()}o{const i=n.store("readonly").get(e.toString());i.transaction.onabort=()=>{r(i.transaction.error)},i.transaction.oncomplete=()=>{t(Boolean(i.result))}}))}function u(e){const t=e.get.bind(e),r=e.has.bind(e);return e.get=i=>async function(e,t,r,i){if(await r(e))return t(e);const s=a(i);if(!s)throw n.notFoundError();return new Promise(((t,r)=>{const i=s.store("readonly").get(e.toString());i.transaction.onabort=()=>{r(i.transaction.error)},i.transaction.oncomplete=()=>{if(i.result)return t(i.result);r(n.notFoundError())}}))}(i,t,r,e),e.has=t=>c(t,r,e),e}r.CONFIG_KEY=s,r.VERSION_KEY=o,r.findLevelJs=a,r.hasWithFallback=c,r.wrapBackends=function(e){return{...e,root:u(e.root),datastore:u(e.datastore),pins:u(e.pins),keys:u(e.keys)}}},{"interface-datastore/key":"9hGOz","datastore-core/errors":"65M4b"}],"5Bi4X":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const i=new(e("interface-datastore/key").Key)("/local/filesroot");const n={version:11,description:"Store mfs root in the datastore",migrate:async function(e,t=(()=>{})){if(t(100,"Migrating MFS root to repo datastore"),await e.root.open(),await e.datastore.open(),await e.root.has(i)){const t=await e.root.get(i);await e.datastore.put(i,t),await e.root.delete(i)}await e.datastore.close(),await e.root.close(),t(100,"Stored MFS root in repo datastore")},revert:async function(e,t=(()=>{})){if(t(100,"Migrating MFS root to repo root datastore"),await e.root.open(),await e.datastore.open(),await e.datastore.has(i)){const t=await e.datastore.get(i);await e.root.put(i,t),await e.datastore.delete(i)}await e.datastore.close(),await e.root.close(),t(100,"Stored MFS root in repo root datastore")}};r.migration=n},{"interface-datastore/key":"9hGOz"}],h9pUV:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./init.js"),n=e("../errors.js"),s=e("../utils.js"),o=e("uint8arrays/from-string"),a=e("uint8arrays/to-string");r.getVersion=async function(e){if(!await i.isRepoInitialized(e))throw new n.NotInitializedRepoError("Repo is not initialized!");const t=e.root;await t.open();try{return parseInt(a.toString(await t.get(s.VERSION_KEY)))}finally{await t.close()}},r.setVersion=async function(e,t){if(!t)throw new n.MissingRepoOptionsError("Please pass repo options when trying to open a repo");const r=t.root;await r.open(),await r.put(s.VERSION_KEY,o.fromString(String(e))),await r.close()}},{"./init.js":"fVppP","../errors.js":"dUdRa","../utils.js":"2ugL9","uint8arrays/from-string":"dF7Y4","uint8arrays/to-string":"hC8JB"}],fVppP:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("debug"),n=e("../utils.js"),s=e("../errors.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const a=o(i).default("ipfs:repo:migrator:repo:init");r.isRepoInitialized=async function(e){if(!e)throw new s.MissingRepoOptionsError("Please pass repo options when trying to open a repo");const t=e.root;try{await t.open();const e=await t.has(n.VERSION_KEY),r=await t.has(n.CONFIG_KEY);return!(!e||!r)||(a(`Version entry present: ${e}`),a(`Config entry present: ${r}`),!1)}catch(e){return a("While checking if repo is initialized error was thrown: "+e.message),!1}finally{if(void 0!==t)try{await t.close()}catch{}}}},{debug:"bO5wM","../utils.js":"2ugL9","../errors.js":"dUdRa"}],dUdRa:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});class i extends Error{constructor(e){super(e),this.name="NonReversibleMigrationError",this.code=i.code,this.message=e}}i.code="ERR_NON_REVERSIBLE_MIGRATION";class n extends Error{constructor(e){super(e),this.name="NotInitializedRepoError",this.code=n.code,this.message=e}}n.code="ERR_NOT_INITIALIZED_REPO";class s extends Error{constructor(e){super(e),this.name="RequiredParameterError",this.code=s.code,this.message=e}}s.code="ERR_REQUIRED_PARAMETER";class o extends Error{constructor(e){super(e),this.name="InvalidValueError",this.code=o.code,this.message=e}}o.code="ERR_INVALID_VALUE";class a extends Error{constructor(e){super(e),this.name="MissingRepoOptionsError",this.code=a.code,this.message=e}}a.code="ERR_MISSING_REPO_OPTIONS",r.InvalidValueError=o,r.MissingRepoOptionsError=a,r.NonReversibleMigrationError=i,r.NotInitializedRepoError=n,r.RequiredParameterError=s},{}],"7yIGD":[function(e,t,r){ /*! * bytes * Copyright(c) 2012-2014 TJ Holowaychuk * Copyright(c) 2015 Jed Watson * MIT Licensed */ "use strict";t.exports=function(e,t){return"string"==typeof e?c(e):"number"==typeof e?a(e,t):null},t.exports.format=a,t.exports.parse=c;var i=/\B(?=(\d{3})+(?!\d))/g,n=/(?:\.0*|(\.[^0]+)0+)$/,s={b:1,kb:1024,mb:1048576,gb:1073741824,tb:Math.pow(1024,4),pb:Math.pow(1024,5)},o=/^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;function a(e,t){if(!Number.isFinite(e))return null;var r=Math.abs(e),o=t&&t.thousandsSeparator||"",a=t&&t.unitSeparator||"",c=t&&void 0!==t.decimalPlaces?t.decimalPlaces:2,u=Boolean(t&&t.fixedDecimals),l=t&&t.unit||"";l&&s[l.toLowerCase()]||(l=r>=s.pb?"PB":r>=s.tb?"TB":r>=s.gb?"GB":r>=s.mb?"MB":r>=s.kb?"KB":"B");var d=(e/s[l.toLowerCase()]).toFixed(c);return u||(d=d.replace(n,"$1")),o&&(d=d.split(".").map((function(e,t){return 0===t?e.replace(i,o):e})).join(".")),d+a+l}function c(e){if("number"==typeof e&&!isNaN(e))return e;if("string"!=typeof e)return null;var t,r=o.exec(e),i="b";return r?(t=parseFloat(r[1]),i=r[4].toLowerCase()):(t=parseInt(e,10),i="b"),Math.floor(s[i]*t)}},{}],"4JQCP":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("interface-datastore/key"),n=e("debug"),s=e("uint8arrays/to-string"),o=e("uint8arrays/from-string"),a=e("./utils/level.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const u=c(n).default("ipfs:repo:version"),l=new i.Key("version");r.version=function(e){return{exists:async()=>a.hasWithFallback(l,e.has.bind(e),e),async get(){const t=await a.getWithFallback(l,e.get.bind(e),e.has.bind(e),e);return parseInt(s.toString(t),10)},set:t=>e.put(l,o.fromString(String(t))),async check(e){const t=await this.get();u("comparing version: %s and %s",t,e);return t===e||(6===t&&7===e||6===e&&7===t)}}}},{"interface-datastore/key":"9hGOz",debug:"bO5wM","uint8arrays/to-string":"hC8JB","uint8arrays/from-string":"dF7Y4","./utils/level.js":"hR5hb"}],hR5hb:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../errors.js");function n(e){let t=e;for(;t.db||t.child;)if(t=t.db||t.child,"level-js"===t.type||"Level"===t.constructor.name)return t}r.getWithFallback=async function(e,t,r,s){if(await r(e))return t(e);const o=n(s);if(!o)throw new i.NotFoundError;return new Promise(((t,r)=>{const n=o.store("readonly").get(e.toString());n.transaction.onabort=()=>{r(n.transaction.error)},n.transaction.oncomplete=()=>{if(n.result)return t(n.result);r(new i.NotFoundError)}}))},r.hasWithFallback=async function(e,t,r){const i=await t(e);if(i)return i;const s=n(r);return!!s&&new Promise(((t,r)=>{const i=s.store("readonly").get(e.toString());i.transaction.onabort=()=>{r(i.transaction.error)},i.transaction.oncomplete=()=>{t(Boolean(i.result))}}))}},{"../errors.js":"jDxkJ"}],jDxkJ:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});class i extends Error{constructor(e){super(e),this.name="LockExistsError",this.code=i.code}}i.code="ERR_LOCK_EXISTS";class n extends Error{constructor(e){super(e),this.name="NotFoundError",this.code=n.code}}n.code="ERR_NOT_FOUND";class s extends Error{constructor(e){super(e),this.name="InvalidRepoVersionError",this.code=s.code}}s.code="ERR_INVALID_REPO_VERSION";r.ERR_REPO_ALREADY_CLOSED="ERR_REPO_ALREADY_CLOSED",r.ERR_REPO_ALREADY_OPEN="ERR_REPO_ALREADY_OPEN",r.ERR_REPO_NOT_INITIALIZED="ERR_REPO_NOT_INITIALIZED",r.InvalidRepoVersionError=s,r.LockExistsError=i,r.NotFoundError=n},{}],"1Sgmj":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("interface-datastore/key"),n=e("p-queue"),s=e("just-safe-get"),o=e("just-safe-set"),a=e("err-code"),c=e("./errors.js"),u=e("uint8arrays/to-string"),l=e("uint8arrays/from-string"),d=e("./utils/level.js");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=f(n),p=f(s),g=f(o),y=f(a);const m=h.default.default?h.default.default:h.default,b=new i.Key("config");r.config=function(e){const t=new m({concurrency:1}),r={async getAll(t={}){const r=await d.getWithFallback(b,e.get.bind(e),e.has.bind(e),e);return JSON.parse(u.toString(r))},async get(e,t={}){if(null==e)throw new c.NotFoundError(`Key ${e} does not exist in config`);const r=await this.getAll(t),i=p.default(r,e);if(void 0===i)throw new c.NotFoundError(`Key ${e} does not exist in config`);return i},set(e,r,n={}){if("string"!=typeof e&&!(e instanceof String))throw y.default(new Error("Invalid key type: "+typeof e),"ERR_INVALID_KEY");if(void 0===r||r instanceof Uint8Array)throw y.default(new Error("Invalid value type: "+typeof r),"ERR_INVALID_VALUE");return t.add((()=>i({key:e,value:r},n.signal)))},replace(e,r={}){if(!e||e instanceof Uint8Array)throw y.default(new Error("Invalid value type: "+typeof e),"ERR_INVALID_VALUE");return t.add((()=>i({key:void 0,value:e},r.signal)))},exists:async()=>d.hasWithFallback(b,e.has.bind(e),e)};async function i(e,t){if(t&&t.aborted)return;const i=e.key,s=e.value;if(i){const e=await r.getAll();return"object"==typeof e&&null!==e&&g.default(e,i,s),n(e)}return n(s)}function n(t){const r=l.fromString(JSON.stringify(t,null,2));return e.put(b,r)}return r}},{"interface-datastore/key":"9hGOz","p-queue":"biPlv","just-safe-get":"6M8pS","just-safe-set":"glUwm","err-code":"chZjB","./errors.js":"jDxkJ","uint8arrays/to-string":"hC8JB","uint8arrays/from-string":"dF7Y4","./utils/level.js":"hR5hb"}],hVqbt:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("interface-datastore"),n=e("sort-keys"),s=e("uint8arrays/to-string"),o=e("uint8arrays/from-string");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=a(n);const u=new i.Key("datastore_spec");r.spec=function(e){return{exists:()=>e.has(u),async get(){const t=await e.get(u);return JSON.parse(s.toString(t))},set:async t=>e.put(u,o.fromString(JSON.stringify(c.default(t,{deep:!0}))))}}},{"interface-datastore":"1Ax6d","sort-keys":"lwzsm","uint8arrays/to-string":"hC8JB","uint8arrays/from-string":"dF7Y4"}],lwzsm:[function(e,t,r){"use strict";const i=e("is-plain-obj");t.exports=(e,t={})=>{if(!i(e)&&!Array.isArray(e))throw new TypeError("Expected a plain object or array");const{deep:r}=t,n=[],s=[],o=e=>{const t=n.indexOf(e);if(-1!==t)return s[t];const r=[];return n.push(e),s.push(r),r.push(...e.map((e=>Array.isArray(e)?o(e):i(e)?a(e):e))),r},a=e=>{const c=n.indexOf(e);if(-1!==c)return s[c];const u={},l=Object.keys(e).sort(t.compare);n.push(e),s.push(u);for(const t of l){const n=e[t];let s;s=r&&Array.isArray(n)?o(n):r&&i(n)?a(n):n,Object.defineProperty(u,t,{...Object.getOwnPropertyDescriptor(e,t),value:s})}return u};return Array.isArray(e)?r?o(e):e.slice():a(e)}},{"is-plain-obj":"jGt65"}],jPLmC:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("interface-datastore/key"),n=e("uint8arrays/from-string");const s=new i.Key("api");r.apiAddr=function(e){return{async get(){const t=await e.get(s);return t&&t.toString()},set:t=>e.put(s,n.fromString(t.toString())),delete:()=>e.delete(s)}}},{"interface-datastore/key":"9hGOz","uint8arrays/from-string":"dF7Y4"}],"4g9K0":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("it-filter"),n=e("it-pushable"),s=e("it-drain"),o=e("multiformats/cid"),a=e("err-code"),c=e("multiformats/hashes/identity");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=u(i),d=u(n),f=u(s),h=u(a);function p(e){const t=o.CID.asCID(e);if(null==t)throw h.default(new Error("Not a valid cid"),"ERR_INVALID_CID");return t.multihash.code!==c.identity.code?{isIdentity:!1}:{isIdentity:!0,digest:t.multihash.digest}}r.createIdStore=function(e){return{open:()=>e.open(),close:()=>e.close(),query:(t,r)=>e.query(t,r),queryKeys:(t,r)=>e.queryKeys(t,r),async get(t,r){const i=p(t);return i.isIdentity?Promise.resolve(i.digest):e.get(t,r)},async*getMany(e,t){for await(const r of e)yield this.get(r,t)},async put(t,r,i){const{isIdentity:n}=p(t);n||await e.put(t,r,i)},async*putMany(t,r){const i=d.default();(globalThis.process&&globalThis.process.nextTick?globalThis.process.nextTick:globalThis.setImmediate||globalThis.setTimeout)((async()=>{try{await f.default(e.putMany(async function*(){for await(const{key:e,value:r}of t)p(e).isIdentity||(yield{key:e,value:r}),i.push({key:e,value:r})}())),i.end()}catch(e){i.end(e)}})),yield*i},has(t,r){const{isIdentity:i}=p(t);return i?Promise.resolve(!0):e.has(t,r)},delete(t,r){const{isIdentity:i}=p(t);return i?Promise.resolve():e.delete(t,r)},deleteMany:(t,r)=>e.deleteMany(l.default(t,(e=>!p(e).isIdentity)),r),batch(){const t=e.batch();return{put(e,r){const{isIdentity:i}=p(e);i||t.put(e,r)},delete(e){const{isIdentity:r}=p(e);r||t.delete(e)},commit:e=>t.commit(e)}}}}},{"it-filter":"5LCTL","it-pushable":"bnpei","it-drain":"dKYhO","multiformats/cid":"9ooAY","err-code":"chZjB","multiformats/hashes/identity":"eYCZn"}],kDkh7:[function(e,t,r){"use strict";var i={autoMigrate:!0,onMigrationProgress:()=>{},repoOwner:!0,repoLock:e("./locks/memory.js").MemoryLock};t.exports=i},{"./locks/memory.js":"xMQlv"}],xMQlv:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../errors.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const s=n(e("debug")).default("ipfs:repo:lock:memory"),o="repo.lock",a={};const c={lock:async function(e){const t=e+"/"+o;if(s("locking %s",t),!0===a[t])throw new i.LockExistsError(`Lock already being held for file: ${t}`);return a[t]=!0,{async close(){a[t]&&delete a[t]}}},locked:async function(e){const t=e+"/"+o;return s(`checking lock: ${t}`),Boolean(a[t])}};r.MemoryLock=c},{"../errors.js":"jDxkJ",debug:"bO5wM"}],gHTwB:[function(e,t,r){"use strict";t.exports={Spec:{type:"mount",mounts:[{mountpoint:"/blocks",type:"measure",prefix:"flatfs.datastore",child:{type:"flatfs",path:"blocks",sync:!0,shardFunc:"/repo/flatfs/shard/v1/next-to-last/2"}},{mountpoint:"/",type:"measure",prefix:"leveldb.datastore",child:{type:"levelds",path:"datastore",compression:"none"}}]}}},{}],byEbm:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("err-code"),s=e("debug"),o=e("it-first"),a=e("multiformats/block"),c=e("cborg"),u=e("@ipld/dag-pb"),l=e("./utils/blockstore.js"),d=e("./utils/walk-dag.js"),f=e("./pin-types.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function p(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var g=h(n),y=h(s),m=h(o),b=p(c),v=p(u);r.PinManager=class{constructor({pinstore:e,blockstore:t,loadCodec:r}){this.pinstore=e,this.blockstore=t,this.loadCodec=r,this.log=y.default("ipfs:repo:pin"),this.directPins=new Set,this.recursivePins=new Set}async pinDirectly(e,t={}){await this.blockstore.get(e,t);const r={depth:0};return 0!==e.version&&(r.version=e.version),e.code!==v.code&&(r.codec=e.code),t.metadata&&(r.metadata=t.metadata),this.pinstore.put(l.cidToKey(e),b.encode(r))}unpin(e,t){return this.pinstore.delete(l.cidToKey(e),t)}async pinRecursively(e,t={}){await this.fetchCompleteDag(e,t);const r={depth:1/0};0!==e.version&&(r.version=e.version),e.code!==v.code&&(r.codec=e.code),t.metadata&&(r.metadata=t.metadata),await this.pinstore.put(l.cidToKey(e),b.encode(r))}async*directKeys(e){for await(const e of this.pinstore.query({filters:[e=>0===b.decode(e.value).depth]})){const t=b.decode(e.value),r=t.version||0,n=null!=t.codec?t.codec:v.code,s=l.keyToMultihash(e.key);yield{cid:i.CID.create(r,n,s),metadata:t.metadata}}}async*recursiveKeys(e){for await(const e of this.pinstore.query({filters:[e=>b.decode(e.value).depth===1/0]})){const t=b.decode(e.value),r=t.version||0,n=null!=t.codec?t.codec:v.code,s=l.keyToMultihash(e.key);yield{cid:i.CID.create(r,n,s),metadata:t.metadata}}}async*indirectKeys(e){for await(const{cid:t}of this.recursiveKeys())for await(const r of d.walkDag(t,this.blockstore,this.loadCodec,e)){const e=[f.PinTypes.recursive];(await this.isPinnedWithType(r,e)).pinned||(yield r)}}async isPinnedWithType(e,t,r){Array.isArray(t)||(t=[t]);const i=t.includes(f.PinTypes.all),n=t.includes(f.PinTypes.direct),s=t.includes(f.PinTypes.recursive),o=t.includes(f.PinTypes.indirect);if(s||n||i){const r=await m.default(this.pinstore.query({prefix:l.cidToKey(e).toString(),filters:[e=>{if(i)return!0;const r=b.decode(e.value);return t.includes(0===r.depth?f.PinTypes.direct:f.PinTypes.recursive)}],limit:1}));if(r){const t=b.decode(r.value);return{cid:e,pinned:!0,reason:0===t.depth?f.PinTypes.direct:f.PinTypes.recursive,metadata:t.metadata}}}const a=this;if(i||o){const t=await m.default(async function*(e,t){for await(const{cid:r}of t)for await(const t of d.walkDag(r,a.blockstore,a.loadCodec))if(t.equals(e))return void(yield r)}(e,this.recursiveKeys()));if(t)return{cid:e,pinned:!0,reason:f.PinTypes.indirect,parent:t}}return{cid:e,pinned:!1}}async fetchCompleteDag(e,t){const r=new Set,i=async(e,t)=>{if(r.has(e.toString()))return;r.add(e.toString());const n=await this.blockstore.get(e,t),s=await this.loadCodec(e.code),o=a.createUnsafe({bytes:n,cid:e,codec:s});await Promise.all([...o.links()].map((([,e])=>i(e,t))))};await i(e,t)}static checkPinType(e){if("string"!=typeof e||!Object.keys(f.PinTypes).includes(e))throw function(e){const t=`Invalid type '${e}', must be one of {direct, indirect, recursive, all}`;return g.default(new Error(t),"ERR_INVALID_PIN_TYPE")}(e);return!0}}},{"multiformats/cid":"9ooAY","err-code":"chZjB",debug:"bO5wM","it-first":"hBrkP","multiformats/block":"i1Z6F",cborg:"iZrkE","@ipld/dag-pb":"i2cdx","./utils/blockstore.js":"gV6JY","./utils/walk-dag.js":"2YVIq","./pin-types.js":"uek22"}],gV6JY:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("interface-datastore/key"),n=e("multiformats"),s=e("multiformats/codecs/raw"),o=e("err-code"),a=e("multiformats/bases/base32"),c=e("multiformats/hashes/digest");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var d=l(s),f=u(o),h=l(c);function p(e){return h.decode(a.base32.decode(`b${e.toString().toLowerCase().substring(1)}`))}r.cidToKey=function(e){const t=n.CID.asCID(e);if(null==t)throw f.default(new Error("Not a valid cid"),"ERR_INVALID_CID");const r=a.base32.encode(t.multihash.bytes);return new i.Key("/"+r.slice(1).toUpperCase(),!1)},r.keyToCid=function(e){return n.CID.createV1(d.code,p(e))},r.keyToMultihash=p},{"interface-datastore/key":"9hGOz",multiformats:"3ANyW","multiformats/codecs/raw":"fdfgp","err-code":"chZjB","multiformats/bases/base32":"5k9Tu","multiformats/hashes/digest":"kpRBg"}],"2YVIq":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("debug"),n=e("multiformats/block");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const o=s(i).default("ipfs:repo:utils:walk-dag");r.walkDag=async function*e(t,r,i,s){try{const o=await r.get(t,s),a=await i(t.code),c=n.createUnsafe({bytes:o,cid:t,codec:a});for(const[,t]of c.links())yield t,yield*e(t,r,i,s)}catch(e){throw o("Could not walk DAG for CID",t.toString(),e),e}}},{debug:"bO5wM","multiformats/block":"i1Z6F"}],ds9CD:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("it-map"),n=e("err-code"),s=e("./pin-types.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(i),c=o(n);async function u(e,t){const{pinned:r,reason:i}=await t.isPinnedWithType(e,s.PinTypes.all);if(r)throw c.default(new Error(`pinned: ${i}`),"ERR_BLOCK_PINNED")}r.createPinnedBlockstore=function(e,t){return{open:()=>t.open(),close:()=>t.close(),query:(e,r)=>t.query(e,r),queryKeys:(e,r)=>t.queryKeys(e,r),get:async(e,r)=>t.get(e,r),async*getMany(e,r){yield*t.getMany(e,r)},async put(e,r,i){await t.put(e,r,i)},async*putMany(e,r){yield*t.putMany(e,r)},has:(e,r)=>t.has(e,r),delete:async(r,i)=>(await u(r,e),t.delete(r,i)),deleteMany:(r,i)=>t.deleteMany(a.default(r,(async t=>(await u(t,e),t))),i),batch:()=>t.batch()}}},{"it-map":"eeqPk","err-code":"chZjB","./pin-types.js":"uek22"}],e9PbA:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("debug"),s=e("datastore-core/errors"),o=e("it-parallel-batch"),a=e("it-pipe"),c=e("it-merge"),u=e("it-map"),l=e("it-filter"),d=e("interface-datastore/key"),f=e("multiformats/bases/base32"),h=e("./utils/walk-dag.js");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g=p(n),y=p(o),m=p(c),b=p(u),v=p(l);const w=g.default("ipfs:repo:gc"),_=s.notFoundError().code,E=new d.Key("/local/filesroot");r.gc=function({gcLock:e,pins:t,blockstore:r,root:n,loadCodec:s}){return async function*(){const o=Date.now();w("Creating set of marked blocks");const c=await e.writeLock();try{const e=await async function({pins:e,blockstore:t,loadCodec:r,root:n}){const s=async function*(){let e;try{e=await n.get(E)}catch(e){if(e.code===_)return void w("No blocks in MFS");throw e}const s=i.CID.decode(e);yield s,yield*h.walkDag(s,t,r)}(),o=m.default(b.default(e.recursiveKeys(),(({cid:e})=>e)),e.indirectKeys(),b.default(e.directKeys(),(({cid:e})=>e)),s),a=new Set;for await(const e of m.default(o,s))a.add(f.base32.encode(e.multihash.bytes));return a}({pins:t,blockstore:r,root:n,loadCodec:s}),u=r.queryKeys({});yield*async function*({blockstore:e},t,r){let i=0,n=0;const s=async r=>async function(){i++;try{const i=f.base32.encode(r.multihash.bytes);if(t.has(i))return null;try{await e.delete(r),n++}catch(e){return{err:new Error(`Could not delete block with CID ${r}: ${e.message}`)}}return{cid:r}}catch(e){const t=`Could delete block with CID ${r}`;return w(t,e),{err:new Error(t+`: ${e.message}`)}}};yield*a.pipe(y.default(b.default(r,s),256),(e=>v.default(e,Boolean))),w(`Marked set has ${t.size} unique blocks. Blockstore has ${i} blocks. Deleted ${n} blocks.`)}({blockstore:r},e,u),w(`Complete (${Date.now()-o}ms)`)}finally{c()}}}},{"multiformats/cid":"9ooAY",debug:"bO5wM","datastore-core/errors":"65M4b","it-parallel-batch":"lPBqc","it-pipe":"giKBQ","it-merge":"cPFu3","it-map":"eeqPk","it-filter":"5LCTL","interface-datastore/key":"9hGOz","multiformats/bases/base32":"5k9Tu","./utils/walk-dag.js":"2YVIq"}],"3taGN":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("interface-datastore"),n=e("datastore-core"),s=e("it-filter"),o=e("it-map"),a=e("it-take"),c=e("it-sort"),u=e("level");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=l(s),f=l(o),h=l(a),p=l(c),g=l(u);class y extends n.BaseDatastore{constructor(e,t){super(),this.path=e,this.opts=t,t&&t.db?(this.database=t.db,delete t.db):this.database=g.default}_initDb(){return new Promise(((e,t)=>{this.db=this.database(this.path,{...this.opts,valueEncoding:"binary",compression:!1},(r=>{if(r)return t(r);e(this.db)}))}))}async open(){try{this.db?await this.db.open():this.db=await this._initDb()}catch(e){throw n.Errors.dbOpenFailedError(e)}}async put(e,t){try{await this.db.put(e.toString(),t)}catch(e){throw n.Errors.dbWriteFailedError(e)}}async get(e){let t;try{t=await this.db.get(e.toString())}catch(e){if(e.notFound)throw n.Errors.notFoundError(e);throw n.Errors.dbWriteFailedError(e)}return t}async has(e){try{await this.db.get(e.toString())}catch(e){if(e.notFound)return!1;throw e}return!0}async delete(e){try{await this.db.del(e.toString())}catch(e){throw n.Errors.dbDeleteFailedError(e)}}close(){return this.db&&this.db.close()}batch(){const e=[];return{put:(t,r)=>{e.push({type:"put",key:t.toString(),value:r})},delete:t=>{e.push({type:"del",key:t.toString()})},commit:()=>this.db.batch(e)}}query(e){let t=this._query({values:!0,prefix:e.prefix});Array.isArray(e.filters)&&(t=e.filters.reduce(((e,t)=>d.default(e,t)),t)),Array.isArray(e.orders)&&(t=e.orders.reduce(((e,t)=>p.default(e,t)),t));const{offset:r,limit:i}=e;if(r){let e=0;t=d.default(t,(()=>e++>=r))}return i&&(t=h.default(t,i)),t}queryKeys(e){let t=f.default(this._query({values:!1,prefix:e.prefix}),(({key:e})=>e));Array.isArray(e.filters)&&(t=e.filters.reduce(((e,t)=>d.default(e,t)),t)),Array.isArray(e.orders)&&(t=e.orders.reduce(((e,t)=>p.default(e,t)),t));const{offset:r,limit:i}=e;if(r){let e=0;t=d.default(t,(()=>e++>=r))}return i&&(t=h.default(t,i)),t}_query(e){const t={keys:!0,keyAsBuffer:!0,values:e.values};if(null!=e.prefix){const r=e.prefix.toString();t.gte=r,t.lt=r+"ÿ"}return r=this.db.iterator(t),{[Symbol.asyncIterator]:()=>({next:()=>new Promise(((e,t)=>{r.next(((n,s,o)=>n?t(n):null==s?r.end((r=>{if(r)return t(r);e({done:!0,value:void 0})})):void e({done:!1,value:{key:new i.Key(s,!1),value:o}})))})),return:()=>new Promise(((e,t)=>{r.end((r=>{if(r)return t(r);e({done:!0,value:void 0})}))}))})};var r}}r.LevelDatastore=y},{"interface-datastore":"1Ax6d","datastore-core":"bBniO","it-filter":"5LCTL","it-map":"eeqPk","it-take":"gxr1t","it-sort":"1r2il",level:"2sKBw"}],"1r2il":[function(e,t,r){"use strict";const i=e("it-all");t.exports=async function*(e,t){const r=await i(e);yield*r.sort(t)}},{"it-all":"iCXBu"}],"2sKBw":[function(e,t,r){t.exports=e("level-packager")(e("level-js"))},{"level-packager":"6lvLX","level-js":"lRPoL"}],"6lvLX":[function(e,t,r){"use strict";const i=e("levelup"),n=e("encoding-down");t.exports=function(e){function t(t,s,o){return"function"==typeof t?o=t:"function"==typeof s&&(o=s),r(s)||(s=r(t)?t:{}),i(n(e(t,s),s),s,o)}function r(e){return"object"==typeof e&&null!==e}for(const r of["destroy","repair"])"function"==typeof e[r]&&(t[r]=function(...t){e[r](...t)});return t.errors=i.errors,t}},{levelup:"axpZu","encoding-down":"eMHkk"}],axpZu:[function(e,t,r){"use strict";const i=e("events").EventEmitter,n=e("util").inherits,s=e("deferred-leveldown"),o=e("level-iterator-stream"),a=e("./batch"),c=e("level-errors"),u=e("level-supports"),l=e("catering"),d=e("./common").getCallback,f=e("./common").getOptions,h=e("./next-tick"),p=c.WriteError,g=c.ReadError,y=c.NotFoundError,m=c.OpenError,b=c.InitializationError;function v(e,t,r){if(!(this instanceof v))return new v(e,t,r);let n;if(i.call(this),this.setMaxListeners(1/0),"function"==typeof t&&(r=t,t={}),t=t||{},!e||"object"!=typeof e){if(n=new b("First argument must be an abstract-leveldown compliant store"),"function"==typeof r)return h(r,n);throw n}if("string"!=typeof e.status)throw new Error(".status required, old abstract-leveldown");this.options=f(t),this._db=e,this.db=null,this.open(r||(e=>{e&&this.emit("error",e)})),this.supports=u(this.db.supports,{status:!0,deferredOpen:!0,openCallback:!0,promises:!0,streams:!0});for(const e of Object.keys(this.supports.additionalMethods))null==this[e]&&(this[e]=function(...t){return this.db[e](...t)})}function w(e,t){return!e.isOperational()&&(h(t,new g("Database is not open")),!0)}v.prototype.emit=i.prototype.emit,v.prototype.once=i.prototype.once,n(v,i),Object.defineProperty(v.prototype,"status",{enumerable:!0,get(){return this.db.status}}),v.prototype.isOperational=function(){return"open"===this.db.status||"opening"===this.db.status},v.prototype.open=function(e,t){return"function"==typeof e&&(t=e,e=null),t=l.fromCallback(t),e||(e=this.options),this.db&&this.isOpen()?(h(t,null,this),t.promise):this.db&&this._isOpening()?(this.once("open",(()=>{t(null,this)})),t.promise):(this.db=new s(this._db),this.emit("opening"),this.db.open(e,(e=>{if(e)return t(new m(e));this.db=this._db,t(null,this),this.emit("open"),this.emit("ready")})),t.promise)},v.prototype.close=function(e){return e=l.fromCallback(e),this.isOpen()?(this.db.close(((t,...r)=>{this.emit("closed"),e(t,...r)})),this.emit("closing")):this.isClosed()?h(e):"closing"===this.db.status?this.once("closed",e):this._isOpening()&&this.once("open",(()=>{this.close(e)})),e.promise},v.prototype.isOpen=function(){return"open"===this.db.status},v.prototype._isOpening=function(){return"opening"===this.db.status},v.prototype.isClosed=function(){return/^clos|new/.test(this.db.status)},v.prototype.get=function(e,t,r){return r=d(t,r),w(this,r=l.fromCallback(r))||(t=f(t),this.db.get(e,t,(function(t,i){if(t)return t=/notfound/i.test(t)||t.notFound?new y("Key not found in database ["+e+"]",t):new g(t),r(t);r(null,i)}))),r.promise},v.prototype.getMany=function(e,t,r){return this.db.getMany(e,t,r)},v.prototype.put=function(e,t,r,i){return i=d(r,i),w(this,i=l.fromCallback(i))||(r=f(r),this.db.put(e,t,r,(r=>{if(r)return i(new p(r));this.emit("put",e,t),i()}))),i.promise},v.prototype.del=function(e,t,r){return r=d(t,r),w(this,r=l.fromCallback(r))||(t=f(t),this.db.del(e,t,(t=>{if(t)return r(new p(t));this.emit("del",e),r()}))),r.promise},v.prototype.batch=function(e,t,r){return arguments.length?(r="function"==typeof e?e:d(t,r),w(this,r=l.fromCallback(r))||(t=f(t),this.db.batch(e,t,(t=>{if(t)return r(new p(t));this.emit("batch",e),r()}))),r.promise):new a(this)},v.prototype.iterator=function(e){return this.db.iterator(e)},v.prototype.clear=function(e,t){return t=d(e,t),e=f(e),w(this,t=l.fromCallback(t))||this.db.clear(e,(r=>{if(r)return t(new p(r));this.emit("clear",e),t()})),t.promise},v.prototype.readStream=v.prototype.createReadStream=function(e){return"number"!=typeof(e=Object.assign({keys:!0,values:!0},e)).limit&&(e.limit=-1),new o(this.db.iterator(e),e)},v.prototype.keyStream=v.prototype.createKeyStream=function(e){return this.createReadStream(Object.assign({},e,{keys:!0,values:!1}))},v.prototype.valueStream=v.prototype.createValueStream=function(e){return this.createReadStream(Object.assign({},e,{keys:!1,values:!0}))},v.prototype.toString=function(){return"LevelUP"},v.prototype.type="levelup",v.prototype._nextTick=h,v.errors=c,t.exports=v},{events:"g82pp",util:"5ZAct","deferred-leveldown":"lVYRW","level-iterator-stream":"284tK","./batch":"8aV2Q","level-errors":"iLFVA","level-supports":"4gseK",catering:"3yKZX","./common":"4WQgu","./next-tick":"8xl4Y"}],"5ZAct":[function(e,t,r){var i=e("process"),n=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),r={},i=0;i=n)return e;switch(e){case"%s":return String(i[r++]);case"%d":return Number(i[r++]);case"%j":try{return JSON.stringify(i[r++])}catch(e){return"[Circular]"}default:return e}})),a=i[r];r=3&&(i.depth=arguments[2]),arguments.length>=4&&(i.colors=arguments[3]),g(t)?i.showHidden=t:t&&r._extend(i,t),v(i.showHidden)&&(i.showHidden=!1),v(i.depth)&&(i.depth=2),v(i.colors)&&(i.colors=!1),v(i.customInspect)&&(i.customInspect=!0),i.colors&&(i.stylize=u),d(i,e,i.depth)}function u(e,t){var r=c.styles[t];return r?"["+c.colors[r][0]+"m"+e+"["+c.colors[r][1]+"m":e}function l(e,t){return e}function d(e,t,i){if(e.customInspect&&t&&T(t.inspect)&&t.inspect!==r.inspect&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(i,e);return b(n)||(n=d(e,n,i)),n}var s=function(e,t){if(v(t))return e.stylize("undefined","undefined");if(b(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(m(t))return e.stylize(""+t,"number");if(g(t))return e.stylize(""+t,"boolean");if(y(t))return e.stylize("null","null")}(e,t);if(s)return s;var o=Object.keys(t),a=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),S(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return f(t);if(0===o.length){if(T(t)){var c=t.name?": "+t.name:"";return e.stylize("[Function"+c+"]","special")}if(w(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(E(t))return e.stylize(Date.prototype.toString.call(t),"date");if(S(t))return f(t)}var u,l="",_=!1,A=["{","}"];(p(t)&&(_=!0,A=["[","]"]),T(t))&&(l=" [Function"+(t.name?": "+t.name:"")+"]");return w(t)&&(l=" "+RegExp.prototype.toString.call(t)),E(t)&&(l=" "+Date.prototype.toUTCString.call(t)),S(t)&&(l=" "+f(t)),0!==o.length||_&&0!=t.length?i<0?w(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),u=_?function(e,t,r,i,n){for(var s=[],o=0,a=t.length;o=0)i++;return e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60?r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}(u,l,A)):A[0]+l+A[1]}function f(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,r,i,n,s){var o,a,c;if((c=Object.getOwnPropertyDescriptor(t,n)||{value:t[n]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),P(i,n)||(o="["+n+"]"),a||(e.seen.indexOf(c.value)<0?(a=y(r)?d(e,c.value,null):d(e,c.value,r-1)).indexOf("\n")>-1&&(a=s?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),v(o)){if(s&&n.match(/^\d+$/))return a;(o=JSON.stringify(""+n)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=e.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=e.stylize(o,"string"))}return o+": "+a}function p(e){return Array.isArray(e)}function g(e){return"boolean"==typeof e}function y(e){return null===e}function m(e){return"number"==typeof e}function b(e){return"string"==typeof e}function v(e){return void 0===e}function w(e){return _(e)&&"[object RegExp]"===A(e)}function _(e){return"object"==typeof e&&null!==e}function E(e){return _(e)&&"[object Date]"===A(e)}function S(e){return _(e)&&("[object Error]"===A(e)||e instanceof Error)}function T(e){return"function"==typeof e}function A(e){return Object.prototype.toString.call(e)}function k(e){return e<10?"0"+e.toString(10):e.toString(10)}r.debuglog=function(e){if(e=e.toUpperCase(),!o[e])if(a.test(e)){var t=i.pid;o[e]=function(){var i=r.format.apply(r,arguments);console.error("%s %d: %s",e,t,i)}}else o[e]=function(){};return o[e]},r.inspect=c,c.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},c.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.types=e("./support/types"),r.isArray=p,r.isBoolean=g,r.isNull=y,r.isNullOrUndefined=function(e){return null==e},r.isNumber=m,r.isString=b,r.isSymbol=function(e){return"symbol"==typeof e},r.isUndefined=v,r.isRegExp=w,r.types.isRegExp=w,r.isObject=_,r.isDate=E,r.types.isDate=E,r.isError=S,r.types.isNativeError=S,r.isFunction=T,r.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},r.isBuffer=e("./support/isBuffer");var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function R(){var e=new Date,t=[k(e.getHours()),k(e.getMinutes()),k(e.getSeconds())].join(":");return[e.getDate(),I[e.getMonth()],t].join(" ")}function P(e,t){return Object.prototype.hasOwnProperty.call(e,t)}r.log=function(){console.log("%s - %s",R(),r.format.apply(r,arguments))},r.inherits=e("inherits"),r._extend=function(e,t){if(!t||!_(t))return e;for(var r=Object.keys(t),i=r.length;i--;)e[r[i]]=t[r[i]];return e};var O="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function C(e,t){if(!e){var r=new Error("Promise was rejected with a falsy value");r.reason=e,e=r}return t(e)}r.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(O&&e[O]){var t;if("function"!=typeof(t=e[O]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,O,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,r,i=new Promise((function(e,i){t=e,r=i})),n=[],s=0;s=0&&"[object Array]"!==n(e)&&"[object Function]"===n(e.callee)},a=function(){return s(arguments)}();s.isLegacyArguments=o,t.exports=a?s:o},{"has-tostringtag/shams":"5rcWo","call-bind/callBound":"1dGMo"}],"5rcWo":[function(e,t,r){"use strict";var i=e("has-symbols/shams");t.exports=function(){return i()&&!!Symbol.toStringTag}},{"has-symbols/shams":"9MVhZ"}],"9MVhZ":[function(e,t,r){"use strict";t.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),r=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(t in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var i=Object.getOwnPropertySymbols(e);if(1!==i.length||i[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var n=Object.getOwnPropertyDescriptor(e,t);if(42!==n.value||!0!==n.enumerable)return!1}return!0}},{}],"1dGMo":[function(e,t,r){"use strict";var i=e("get-intrinsic"),n=e("./"),s=n(i("String.prototype.indexOf"));t.exports=function(e,t){var r=i(e,!!t);return"function"==typeof r&&s(e,".prototype.")>-1?n(r):r}},{"get-intrinsic":"hgNcX","./":"xRFOX"}],hgNcX:[function(e,t,r){"use strict";var i,n=SyntaxError,s=Function,o=TypeError,a=function(e){try{return s('"use strict"; return ('+e+").constructor;")()}catch(e){}},c=Object.getOwnPropertyDescriptor;if(c)try{c({},"")}catch(e){c=null}var u=function(){throw new o},l=c?function(){try{return u}catch(e){try{return c(arguments,"callee").get}catch(e){return u}}}():u,d=e("has-symbols")(),f=Object.getPrototypeOf||function(e){return e.__proto__},h={},p="undefined"==typeof Uint8Array?i:f(Uint8Array),g={"%AggregateError%":"undefined"==typeof AggregateError?i:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?i:ArrayBuffer,"%ArrayIteratorPrototype%":d?f([][Symbol.iterator]()):i,"%AsyncFromSyncIteratorPrototype%":i,"%AsyncFunction%":h,"%AsyncGenerator%":h,"%AsyncGeneratorFunction%":h,"%AsyncIteratorPrototype%":h,"%Atomics%":"undefined"==typeof Atomics?i:Atomics,"%BigInt%":"undefined"==typeof BigInt?i:BigInt,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?i:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":"undefined"==typeof Float32Array?i:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?i:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?i:FinalizationRegistry,"%Function%":s,"%GeneratorFunction%":h,"%Int8Array%":"undefined"==typeof Int8Array?i:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?i:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?i:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":d?f(f([][Symbol.iterator]())):i,"%JSON%":"object"==typeof JSON?JSON:i,"%Map%":"undefined"==typeof Map?i:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&d?f((new Map)[Symbol.iterator]()):i,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?i:Promise,"%Proxy%":"undefined"==typeof Proxy?i:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":"undefined"==typeof Reflect?i:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?i:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&d?f((new Set)[Symbol.iterator]()):i,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?i:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":d?f(""[Symbol.iterator]()):i,"%Symbol%":d?Symbol:i,"%SyntaxError%":n,"%ThrowTypeError%":l,"%TypedArray%":p,"%TypeError%":o,"%Uint8Array%":"undefined"==typeof Uint8Array?i:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?i:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?i:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?i:Uint32Array,"%URIError%":URIError,"%WeakMap%":"undefined"==typeof WeakMap?i:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?i:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?i:WeakSet},y=function e(t){var r;if("%AsyncFunction%"===t)r=a("async function () {}");else if("%GeneratorFunction%"===t)r=a("function* () {}");else if("%AsyncGeneratorFunction%"===t)r=a("async function* () {}");else if("%AsyncGenerator%"===t){var i=e("%AsyncGeneratorFunction%");i&&(r=i.prototype)}else if("%AsyncIteratorPrototype%"===t){var n=e("%AsyncGenerator%");n&&(r=f(n.prototype))}return g[t]=r,r},m={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},b=e("function-bind"),v=e("has"),w=b.call(Function.call,Array.prototype.concat),_=b.call(Function.apply,Array.prototype.splice),E=b.call(Function.call,String.prototype.replace),S=b.call(Function.call,String.prototype.slice),T=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,A=/\\(\\)?/g,k=function(e){var t=S(e,0,1),r=S(e,-1);if("%"===t&&"%"!==r)throw new n("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new n("invalid intrinsic syntax, expected opening `%`");var i=[];return E(e,T,(function(e,t,r,n){i[i.length]=r?E(n,A,"$1"):t||e})),i},I=function(e,t){var r,i=e;if(v(m,i)&&(i="%"+(r=m[i])[0]+"%"),v(g,i)){var s=g[i];if(s===h&&(s=y(i)),void 0===s&&!t)throw new o("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:i,value:s}}throw new n("intrinsic "+e+" does not exist!")};t.exports=function(e,t){if("string"!=typeof e||0===e.length)throw new o("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new o('"allowMissing" argument must be a boolean');var r=k(e),i=r.length>0?r[0]:"",s=I("%"+i+"%",t),a=s.name,u=s.value,l=!1,d=s.alias;d&&(i=d[0],_(r,w([0,1],d)));for(var f=1,h=!0;f=r.length){var b=c(u,p);u=(h=!!b)&&"get"in b&&!("originalValue"in b.get)?b.get:u[p]}else h=v(u,p),u=u[p];h&&!l&&(g[a]=u)}}return u}},{"has-symbols":"6NJIK","function-bind":"fm3P8",has:"a1vs2"}],"6NJIK":[function(e,t,r){"use strict";var i="undefined"!=typeof Symbol&&Symbol,n=e("./shams");t.exports=function(){return"function"==typeof i&&("function"==typeof Symbol&&("symbol"==typeof i("foo")&&("symbol"==typeof Symbol("bar")&&n())))}},{"./shams":"9MVhZ"}],fm3P8:[function(e,t,r){"use strict";var i=e("./implementation");t.exports=Function.prototype.bind||i},{"./implementation":"kD0YI"}],kD0YI:[function(e,t,r){"use strict";var i="Function.prototype.bind called on incompatible ",n=Array.prototype.slice,s=Object.prototype.toString,o="[object Function]";t.exports=function(e){var t=this;if("function"!=typeof t||s.call(t)!==o)throw new TypeError(i+t);for(var r,a=n.call(arguments,1),c=function(){if(this instanceof r){var i=t.apply(this,a.concat(n.call(arguments)));return Object(i)===i?i:this}return t.apply(e,a.concat(n.call(arguments)))},u=Math.max(0,t.length-a.length),l=[],d=0;d-1}return!!p&&y(e)}},{foreach:"aKWtH","available-typed-arrays":"8JQPQ","call-bind/callBound":"1dGMo","has-tostringtag/shams":"5rcWo","es-abstract/helpers/getOwnPropertyDescriptor":"5W76e"}],TyASC:[function(e,t,r){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],lVYRW:[function(e,t,r){"use strict";const{AbstractLevelDOWN:i}=e("abstract-leveldown"),n=e("inherits"),s=e("./deferred-iterator"),o=e("./deferred-chained-batch"),a=e("./util").getCallback,c=["put","get","getMany","del","batch","clear"],u=["approximateSize","compactRange"],l=Symbol("innerDb"),d=Symbol("operations"),f=Symbol("promise");function h(e){i.call(this,e.supports||{});for(const t of u)"function"!=typeof e[t]||this.supports.additionalMethods[t]||(this.supports.additionalMethods[t]=!0);this[l]=e,this[d]=[],function(e){const t=Object.keys(e.supports.additionalMethods);for(const r of c.concat(t))e[r]=function(...e){if("batch"===r&&0===e.length)return new o(this);if("open"===this.status)return this[l][r](...e);const t=a(e,f);return"opening"===this.status?this[d].push({method:r,args:e}):this._nextTick(t,new Error("Database is not open")),t[f]};e.iterator=function(e){if("open"===this.status)return this[l].iterator(e);if("opening"===this.status){const t=new s(this,e);return this[d].push({iterator:t}),t}throw new Error("Database is not open")};for(const t of c.concat(["iterator"]))e["_"+t]=function(){throw new Error("Did not expect private method to be called: "+t)}}(this)}n(h,i),h.prototype.type="deferred-leveldown",Object.defineProperty(h.prototype,"_db",{enumerable:!0,get(){return this[l]}}),h.prototype._open=function(e,t){const r=e=>{if(e||"open"!==this[l].status)return t(e||new Error("Database is not open"));const r=this[d];this[d]=[];for(const e of r)e.iterator?e.iterator.setDb(this[l]):this[l][e.method](...e.args);if(this[d].length>0)throw new Error("Did not expect further operations");t()};"new"===this[l].status||"closed"===this[l].status?this[l].open(e,r):this._nextTick(r)},h.prototype._close=function(e){this[l].close(e)},h.prototype._isOperational=function(){return"opening"===this.status},t.exports=h,t.exports.DeferredIterator=s},{"abstract-leveldown":"f3ZXE",inherits:"j5plK","./deferred-iterator":"35pXB","./deferred-chained-batch":"fHwIS","./util":"hJkDA"}],f3ZXE:[function(e,t,r){"use strict";r.AbstractLevelDOWN=e("./abstract-leveldown"),r.AbstractIterator=e("./abstract-iterator"),r.AbstractChainedBatch=e("./abstract-chained-batch")},{"./abstract-leveldown":"cguMf","./abstract-iterator":"lYFsd","./abstract-chained-batch":"hpfv2"}],cguMf:[function(e,t,r){"use strict";const i=e("level-supports"),n=e("is-buffer"),s=e("catering"),o=e("./abstract-iterator"),a=e("./abstract-chained-batch"),c=e("./lib/common").getCallback,u=e("./lib/common").getOptions,l=Object.prototype.hasOwnProperty,d=["lt","lte","gt","gte"];function f(e){this.status="new",this.supports=i(e,{status:!0})}function h(e,t){const r={};for(const i in t){if(!l.call(t,i))continue;if("start"===i||"end"===i)throw new Error('Legacy range options ("start" and "end") have been removed');let n=t[i];p(i)&&(n=e._serializeKey(n)),r[i]=n}return r}function p(e){return-1!==d.indexOf(e)}f.prototype.open=function(e,t){const r=this.status;if("function"==typeof e&&(t=e),"function"!=typeof t)throw new Error("open() requires a callback argument");"object"==typeof e&&null!==e||(e={}),e.createIfMissing=!1!==e.createIfMissing,e.errorIfExists=!!e.errorIfExists,this.status="opening",this._open(e,(e=>{if(e)return this.status=r,t(e);this.status="open",t()}))},f.prototype._open=function(e,t){this._nextTick(t)},f.prototype.close=function(e){const t=this.status;if("function"!=typeof e)throw new Error("close() requires a callback argument");this.status="closing",this._close((r=>{if(r)return this.status=t,e(r);this.status="closed",e()}))},f.prototype._close=function(e){this._nextTick(e)},f.prototype.get=function(e,t,r){if("function"==typeof t&&(r=t),"function"!=typeof r)throw new Error("get() requires a callback argument");const i=this._checkKey(e);if(i)return this._nextTick(r,i);e=this._serializeKey(e),"object"==typeof t&&null!==t||(t={}),t.asBuffer=!1!==t.asBuffer,this._get(e,t,r)},f.prototype._get=function(e,t,r){this._nextTick((function(){r(new Error("NotFound"))}))},f.prototype.getMany=function(e,t,r){if(r=c(t,r),r=s.fromCallback(r),t=u(t),function(e,t){if(!e.isOperational())return e._nextTick(t,new Error("Database is not open")),!0;return!1}(this,r))return r.promise;if(!Array.isArray(e))return this._nextTick(r,new Error("getMany() requires an array argument")),r.promise;if(0===e.length)return this._nextTick(r,null,[]),r.promise;"boolean"!=typeof t.asBuffer&&(t={...t,asBuffer:!0});const i=new Array(e.length);for(let t=0;t{if(e)return r.end((function(){t(e)}));r.next(((e,s)=>e?n(e):void 0===s?r.end(t):void this._del(s,i,n)))};n()},f.prototype._setupIteratorOptions=function(e){return(e=h(this,e)).reverse=!!e.reverse,e.keys=!1!==e.keys,e.values=!1!==e.values,e.limit="limit"in e?e.limit:-1,e.keyAsBuffer=!1!==e.keyAsBuffer,e.valueAsBuffer=!1!==e.valueAsBuffer,e},f.prototype.iterator=function(e){return"object"==typeof e&&null!==e||(e={}),e=this._setupIteratorOptions(e),this._iterator(e)},f.prototype._iterator=function(e){return new o(this)},f.prototype._chainedBatch=function(){return new a(this)},f.prototype._serializeKey=function(e){return e},f.prototype._serializeValue=function(e){return e},f.prototype._checkKey=function(e){return null==e?new Error("key cannot be `null` or `undefined`"):n(e)&&0===e.length?new Error("key cannot be an empty Buffer"):""===e?new Error("key cannot be an empty String"):Array.isArray(e)&&0===e.length?new Error("key cannot be an empty Array"):void 0},f.prototype._checkValue=function(e){if(null==e)return new Error("value cannot be `null` or `undefined`")},f.prototype.isOperational=function(){return"open"===this.status||this._isOperational()},f.prototype._isOperational=function(){return!1},f.prototype._nextTick=e("./next-tick"),t.exports=f},{"level-supports":"4gseK","is-buffer":"5yoKf",catering:"3yKZX","./abstract-iterator":"lYFsd","./abstract-chained-batch":"hpfv2","./lib/common":"aaqLC","./next-tick":"clHeC"}],"4gseK":[function(e,t,r){"use strict";function i(e){return!!e&&Object.assign({},e)}t.exports=function(...e){const t=e.reduce(((e,t)=>Object.assign(e,t)),{});return Object.assign(t,{bufferKeys:t.bufferKeys||!1,snapshots:t.snapshots||!1,permanence:t.permanence||!1,seek:t.seek||!1,clear:t.clear||!1,getMany:t.getMany||!1,keyIterator:t.keyIterator||!1,valueIterator:t.valueIterator||!1,iteratorNextv:t.iteratorNextv||!1,iteratorAll:t.iteratorAll||!1,status:t.status||!1,idempotentOpen:t.idempotentOpen||!1,passiveOpen:t.passiveOpen||!1,serialize:t.serialize||!1,createIfMissing:t.createIfMissing||!1,errorIfExists:t.errorIfExists||!1,deferredOpen:t.deferredOpen||!1,openCallback:t.openCallback||!1,promises:t.promises||!1,streams:t.streams||!1,encodings:i(t.encodings),events:i(t.events),additionalMethods:Object.assign({},t.additionalMethods)})}},{}],"5yoKf":[function(e,t,r){ /*! * Determine if an object is a Buffer * * @author Feross Aboukhadijeh * @license MIT */ t.exports=function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}},{}],"3yKZX":[function(e,t,r){"use strict";var i=e("queue-tick");r.fromCallback=function(e,t){if(void 0===e){var r=new Promise((function(t,r){e=function(e,i){e?r(e):t(i)}}));e[void 0!==t?t:"promise"]=r}else if("function"!=typeof e)throw new TypeError("Callback must be a function");return e},r.fromPromise=function(e,t){if(void 0===t)return e;e.then((function(e){i((()=>t(null,e)))})).catch((function(e){i((()=>t(e)))}))}},{"queue-tick":"gJSe0"}],gJSe0:[function(e,t,r){t.exports="function"==typeof queueMicrotask?queueMicrotask:e=>Promise.resolve().then(e)},{}],lYFsd:[function(e,t,r){"use strict";function i(e){if("object"!=typeof e||null===e)throw new TypeError("First argument must be an abstract-leveldown compliant store");this.db=e,this._ended=!1,this._nexting=!1}i.prototype.next=function(e){let t=this;if(void 0===e)t=new Promise((function(t,r){e=function(e,i,n){e?r(e):void 0===i&&void 0===n?t():t([i,n])}}));else if("function"!=typeof e)throw new Error("next() requires a callback argument");return this._ended?(this._nextTick(e,new Error("cannot call next() after end()")),t):this._nexting?(this._nextTick(e,new Error("cannot call next() before previous next() has completed")),t):(this._nexting=!0,this._next(((t,...r)=>{this._nexting=!1,e(t,...r)})),t)},i.prototype._next=function(e){this._nextTick(e)},i.prototype.seek=function(e){if(this._ended)throw new Error("cannot call seek() after end()");if(this._nexting)throw new Error("cannot call seek() before next() has completed");e=this.db._serializeKey(e),this._seek(e)},i.prototype._seek=function(e){},i.prototype.end=function(e){let t;if(void 0===e)t=new Promise((function(t,r){e=function(e){e?r(e):t()}}));else if("function"!=typeof e)throw new Error("end() requires a callback argument");return this._ended?(this._nextTick(e,new Error("end() already called on iterator")),t):(this._ended=!0,this._end(e),t)},i.prototype._end=function(e){this._nextTick(e)},i.prototype[Symbol.asyncIterator]=async function*(){try{let e;for(;void 0!==(e=await this.next());)yield e}finally{this._ended||await this.end()}},i.prototype._nextTick=e("./next-tick"),t.exports=i},{"./next-tick":"clHeC"}],clHeC:[function(e,t,r){"use strict";const i=e("queue-microtask");t.exports=function(e,...t){0===t.length?i(e):i((()=>e(...t)))}},{"queue-microtask":"3aIgO"}],"3aIgO":[function(e,t,r){var i=arguments[3]; /*! queue-microtask. MIT License. Feross Aboukhadijeh */let n;t.exports="function"==typeof queueMicrotask?queueMicrotask.bind("undefined"!=typeof window?window:i):e=>(n||(n=Promise.resolve())).then(e).catch((e=>setTimeout((()=>{throw e}),0)))},{}],hpfv2:[function(e,t,r){"use strict";const i=Object.freeze({});function n(e){if("object"!=typeof e||null===e)throw new TypeError("First argument must be an abstract-leveldown compliant store");this.db=e,this._operations=[],this._written=!1}n.prototype._checkWritten=function(){if(this._written)throw new Error("write() already called on this batch")},n.prototype.put=function(e,t,r){this._checkWritten();const n=this.db._checkKey(e)||this.db._checkValue(t);if(n)throw n;return e=this.db._serializeKey(e),t=this.db._serializeValue(t),this._put(e,t,null!=r?r:i),this},n.prototype._put=function(e,t,r){this._operations.push({...r,type:"put",key:e,value:t})},n.prototype.del=function(e,t){this._checkWritten();const r=this.db._checkKey(e);if(r)throw r;return e=this.db._serializeKey(e),this._del(e,null!=t?t:i),this},n.prototype._del=function(e,t){this._operations.push({...t,type:"del",key:e})},n.prototype.clear=function(){return this._checkWritten(),this._clear(),this},n.prototype._clear=function(){this._operations=[]},n.prototype.write=function(e,t){if(this._checkWritten(),"function"==typeof e&&(t=e),"function"!=typeof t)throw new Error("write() requires a callback argument");"object"==typeof e&&null!==e||(e={}),this._written=!0,this._write(e,t)},n.prototype._write=function(e,t){this.db._batch(this._operations,e,t)},n.prototype._nextTick=e("./next-tick"),t.exports=n},{"./next-tick":"clHeC"}],aaqLC:[function(e,t,r){"use strict";r.getCallback=function(e,t){return"function"==typeof e?e:t},r.getOptions=function(e){return"object"==typeof e&&null!==e?e:{}}},{}],"35pXB":[function(e,t,r){"use strict";const{AbstractIterator:i}=e("abstract-leveldown"),n=e("inherits"),s=e("./util").getCallback,o=Symbol("options"),a=Symbol("iterator"),c=Symbol("operations"),u=Symbol("promise");function l(e,t){i.call(this,e),this[o]=t,this[a]=null,this[c]=[]}n(l,i),l.prototype.setDb=function(e){this[a]=e.iterator(this[o]);for(const e of this[c].splice(0,this[c].length))this[a][e.method](...e.args)},l.prototype.next=function(...e){if("open"===this.db.status)return this[a].next(...e);const t=s(e,u,(function(e,t){return void 0===e&&void 0===t?void 0:[e,t]}));return"opening"===this.db.status?this[c].push({method:"next",args:e}):this._nextTick(t,new Error("Database is not open")),t[u]||this},l.prototype.seek=function(...e){if("open"===this.db.status)this[a].seek(...e);else{if("opening"!==this.db.status)throw new Error("Database is not open");this[c].push({method:"seek",args:e})}},l.prototype.end=function(...e){if("open"===this.db.status)return this[a].end(...e);const t=s(e,u);return"opening"===this.db.status?this[c].push({method:"end",args:e}):this._nextTick(t,new Error("Database is not open")),t[u]||this};for(const e of["next","seek","end"])l.prototype["_"+e]=function(){throw new Error("Did not expect private method to be called: "+e)};t.exports=l},{"abstract-leveldown":"f3ZXE",inherits:"j5plK","./util":"hJkDA"}],hJkDA:[function(e,t,r){"use strict";r.getCallback=function(e,t,r){let i=e[e.length-1];if("function"!=typeof i){const n=new Promise(((t,n)=>{e.push(i=function(e,...i){e?n(e):t(r?r(...i):i[0])})}));i[t]=n}return i}},{}],fHwIS:[function(e,t,r){"use strict";const{AbstractChainedBatch:i}=e("abstract-leveldown"),n=Symbol("operations");t.exports=class extends i{constructor(e){super(e),this[n]=[]}_put(e,t,r){this[n].push({...r,type:"put",key:e,value:t})}_del(e,t){this[n].push({...t,type:"del",key:e})}_clear(){this[n]=[]}_write(e,t){this.db.batch(this[n],e,t)}}},{"abstract-leveldown":"f3ZXE"}],"284tK":[function(e,t,r){"use strict";const i=e("inherits"),{Readable:n}=e("readable-stream");function s(e,t){if(!(this instanceof s))return new s(e,t);t=t||{},n.call(this,Object.assign({},t,{objectMode:!0})),this._iterator=e,this._options=t,this.on("end",this.destroy.bind(this,null,null))}t.exports=s,i(s,n),s.prototype._read=function(){this.destroyed||this._iterator.next(((e,t,r)=>{if(!this.destroyed)return e?this.destroy(e):void(void 0===t&&void 0===r?this.push(null):!1!==this._options.keys&&!1===this._options.values?this.push(t):!1===this._options.keys&&!1!==this._options.values?this.push(r):this.push({key:t,value:r}))}))},s.prototype._destroy=function(e,t){this._iterator.end((function(r){t(e||r)}))}},{inherits:"j5plK","readable-stream":"w0M38"}],w0M38:[function(e,t,r){(r=t.exports=e("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=e("./lib/_stream_writable.js"),r.Duplex=e("./lib/_stream_duplex.js"),r.Transform=e("./lib/_stream_transform.js"),r.PassThrough=e("./lib/_stream_passthrough.js"),r.finished=e("./lib/internal/streams/end-of-stream.js"),r.pipeline=e("./lib/internal/streams/pipeline.js")},{"./lib/_stream_readable.js":"hUJUV","./lib/_stream_writable.js":"5EyvX","./lib/_stream_duplex.js":"bbfLz","./lib/_stream_transform.js":"9ioV2","./lib/_stream_passthrough.js":"8DY2M","./lib/internal/streams/end-of-stream.js":"6WyPU","./lib/internal/streams/pipeline.js":"7zSdy"}],hUJUV:[function(e,t,r){var i,n=e("process"),s=arguments[3];t.exports=O,O.ReadableState=P;e("events").EventEmitter;var o=function(e,t){return e.listeners(t).length},a=e("./internal/streams/stream"),c=e("buffer").Buffer,u=s.Uint8Array||function(){};function l(e){return c.from(e)}function d(e){return c.isBuffer(e)||e instanceof u}var f,h=e("util");f=h&&h.debuglog?h.debuglog("stream"):function(){};var p,g,y,m=e("./internal/streams/buffer_list"),b=e("./internal/streams/destroy"),v=e("./internal/streams/state"),w=v.getHighWaterMark,_=e("../errors").codes,E=_.ERR_INVALID_ARG_TYPE,S=_.ERR_STREAM_PUSH_AFTER_EOF,T=_.ERR_METHOD_NOT_IMPLEMENTED,A=_.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;e("inherits")(O,a);var k=b.errorOrDestroy,I=["error","close","destroy","pause","resume"];function R(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}function P(t,r,n){i=i||e("./_stream_duplex"),t=t||{},"boolean"!=typeof n&&(n=r instanceof i),this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=w(this,t,"readableHighWaterMark",n),this.buffer=new m,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(p||(p=e("string_decoder/").StringDecoder),this.decoder=new p(t.encoding),this.encoding=t.encoding)}function O(t){if(i=i||e("./_stream_duplex"),!(this instanceof O))return new O(t);var r=this instanceof i;this._readableState=new P(t,this,r),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),a.call(this)}function C(e,t,r,i,n){f("readableAddChunk",t);var s,o=e._readableState;if(null===t)o.reading=!1,L(e,o);else if(n||(s=D(o,t)),s)k(e,s);else if(o.objectMode||t&&t.length>0)if("string"==typeof t||o.objectMode||Object.getPrototypeOf(t)===c.prototype||(t=l(t)),i)o.endEmitted?k(e,new A):j(e,o,t,!0);else if(o.ended)k(e,new S);else{if(o.destroyed)return!1;o.reading=!1,o.decoder&&!r?(t=o.decoder.write(t),o.objectMode||0!==t.length?j(e,o,t,!1):F(e,o)):j(e,o,t,!1)}else i||(o.reading=!1,F(e,o));return!o.ended&&(o.length=M?e=M:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function B(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=x(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function L(e,t){if(f("onEofChunk"),!t.ended){if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?N(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,U(e)))}}function N(e){var t=e._readableState;f("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(f("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(U,e))}function U(e){var t=e._readableState;f("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,$(e)}function F(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(K,e,t))}function K(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function q(e){f("readable nexttick read 0"),e.read(0)}function G(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(H,e,t))}function H(e,t){f("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),$(e),t.flowing&&!t.reading&&e.read(0)}function $(e){var t=e._readableState;for(f("flow",t.flowing);t.flowing&&null!==e.read(););}function W(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function Y(e){var t=e._readableState;f("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(X,t,e))}function X(e,t){if(f("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function Z(e,t){for(var r=0,i=e.length;r=t.highWaterMark:t.length>0)||t.ended))return f("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Y(this):N(this),null;if(0===(e=B(e,t))&&t.ended)return 0===t.length&&Y(this),null;var i,n=t.needReadable;return f("need readable",n),(0===t.length||t.length-e0?W(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Y(this)),null!==i&&this.emit("data",i),i},O.prototype._read=function(e){k(this,new T("_read()"))},O.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e)}i.pipesCount+=1,f("pipe count=%d opts=%j",i.pipesCount,t);var s=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?c:y;function a(t,n){f("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,f("cleanup"),e.removeListener("close",p),e.removeListener("finish",g),e.removeListener("drain",u),e.removeListener("error",h),e.removeListener("unpipe",a),r.removeListener("end",c),r.removeListener("end",y),r.removeListener("data",d),l=!0,!i.awaitDrain||e._writableState&&!e._writableState.needDrain||u())}function c(){f("onend"),e.end()}i.endEmitted?n.nextTick(s):r.once("end",s),e.on("unpipe",a);var u=z(r);e.on("drain",u);var l=!1;function d(t){f("ondata");var n=e.write(t);f("dest.write",n),!1===n&&((1===i.pipesCount&&i.pipes===e||i.pipesCount>1&&-1!==Z(i.pipes,e))&&!l&&(f("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function h(t){f("onerror",t),y(),e.removeListener("error",h),0===o(e,"error")&&k(e,t)}function p(){e.removeListener("finish",g),y()}function g(){f("onfinish"),e.removeListener("close",p),y()}function y(){f("unpipe"),r.unpipe(e)}return r.on("data",d),R(e,"error",h),e.once("close",p),e.once("finish",g),e.emit("pipe",r),i.flowing||(f("pipe resume"),r.resume()),e},O.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var i=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var s=0;s0,!1!==i.flowing&&this.resume()):"readable"===e&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,f("on readable",i.length,i.reading),i.length?N(this):i.reading||n.nextTick(q,this))),r},O.prototype.addListener=O.prototype.on,O.prototype.removeListener=function(e,t){var r=a.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(V,this),r},O.prototype.removeAllListeners=function(e){var t=a.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(V,this),t},O.prototype.resume=function(){var e=this._readableState;return e.flowing||(f("resume"),e.flowing=!e.readableListening,G(this,e)),e.paused=!1,this},O.prototype.pause=function(){return f("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(f("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},O.prototype.wrap=function(e){var t=this,r=this._readableState,i=!1;for(var n in e.on("end",(function(){if(f("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(n){(f("wrapped data"),r.decoder&&(n=r.decoder.write(n)),r.objectMode&&null==n)||(r.objectMode||n&&n.length)&&(t.push(n)||(i=!0,e.pause()))})),e)void 0===this[n]&&"function"==typeof e[n]&&(this[n]=function(t){return function(){return e[t].apply(e,arguments)}}(n));for(var s=0;s0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return o.alloc(0);for(var t,r,i,n=o.allocUnsafe(e>>>0),s=this.head,a=0;s;)t=s.data,r=n,i=a,o.prototype.copy.call(t,r,i),a+=s.data.length,s=s.next;return n}},{key:"consume",value:function(e,t){var r;return en.length?n.length:e;if(s===n.length?i+=n:i+=n.slice(0,e),0==(e-=s)){s===n.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=n.slice(s));break}++r}return this.length-=r,i}},{key:"_getBuffer",value:function(e){var t=o.allocUnsafe(e),r=this.head,i=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var n=r.data,s=e>n.length?n.length:e;if(n.copy(t,t.length-e,0,s),0==(e-=s)){s===n.length?(++i,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=n.slice(s));break}++i}return this.length-=i,t}},{key:c,value:function(e,t){return a(this,function(e){for(var t=1;t2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}n("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),n("ERR_INVALID_ARG_TYPE",(function(e,t,r){var i,n,o,a;if("string"==typeof t&&(n="not ",t.substr(!o||o<0?0:+o,n.length)===n)?(i="must not be",t=t.replace(/^not /,"")):i="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))a="The ".concat(e," ").concat(i," ").concat(s(t,"type"));else{var c=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(e,".")?"property":"argument";a='The "'.concat(e,'" ').concat(c," ").concat(i," ").concat(s(t,"type"))}return a+=". Received type ".concat(typeof r)}),TypeError),n("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),n("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),n("ERR_STREAM_PREMATURE_CLOSE","Premature close"),n("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),n("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),n("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),n("ERR_STREAM_WRITE_AFTER_END","write after end"),n("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),n("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),n("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=i},{}],bbfLz:[function(e,t,r){var i=e("process"),n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=l;var s=e("./_stream_readable"),o=e("./_stream_writable");e("inherits")(l,s);for(var a=n(o.prototype),c=0;c-1))throw new A(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(P.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(P.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),P.prototype._write=function(e,t,r){r(new v("_write()"))},P.prototype._writev=null,P.prototype.end=function(e,t,r){var i=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||G(this,i,r),this},Object.defineProperty(P.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(P.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),P.prototype.destroy=p.destroy,P.prototype._undestroy=p.undestroy,P.prototype._destroy=function(e,t){t(e)}},{process:"bjUAi","util-deprecate":"3zH8r","./internal/streams/stream":"WXKP8",buffer:"etowf","./internal/streams/destroy":"hWarO","./internal/streams/state":"kof1d","../errors":"7Ny4a",inherits:"j5plK","./_stream_duplex":"bbfLz"}],"3zH8r":[function(e,t,r){var i=arguments[3];function n(e,t){if(s("noDeprecation"))return e;var r=!1;return function(){if(!r){if(s("throwDeprecation"))throw new Error(t);s("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}}function s(e){try{if(!i.localStorage)return!1}catch(e){return!1}var t=i.localStorage[e];return null!=t&&"true"===String(t).toLowerCase()}t.exports=n},{}],cHJFU:[function(e,t,r){"use strict";var i=e("safe-buffer").Buffer,n=i.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function s(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(i.isEncoding===n||!n(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=c,this.end=u,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=l,this.end=d,t=3;break;default:return this.write=f,void(this.end=h)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(t)}function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function c(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function u(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function l(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function f(e){return e.toString(this.encoding)}function h(e){return e&&e.length?this.write(e):""}r.StringDecoder=s,s.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return n>0&&(e.lastNeed=n-1),n;if(--i=0)return n>0&&(e.lastNeed=n-2),n;if(--i=0)return n>0&&(2===n?n=0:e.lastNeed=n-3),n;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var i=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)},s.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{"safe-buffer":"2ZY92"}],"2ZY92":[function(e,t,r){ /*! safe-buffer. MIT License. Feross Aboukhadijeh */var i=e("buffer"),n=i.Buffer;function s(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?t.exports=i:(s(i,r),r.Buffer=o),o.prototype=Object.create(n.prototype),s(n,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var i=n(e);return void 0!==t?"string"==typeof r?i.fill(t,r):i.fill(t):i.fill(0),i},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i.SlowBuffer(e)}},{buffer:"etowf"}],deb8T:[function(e,t,r){var i,n=e("process");function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var o=e("./end-of-stream"),a=Symbol("lastResolve"),c=Symbol("lastReject"),u=Symbol("error"),l=Symbol("ended"),d=Symbol("lastPromise"),f=Symbol("handlePromise"),h=Symbol("stream");function p(e,t){return{value:e,done:t}}function g(e){var t=e[a];if(null!==t){var r=e[h].read();null!==r&&(e[d]=null,e[a]=null,e[c]=null,t(p(r,!1)))}}function y(e){n.nextTick(g,e)}var m=Object.getPrototypeOf((function(){})),b=Object.setPrototypeOf((s(i={get stream(){return this[h]},next:function(){var e=this,t=this[u];if(null!==t)return Promise.reject(t);if(this[l])return Promise.resolve(p(void 0,!0));if(this[h].destroyed)return new Promise((function(t,r){n.nextTick((function(){e[u]?r(e[u]):t(p(void 0,!0))}))}));var r,i=this[d];if(i)r=new Promise(function(e,t){return function(r,i){e.then((function(){t[l]?r(p(void 0,!0)):t[f](r,i)}),i)}}(i,this));else{var s=this[h].read();if(null!==s)return Promise.resolve(p(s,!1));r=new Promise(this[f])}return this[d]=r,r}},Symbol.asyncIterator,(function(){return this})),s(i,"return",(function(){var e=this;return new Promise((function(t,r){e[h].destroy(null,(function(e){e?r(e):t(p(void 0,!0))}))}))})),i),m);t.exports=function(e){var t,r=Object.create(b,(s(t={},h,{value:e,writable:!0}),s(t,a,{value:null,writable:!0}),s(t,c,{value:null,writable:!0}),s(t,u,{value:null,writable:!0}),s(t,l,{value:e._readableState.endEmitted,writable:!0}),s(t,f,{value:function(e,t){var i=r[h].read();i?(r[d]=null,r[a]=null,r[c]=null,e(p(i,!1))):(r[a]=e,r[c]=t)},writable:!0}),t));return r[d]=null,o(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=r[c];return null!==t&&(r[d]=null,r[a]=null,r[c]=null,t(e)),void(r[u]=e)}var i=r[a];null!==i&&(r[d]=null,r[a]=null,r[c]=null,i(p(void 0,!0))),r[l]=!0})),e.on("readable",y.bind(null,r)),r}},{process:"bjUAi","./end-of-stream":"6WyPU"}],"6WyPU":[function(e,t,r){"use strict";var i=e("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;function n(){}t.exports=function e(t,r,s){if("function"==typeof r)return e(t,null,r);r||(r={}),s=function(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,i=new Array(r),n=0;n0,(function(e){i||(i=e),e&&o.forEach(u),s||(o.forEach(u),n(i))}))}));return t.reduce(l)}},{"../../../errors":"7Ny4a","./end-of-stream":"6WyPU"}],"8aV2Q":[function(e,t,r){"use strict";const i=e("level-errors").WriteError,n=e("catering"),s=e("./common").getCallback,o=e("./common").getOptions;function a(e){this.db=e,this.batch=e.db.batch(),this.ops=[],this.length=0}a.prototype.put=function(e,t,r){try{this.batch.put(e,t,r)}catch(e){throw new i(e)}return this.ops.push({...r,type:"put",key:e,value:t}),this.length++,this},a.prototype.del=function(e,t){try{this.batch.del(e,t)}catch(e){throw new i(e)}return this.ops.push({...t,type:"del",key:e}),this.length++,this},a.prototype.clear=function(){try{this.batch.clear()}catch(e){throw new i(e)}return this.ops=[],this.length=0,this},a.prototype.write=function(e,t){const r=this.db,a=this.ops;t=s(e,t),t=n.fromCallback(t),e=o(e);try{this.batch.write(e,(function(e){if(e)return t(new i(e));r.emit("batch",a),t()}))}catch(e){throw new i(e)}return t.promise},t.exports=a},{"level-errors":"iLFVA",catering:"3yKZX","./common":"4WQgu"}],iLFVA:[function(e,t,r){"use strict";function i(e,t){const r=function(t,i){if("object"==typeof t&&null!==t&&(i=i||t,t=t.message||t.name),t=t||"","object"==typeof(i=i||void 0)&&i.type===e&&i.message===t)return i;Object.defineProperty(this,"type",{value:e,enumerable:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"name",{value:e,enumerable:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"cause",{value:i,enumerable:!1,writable:!0,configurable:!0}),Object.defineProperty(this,"message",{value:t,enumerable:!1,writable:!0,configurable:!0}),Error.call(this),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,r)};return r.prototype=new t,r}const n=i("LevelUPError",Error);t.exports={LevelUPError:n,InitializationError:i("InitializationError",n),OpenError:i("OpenError",n),ReadError:i("ReadError",n),WriteError:i("WriteError",n),NotFoundError:i("NotFoundError",n),EncodingError:i("EncodingError",n)},t.exports.NotFoundError.prototype.notFound=!0,t.exports.NotFoundError.prototype.status=404},{}],"4WQgu":[function(e,t,r){"use strict";r.getCallback=function(e,t){return"function"==typeof e?e:t},r.getOptions=function(e){return"object"==typeof e&&null!==e?e:{}}},{}],"8xl4Y":[function(e,t,r){"use strict";const i=e("queue-microtask");t.exports=function(e,...t){0===t.length?i(e):i((()=>e(...t)))}},{"queue-microtask":"3aIgO"}],eMHkk:[function(e,t,r){"use strict";const i=e("abstract-leveldown").AbstractLevelDOWN,n=e("abstract-leveldown").AbstractChainedBatch,s=e("abstract-leveldown").AbstractIterator,o=e("inherits"),a=e("level-codec"),c=e("level-errors").EncodingError,u=["approximateSize","compactRange"];function l(e,t){if(!(this instanceof l))return new l(e,t);const r=e.supports||{},n=r.additionalMethods||{};i.call(this,r),this.supports.encodings=!0,this.supports.additionalMethods={},u.forEach((function(t){const r="function"==typeof e[t];(n[t]||r)&&(this.supports.additionalMethods[t]=!0,this[t]=function(e,r,i,n){return e=this.codec.encodeKey(e,i),r=this.codec.encodeKey(r,i),this.db[t](e,r,i,n)})}),this),void 0===(t=t||{}).keyEncoding&&(t.keyEncoding="utf8"),void 0===t.valueEncoding&&(t.valueEncoding="utf8"),this.db=e,this.codec=new a(t)}function d(e,t){s.call(this,e),this.codec=e.codec,this.keys=t.keys,this.values=t.values,this.opts=this.codec.encodeLtgt(t),this.it=e.db.iterator(this.opts)}function f(e,t){n.call(this,e),this.codec=e.codec,this.batch=e.db.batch()}t.exports=l,o(l,i),l.prototype.type="encoding-down",l.prototype._serializeKey=l.prototype._serializeValue=function(e){return e},l.prototype._open=function(e,t){this.db.open(e,t)},l.prototype._close=function(e){this.db.close(e)},l.prototype._put=function(e,t,r,i){e=this.codec.encodeKey(e,r),t=this.codec.encodeValue(t,r),this.db.put(e,t,r,i)},l.prototype._get=function(e,t,r){e=this.codec.encodeKey(e,t),t.asBuffer=this.codec.valueAsBuffer(t),this.db.get(e,t,((e,i)=>{if(e)return r(e);try{i=this.codec.decodeValue(i,t)}catch(e){return r(new c(e))}r(null,i)}))},l.prototype._getMany=function(e,t,r){e=e.map((e=>this.codec.encodeKey(e,t))),t.asBuffer=this.codec.valueAsBuffer(t),this.db.getMany(e,t,((e,i)=>{if(e)return r(e);const n=new Array(i.length);for(let s=0;s{if(t)return e(t);try{r=this.keys&&void 0!==r?this.codec.decodeKey(r,this.opts):void 0,i=this.values&&void 0!==i?this.codec.decodeValue(i,this.opts):void 0}catch(t){return e(new c(t))}e(null,r,i)}))},d.prototype._seek=function(e){e=this.codec.encodeKey(e,this.opts),this.it.seek(e)},d.prototype._end=function(e){this.it.end(e)},o(f,n),f.prototype._put=function(e,t,r){e=this.codec.encodeKey(e,r),t=this.codec.encodeValue(t,r),this.batch.put(e,t)},f.prototype._del=function(e,t){e=this.codec.encodeKey(e,t),this.batch.del(e)},f.prototype._clear=function(){this.batch.clear()},f.prototype._write=function(e,t){this.batch.write(e,t)}},{"abstract-leveldown":"f3ZXE",inherits:"j5plK","level-codec":"avh2o","level-errors":"iLFVA"}],avh2o:[function(e,t,r){"use strict";const i=e("./lib/encodings"),n=new Set(["lt","gt","lte","gte"]);function s(e){if(!(this instanceof s))return new s(e);this.opts=e||{},this.encodings=i}t.exports=s,s.prototype._encoding=function(e){return"string"==typeof e&&(e=i[e]),e||(e=i.id),e},s.prototype._keyEncoding=function(e,t){return this._encoding(t&&t.keyEncoding||e&&e.keyEncoding||this.opts.keyEncoding)},s.prototype._valueEncoding=function(e,t){return this._encoding(t&&(t.valueEncoding||t.encoding)||e&&(e.valueEncoding||e.encoding)||this.opts.valueEncoding||this.opts.encoding)},s.prototype.encodeKey=function(e,t,r){return this._keyEncoding(t,r).encode(e)},s.prototype.encodeValue=function(e,t,r){return this._valueEncoding(t,r).encode(e)},s.prototype.decodeKey=function(e,t){return this._keyEncoding(t).decode(e)},s.prototype.decodeValue=function(e,t){return this._valueEncoding(t).decode(e)},s.prototype.encodeBatch=function(e,t){return e.map((e=>{const r={type:e.type,key:this.encodeKey(e.key,t,e)};return this.keyAsBuffer(t,e)&&(r.keyEncoding="binary"),e.prefix&&(r.prefix=e.prefix),"value"in e&&(r.value=this.encodeValue(e.value,t,e),this.valueAsBuffer(t,e)&&(r.valueEncoding="binary")),r}))},s.prototype.encodeLtgt=function(e){const t={};for(const r of Object.keys(e)){if("start"===r||"end"===r)throw new Error('Legacy range options ("start" and "end") have been removed');t[r]=n.has(r)?this.encodeKey(e[r],e):e[r]}return t},s.prototype.createStreamDecoder=function(e){return e.keys&&e.values?(t,r)=>({key:this.decodeKey(t,e),value:this.decodeValue(r,e)}):e.keys?t=>this.decodeKey(t,e):e.values?(t,r)=>this.decodeValue(r,e):function(){}},s.prototype.keyAsBuffer=function(e){return this._keyEncoding(e).buffer},s.prototype.valueAsBuffer=function(e){return this._valueEncoding(e).buffer}},{"./lib/encodings":"yLou2"}],yLou2:[function(e,t,r){"use strict";const{Buffer:i}=e("buffer");r.utf8=r["utf-8"]={encode:function(e){return o(e)?e:String(e)},decode:s,buffer:!1,type:"utf8"},r.json={encode:JSON.stringify,decode:JSON.parse,buffer:!1,type:"json"},r.binary={encode:function(e){return o(e)?e:i.from(e)},decode:s,buffer:!0,type:"binary"},r.none={encode:s,decode:s,buffer:!1,type:"id"},r.id=r.none;const n=["hex","ascii","base64","ucs2","ucs-2","utf16le","utf-16le"];for(const e of n)r[e]={encode:function(t){return o(t)?t:i.from(t,e)},decode:function(t){return t.toString(e)},buffer:!0,type:e};function s(e){return e}function o(e){return null==e||i.isBuffer(e)}},{buffer:"etowf"}],lRPoL:[function(e,t,r){"use strict";t.exports=h;const i=e("abstract-leveldown").AbstractLevelDOWN,n=e("inherits"),s=e("run-parallel-limit"),o=e("./iterator"),a=e("./util/serialize"),c=e("./util/deserialize"),u=e("./util/support"),l=e("./util/clear"),d=e("./util/key-range"),f="level-js-";function h(e,t){if(!(this instanceof h))return new h(e,t);if(i.call(this,{bufferKeys:u.bufferKeys(indexedDB),snapshots:!0,permanence:!0,clear:!0,getMany:!0}),t=t||{},"string"!=typeof e)throw new Error("constructor requires a location string argument");this.location=e,this.prefix=null==t.prefix?f:t.prefix,this.version=parseInt(t.version||1,10)}n(h,i),h.prototype.type="level-js",h.prototype._open=function(e,t){const r=indexedDB.open(this.prefix+this.location,this.version);r.onerror=function(){t(r.error||new Error("unknown error"))},r.onsuccess=()=>{this.db=r.result,t()},r.onupgradeneeded=e=>{const t=e.target.result;t.objectStoreNames.contains(this.location)||t.createObjectStore(this.location)}},h.prototype.store=function(e){return this.db.transaction([this.location],e).objectStore(this.location)},h.prototype.await=function(e,t){const r=e.transaction;r.onabort=function(){t(r.error||new Error("aborted by user"))},r.oncomplete=function(){t(null,e.result)}},h.prototype._get=function(e,t,r){const i=this.store("readonly");let n;try{n=i.get(e)}catch(e){return this._nextTick(r,e)}this.await(n,(function(e,i){return e?r(e):void 0===i?r(new Error("NotFound")):void r(null,c(i,t.asBuffer))}))},h.prototype._getMany=function(e,t,r){const i=t.asBuffer,n=this.store("readonly"),o=e.map((e=>t=>{let r;try{r=n.get(e)}catch(e){return t(e)}r.onsuccess=()=>{const e=r.result;t(null,void 0===e?e:c(e,i))},r.onerror=e=>{e.stopPropagation(),t(r.error)}}));s(o,16,r)},h.prototype._del=function(e,t,r){const i=this.store("readwrite");let n;try{n=i.delete(e)}catch(e){return this._nextTick(r,e)}this.await(n,r)},h.prototype._put=function(e,t,r,i){const n=this.store("readwrite");let s;try{s=n.put(t,e)}catch(e){return this._nextTick(i,e)}this.await(s,i)},h.prototype._serializeKey=function(e){return a(e,this.supports.bufferKeys)},h.prototype._serializeValue=function(e){return a(e,!0)},h.prototype._iterator=function(e){return new o(this,this.location,e)},h.prototype._batch=function(e,t,r){if(0===e.length)return this._nextTick(r);const i=this.store("readwrite"),n=i.transaction;let s,o=0;n.onabort=function(){r(s||n.error||new Error("aborted by user"))},n.oncomplete=function(){r()},function t(){const r=e[o++],a=r.key;let c;try{c="del"===r.type?i.delete(a):i.put(r.value,a)}catch(e){return s=e,void n.abort()}o=0)return l(this,this.location,r,e,t);try{const e=this.store("readwrite");i=r?e.delete(r):e.clear()}catch(e){return this._nextTick(t,e)}this.await(i,t)},h.prototype._close=function(e){this.db.close(),this._nextTick(e)},h.prototype.upgrade=function(e){if("open"!==this.status)return this._nextTick(e,new Error("cannot upgrade() before open()"));const t=this.iterator(),r={},i=this;function n(e){if(e)return o(e);t.next(s)}function s(e,t,s){if(e||void 0===t)return o(e);const a=i._serializeKey(c(t,!0)),u=i._serializeValue(c(s,!0));i._batch([{type:"del",key:t},{type:"put",key:a,value:u}],r,n)}function o(r){t.end((function(t){e(r||t)}))}t._deserializeKey=t._deserializeValue=function(e){return e},n()},h.destroy=function(e,t,r){"function"==typeof t&&(r=t,t=f);const i=indexedDB.deleteDatabase(t+e);i.onsuccess=function(){r()},i.onerror=function(e){r(e)}}},{"abstract-leveldown":"f3ZXE",inherits:"j5plK","run-parallel-limit":"i7UCm","./iterator":"K8EMC","./util/serialize":"hGPws","./util/deserialize":"kV0qO","./util/support":"8xE1u","./util/clear":"6sCF8","./util/key-range":"iJjZ3"}],i7UCm:[function(e,t,r){ /*! run-parallel-limit. MIT License. Feross Aboukhadijeh */t.exports=function(e,t,r){if("number"!=typeof t)throw new Error("second argument must be a Number");let n,s,o,a,c,u,l=!0;Array.isArray(e)?(n=[],o=s=e.length):(a=Object.keys(e),n={},o=s=a.length);function d(e){function t(){r&&r(e,n),r=null}l?i(t):t()}function f(t,r,i){if(n[t]=i,r&&(c=!0),0==--o||r)d(r);else if(!c&&u{const t=e.target.result;t&&this.onItem(t)},this._transaction=i,i.onabort=()=>{this.onAbort(this._transaction.error||new Error("aborted by user"))},i.oncomplete=()=>{this.onComplete()}},c.prototype.onItem=function(e){this._cache.push(e.key,e.value),(this._limit<=0||++this._count0){let t=this._cache.shift(),r=this._cache.shift();t=this._keys&&void 0!==t?this._deserializeKey(t,this._keyAsBuffer):void 0,r=this._values&&void 0!==r?this._deserializeValue(r,this._valueAsBuffer):void 0,this._nextTick(e,null,t,r)}else this._completed?this._nextTick(e):this._callback=e},c.prototype._deserializeKey=o,c.prototype._deserializeValue=o,c.prototype._end=function(e){if(this._aborted||this._completed)return this._nextTick(e,this._error);this.onItem=a,this.onAbort=e,this.onComplete=e}},{inherits:"j5plK","abstract-leveldown":"f3ZXE","./util/key-range":"iJjZ3","./util/deserialize":"kV0qO"}],iJjZ3:[function(e,t,r){"use strict";const i=e("ltgt"),n=Symbol("none");t.exports=function(e){const t=i.lowerBound(e,n),r=i.upperBound(e,n),s=i.lowerBoundExclusive(e,n),o=i.upperBoundExclusive(e,n);return t!==n&&r!==n?IDBKeyRange.bound(t,r,s,o):t!==n?IDBKeyRange.lowerBound(t,s):r!==n?IDBKeyRange.upperBound(r,o):null}},{ltgt:"fRjrc"}],fRjrc:[function(e,t,r){var i=e("buffer").Buffer;function n(e){return void 0!==e&&""!==e}function s(e,t){return Object.hasOwnProperty.call(e,t)}function o(e,t){return Object.hasOwnProperty.call(e,t)&&t}r.compare=function(e,t){if(i.isBuffer(e)){for(var r=Math.min(e.length,t.length),n=0;nt?1:0};var a=r.lowerBoundKey=function(e){return o(e,"gt")||o(e,"gte")||o(e,"min")||(e.reverse?o(e,"end"):o(e,"start"))||void 0},c=r.lowerBound=function(e,t){var r=a(e);return r?e[r]:t},u=r.lowerBoundInclusive=function(e){return!s(e,"gt")},l=r.upperBoundInclusive=function(e){return!s(e,"lt")},d=r.lowerBoundExclusive=function(e){return!u(e)},f=r.upperBoundExclusive=function(e){return!l(e)},h=r.upperBoundKey=function(e){return o(e,"lt")||o(e,"lte")||o(e,"max")||(e.reverse?o(e,"start"):o(e,"end"))||void 0},p=r.upperBound=function(e,t){var r=h(e);return r?e[r]:t};function g(e){return e}r.start=function(e,t){return e.reverse?p(e,t):c(e,t)},r.end=function(e,t){return e.reverse?c(e,t):p(e,t)},r.startInclusive=function(e){return e.reverse?l(e):u(e)},r.endInclusive=function(e){return e.reverse?u(e):l(e)},r.toLtgt=function(e,t,i,n,o){t=t||{},i=i||g;var a=arguments.length>3,c=r.lowerBoundKey(e),u=r.upperBoundKey(e);return c?"gt"===c?t.gt=i(e.gt,!1):t.gte=i(e[c],!1):a&&(t.gte=i(n,!1)),u?"lt"===u?t.lt=i(e.lt,!0):t.lte=i(e[u],!0):a&&(t.lte=i(o,!0)),null!=e.reverse&&(t.reverse=!!e.reverse),s(t,"max")&&delete t.max,s(t,"min")&&delete t.min,s(t,"start")&&delete t.start,s(t,"end")&&delete t.end,t},r.contains=function(e,t,i){i=i||r.compare;var s=c(e);if(n(s)&&((o=i(t,s))<0||0===o&&d(e)))return!1;var o,a=p(e);if(n(a)&&((o=i(t,a))>0||0===o&&f(e)))return!1;return!0},r.filter=function(e,t){return function(i){return r.contains(e,i,t)}}},{buffer:"etowf"}],kV0qO:[function(e,t,r){var i=arguments[3];const n=e("buffer").Buffer,s=function(){if(i.TextDecoder){const e=new TextDecoder("utf-8");return e.decode.bind(e)}return function(e){return a(e).toString()}}(),o=function(){if(i.TextDecoder){const e=new TextDecoder("utf-8");return e.decode.bind(e)}return function(e){return n.from(e).toString()}}();function a(e){const t=n.from(e.buffer);return e.byteLength===e.buffer.byteLength?t:t.slice(e.byteOffset,e.byteOffset+e.byteLength)}t.exports=function(e,t){return e instanceof Uint8Array?t?a(e):s(e):e instanceof ArrayBuffer?t?n.from(e):o(e):t?n.from(String(e)):String(e)}},{buffer:"etowf"}],hGPws:[function(e,t,r){var i=arguments[3];const n=e("buffer").Buffer,s=function(){if(i.TextEncoder){const e=new TextEncoder("utf-8");return e.encode.bind(e)}return n.from}();t.exports=function(e,t){return t?n.isBuffer(e)?e:s(String(e)):String(e)}},{buffer:"etowf"}],"8xE1u":[function(e,t,r){"use strict";const i=e("buffer").Buffer;r.test=function(e){return function(t){try{return t.cmp(e,0),!0}catch(e){return!1}}},r.bufferKeys=r.test(i.alloc(0))},{buffer:"etowf"}],"6sCF8":[function(e,t,r){"use strict";t.exports=function(e,t,r,i,n){if(0===i.limit)return e._nextTick(n);const s=e.db.transaction([t],"readwrite"),o=s.objectStore(t);let a=0;s.oncomplete=function(){n()},s.onabort=function(){n(s.error||new Error("aborted by user"))};const c=o.openKeyCursor?"openKeyCursor":"openCursor",u=i.reverse?"prev":"next";o[c](r,u).onsuccess=function(e){const t=e.target.result;t&&(o.delete(t.key).onsuccess=function(){(i.limit<=0||++au.base32.decode(e.toLowerCase()).subarray(2):"c"===t.toLowerCase()?e=>u.base32pad.decode(e.toLowerCase()).subarray(2):"z"===t?e=>l.base58btc.decode(e).subarray(2):"Q"===t?e=>l.base58btc.decode("z"+e):e=>u.base32.decode("b"+e.toLowerCase()).subarray(2);for(let t=1;tt=>e({key:_(t.key),value:t.value}))):void 0,orders:e.orders?e.orders.map((e=>(t,r)=>e({key:_(t.key),value:t.value},{key:_(r.key),value:r.value}))):void 0}}(e),t))yield{key:_(r),value:i}}async*queryKeys(e,t){for await(const i of this.child.queryKeys((r=e,{...r,prefix:r.prefix?E(r.prefix):void 0,filters:r.filters?r.filters.map((e=>t=>e(_(t)))):void 0,orders:r.orders?r.orders.map((e=>(t,r)=>e(_(t),_(r)))):void 0}),t))yield _(i);var r}async get(e,t){return this.child.get(w(e),t)}async*getMany(e,t){for await(const r of e)yield this.get(r,t)}async put(e,t,r){await this.child.put(w(e),t,r)}async*putMany(e,t){const r=y.default();(globalThis.process&&globalThis.process.nextTick?globalThis.process.nextTick:globalThis.setImmediate||globalThis.setTimeout)((async()=>{try{const i=this.child;await g.default(this.child.putMany(async function*(){for await(const n of e){const e=w(n.key);await i.has(e,t)||(yield{key:e,value:n.value}),r.push(n)}}())),r.end()}catch(e){r.end(e)}})),yield*r}has(e,t){return this.child.has(w(e),t)}delete(e,t){return this.child.delete(w(e),t)}deleteMany(e,t){const r=y.default();return g.default(this.child.deleteMany(async function*(){for await(const t of e)yield w(t),r.push(t);r.end()}(),t)).catch((e=>{r.end(e)})),r}}r.BlockstoreDatastoreAdapter=S},{"it-drain":"dKYhO","it-pushable":"bnpei","interface-datastore/key":"9hGOz","multiformats/cid":"9ooAY","multiformats/codecs/raw":"fdfgp","multiformats/hashes/digest":"kpRBg","multiformats/bases/base32":"5k9Tu","multiformats/bases/base58":"4n7mA","err-code":"chZjB","blockstore-core/base":"l2CNM"}],l2CNM:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("it-drain"),n=e("it-filter"),s=e("it-take"),o=e("it-all");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=a(i),u=a(n),l=a(s),d=a(o);const f=(e,t)=>async function*(){const r=await d.default(e);yield*r.sort(t)}();r.BaseBlockstore=class{open(){return Promise.reject(new Error(".open is not implemented"))}close(){return Promise.reject(new Error(".close is not implemented"))}put(e,t,r){return Promise.reject(new Error(".put is not implemented"))}get(e,t){return Promise.reject(new Error(".get is not implemented"))}has(e,t){return Promise.reject(new Error(".has is not implemented"))}delete(e,t){return Promise.reject(new Error(".delete is not implemented"))}async*putMany(e,t={}){for await(const{key:r,value:i}of e)await this.put(r,i,t),yield{key:r,value:i}}async*getMany(e,t={}){for await(const r of e)yield this.get(r,t)}async*deleteMany(e,t={}){for await(const r of e)await this.delete(r,t),yield r}batch(){let e=[],t=[];return{put(t,r){e.push({key:t,value:r})},delete(e){t.push(e)},commit:async r=>{await c.default(this.putMany(e,r)),e=[],await c.default(this.deleteMany(t,r)),t=[]}}}async*_all(e,t){throw new Error("._all is not implemented")}async*_allKeys(e,t){throw new Error("._allKeys is not implemented")}query(e,t){let r=this._all(e,t);if(null!=e.prefix&&(r=u.default(r,(t=>t.key.toString().startsWith(e.prefix||"")))),Array.isArray(e.filters)&&(r=e.filters.reduce(((e,t)=>u.default(e,t)),r)),Array.isArray(e.orders)&&(r=e.orders.reduce(((e,t)=>f(e,t)),r)),null!=e.offset){let t=0;r=u.default(r,(()=>t++>=(e.offset||0)))}return null!=e.limit&&(r=l.default(r,e.limit)),r}queryKeys(e,t){let r=this._allKeys(e,t);if(null!=e.prefix&&(r=u.default(r,(t=>t.toString().startsWith(e.prefix||"")))),Array.isArray(e.filters)&&(r=e.filters.reduce(((e,t)=>u.default(e,t)),r)),Array.isArray(e.orders)&&(r=e.orders.reduce(((e,t)=>f(e,t)),r)),null!=e.offset){let t=0;r=u.default(r,(()=>t++>=e.offset))}return null!=e.limit&&(r=l.default(r,e.limit)),r}}},{"it-drain":"dKYhO","it-filter":"5LCTL","it-take":"gxr1t","it-all":"iCXBu"}],jcB2q:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("dlv"),n=e("merge-options"),s=e("err-code"),o=e("ipfs-core-config/libp2p-pubsub-routers"),a=e("libp2p-delegated-peer-routing"),c=e("libp2p-delegated-content-routing"),u=e("ipfs-http-client"),l=e("multiaddr"),d=e("../version.js"),f=e("ipfs-core-config/libp2p"),h=e("libp2p-bootstrap"),p=e("libp2p");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var y=g(i),m=g(n),b=g(s),v=g(a),w=g(c),_=g(h),E=g(p);const S=m.default.bind({ignoreUndefined:!0});r.createLibp2p=function({options:e={},peerId:t,multiaddrs:r=[],repo:i,keychainConfig:n={},config:s={}}){const{datastore:a,keys:c}=i,h=function({options:e,config:t,datastore:r,keys:i,keychainConfig:n,peerId:s,multiaddrs:a}){const c={datastore:r,peerId:s,modules:{}},h={modules:{pubsub:(()=>{const e=y.default(t,"Pubsub.Router")||"gossipsub";if(!o.routers[e])throw b.default(new Error(`Router unavailable. Configure libp2p.modules.pubsub to use the ${e} router.`),"ERR_NOT_SUPPORTED");return o.routers[e]})(),contentRouting:[],peerRouting:[]},config:{peerDiscovery:{mdns:{enabled:y.default(e,"config.Discovery.MDNS.Enabled",y.default(t,"Discovery.MDNS.Enabled",!0))},webRTCStar:{enabled:y.default(e,"config.Discovery.webRTCStar.Enabled",y.default(t,"Discovery.webRTCStar.Enabled",!0))},bootstrap:{list:y.default(e,"config.Bootstrap",y.default(t,"Bootstrap",[]))}},relay:{enabled:y.default(e,"relay.enabled",y.default(t,"relay.enabled",!0)),hop:{enabled:y.default(e,"relay.hop.enabled",y.default(t,"relay.hop.enabled",!1)),active:y.default(e,"relay.hop.active",y.default(t,"relay.hop.active",!1))}},dht:{enabled:"none"!==y.default(t,"Routing.Type","none"),clientMode:"dhtserver"!==y.default(t,"Routing.Type","dht"),kBucketSize:y.default(e,"dht.kBucketSize",20)},pubsub:{enabled:y.default(e,"config.Pubsub.Enabled",y.default(t,"Pubsub.Enabled",!0))},nat:{enabled:!y.default(t,"Swarm.DisableNatPortMap",!1)}},addresses:{listen:a.map((e=>e.toString())),announce:y.default(e,"addresses.announce",y.default(t,"Addresses.Announce",[])),noAnnounce:y.default(e,"addresses.noAnnounce",y.default(t,"Addresses.NoAnnounce",[]))},connectionManager:y.default(e,"connectionManager",{maxConnections:y.default(e,"config.Swarm.ConnMgr.HighWater",y.default(t,"Swarm.ConnMgr.HighWater")),minConnections:y.default(e,"config.Swarm.ConnMgr.LowWater",y.default(t,"Swarm.ConnMgr.LowWater"))}),keychain:{datastore:i,...n},host:{agentVersion:`js-ipfs/${d.ipfsCore}`}};let p=y.default(e,"libp2p",void 0);"function"==typeof p&&(p=void 0);const g=S(c,f.libp2pConfig(),h,p);y.default(g,"config.peerDiscovery.bootstrap.list",[]).length>0&&g.modules.peerDiscovery.push(_.default);const m=y.default(e,"config.Addresses.Delegates",y.default(t,"Addresses.Delegates",[]));if(m.length>0){const e=m[Math.floor(Math.random()*m.length)],t=new l.Multiaddr(e).toOptions(),r={host:t.host,protocol:443===parseInt(t.port)?"https":"http",port:t.port},i=u.create(r);h.modules.contentRouting=h.modules.contentRouting||[],h.modules.contentRouting.push(new w.default(s,i)),h.modules.peerRouting=h.modules.peerRouting||[],h.modules.peerRouting.push(new v.default(i))}return g}({options:e,config:s,datastore:a,keys:c,keychainConfig:n,peerId:t,multiaddrs:r});return"function"==typeof e.libp2p?e.libp2p({libp2pOptions:h,options:e,config:s,datastore:a,peerId:t}):E.default.create(h)}},{dlv:"hp0pQ","merge-options":"fupyv","err-code":"chZjB","ipfs-core-config/libp2p-pubsub-routers":"3XeOM","libp2p-delegated-peer-routing":"jgA5e","libp2p-delegated-content-routing":"gg6SI","ipfs-http-client":"h5Uk6",multiaddr:"8Mu1u","../version.js":"cyFMr","ipfs-core-config/libp2p":"eStoI","libp2p-bootstrap":"hla2J",libp2p:"757Qe"}],"3XeOM":[function(e,t,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(r,"__esModule",{value:!0});const n={gossipsub:i(e("libp2p-gossipsub")).default};r.routers=n},{"libp2p-gossipsub":"eSowE"}],eSowE:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t},o=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))((function(n,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))};const a=s(e("libp2p-interfaces/src/pubsub")),c=e("./message-cache"),u=e("./message/rpc"),l=s(e("./constants")),d=e("./heartbeat"),f=e("./get-gossip-peers"),h=e("./utils"),p=e("./score"),g=e("./tracer"),y=e("time-cache"),m=e("peer-id"),b=e("libp2p/src/record/envelope");class v extends a.default{constructor(e,t={}){const r=[l.GossipsubIDv11,l.GossipsubIDv10],i=Object.assign(Object.assign({gossipIncoming:!0,fallbackToFloodsub:!0,floodPublish:!0,doPX:!1,directPeers:[],D:l.GossipsubD,Dlo:l.GossipsubDlo,Dhi:l.GossipsubDhi,Dscore:l.GossipsubDscore,Dout:l.GossipsubDout,Dlazy:l.GossipsubDlazy,heartbeatInterval:l.GossipsubHeartbeatInterval,fanoutTTL:l.GossipsubFanoutTTL,mcacheLength:l.GossipsubHistoryLength,mcacheGossip:l.GossipsubHistoryGossip,seenTTL:l.GossipsubSeenTTL},t),{scoreParams:p.createPeerScoreParams(t.scoreParams),scoreThresholds:p.createPeerScoreThresholds(t.scoreThresholds)});i.fallbackToFloodsub&&r.push(l.FloodsubID),super(Object.assign({debugName:"libp2p:gossipsub",multicodecs:r,libp2p:e},i)),this._options=i,this.direct=new Set(i.directPeers.map((e=>e.id.toB58String()))),i.directPeers.forEach((t=>{e.peerStore.addressBook.add(t.id,t.addrs)})),this.seenCache=new y({validity:i.seenTTL/1e3}),this.mesh=new Map,this.fanout=new Map,this.lastpub=new Map,this.gossip=new Map,this.control=new Map,this.peerhave=new Map,this.iasked=new Map,this.backoff=new Map,this.outbound=new Map,this.messageCache=t.messageCache||new c.MessageCache(i.mcacheGossip,i.mcacheLength,this.getMsgId.bind(this)),this.heartbeat=new d.Heartbeat(this),this.heartbeatTicks=0,this.gossipTracer=new g.IWantTracer(this.getMsgId.bind(this)),this._libp2p=e,this.score=new p.PeerScore(this._options.scoreParams,e.connectionManager,this.getMsgId.bind(this))}_decodeRpc(e){return u.RPC.decode(e)}_encodeRpc(e){return u.RPC.encode(e).finish()}_addPeer(e,t){const r=super._addPeer(e,t);this.score.addPeer(e.toB58String());let i=!1;for(const r of this._libp2p.connectionManager.getAll(e))if("outbound"===r.stat.direction&&Array.from(r.registry.values()).some((e=>t===e.protocol))){i=!0;break}return this.outbound.set(r.id.toB58String(),i),r}_removePeer(e){const t=super._removePeer(e),r=e.toB58String();for(const e of this.mesh.values())e.delete(r);for(const e of this.fanout.values())e.delete(r);return this.gossip.delete(r),this.control.delete(r),this.outbound.delete(r),this.score.removePeer(r),t}_processRpc(e,t,r){const i=Object.create(null,{_processRpc:{get:()=>super._processRpc}});return o(this,void 0,void 0,(function*(){return!!(yield i._processRpc.call(this,e,t,r))&&(r.control&&this._processRpcControlMessage(e,r.control),!0)}))}_processRpcControlMessage(e,t){if(!t)return;const r=t.ihave?this._handleIHave(e,t.ihave):[],i=t.iwant?this._handleIWant(e,t.iwant):[],n=t.graft?this._handleGraft(e,t.graft):[];if(t.prune&&this._handlePrune(e,t.prune),!r.length&&!i.length&&!n.length)return;const s=h.createGossipRpc(i,{iwant:r,prune:n});this._sendRpc(e,s)}_processRpcMessage(e){const t=Object.create(null,{_processRpcMessage:{get:()=>super._processRpcMessage}});return o(this,void 0,void 0,(function*(){const r=yield this.getMsgId(e),i=h.messageIdToString(r);this.seenCache.has(i)?this.score.duplicateMessage(e):(this.seenCache.put(i),yield this.score.validateMessage(e),yield t._processRpcMessage.call(this,e))}))}_acceptFrom(e){return this.direct.has(e)||this.score.score(e)>=this._options.scoreThresholds.graylistThreshold}validate(e){const t=Object.create(null,{validate:{get:()=>super.validate}});return o(this,void 0,void 0,(function*(){try{yield t.validate.call(this,e)}catch(t){throw this.score.rejectMessage(e,t.code),this.gossipTracer.rejectMessage(e,t.code),t}}))}_handleIHave(e,t){if(!t.length)return[];const r=this.score.score(e);if(rl.GossipsubMaxIHaveMessages)return this.log("IHAVE: peer %s has advertised too many times (%d) within this heartbeat interval; ignoring",e,i),[];const n=this.iasked.get(e)||0;if(n>=l.GossipsubMaxIHaveLength)return this.log("IHAVE: peer %s has already advertised too many messages (%d); ignoring",e,n),[];const s=new Map;if(t.forEach((({topicID:e,messageIDs:t})=>{e&&t&&this.mesh.has(e)&&t.forEach((e=>{const t=h.messageIdToString(e);this.seenCache.has(t)||s.set(t,e)}))})),!s.size)return[];let o=s.size;o+n>l.GossipsubMaxIHaveLength&&(o=l.GossipsubMaxIHaveLength-n),this.log("IHAVE: Asking for %d out of %d messages from %s",o,s.size,e);let a=Array.from(s.values());return h.shuffle(a),a=a.slice(0,o),this.iasked.set(e,n+o),this.gossipTracer.addPromise(e,a),[{messageIDs:a}]}_handleIWant(e,t){if(!t.length)return[];const r=this.score.score(e);if(r{t&&t.forEach((t=>{const[r,n]=this.messageCache.getForPeer(t,e);r&&(n>l.GossipsubGossipRetransmission?this.log("IWANT: Peer %s has asked for message %s too many times: ignoring request",e,t):i.set(h.messageIdToString(t),r))}))})),i.size?(this.log("IWANT: Sending %d messages to %s",i.size,e),Array.from(i.values()).map(a.utils.normalizeOutRpcMessage)):[]}_handleGraft(e,t){const r=[],i=this.score.score(e),n=this._now();let s=this._options.doPX;return t.forEach((({topicID:t})=>{var o;if(!t)return;const a=this.mesh.get(t);if(!a)return void(s=!1);if(a.has(e))return;if(this.direct.has(e))return this.log("GRAFT: ignoring request from direct peer %s",e),r.push(t),void(s=!1);const c=null===(o=this.backoff.get(t))||void 0===o?void 0:o.get(e);if("number"==typeof c&&n=this._options.Dhi&&!this.outbound.get(e)?(r.push(t),void this._addBackoff(e,t)):(this.log("GRAFT: Add mesh link from %s in %s",e,t),this.score.graft(e,t),void a.add(e))})),r.length?r.map((t=>this._makePrune(e,t,s))):[]}_handlePrune(e,t){const r=this.score.score(e);t.forEach((({topicID:t,backoff:i,peers:n})=>{if(!t)return;const s=this.mesh.get(t);if(s&&(this.log("PRUNE: Remove mesh link to %s in %s",e,t),this.score.prune(e,t),s.delete(e),"number"==typeof i&&i>0?this._doAddBackoff(e,t,1e3*i):this._addBackoff(e,t),n&&n.length)){if(r{this.log("peer %s didn't follow up in %d IWANT requests; adding penalty",t,e),this.score.addPenalty(t,e)}))}_clearBackoff(){if(this.heartbeatTicks%l.GossipsubPruneBackoffTicks!=0)return;const e=this._now();this.backoff.forEach(((t,r)=>{t.forEach(((r,i)=>{r{const r=this.peers.get(t);r&&r.isWritable||e.push(t)})),e.length&&e.forEach((e=>{this._connect(e)}))}_pxConnect(e){return o(this,void 0,void 0,(function*(){e.length>l.GossipsubPrunePeers&&(h.shuffle(e),e=e.slice(0,l.GossipsubPrunePeers));const t=[];yield Promise.all(e.map((e=>o(this,void 0,void 0,(function*(){if(!e.peerID)return;const r=m.createFromBytes(e.peerID).toB58String();if(!this.peers.has(r))if(e.signedPeerRecord)try{const i=yield b.openAndCertify(e.signedPeerRecord,"libp2p-peer-record"),n=i.peerId.toB58String();if(r!==n)return void this.log("bogus peer record obtained through px: peer ID %s doesn't match expected peer %s",n,r);if(!this._libp2p.peerStore.addressBook.consumePeerRecord(i))return void this.log("bogus peer record obtained through px: could not add peer record to address book");t.push(r)}catch(e){this.log("bogus peer record obtained through px: invalid signature or not a peer record")}else t.push(r)}))))),t.length&&t.forEach((e=>this._connect(e)))}))}start(){super.start(),this.heartbeat.start(),this.score.start(),this._directPeerInitial=setTimeout((()=>{this.direct.forEach((e=>{this._connect(e)}))}),l.GossipsubDirectConnectInitialDelay)}stop(){super.stop(),this.heartbeat.stop(),this.score.stop(),this.mesh=new Map,this.fanout=new Map,this.lastpub=new Map,this.gossip=new Map,this.control=new Map,this.peerhave=new Map,this.iasked=new Map,this.backoff=new Map,this.outbound=new Map,this.gossipTracer.clear(),clearTimeout(this._directPeerInitial)}_connect(e){this.log("Initiating connection with %s",e),this._libp2p.dialProtocol(m.createFromB58String(e),this.multicodecs)}subscribe(e){super.subscribe(e),this.join(e)}unsubscribe(e){super.unsubscribe(e),this.leave(e)}join(e){if(!this.started)throw new Error("Gossipsub has not started");this.log("JOIN %s",e);const t=this.fanout.get(e);if(t)t.forEach((e=>{this.score.score(e)<0&&t.delete(e)})),t.size!t.has(e)&&!this.direct.has(e)&&this.score.score(e)>=0)).forEach((e=>t.add(e))),this.mesh.set(e,t),this.fanout.delete(e),this.lastpub.delete(e);else{const t=f.getGossipPeers(this,e,this._options.D,(e=>!this.direct.has(e)&&this.score.score(e)>=0));this.mesh.set(e,t)}this.mesh.get(e).forEach((t=>{this.log("JOIN: Add mesh link to %s in %s",t,e),this._sendGraft(t,e)}))}leave(e){if(!this.started)throw new Error("Gossipsub has not started");this.log("LEAVE %s",e);const t=this.mesh.get(e);t&&(t.forEach((t=>{this.log("LEAVE: Remove mesh link to %s in %s",t,e),this._sendPrune(t,e)})),this.mesh.delete(e))}_publish(e){return o(this,void 0,void 0,(function*(){e.receivedFrom!==this.peerId.toB58String()&&(this.score.deliverMessage(e),this.gossipTracer.deliverMessage(e));const t=yield this.getMsgId(e),r=h.messageIdToString(t);this.seenCache.put(r),this.messageCache.put(e);const i=new Set;e.topicIDs.forEach((t=>{const r=this.topics.get(t);if(r)if(this._options.floodPublish&&e.from===this.peerId.toB58String())r.forEach((e=>{(this.direct.has(e)||this.score.score(e)>=this._options.scoreThresholds.publishThreshold)&&i.add(e)}));else{this.direct.forEach((e=>{i.add(e)})),r.forEach((e=>{const t=this.score.score(e),r=this.peers.get(e);r&&r.protocol===l.FloodsubID&&t>=this._options.scoreThresholds.publishThreshold&&i.add(e)}));let e=this.mesh.get(t);if(!e||!e.size){if(e=this.fanout.get(t),!e){const r=f.getGossipPeers(this,t,this._options.D,(e=>this.score.score(e)>=this._options.scoreThresholds.publishThreshold));r.size>0?(e=r,this.fanout.set(t,r)):e=new Set}this.lastpub.set(t,this._now())}e.forEach((e=>{i.add(e)}))}}));const n=h.createGossipRpc([a.utils.normalizeOutRpcMessage(e)]);i.forEach((t=>{t!==e.from&&this._sendRpc(t,n)}))}))}_sendGraft(e,t){const r=[{topicID:t}],i=h.createGossipRpc([],{graft:r});this._sendRpc(e,i)}_sendPrune(e,t){const r=[this._makePrune(e,t,this._options.doPX)],i=h.createGossipRpc([],{prune:r});this._sendRpc(e,i)}_sendRpc(e,t){const r=this.peers.get(e);if(!r||!r.isWritable)return;const i=this.control.get(e);i&&(this._piggybackControl(e,t,i),this.control.delete(e));const n=this.gossip.get(e);n&&(this._piggybackGossip(e,t,n),this.gossip.delete(e)),r.write(u.RPC.encode(t).finish())}_piggybackControl(e,t,r){const i=(r.graft||[]).filter((({topicID:t})=>(t&&this.mesh.get(t)||new Set).has(e))),n=(r.prune||[]).filter((({topicID:t})=>!(t&&this.mesh.get(t)||new Set).has(e)));(i.length||n.length)&&(t.control?(t.control.graft=t.control.graft&&t.control.graft.concat(i),t.control.prune=t.control.prune&&t.control.prune.concat(n)):t.control={ihave:[],iwant:[],graft:i,prune:n})}_piggybackGossip(e,t,r){t.control||(t.control={ihave:[],iwant:[],graft:[],prune:[]}),t.control.ihave=r}_sendGraftPrune(e,t,r){const i=this._options.doPX;for(const[n,s]of e){const e=s.map((e=>({topicID:e})));let o=[];const a=t.get(n);a&&(o=a.map((e=>this._makePrune(n,e,i&&!r.get(n)))),t.delete(n));const c=h.createGossipRpc([],{graft:e,prune:o});this._sendRpc(n,c)}for(const[e,n]of t){const t=n.map((t=>this._makePrune(e,t,i&&!r.get(e)))),s=h.createGossipRpc([],{prune:t});this._sendRpc(e,s)}}_emitGossip(e,t){const r=this.messageCache.getGossipIDs(e);if(!r.length)return;h.shuffle(r),r.length>l.GossipsubMaxIHaveLength&&this.log("too many messages for gossip; will truncate IHAVE list (%d messages)",r.length);const i=[],n=this.topics.get(e);if(!n)return;n.forEach((e=>{const r=this.peers.get(e);r&&!t.has(e)&&!this.direct.has(e)&&h.hasGossipProtocol(r.protocol)&&this.score.score(e)>=this._options.scoreThresholds.gossipThreshold&&i.push(e)}));let s=this._options.Dlazy;const o=l.GossipsubGossipFactor*i.length;o>s&&(s=o),s>i.length?s=i.length:h.shuffle(i),i.slice(0,s).forEach((t=>{let i=r;r.length>l.GossipsubMaxIHaveLength&&(i=h.shuffle(i.slice()).slice(0,l.GossipsubMaxIHaveLength)),this._pushGossip(t,{topicID:e,messageIDs:i})}))}_flush(){for(const[e,t]of this.gossip.entries()){this.gossip.delete(e);const r=h.createGossipRpc([],{ihave:t});this._sendRpc(e,r)}for(const[e,t]of this.control.entries()){this.control.delete(e);const r=h.createGossipRpc([],{graft:t.graft,prune:t.prune});this._sendRpc(e,r)}}_pushGossip(e,t){this.log("Add gossip to %s",e);const r=this.gossip.get(e)||[];this.gossip.set(e,r.concat(t))}_now(){return Date.now()}_makePrune(e,t,r){if(this.peers.get(e).protocol===l.GossipsubIDv10)return{topicID:t,peers:[]};const i=l.GossipsubPruneBackoff/1e3,n=[];if(r){f.getGossipPeers(this,t,l.GossipsubPrunePeers,(t=>t!==e&&this.score.score(t)>=0)).forEach((e=>{const t=m.createFromB58String(e);n.push({peerID:t.toBytes(),signedPeerRecord:this._libp2p.peerStore.addressBook.getRawEnvelope(t)})}))}return{topicID:t,peers:n,backoff:i}}}v.multicodec=l.GossipsubIDv11,t.exports=v},{"libp2p-interfaces/src/pubsub":"6JRpn","./message-cache":"gJumF","./message/rpc":"8UPPx","./constants":"kx67k","./heartbeat":"l9R1d","./get-gossip-peers":"jYUGm","./utils":"8kUZs","./score":"8Uy6q","./tracer":"8V5x8","time-cache":"gpqKk","peer-id":"8Bdb3","libp2p/src/record/envelope":"27rHX"}],"6JRpn":[function(e,t,r){"use strict";const i=e("debug"),{EventEmitter:n}=e("events"),s=e("err-code"),{pipe:o}=e("it-pipe"),{default:a}=e("p-queue"),c=e("../topology/multicodec-topology"),{codes:u}=e("./errors"),{RPC:l}=e("./message/rpc"),d=e("./peer-streams"),{SignaturePolicy:f}=e("./signature-policy"),h=e("./utils"),{signMessage:p,verifySignature:g}=e("./message/sign");class y extends n{constructor({debugName:e,multicodecs:t,libp2p:r,globalSignaturePolicy:n=f.StrictSign,canRelayMessage:o=!1,emitSelf:c=!1,messageProcessingConcurrency:l=10}){if("string"!=typeof e)throw new Error("a debugname `string` is required");if(!t)throw new Error("multicodecs are required");if(!r)throw new Error("libp2p is required");if(super(),this.log=Object.assign(i(e),{err:i(`${e}:error`)}),this.multicodecs=h.ensureArray(t),this._libp2p=r,this.registrar=r.registrar,this.peerId=r.peerId,this.started=!1,this.topics=new Map,this.subscriptions=new Set,this.peers=new Map,!f[n])throw s(new Error("Invalid global signature policy"),u.ERR_INVALID_SIGNATURE_POLICY);this.globalSignaturePolicy=n,this.canRelayMessage=o,this.emitSelf=c,this.topicValidators=new Map,this.queue=new a({concurrency:l}),this._registrarId=void 0,this._onIncomingStream=this._onIncomingStream.bind(this),this._onPeerConnected=this._onPeerConnected.bind(this),this._onPeerDisconnected=this._onPeerDisconnected.bind(this)}start(){if(this.started)return;this.log("starting"),this.registrar.handle(this.multicodecs,this._onIncomingStream);const e=new c({multicodecs:this.multicodecs,handlers:{onConnect:this._onPeerConnected,onDisconnect:this._onPeerDisconnected}});this._registrarId=this.registrar.register(e),this.log("started"),this.started=!0}stop(){this.started&&(this.registrar.unregister(this._registrarId),this.log("stopping"),this.peers.forEach((e=>e.close())),this.peers=new Map,this.subscriptions=new Set,this.started=!1,this.log("stopped"))}_onIncomingStream({protocol:e,stream:t,connection:r}){const i=r.remotePeer,n=i.toB58String(),s=this._addPeer(i,e),o=s.attachInboundStream(t);this._processMessages(n,o,s)}async _onPeerConnected(e,t){const r=e.toB58String();this.log("connected",r);try{const{stream:r,protocol:i}=await t.newStream(this.multicodecs),n=this._addPeer(e,i);await n.attachOutboundStream(r)}catch(e){this.log.err(e)}this._sendSubscriptions(r,Array.from(this.subscriptions),!0)}_onPeerDisconnected(e,t){const r=e.toB58String();this.log("connection ended",r,t?t.message:""),this._removePeer(e)}_addPeer(e,t){const r=e.toB58String(),i=this.peers.get(r);if(i)return i;this.log("new peer",r);const n=new d({id:e,protocol:t});return this.peers.set(r,n),n.once("close",(()=>this._removePeer(e))),n}_removePeer(e){if(!e)return;const t=e.toB58String(),r=this.peers.get(t);if(r){r.removeAllListeners(),r.close(),this.log("delete peer",t),this.peers.delete(t);for(const e of this.topics.values())e.delete(t);return r}}async _processMessages(e,t,r){try{await o(t,(async t=>{for await(const i of t){const t=i instanceof Uint8Array?i:i.slice(),n=this._decodeRpc(t);(async()=>{try{await this._processRpc(e,r,n)}catch(e){this.log.err(e)}})()}}))}catch(e){this._onPeerDisconnected(r.id,e)}}async _processRpc(e,t,r){this.log("rpc from",e);const i=r.subscriptions,n=r.msgs;return i.length&&(i.forEach((t=>{this._processRpcSubOpt(e,t)})),this.emit("pubsub:subscription-change",t.id,i)),this._acceptFrom(e)?(n.length&&this.queue.addAll(n.map((t=>async()=>{if(this.canRelayMessage||t.topicIDs&&t.topicIDs.some((e=>this.subscriptions.has(e))))try{const r=h.normalizeInRpcMessage(t,e);await this._processRpcMessage(r)}catch(e){this.log.err(e)}else this.log("received message we didn't subscribe to. Dropping.")}))),!0):(this.log("received message from unacceptable peer %s",e),!1)}_processRpcSubOpt(e,t){const r=t.topicID;if(!r)return;let i=this.topics.get(r);i||(i=new Set,this.topics.set(r,i)),t.subscribe?i.add(e):i.delete(e)}async _processRpcMessage(e){if(this.peerId.toB58String()!==e.from||this.emitSelf){try{await this.validate(e)}catch(e){return void this.log("Message is invalid, dropping it. %O",e)}return this._emitMessage(e),this._publish(h.normalizeOutRpcMessage(e))}}_emitMessage(e){e.topicIDs.forEach((t=>{this.subscriptions.has(t)&&this.emit(t,e)}))}getMsgId(e){const t=this.globalSignaturePolicy;switch(t){case f.StrictSign:return h.msgId(e.from,e.seqno);case f.StrictNoSign:return h.noSignMsgId(e.data);default:throw s(new Error("Cannot get message id: unhandled signature policy: "+t),u.ERR_UNHANDLED_SIGNATURE_POLICY)}}_acceptFrom(e){return!0}_decodeRpc(e){return l.decode(e)}_encodeRpc(e){return l.encode(e).finish()}_sendRpc(e,t){const r=this.peers.get(e);if(r&&r.isWritable)r.write(this._encodeRpc(t));else{const t=`Cannot send RPC to ${e} as there is no open stream to it available`;this.log.err(t)}}_sendSubscriptions(e,t,r){return this._sendRpc(e,{subscriptions:t.map((e=>({topicID:e,subscribe:r})))})}async validate(e){const t=this.globalSignaturePolicy;switch(t){case f.StrictNoSign:if(e.from)throw s(new Error("StrictNoSigning: from should not be present"),u.ERR_UNEXPECTED_FROM);if(e.signature)throw s(new Error("StrictNoSigning: signature should not be present"),u.ERR_UNEXPECTED_SIGNATURE);if(e.key)throw s(new Error("StrictNoSigning: key should not be present"),u.ERR_UNEXPECTED_KEY);if(e.seqno)throw s(new Error("StrictNoSigning: seqno should not be present"),u.ERR_UNEXPECTED_SEQNO);break;case f.StrictSign:if(!e.signature)throw s(new Error("StrictSigning: Signing required and no signature was present"),u.ERR_MISSING_SIGNATURE);if(!e.seqno)throw s(new Error("StrictSigning: Signing required and no seqno was present"),u.ERR_MISSING_SEQNO);if(!await g(e))throw s(new Error("StrictSigning: Invalid message signature"),u.ERR_INVALID_SIGNATURE);break;default:throw s(new Error("Cannot validate message: unhandled signature policy: "+t),u.ERR_UNHANDLED_SIGNATURE_POLICY)}for(const t of e.topicIDs){const r=this.topicValidators.get(t);r&&await r(t,e)}}_buildMessage(e){const t=this.globalSignaturePolicy;switch(t){case f.StrictSign:return e.from=this.peerId.toB58String(),e.seqno=h.randomSeqno(),p(this.peerId,e);case f.StrictNoSign:return Promise.resolve(e);default:throw s(new Error("Cannot build message: unhandled signature policy: "+t),u.ERR_UNHANDLED_SIGNATURE_POLICY)}}getSubscribers(e){if(!this.started)throw s(new Error("not started yet"),"ERR_NOT_STARTED_YET");if(!e||"string"!=typeof e)throw s(new Error("a string topic must be provided"),"ERR_NOT_VALID_TOPIC");const t=this.topics.get(e);return t?Array.from(t):[]}async publish(e,t){if(!this.started)throw new Error("Pubsub has not started");this.log("publish",e,t);const r={receivedFrom:this.peerId.toB58String(),data:t,topicIDs:[e]},i=await this._buildMessage(r),n=h.normalizeInRpcMessage(i);this.emitSelf&&this._emitMessage(n),await this._publish(n)}_publish(e){throw s(new Error("publish must be implemented by the subclass"),"ERR_NOT_IMPLEMENTED")}subscribe(e){if(!this.started)throw new Error("Pubsub has not started");this.subscriptions.has(e)||(this.subscriptions.add(e),this.peers.forEach(((t,r)=>this._sendSubscriptions(r,[e],!0))))}unsubscribe(e){if(!this.started)throw new Error("Pubsub is not started");this.subscriptions.has(e)&&0===this.listenerCount(e)&&(this.subscriptions.delete(e),this.peers.forEach(((t,r)=>this._sendSubscriptions(r,[e],!1))))}getTopics(){if(!this.started)throw new Error("Pubsub is not started");return Array.from(this.subscriptions)}}y.utils=h,y.SignaturePolicy=f,t.exports=y},{debug:"bO5wM",events:"g82pp","err-code":"chZjB","it-pipe":"giKBQ","p-queue":"biPlv","../topology/multicodec-topology":"52SML","./errors":"i7hyG","./message/rpc":"27BcS","./peer-streams":"l6fHJ","./signature-policy":"dUKk2","./utils":"3CEYj","./message/sign":"2dsDd"}],"52SML":[function(e,t,r){"use strict";const i=e("./index"),n=Symbol.for("@libp2p/js-interfaces/topology/multicodec-topology");class s extends i{constructor({min:e,max:t,multicodecs:r,handlers:i}){if(super({min:e,max:t,handlers:i}),!r)throw new Error("one or more multicodec should be provided");if(!i)throw new Error("the handlers should be provided");if("function"!=typeof i.onConnect)throw new Error("the 'onConnect' handler must be provided");if("function"!=typeof i.onDisconnect)throw new Error("the 'onDisconnect' handler must be provided");this.multicodecs=Array.isArray(r)?r:[r],this._registrar=void 0,this._onProtocolChange=this._onProtocolChange.bind(this),this._onPeerConnect=this._onPeerConnect.bind(this)}get[Symbol.toStringTag](){return"Topology"}get[n](){return!0}static isMulticodecTopology(e){return Boolean(e&&e[n])}set registrar(e){this._registrar=e,this._registrar.peerStore.on("change:protocols",this._onProtocolChange),this._registrar.connectionManager.on("peer:connect",this._onPeerConnect),this._updatePeers(this._registrar.peerStore.peers.values())}_updatePeers(e){for(const{id:t,protocols:r}of e)if(this.multicodecs.filter((e=>r.includes(e))).length){this.peers.add(t.toB58String());const e=this._registrar.getConnection(t);e&&this._onConnect(t,e)}else this.peers.delete(t.toB58String())}_onProtocolChange({peerId:e,protocols:t}){const r=this.peers.has(e.toB58String()),i=t.filter((e=>this.multicodecs.includes(e)));r&&0===i.length&&this._onDisconnect(e);for(const r of t)if(this.multicodecs.includes(r)){const t=this._registrar.peerStore.get(e);return void this._updatePeers([t])}}_onPeerConnect(e){const t=e.remotePeer,r=this._registrar.peerStore.protoBook.get(t);r&&this.multicodecs.find((e=>r.includes(e)))&&(this.peers.add(t.toB58String()),this._onConnect(t,e))}}t.exports=s},{"./index":"6HbOL"}],"6HbOL":[function(e,t,r){"use strict";const i=()=>{},n=Symbol.for("@libp2p/js-interfaces/topology");class s{constructor({min:e=0,max:t=1/0,handlers:r={}}){this.min=e,this.max=t,this._onConnect=r.onConnect||i,this._onDisconnect=r.onDisconnect||i,this.peers=new Set}get[Symbol.toStringTag](){return"Topology"}get[n](){return!0}static isTopology(e){return Boolean(e&&e[n])}set registrar(e){this._registrar=e}disconnect(e){this._onDisconnect(e)}}t.exports=s},{}],i7hyG:[function(e,t,r){"use strict";r.codes={ERR_INVALID_SIGNATURE_POLICY:"ERR_INVALID_SIGNATURE_POLICY",ERR_UNHANDLED_SIGNATURE_POLICY:"ERR_UNHANDLED_SIGNATURE_POLICY",ERR_MISSING_SIGNATURE:"ERR_MISSING_SIGNATURE",ERR_MISSING_SEQNO:"ERR_MISSING_SEQNO",ERR_INVALID_SIGNATURE:"ERR_INVALID_SIGNATURE",ERR_UNEXPECTED_FROM:"ERR_UNEXPECTED_FROM",ERR_UNEXPECTED_SIGNATURE:"ERR_UNEXPECTED_SIGNATURE",ERR_UNEXPECTED_KEY:"ERR_UNEXPECTED_KEY",ERR_UNEXPECTED_SEQNO:"ERR_UNEXPECTED_SEQNO"}},{}],"27BcS":[function(e,t,r){"use strict";var i=e("protobufjs/minimal"),n=i.Reader,s=i.Writer,o=i.util,a=i.roots["libp2p-pubsub-rpc"]||(i.roots["libp2p-pubsub-rpc"]={});a.RPC=function(){function e(e){if(this.subscriptions=[],this.msgs=[],e)for(var t=Object.keys(e),r=0;r>>3){case 1:i.subscriptions&&i.subscriptions.length||(i.subscriptions=[]),i.subscriptions.push(a.RPC.SubOpts.decode(e,e.uint32()));break;case 2:i.msgs&&i.msgs.length||(i.msgs=[]),i.msgs.push(a.RPC.Message.decode(e,e.uint32()));break;default:e.skipType(7&s)}}return i},e.fromObject=function(e){if(e instanceof a.RPC)return e;var t=new a.RPC;if(e.subscriptions){if(!Array.isArray(e.subscriptions))throw TypeError(".RPC.subscriptions: array expected");t.subscriptions=[];for(var r=0;r>>3){case 1:i.subscribe=e.bool();break;case 2:i.topicID=e.string();break;default:e.skipType(7&s)}}return i},e.fromObject=function(e){if(e instanceof a.RPC.SubOpts)return e;var t=new a.RPC.SubOpts;return null!=e.subscribe&&(t.subscribe=Boolean(e.subscribe)),null!=e.topicID&&(t.topicID=String(e.topicID)),t},e.toObject=function(e,t){t||(t={});var r={};return null!=e.subscribe&&e.hasOwnProperty("subscribe")&&(r.subscribe=e.subscribe,t.oneofs&&(r._subscribe="subscribe")),null!=e.topicID&&e.hasOwnProperty("topicID")&&(r.topicID=e.topicID,t.oneofs&&(r._topicID="topicID")),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e}(),e.Message=function(){function e(e){if(this.topicIDs=[],e)for(var t=Object.keys(e),r=0;r>>3){case 1:i.from=e.bytes();break;case 2:i.data=e.bytes();break;case 3:i.seqno=e.bytes();break;case 4:i.topicIDs&&i.topicIDs.length||(i.topicIDs=[]),i.topicIDs.push(e.string());break;case 5:i.signature=e.bytes();break;case 6:i.key=e.bytes();break;default:e.skipType(7&s)}}return i},e.fromObject=function(e){if(e instanceof a.RPC.Message)return e;var t=new a.RPC.Message;if(null!=e.from&&("string"==typeof e.from?o.base64.decode(e.from,t.from=o.newBuffer(o.base64.length(e.from)),0):e.from.length&&(t.from=e.from)),null!=e.data&&("string"==typeof e.data?o.base64.decode(e.data,t.data=o.newBuffer(o.base64.length(e.data)),0):e.data.length&&(t.data=e.data)),null!=e.seqno&&("string"==typeof e.seqno?o.base64.decode(e.seqno,t.seqno=o.newBuffer(o.base64.length(e.seqno)),0):e.seqno.length&&(t.seqno=e.seqno)),e.topicIDs){if(!Array.isArray(e.topicIDs))throw TypeError(".RPC.Message.topicIDs: array expected");t.topicIDs=[];for(var r=0;r{this._rawOutboundStream&&this._rawOutboundStream.reset&&this._rawOutboundStream.reset(),this._rawOutboundStream=null,this.outboundStream=null,e&&this.emit("close")}}),c(this.outboundStream,o.encode(),this._rawOutboundStream).catch((e=>{n.error(e)})),t||this.emit("stream:outbound")}close(){this.outboundStream&&this.outboundStream.end(),this.inboundStream&&this._inboundAbortController.abort(),this._rawOutboundStream=null,this.outboundStream=null,this._rawInboundStream=null,this.inboundStream=null,this.emit("close")}}},{debug:"bO5wM",events:"g82pp","it-length-prefixed":"3yxIE","it-pushable":"bnpei","it-pipe":"giKBQ","abortable-iterator":"awlU8","abort-controller":"lNJ7z"}],"3yxIE":[function(e,t,r){"use strict";r.encode=e("./encode"),r.decode=e("./decode"),r.varintEncode=e("./varint-encode"),r.varintDecode=e("./varint-decode"),r.int32BEEncode=e("./int32BE-encode"),r.int32BEDecode=e("./int32BE-decode")},{"./encode":"d162i","./decode":"gBAfD","./varint-encode":"c11wj","./varint-decode":"eMugP","./int32BE-encode":"lRnoQ","./int32BE-decode":"aDo5s"}],d162i:[function(e,t,r){"use strict";const{Buffer:i}=e("buffer"),n=e("bl/BufferList"),s=e("./varint-encode");function o(e){e=e||{};const t=Math.max(e.poolSize||10240,e.minPoolSize||8),r=e.lengthEncoder||s;return async function*(e){let s=i.alloc(t),o=0;for await(const a of e){r(a.length,s,o);const e=s.slice(o,o+r.bytes);o+=r.bytes,s.length-o<8&&(s=i.alloc(t),o=0),yield(new n).append(e).append(a)}}}o.single=(e,t)=>{const r=(t=t||{}).lengthEncoder||s;return new n([r(e.length),e.slice()])},t.exports=o,t.exports.MIN_POOL_SIZE=8,t.exports.DEFAULT_POOL_SIZE=10240},{buffer:"etowf","bl/BufferList":"im7j6","./varint-encode":"c11wj"}],c11wj:[function(e,t,r){"use strict";const i=e("varint"),{Buffer:n}=e("buffer"),s=(e,t,r)=>{const o=i.encode(e,t,r);return s.bytes=i.encode.bytes,t||n.from(o)};t.exports=s},{varint:"aN1CO",buffer:"etowf"}],gBAfD:[function(e,t,r){"use strict";const{Buffer:i}=e("buffer"),n=e("bl/BufferList"),s=e("./varint-decode"),o=4194304,a=i.alloc(0),c="readLength",u="readData",l={[c]:(e,t,r,i)=>{let s;t=t.append(e);try{s=i.lengthDecoder(t)}catch(e){if(t.length>i.maxLengthLength)throw Object.assign(e,{message:"message length too long",code:"ERR_MSG_LENGTH_TOO_LONG"});if(e instanceof RangeError)return{mode:c,buffer:t,chunk:void 0,state:void 0,data:void 0};throw e}if(s>i.maxDataLength)throw Object.assign(new Error("message data too long"),{code:"ERR_MSG_DATA_TOO_LONG"});return e=t.shallowSlice(i.lengthDecoder.bytes),t=new n,i.onLength&&i.onLength(s),s<=0?(i.onData&&i.onData(a),{mode:c,chunk:e,buffer:t,data:a}):{mode:u,chunk:e,buffer:t,state:{dataLength:s},data:void 0}},[u]:(e,t,r,i)=>{if(t=t.append(e),!r)throw new Error("state is required");if(t.lengths?t.shallowSlice(s):void 0;return t=new n,i.onData&&i.onData(o),{mode:c,chunk:a,buffer:t,state:void 0,data:o}}};function d(e){const t={lengthDecoder:(e=e||{}).lengthDecoder||s,maxLengthLength:e.maxLengthLength||8,maxDataLength:e.maxDataLength||o,onLength:e.onLength,onData:e.onData};return async function*(e){let r,i=new n,s=c;for await(const n of e){let e=n;for(;e;){const n=l[s](e,i,r,t);s=n.mode,e=n.chunk,i=n.buffer,r=n.state,n.data&&(yield n.data)}}if(i.length)throw Object.assign(new Error("unexpected end of input"),{code:"ERR_UNEXPECTED_EOF"})}}d.fromReader=(e,t)=>{let r=1;const i={[Symbol.asyncIterator](){return this},next:async()=>{try{return await e.next(r)}catch(e){if("ERR_UNDER_READ"===e.code)return{done:!0,value:null};throw e}finally{r=1}}};return d({...t||{},onLength:e=>{r=e}})(i)},t.exports=d,t.exports.MAX_LENGTH_LENGTH=8,t.exports.MAX_DATA_LENGTH=o},{buffer:"etowf","bl/BufferList":"im7j6","./varint-decode":"eMugP"}],eMugP:[function(e,t,r){"use strict";const i=e("varint"),{Buffer:n}=e("buffer"),s=e=>{const t=i.decode(n.isBuffer(e)?e:(r=e,new Proxy({},{get:(e,t)=>"l"===t[0]?r[t]:r.get(parseInt(t))})));var r;return s.bytes=i.decode.bytes,t};t.exports=s},{varint:"aN1CO",buffer:"etowf"}],lRnoQ:[function(e,t,r){"use strict";const{Buffer:i}=e("buffer"),n=(e,t,r)=>((t=t||i.allocUnsafe(4)).writeInt32BE(e,r),t);n.bytes=4,t.exports=n},{buffer:"etowf"}],aDo5s:[function(e,t,r){"use strict";const i=e=>{if(e.length<4)throw RangeError("Could not decode int32BE");return e.readInt32BE(0)};i.bytes=4,t.exports=i},{}],awlU8:[function(e,t,r){const i=e("get-iterator"),n=e("./AbortError"),s=(e,t,r)=>o(e,Array.isArray(t)?t:[{signal:t,options:r}]),o=(e,t)=>(e=i(e),t=t.map((({signal:e,options:t})=>({signal:e,options:t||{}}))),async function*(){let r;const i=()=>{r&&r()};for(const{signal:e}of t)e.addEventListener("abort",i);for(;;){let s;try{for(const{signal:e,options:r}of t)if(e.aborted){const{abortMessage:e,abortCode:t}=r;throw new n(e,t)}const i=new Promise(((e,i)=>{r=()=>{const{options:e}=t.find((({signal:e})=>e.aborted)),{abortMessage:r,abortCode:s}=e;i(new n(r,s))}}));s=await Promise.race([i,e.next()]),r=null}catch(r){for(const{signal:e}of t)e.removeEventListener("abort",i);const n=t.find((({signal:e})=>e.aborted)),s="aborted"===r.type&&n;if(s&&n.options.onAbort&&await n.options.onAbort(e),"function"==typeof e.return&&await e.return(),s&&n.options.returnOnAbort)return;throw r}if(s.done)break;yield s.value}for(const{signal:e}of t)e.removeEventListener("abort",i)}()),a=(e,t,r)=>c(e,Array.isArray(t)?t:[{signal:t,options:r}]),c=(e,t)=>r=>e(o(r,t)),u=(e,t)=>({sink:c(e.sink,t),source:o(e.source,t)});t.exports=s,t.exports.AbortError=n,t.exports.source=s,t.exports.sink=a,t.exports.transform=a,t.exports.duplex=(e,t,r)=>u(e,Array.isArray(t)?t:[{signal:t,options:r}])},{"get-iterator":"li8y1","./AbortError":"daAph"}],li8y1:[function(e,t,r){t.exports=function(e){if(e){if("function"==typeof e[Symbol.iterator])return e[Symbol.iterator]();if("function"==typeof e[Symbol.asyncIterator])return e[Symbol.asyncIterator]();if("function"==typeof e.next)return e}throw new Error("argument is not an iterator or iterable")}},{}],daAph:[function(e,t,r){t.exports=class extends Error{constructor(e,t){super(e||"The operation was aborted"),this.type="aborted",this.code=t||"ABORT_ERR"}}},{}],dUKk2:[function(e,t,r){"use strict";r.SignaturePolicy={StrictSign:"StrictSign",StrictNoSign:"StrictNoSign"}},{}],"3CEYj":[function(e,t,r){"use strict";const i=e("libp2p-crypto/src/random-bytes"),{toString:n}=e("uint8arrays/to-string"),{fromString:s}=e("uint8arrays/from-string"),o=e("peer-id"),{sha256:a}=e("multiformats/hashes/sha2");t.exports={randomSeqno:()=>i(8),msgId:(e,t)=>{let r;r=e instanceof Uint8Array?o.createFromBytes(e).id:o.parse(e).id;const i=new Uint8Array(r.length+t.length);return i.set(r,0),i.set(t,r.length),i},noSignMsgId:e=>a.encode(e),anyMatch:(e,t)=>{let r;r=Array.isArray(t)?e=>t.indexOf(e)>-1:e=>t.has(e);for(const t of e)if(r(t))return!0;return!1},ensureArray:e=>Array.isArray(e)?e:[e],normalizeInRpcMessage:(e,t)=>{const r=Object.assign({},e);return e.from instanceof Uint8Array&&(r.from=n(e.from,"base58btc")),t&&(r.receivedFrom=t),r},normalizeOutRpcMessage:e=>{const t=Object.assign({},e);return"string"==typeof e.from&&(t.from=s(e.from,"base58btc")),"string"==typeof e.data&&(t.data=s(e.data)),t}}},{"libp2p-crypto/src/random-bytes":"gsnuW","uint8arrays/to-string":"hC8JB","uint8arrays/from-string":"dF7Y4","peer-id":"8Bdb3","multiformats/hashes/sha2":"7i9MT"}],"2dsDd":[function(e,t,r){"use strict";const i=e("peer-id"),{RPC:n}=e("./rpc"),{concat:s}=e("uint8arrays/concat"),{fromString:o}=e("uint8arrays/from-string"),a=o("libp2p-pubsub:"),{normalizeOutRpcMessage:c}=e("../utils");async function u(e){if(!e.from)throw new Error("Could not get the public key from the originator id");const t=i.createFromB58String(e.from);if(e.key){const r=await i.createFromPubKey(e.key);if(r.equals(t))return r.pubKey;throw new Error("Public Key does not match the originator")}if(t.pubKey)return t.pubKey;throw new Error("Could not get the public key from the originator id")}t.exports={messagePublicKey:u,signMessage:async function(e,t){const r=s([a,n.Message.encode(c(t)).finish()]),i=await e.privKey.sign(r);return{...t,signature:i,key:e.pubKey.bytes}},SignPrefix:a,verifySignature:async function(e){if(!e.signature)throw new Error("Message must contain a signature to be verified");if(!e.from)throw new Error("Message must contain a from property to be verified");const t=s([a,n.Message.encode({...e,from:i.createFromB58String(e.from).toBytes(),signature:void 0,key:void 0}).finish()]);return(await u(e)).verify(t,e.signature)}}},{"peer-id":"8Bdb3","./rpc":"27BcS","uint8arrays/concat":"4EBjG","uint8arrays/from-string":"dF7Y4","../utils":"3CEYj"}],gJumF:[function(e,t,r){"use strict";var i=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))((function(n,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(r,"__esModule",{value:!0}),r.MessageCache=void 0;const n=e("./utils");r.MessageCache=class{constructor(e,t,r){this.msgs=new Map,this.peertx=new Map,this.history=[];for(let e=0;e{for(const i of r.topics)if(i===e){t.push(r.msgID);break}}));return t}shift(){this.history[this.history.length-1].forEach((e=>{const t=n.messageIdToString(e.msgID);this.msgs.delete(t),this.peertx.delete(t)})),this.history.pop(),this.history.unshift([])}}},{"./utils":"8kUZs"}],"8kUZs":[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),n(e("./create-gossip-rpc"),r),n(e("./shuffle"),r),n(e("./has-gossip-protocol"),r),n(e("./messageIdToString"),r)},{"./create-gossip-rpc":"8OYkT","./shuffle":"e1hER","./has-gossip-protocol":"l4KwQ","./messageIdToString":"8V5xp"}],"8OYkT":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.createGossipRpc=void 0,r.createGossipRpc=function(e=[],t={}){return{subscriptions:[],msgs:e,control:Object.assign({ihave:[],iwant:[],graft:[],prune:[]},t)}}},{}],e1hER:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.shuffle=void 0,r.shuffle=function(e){if(e.length<=1)return e;for(let t=0;t>>3){case 1:s.subscriptions&&s.subscriptions.length||(s.subscriptions=[]),s.subscriptions.push(n.RPC.SubOpts.decode(e,e.uint32()));break;case 2:s.msgs&&s.msgs.length||(s.msgs=[]),s.msgs.push(n.RPC.Message.decode(e,e.uint32()));break;case 3:s.control=n.RPC.ControlMessage.decode(e,e.uint32());break;default:e.skipType(7&o)}}return s},s.fromObject=function(e){if(e instanceof n.RPC)return e;var t=new n.RPC;if(e.subscriptions){if(!Array.isArray(e.subscriptions))throw TypeError(".RPC.subscriptions: array expected");t.subscriptions=[];for(var r=0;r>>3){case 1:s.subscribe=e.bool();break;case 2:s.topicID=e.string();break;default:e.skipType(7&o)}}return s},s.fromObject=function(e){if(e instanceof n.RPC.SubOpts)return e;var t=new n.RPC.SubOpts;return null!=e.subscribe&&(t.subscribe=Boolean(e.subscribe)),null!=e.topicID&&(t.topicID=String(e.topicID)),t},s.toObject=function(e,t){t||(t={});var r={};return null!=e.subscribe&&e.hasOwnProperty("subscribe")&&(r.subscribe=e.subscribe,t.oneofs&&(r._subscribe="subscribe")),null!=e.topicID&&e.hasOwnProperty("topicID")&&(r.topicID=e.topicID,t.oneofs&&(r._topicID="topicID")),r},s.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},s}(),s.Message=function(){function s(e){if(this.topicIDs=[],e)for(var t=Object.keys(e),r=0;r>>3){case 1:s.from=e.bytes();break;case 2:s.data=e.bytes();break;case 3:s.seqno=e.bytes();break;case 4:s.topicIDs&&s.topicIDs.length||(s.topicIDs=[]),s.topicIDs.push(e.string());break;case 5:s.signature=e.bytes();break;case 6:s.key=e.bytes();break;default:e.skipType(7&o)}}return s},s.fromObject=function(e){if(e instanceof n.RPC.Message)return e;var t=new n.RPC.Message;if(null!=e.from&&("string"==typeof e.from?i.base64.decode(e.from,t.from=i.newBuffer(i.base64.length(e.from)),0):e.from.length&&(t.from=e.from)),null!=e.data&&("string"==typeof e.data?i.base64.decode(e.data,t.data=i.newBuffer(i.base64.length(e.data)),0):e.data.length&&(t.data=e.data)),null!=e.seqno&&("string"==typeof e.seqno?i.base64.decode(e.seqno,t.seqno=i.newBuffer(i.base64.length(e.seqno)),0):e.seqno.length&&(t.seqno=e.seqno)),e.topicIDs){if(!Array.isArray(e.topicIDs))throw TypeError(".RPC.Message.topicIDs: array expected");t.topicIDs=[];for(var r=0;r>>3){case 1:s.ihave&&s.ihave.length||(s.ihave=[]),s.ihave.push(n.RPC.ControlIHave.decode(e,e.uint32()));break;case 2:s.iwant&&s.iwant.length||(s.iwant=[]),s.iwant.push(n.RPC.ControlIWant.decode(e,e.uint32()));break;case 3:s.graft&&s.graft.length||(s.graft=[]),s.graft.push(n.RPC.ControlGraft.decode(e,e.uint32()));break;case 4:s.prune&&s.prune.length||(s.prune=[]),s.prune.push(n.RPC.ControlPrune.decode(e,e.uint32()));break;default:e.skipType(7&o)}}return s},s.fromObject=function(e){if(e instanceof n.RPC.ControlMessage)return e;var t=new n.RPC.ControlMessage;if(e.ihave){if(!Array.isArray(e.ihave))throw TypeError(".RPC.ControlMessage.ihave: array expected");t.ihave=[];for(var r=0;r>>3){case 1:s.topicID=e.string();break;case 2:s.messageIDs&&s.messageIDs.length||(s.messageIDs=[]),s.messageIDs.push(e.bytes());break;default:e.skipType(7&o)}}return s},s.fromObject=function(e){if(e instanceof n.RPC.ControlIHave)return e;var t=new n.RPC.ControlIHave;if(null!=e.topicID&&(t.topicID=String(e.topicID)),e.messageIDs){if(!Array.isArray(e.messageIDs))throw TypeError(".RPC.ControlIHave.messageIDs: array expected");t.messageIDs=[];for(var r=0;r>>3==1?(s.messageIDs&&s.messageIDs.length||(s.messageIDs=[]),s.messageIDs.push(e.bytes())):e.skipType(7&o)}return s},s.fromObject=function(e){if(e instanceof n.RPC.ControlIWant)return e;var t=new n.RPC.ControlIWant;if(e.messageIDs){if(!Array.isArray(e.messageIDs))throw TypeError(".RPC.ControlIWant.messageIDs: array expected");t.messageIDs=[];for(var r=0;r>>3==1?s.topicID=e.string():e.skipType(7&o)}return s},s.fromObject=function(e){if(e instanceof n.RPC.ControlGraft)return e;var t=new n.RPC.ControlGraft;return null!=e.topicID&&(t.topicID=String(e.topicID)),t},s.toObject=function(e,t){t||(t={});var r={};return null!=e.topicID&&e.hasOwnProperty("topicID")&&(r.topicID=e.topicID,t.oneofs&&(r._topicID="topicID")),r},s.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},s}(),s.ControlPrune=function(){function s(e){if(this.peers=[],e)for(var t=Object.keys(e),r=0;r>>3){case 1:s.topicID=e.string();break;case 2:s.peers&&s.peers.length||(s.peers=[]),s.peers.push(n.RPC.PeerInfo.decode(e,e.uint32()));break;case 3:s.backoff=e.uint64();break;default:e.skipType(7&o)}}return s},s.fromObject=function(e){if(e instanceof n.RPC.ControlPrune)return e;var t=new n.RPC.ControlPrune;if(null!=e.topicID&&(t.topicID=String(e.topicID)),e.peers){if(!Array.isArray(e.peers))throw TypeError(".RPC.ControlPrune.peers: array expected");t.peers=[];for(var r=0;r>>0,e.backoff.high>>>0).toNumber(!0))),t},s.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.peers=[]),null!=e.topicID&&e.hasOwnProperty("topicID")&&(r.topicID=e.topicID,t.oneofs&&(r._topicID="topicID")),e.peers&&e.peers.length){r.peers=[];for(var s=0;s>>0,e.backoff.high>>>0).toNumber(!0):e.backoff,t.oneofs&&(r._backoff="backoff")),r},s.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},s}(),s.PeerInfo=function(){function s(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:s.peerID=e.bytes();break;case 2:s.signedPeerRecord=e.bytes();break;default:e.skipType(7&o)}}return s},s.fromObject=function(e){if(e instanceof n.RPC.PeerInfo)return e;var t=new n.RPC.PeerInfo;return null!=e.peerID&&("string"==typeof e.peerID?i.base64.decode(e.peerID,t.peerID=i.newBuffer(i.base64.length(e.peerID)),0):e.peerID.length&&(t.peerID=e.peerID)),null!=e.signedPeerRecord&&("string"==typeof e.signedPeerRecord?i.base64.decode(e.signedPeerRecord,t.signedPeerRecord=i.newBuffer(i.base64.length(e.signedPeerRecord)),0):e.signedPeerRecord.length&&(t.signedPeerRecord=e.signedPeerRecord)),t},s.toObject=function(e,t){t||(t={});var r={};return null!=e.peerID&&e.hasOwnProperty("peerID")&&(r.peerID=t.bytes===String?i.base64.encode(e.peerID,0,e.peerID.length):t.bytes===Array?Array.prototype.slice.call(e.peerID):e.peerID,t.oneofs&&(r._peerID="peerID")),null!=e.signedPeerRecord&&e.hasOwnProperty("signedPeerRecord")&&(r.signedPeerRecord=t.bytes===String?i.base64.encode(e.signedPeerRecord,0,e.signedPeerRecord.length):t.bytes===Array?Array.prototype.slice.call(e.signedPeerRecord):e.signedPeerRecord,t.oneofs&&(r._signedPeerRecord="signedPeerRecord")),r},s.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},s}(),s}(),n},"function"==typeof define&&define.amd?define(["protobufjs/minimal"],i):"function"==typeof e&&"object"==typeof t&&t&&t.exports&&(t.exports=i(e("protobufjs/minimal")))},{"protobufjs/minimal":"grAXL"}],l9R1d:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.Heartbeat=void 0;const o=s(e("./constants")),a=e("./get-gossip-peers"),c=e("./utils");r.Heartbeat=class{constructor(e){this.gossipsub=e}start(){if(this._heartbeatTimer)return;const e=this._heartbeat.bind(this),t=setTimeout((()=>{e(),this._heartbeatTimer.runPeriodically(e,this.gossipsub._options.heartbeatInterval)}),o.GossipsubHeartbeatInitialDelay);this._heartbeatTimer={_intervalId:void 0,runPeriodically:(e,t)=>{this._heartbeatTimer._intervalId=setInterval(e,t)},cancel:()=>{clearTimeout(t),clearInterval(this._heartbeatTimer._intervalId)}}}stop(){this._heartbeatTimer&&(this._heartbeatTimer.cancel(),this._heartbeatTimer=null)}_heartbeat(){const{D:e,Dlo:t,Dhi:r,Dscore:i,Dout:n,fanoutTTL:s}=this.gossipsub._options;this.gossipsub.heartbeatTicks++;const u=new Map,l=e=>{let t=u.get(e);return void 0===t&&(t=this.gossipsub.score.score(e),u.set(e,t)),t},d=new Map,f=new Map,h=new Map;this.gossipsub._clearBackoff(),this.gossipsub.peerhave.clear(),this.gossipsub.iasked.clear(),this.gossipsub._applyIwantPenalties(),this.gossipsub._directConnect(),this.gossipsub.mesh.forEach(((s,u)=>{const p=e=>{this.gossipsub.log("HEARTBEAT: Remove mesh link to %s in %s",e,u),this.gossipsub.score.prune(e,u),this.gossipsub._addBackoff(e,u),s.delete(e);const t=f.get(e);t?t.push(u):f.set(e,[u])},g=e=>{this.gossipsub.log("HEARTBEAT: Add mesh link to %s in %s",e,u),this.gossipsub.score.graft(e,u),s.add(e);const t=d.get(e);t?t.push(u):d.set(e,[u])};if(s.forEach((e=>{const t=l(e);t<0&&(this.gossipsub.log("HEARTBEAT: Prune peer %s with negative score: score=%d, topic=%s",e,t,u),p(e),h.set(e,!0))})),s.size!s.has(e)&&!this.gossipsub.direct.has(e)&&(!t||!t.has(e))&&l(e)>=0)).forEach(g)}if(s.size>r){let t=Array.from(s);t.sort(((e,t)=>l(t)-l(e))),t=t.slice(0,i).concat(c.shuffle(t.slice(i)));let r=0;if(t.slice(0,e).forEach((e=>{this.gossipsub.outbound.get(e)&&r++})),r{const r=t[e];for(let r=e;r>0;r--)t[r]=t[r-1];t[0]=r};if(r>0){let n=r;for(let r=1;r0;r++)this.gossipsub.outbound.get(t[r])&&(i(r),n--)}let n=e-r;for(let r=e;r0;r++)this.gossipsub.outbound.get(t[r])&&(i(r),n--)}t.slice(e).forEach(p)}if(s.size>=t){let e=0;if(s.forEach((t=>{this.gossipsub.outbound.get(t)&&e++})),e!s.has(e)&&!this.gossipsub.direct.has(e)&&(!r||!r.has(e))&&l(e)>=0)).forEach(g)}}if(this.gossipsub.heartbeatTicks%o.GossipsubOpportunisticGraftTicks==0&&s.size>1){const e=Array.from(s).sort(((e,t)=>l(e)-l(t))),t=Math.floor(s.size/2),r=l(e[t]);if(rs.has(t)&&!this.gossipsub.direct.has(t)&&(!e||!e.has(t))&&l(t)>r)).forEach((e=>{this.gossipsub.log("HEARTBEAT: Opportunistically graft peer %s on topic %s",e,u),g(e)}))}}this.gossipsub._emitGossip(u,s)}));const p=this.gossipsub._now();this.gossipsub.lastpub.forEach(((e,t)=>{e+s{const i=this.gossipsub.topics.get(r);if(t.forEach((e=>{(!i.has(e)||l(e)!t.has(e)&&!this.gossipsub.direct.has(e)&&l(e)>=this.gossipsub._options.scoreThresholds.publishThreshold)).forEach((e=>{t.add(e)}))}this.gossipsub._emitGossip(r,t)})),this.gossipsub._sendGraftPrune(d,f,h),this.gossipsub._flush(),this.gossipsub.messageCache.shift(),this.gossipsub.emit("gossipsub:heartbeat")}}},{"./constants":"kx67k","./get-gossip-peers":"jYUGm","./utils":"8kUZs"}],jYUGm:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.getGossipPeers=void 0;const i=e("./utils");r.getGossipPeers=function(e,t,r,n=(()=>!0)){const s=e.topics.get(t);if(!s)return new Set;let o=[];return s.forEach((t=>{const r=e.peers.get(t);r&&i.hasGossipProtocol(r.protocol)&&n(t)&&o.push(t)})),o=i.shuffle(o),r>0&&o.length>r&&(o=o.slice(0,r)),new Set(o)}},{"./utils":"8kUZs"}],"8Uy6q":[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),n(e("./peer-score-params"),r),n(e("./peer-score-thresholds"),r),n(e("./peer-score"),r)},{"./peer-score-params":"lHcoR","./peer-score-thresholds":"kpAfK","./peer-score":"2EtC2"}],lHcoR:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.validateTopicScoreParams=r.validatePeerScoreParams=r.createTopicScoreParams=r.createPeerScoreParams=r.defaultTopicScoreParams=r.defaultPeerScoreParams=void 0;const i=e("./constants"),n=e("err-code");function s(e={}){return Object.assign(Object.assign({},r.defaultTopicScoreParams),e)}function o(e){if(e.topicWeight<0)throw n(new Error("invalid topic weight; must be >= 0"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(0===e.timeInMeshQuantum)throw n(new Error("invalid TimeInMeshQuantum; must be non zero"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(e.timeInMeshWeight<0)throw n(new Error("invalid TimeInMeshWeight; must be positive (or 0 to disable)"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.timeInMeshWeight&&e.timeInMeshQuantum<=0)throw n(new Error("invalid TimeInMeshQuantum; must be positive"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.timeInMeshWeight&&e.timeInMeshCap<=0)throw n(new Error("invalid TimeInMeshCap; must be positive"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(e.firstMessageDeliveriesWeight<0)throw n(new Error("invallid FirstMessageDeliveriesWeight; must be positive (or 0 to disable)"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.firstMessageDeliveriesWeight&&(e.firstMessageDeliveriesDecay<=0||e.firstMessageDeliveriesDecay>=1))throw n(new Error("invalid FirstMessageDeliveriesDecay; must be between 0 and 1"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.firstMessageDeliveriesWeight&&e.firstMessageDeliveriesCap<=0)throw n(new Error("invalid FirstMessageDeliveriesCap; must be positive"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(e.meshMessageDeliveriesWeight>0)throw n(new Error("invalid MeshMessageDeliveriesWeight; must be negative (or 0 to disable)"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.meshMessageDeliveriesWeight&&(e.meshMessageDeliveriesDecay<=0||e.meshMessageDeliveriesDecay>=1))throw n(new Error("invalid MeshMessageDeliveriesDecay; must be between 0 and 1"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.meshMessageDeliveriesWeight&&e.meshMessageDeliveriesCap<=0)throw n(new Error("invalid MeshMessageDeliveriesCap; must be positive"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.meshMessageDeliveriesWeight&&e.meshMessageDeliveriesThreshold<=0)throw n(new Error("invalid MeshMessageDeliveriesThreshold; must be positive"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(e.meshMessageDeliveriesWindow<0)throw n(new Error("invalid MeshMessageDeliveriesWindow; must be non-negative"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.meshMessageDeliveriesWeight&&e.meshMessageDeliveriesActivation<1e3)throw n(new Error("invalid MeshMessageDeliveriesActivation; must be at least 1s"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(e.meshFailurePenaltyWeight>0)throw n(new Error("invalid MeshFailurePenaltyWeight; must be negative (or 0 to disable)"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.meshFailurePenaltyWeight&&(e.meshFailurePenaltyDecay<=0||e.meshFailurePenaltyDecay>=1))throw n(new Error("invalid MeshFailurePenaltyDecay; must be between 0 and 1"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(e.invalidMessageDeliveriesWeight>0)throw n(new Error("invalid InvalidMessageDeliveriesWeight; must be negative (or 0 to disable)"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(e.invalidMessageDeliveriesDecay<=0||e.invalidMessageDeliveriesDecay>=1)throw n(new Error("invalid InvalidMessageDeliveriesDecay; must be between 0 and 1"),i.ERR_INVALID_PEER_SCORE_PARAMS)}r.defaultPeerScoreParams={topics:{},topicScoreCap:10,appSpecificScore:()=>0,appSpecificWeight:10,IPColocationFactorWeight:-5,IPColocationFactorThreshold:10,IPColocationFactorWhitelist:new Set,behaviourPenaltyWeight:-10,behaviourPenaltyDecay:.2,decayInterval:1e3,decayToZero:.1,retainScore:36e5},r.defaultTopicScoreParams={topicWeight:.5,timeInMeshWeight:1,timeInMeshQuantum:1,timeInMeshCap:3600,firstMessageDeliveriesWeight:1,firstMessageDeliveriesDecay:.5,firstMessageDeliveriesCap:2e3,meshMessageDeliveriesWeight:-1,meshMessageDeliveriesDecay:.5,meshMessageDeliveriesCap:100,meshMessageDeliveriesThreshold:20,meshMessageDeliveriesWindow:10,meshMessageDeliveriesActivation:5e3,meshFailurePenaltyWeight:-1,meshFailurePenaltyDecay:.5,invalidMessageDeliveriesWeight:-1,invalidMessageDeliveriesDecay:.3},r.createPeerScoreParams=function(e={}){return Object.assign(Object.assign(Object.assign({},r.defaultPeerScoreParams),e),{topics:e.topics?Object.entries(e.topics).reduce(((e,[t,r])=>(e[t]=s(r),e)),{}):{}})},r.createTopicScoreParams=s,r.validatePeerScoreParams=function(e){for(const[t,r]of Object.entries(e.topics))try{o(r)}catch(e){throw n(new Error(`invalid score parameters for topic ${t}: ${e.message}`),i.ERR_INVALID_PEER_SCORE_PARAMS)}if(e.topicScoreCap<0)throw n(new Error("invalid topic score cap; must be positive (or 0 for no cap)"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(null===e.appSpecificScore||void 0===e.appSpecificScore)throw n(new Error("missing application specific score function"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(e.IPColocationFactorWeight>0)throw n(new Error("invalid IPColocationFactorWeight; must be negative (or 0 to disable)"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.IPColocationFactorWeight&&e.IPColocationFactorThreshold<1)throw n(new Error("invalid IPColocationFactorThreshold; must be at least 1"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(e.behaviourPenaltyWeight>0)throw n(new Error("invalid BehaviourPenaltyWeight; must be negative (or 0 to disable)"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(0!==e.behaviourPenaltyWeight&&(e.behaviourPenaltyDecay<=0||e.behaviourPenaltyDecay>=1))throw n(new Error("invalid BehaviourPenaltyDecay; must be between 0 and 1"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(e.decayInterval<1e3)throw n(new Error("invalid DecayInterval; must be at least 1s"),i.ERR_INVALID_PEER_SCORE_PARAMS);if(e.decayToZero<=0||e.decayToZero>=1)throw n(new Error("invalid DecayToZero; must be between 0 and 1"),i.ERR_INVALID_PEER_SCORE_PARAMS)},r.validateTopicScoreParams=o},{"./constants":"eJAl3","err-code":"chZjB"}],eJAl3:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.ERR_INVALID_PEER_SCORE_THRESHOLDS=r.ERR_INVALID_PEER_SCORE_PARAMS=void 0,r.ERR_INVALID_PEER_SCORE_PARAMS="ERR_INVALID_PEER_SCORE_PARAMS",r.ERR_INVALID_PEER_SCORE_THRESHOLDS="ERR_INVALID_PEER_SCORE_THRESHOLDS"},{}],kpAfK:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.validatePeerScoreThresholds=r.createPeerScoreThresholds=r.defaultPeerScoreThresholds=void 0;const i=e("./constants"),n=e("err-code");r.defaultPeerScoreThresholds={gossipThreshold:-10,publishThreshold:-50,graylistThreshold:-80,acceptPXThreshold:10,opportunisticGraftThreshold:20},r.createPeerScoreThresholds=function(e={}){return Object.assign(Object.assign({},r.defaultPeerScoreThresholds),e)},r.validatePeerScoreThresholds=function(e){if(e.gossipThreshold>0)throw n(new Error("invalid gossip threshold; it must be <= 0"),i.ERR_INVALID_PEER_SCORE_THRESHOLDS);if(e.publishThreshold>0||e.publishThreshold>e.gossipThreshold)throw n(new Error("invalid publish threshold; it must be <= 0 and <= gossip threshold"),i.ERR_INVALID_PEER_SCORE_THRESHOLDS);if(e.graylistThreshold>0||e.graylistThreshold>e.publishThreshold)throw n(new Error("invalid graylist threshold; it must be <= 0 and <= publish threshold"),i.ERR_INVALID_PEER_SCORE_THRESHOLDS);if(e.acceptPXThreshold<0)throw n(new Error("invalid accept PX threshold; it must be >= 0"),i.ERR_INVALID_PEER_SCORE_THRESHOLDS);if(e.opportunisticGraftThreshold<0)throw n(new Error("invalid opportunistic grafting threshold; it must be >= 0"),i.ERR_INVALID_PEER_SCORE_THRESHOLDS)}},{"./constants":"eJAl3","err-code":"chZjB"}],"2EtC2":[function(e,t,r){"use strict";var i=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))((function(n,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.PeerScore=void 0;const s=e("./peer-score-params"),o=e("./peer-stats"),a=e("./compute-score"),c=e("./message-deliveries"),u=e("../constants"),l=n(e("peer-id")),d=e("debug"),f=e("libp2p-interfaces/src/pubsub/errors"),{ERR_INVALID_SIGNATURE:h,ERR_MISSING_SIGNATURE:p}=f.codes,g=d("libp2p:gossipsub:score");r.PeerScore=class{constructor(e,t,r){s.validatePeerScoreParams(e),this.params=e,this._connectionManager=t,this.peerStats=new Map,this.peerIPs=new Map,this.deliveryRecords=new c.MessageDeliveries,this.msgId=r}start(){this._backgroundInterval?g("Peer score already running"):(this._backgroundInterval=setInterval((()=>this.background()),this.params.decayInterval),g("started"))}stop(){this._backgroundInterval?(clearInterval(this._backgroundInterval),delete this._backgroundInterval,this.peerIPs.clear(),this.peerStats.clear(),this.deliveryRecords.clear(),g("stopped")):g("Peer score already stopped")}background(){this._refreshScores(),this._updateIPs(),this.deliveryRecords.gc()}_refreshScores(){const e=Date.now(),t=this.params.decayToZero;this.peerStats.forEach(((r,i)=>{r.connected?(Object.entries(r.topics).forEach((([r,i])=>{const n=this.params.topics[r];n&&(i.firstMessageDeliveries*=n.firstMessageDeliveriesDecay,i.firstMessageDeliveriesn.meshMessageDeliveriesActivation&&(i.meshMessageDeliveriesActive=!0)))})),r.behaviourPenalty*=this.params.behaviourPenaltyDecay,r.behaviourPenaltyr.expire&&(this._removeIPs(i,r.ips),this.peerStats.delete(i))}))}score(e){const t=this.peerStats.get(e);return t?a.computeScore(e,t,this.params,this.peerIPs):0}addPenalty(e,t){const r=this.peerStats.get(e);r&&(r.behaviourPenalty+=t)}addPeer(e){const t=o.createPeerStats({connected:!0});this.peerStats.set(e,t);const r=this._getIPs(e);this._setIPs(e,r,t.ips),t.ips=r}removePeer(e){const t=this.peerStats.get(e);if(t){if(this.score(e)>0)return this._removeIPs(e,t.ips),void this.peerStats.delete(e);Object.entries(t.topics).forEach((([e,t])=>{t.firstMessageDeliveries=0;const r=this.params.topics[e].meshMessageDeliveriesThreshold;if(t.inMesh&&t.meshMessageDeliveriesActive&&t.meshMessageDeliveries{r!==t&&this._markDuplicateMessageDelivery(r,e)}))):g("unexpected delivery: message from %s was first seen %s ago and has delivery status %d",t,i-r.firstSeen,c.DeliveryRecordStatus[r.status])}))}rejectMessage(e,t){return i(this,void 0,void 0,(function*(){const r=e.receivedFrom;switch(t){case p:case h:return void this._markInvalidMessageDelivery(r,e)}const i=this.deliveryRecords.ensureRecord(yield this.msgId(e));i.status===c.DeliveryRecordStatus.unknown?t!==u.ERR_TOPIC_VALIDATOR_IGNORE?(i.status=c.DeliveryRecordStatus.invalid,this._markInvalidMessageDelivery(r,e),i.peers.forEach((t=>{this._markInvalidMessageDelivery(t,e)}))):i.status=c.DeliveryRecordStatus.ignored:g("unexpected rejection: message from %s was first seen %s ago and has delivery status %d",r,Date.now()-i.firstSeen,c.DeliveryRecordStatus[i.status])}))}duplicateMessage(e){return i(this,void 0,void 0,(function*(){const t=e.receivedFrom,r=this.deliveryRecords.ensureRecord(yield this.msgId(e));if(!r.peers.has(t))switch(r.status){case c.DeliveryRecordStatus.unknown:r.peers.add(t);break;case c.DeliveryRecordStatus.valid:r.peers.add(t),this._markDuplicateMessageDelivery(t,e,r.validated);break;case c.DeliveryRecordStatus.invalid:this._markInvalidMessageDelivery(t,e)}}))}_markInvalidMessageDelivery(e,t){const r=this.peerStats.get(e);r&&t.topicIDs.forEach((e=>{const t=o.ensureTopicStats(e,r,this.params);t&&(t.invalidMessageDeliveries+=1)}))}_markFirstMessageDelivery(e,t){const r=this.peerStats.get(e);r&&t.topicIDs.forEach((e=>{const t=o.ensureTopicStats(e,r,this.params);if(!t)return;let i=this.params.topics[e].firstMessageDeliveriesCap;t.firstMessageDeliveries+=1,t.firstMessageDeliveries>i&&(t.firstMessageDeliveries=i),t.inMesh&&(i=this.params.topics[e].meshMessageDeliveriesCap,t.meshMessageDeliveries+=1,t.meshMessageDeliveries>i&&(t.meshMessageDeliveries=i))}))}_markDuplicateMessageDelivery(e,t,r=0){const i=this.peerStats.get(e);if(!i)return;const n=r?Date.now():0;t.topicIDs.forEach((e=>{const t=o.ensureTopicStats(e,i,this.params);if(!t)return;if(!t.inMesh)return;const s=this.params.topics[e];if(r&&n>r+s.meshMessageDeliveriesWindow)return;const a=s.meshMessageDeliveriesCap;t.meshMessageDeliveries+=1,t.meshMessageDeliveries>a&&(t.meshMessageDeliveries=a)}))}_getIPs(e){return this._connectionManager.getAll(l.default.createFromB58String(e)).map((e=>e.remoteAddr.toOptions().host))}_setIPs(e,t,r){e:for(const i of t){for(const e of r)if(i===e)continue e;let t=this.peerIPs.get(i);t||(t=new Set,this.peerIPs.set(i,t)),t.add(e)}e:for(const i of r){for(const e of t)if(i===e)continue e;const r=this.peerIPs.get(i);r&&(r.delete(e),r.size||this.peerIPs.delete(i))}}_removeIPs(e,t){t.forEach((t=>{const r=this.peerIPs.get(t);r&&(r.delete(e),r.size||this.peerIPs.delete(t))}))}_updateIPs(){this.peerStats.forEach(((e,t)=>{const r=this._getIPs(t);this._setIPs(t,r,e.ips),e.ips=r}))}}},{"./peer-score-params":"lHcoR","./peer-stats":"ghpOC","./compute-score":"b22gU","./message-deliveries":"pijyj","../constants":"kx67k","peer-id":"8Bdb3",debug:"bO5wM","libp2p-interfaces/src/pubsub/errors":"i7hyG"}],ghpOC:[function(e,t,r){"use strict";function i(e={}){return Object.assign({inMesh:!1,graftTime:0,meshTime:0,firstMessageDeliveries:0,meshMessageDeliveries:0,meshMessageDeliveriesActive:!1,meshFailurePenalty:0,invalidMessageDeliveries:0},e)}Object.defineProperty(r,"__esModule",{value:!0}),r.ensureTopicStats=r.createTopicStats=r.createPeerStats=void 0,r.createPeerStats=function(e={}){return Object.assign(Object.assign({connected:!1,expire:0,ips:[],behaviourPenalty:0},e),{topics:e.topics?Object.entries(e.topics).reduce(((e,[t,r])=>(e[t]=i(r),e)),{}):{}})},r.createTopicStats=i,r.ensureTopicStats=function(e,t,r){let n=t.topics[e];return n||(r.topics[e]?(t.topics[e]=n=i(),n):void 0)}},{}],b22gU:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.computeScore=void 0,r.computeScore=function(e,t,r,i){let n=0;Object.entries(t.topics).forEach((([e,t])=>{const i=r.topics[e];if(!i)return;let s=0;if(t.inMesh){let e=t.meshTime/i.timeInMeshQuantum;e>i.timeInMeshCap&&(e=i.timeInMeshCap),s+=e*i.timeInMeshWeight}if(s+=t.firstMessageDeliveries*i.firstMessageDeliveriesWeight,t.meshMessageDeliveriesActive&&t.meshMessageDeliveries0&&n>r.topicScoreCap&&(n=r.topicScoreCap);const s=r.appSpecificScore(e);n+=s*r.appSpecificWeight,t.ips.forEach((e=>{if(r.IPColocationFactorWhitelist.has(e))return;const t=i.get(e),s=t?t.size:0;if(s>r.IPColocationFactorThreshold){const e=s-r.IPColocationFactorThreshold;n+=e*e*r.IPColocationFactorWeight}}));const o=t.behaviourPenalty*t.behaviourPenalty;return n+=o*r.behaviourPenaltyWeight,n}},{}],pijyj:[function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.MessageDeliveries=r.DeliveryRecordStatus=void 0;const n=e("../constants"),s=i(e("denque")),o=e("../utils");var a,c;(c=a=r.DeliveryRecordStatus||(r.DeliveryRecordStatus={}))[c.unknown=0]="unknown",c[c.valid=1]="valid",c[c.invalid=2]="invalid",c[c.ignored=3]="ignored";r.MessageDeliveries=class{constructor(){this.records=new Map,this.queue=new s.default}ensureRecord(e){const t=o.messageIdToString(e);let r=this.records.get(t);if(r)return r;r={status:a.unknown,firstSeen:Date.now(),validated:0,peers:new Set},this.records.set(t,r);const i={msgId:t,expire:Date.now()+n.TimeCacheDuration};return this.queue.push(i),r}gc(){const e=Date.now();let t=this.queue.peekFront();for(;t&&t.expire=r||t<-r))return t<0&&(t+=r),t=this._head+t&this._capacityMask,this._list[t]}},i.prototype.get=function(e){return this.peekAt(e)},i.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},i.prototype.peekFront=function(){return this.peek()},i.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(i.prototype,"length",{get:function(){return this.size()}}),i.prototype.size=function(){return this._head===this._tail?0:this._headthis._capacity&&this.pop(),this._head1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),t}},i.prototype.push=function(e){if(void 0===e)return this.size();var t=this._tail;return this._list[t]=e,this._tail=t+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head1e4&&e<=t>>>2&&this._shrinkArray(),r}},i.prototype.removeOne=function(e){var t=e;if(t===(0|t)&&this._head!==this._tail){var r=this.size(),i=this._list.length;if(!(t>=r||t<-r)){t<0&&(t+=r),t=this._head+t&this._capacityMask;var n,s=this._list[t];if(e0;n--)this._list[t]=this._list[t=t-1+i&this._capacityMask];this._list[t]=void 0,this._head=this._head+1+i&this._capacityMask}else{for(n=r-1-e;n>0;n--)this._list[t]=this._list[t=t+1+i&this._capacityMask];this._list[t]=void 0,this._tail=this._tail-1+i&this._capacityMask}return s}}},i.prototype.remove=function(e,t){var r,i=e,n=t;if(i===(0|i)&&this._head!==this._tail){var s=this.size(),o=this._list.length;if(!(i>=s||i<-s||t<1)){if(i<0&&(i+=s),1===t||!t)return(r=new Array(1))[0]=this.removeOne(i),r;if(0===i&&i+t>=s)return r=this.toArray(),this.clear(),r;var a;for(i+t>s&&(t=s-i),r=new Array(t),a=0;a0;a--)this._list[i=i+1+o&this._capacityMask]=void 0;return r}if(0===e){for(this._head=this._head+t+o&this._capacityMask,a=t-1;a>0;a--)this._list[i=i+1+o&this._capacityMask]=void 0;return r}if(i0;a--)this.unshift(this._list[i=i-1+o&this._capacityMask]);for(i=this._head-1+o&this._capacityMask;n>0;)this._list[i=i-1+o&this._capacityMask]=void 0,n--;e<0&&(this._tail=i)}else{for(this._tail=i,i=i+t+o&this._capacityMask,a=s-(t+e);a>0;a--)this.push(this._list[i++]);for(i=this._tail;n>0;)this._list[i=i+1+o&this._capacityMask]=void 0,n--}return this._head<2&&this._tail>1e4&&this._tail<=o>>>2&&this._shrinkArray(),r}}},i.prototype.splice=function(e,t){var r=e;if(r===(0|r)){var i=this.size();if(r<0&&(r+=i),!(r>i)){if(arguments.length>2){var n,s,o,a=arguments.length,c=this._list.length,u=2;if(!i||r0&&(this._head=this._head+r+c&this._capacityMask)):(o=this.remove(r,t),this._head=this._head+r+c&this._capacityMask);a>u;)this.unshift(arguments[--a]);for(n=r;n>0;n--)this.unshift(s[n-1])}else{var l=(s=new Array(i-(r+t))).length;for(n=0;nthis._tail){for(t=this._head;t>>=1,this._capacityMask>>>=1},t.exports=i},{}],"8V5x8":[function(e,t,r){"use strict";var i=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))((function(n,s){function o(e){try{c(i.next(e))}catch(e){s(e)}}function a(e){try{c(i.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))};Object.defineProperty(r,"__esModule",{value:!0}),r.IWantTracer=void 0;const n=e("./constants"),s=e("./utils"),o=e("libp2p-interfaces/src/pubsub/errors"),{ERR_INVALID_SIGNATURE:a,ERR_MISSING_SIGNATURE:c}=o.codes;r.IWantTracer=class{constructor(e){this.getMsgId=e,this.promises=new Map}addPromise(e,t){const r=t[Math.floor(Math.random()*t.length)],i=s.messageIdToString(r);let o=this.promises.get(i);o||(o=new Map,this.promises.set(i,o)),o.has(e)||o.set(e,Date.now()+n.GossipsubIWantFollowupTime)}getBrokenPromises(){const e=Date.now(),t=new Map;return this.promises.forEach(((r,i)=>{r.forEach(((i,n)=>{i{n.forEach(((e,t)=>{const i=e.validity||r;(function(e){const t=(new Date).getTime()-e.getTime();return Math.floor(t/1e3)})(e.timestamp)>i&&n.delete(t)}))}),200);this.put=(e,t,r)=>{this.has(e)||n.set(e,{value:t,timestamp:new Date,validity:r}),s()},this.get=e=>{if(n.has(e))return n.get(e).value;throw new Error("key does not exist")},this.has=e=>n.has(e)}},{"lodash.throttle":"3gPBz"}],"3gPBz":[function(e,t,r){var i=arguments[3],n="Expected a function",s=NaN,o="[object Symbol]",a=/^\s+|\s+$/g,c=/^[-+]0x[0-9a-f]+$/i,u=/^0b[01]+$/i,l=/^0o[0-7]+$/i,d=parseInt,f="object"==typeof i&&i&&i.Object===Object&&i,h="object"==typeof self&&self&&self.Object===Object&&self,p=f||h||Function("return this")(),g=Object.prototype,y=g.toString,m=Math.max,b=Math.min,v=function(){return p.Date.now()};function w(e,t,r){var i,s,o,a,c,u,l=0,d=!1,f=!1,h=!0;if("function"!=typeof e)throw new TypeError(n);function p(t){var r=i,n=s;return i=s=void 0,l=t,a=e.apply(n,r)}function g(e){return l=e,c=setTimeout(w,t),d?p(e):a}function y(e){var r=e-u;return void 0===u||r>=t||r<0||f&&e-l>=o}function w(){var e=v();if(y(e))return _(e);c=setTimeout(w,function(e){var r=t-(e-u);return f?b(r,o-(e-l)):r}(e))}function _(e){return c=void 0,h&&i?p(e):(i=s=void 0,a)}function S(){var e=v(),r=y(e);if(i=arguments,s=this,u=e,r){if(void 0===c)return g(u);if(f)return c=setTimeout(w,t),p(u)}return void 0===c&&(c=setTimeout(w,t)),a}return t=A(t)||0,E(r)&&(d=!!r.leading,o=(f="maxWait"in r)?m(A(r.maxWait)||0,t):o,h="trailing"in r?!!r.trailing:h),S.cancel=function(){void 0!==c&&clearTimeout(c),l=0,i=u=s=c=void 0},S.flush=function(){return void 0===c?a:_(v())},S}function _(e,t,r){var i=!0,s=!0;if("function"!=typeof e)throw new TypeError(n);return E(r)&&(i="leading"in r?!!r.leading:i,s="trailing"in r?!!r.trailing:s),w(e,t,{leading:i,maxWait:t,trailing:s})}function E(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function S(e){return!!e&&"object"==typeof e}function T(e){return"symbol"==typeof e||S(e)&&y.call(e)==o}function A(e){if("number"==typeof e)return e;if(T(e))return s;if(E(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=E(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(a,"");var r=u.test(e);return r||l.test(e)?d(e.slice(2),r?2:8):c.test(e)?s:+e}t.exports=_},{}],"27rHX":[function(e,t,r){"use strict";const i=e("err-code"),{concat:n}=e("uint8arrays/concat"),{fromString:s}=e("uint8arrays/from-string"),o=e("libp2p-crypto/src/keys"),a=e("peer-id"),c=e("varint"),{equals:u}=e("uint8arrays/equals"),{codes:l}=e("../../errors"),{Envelope:d}=e("./envelope");class f{constructor({peerId:e,payloadType:t,payload:r,signature:i}){this.peerId=e,this.payloadType=t,this.payload=r,this.signature=i,this._marshal=void 0}marshal(){if(this._marshal)return this._marshal;const e=o.marshalPublicKey(this.peerId.pubKey);return this._marshal=d.encode({publicKey:e,payloadType:this.payloadType,payload:this.payload,signature:this.signature}).finish(),this._marshal}equals(e){return u(this.peerId.pubKey.bytes,e.peerId.pubKey.bytes)&&u(this.payloadType,e.payloadType)&&u(this.payload,e.payload)&&u(this.signature,e.signature)}validate(e){const t=h(e,this.payloadType,this.payload);return this.peerId.pubKey.verify(t,this.signature)}}const h=(e,t,r)=>{const i=s(e),o=c.encode(i.byteLength),a=c.encode(t.length),u=c.encode(r.length);return n([new Uint8Array(o),i,new Uint8Array(a),t,new Uint8Array(u),r])};f.createFromProtobuf=async e=>{const t=d.decode(e),r=await a.createFromPubKey(t.publicKey);return new f({peerId:r,payloadType:t.payloadType,payload:t.payload,signature:t.signature})},f.seal=async(e,t)=>{const r=e.domain,i=e.codec,n=e.marshal(),s=h(r,i,n),o=await t.privKey.sign(s);return new f({peerId:t,payloadType:i,payload:n,signature:o})},f.openAndCertify=async(e,t)=>{const r=await f.createFromProtobuf(e);if(!await r.validate(t))throw i(new Error("envelope signature is not valid for the given domain"),l.ERR_SIGNATURE_NOT_VALID);return r},t.exports=f},{"err-code":"chZjB","uint8arrays/concat":"4EBjG","uint8arrays/from-string":"dF7Y4","libp2p-crypto/src/keys":"kWJWg","peer-id":"8Bdb3",varint:"aN1CO","uint8arrays/equals":"eY3cX","../../errors":"3rNo5","./envelope":"1obky"}],"3rNo5":[function(e,t,r){"use strict";r.messages={NOT_STARTED_YET:"The libp2p node is not started yet",DHT_DISABLED:"DHT is not available",CONN_ENCRYPTION_REQUIRED:"At least one connection encryption module is required"},r.codes={DHT_DISABLED:"ERR_DHT_DISABLED",PUBSUB_NOT_STARTED:"ERR_PUBSUB_NOT_STARTED",DHT_NOT_STARTED:"ERR_DHT_NOT_STARTED",CONN_ENCRYPTION_REQUIRED:"ERR_CONN_ENCRYPTION_REQUIRED",ERR_INVALID_PROTOCOLS_FOR_STREAM:"ERR_INVALID_PROTOCOLS_FOR_STREAM",ERR_CONNECTION_ENDED:"ERR_CONNECTION_ENDED",ERR_CONNECTION_FAILED:"ERR_CONNECTION_FAILED",ERR_NODE_NOT_STARTED:"ERR_NODE_NOT_STARTED",ERR_ALREADY_ABORTED:"ERR_ALREADY_ABORTED",ERR_TOO_MANY_ADDRESSES:"ERR_TOO_MANY_ADDRESSES",ERR_NO_VALID_ADDRESSES:"ERR_NO_VALID_ADDRESSES",ERR_RELAYED_DIAL:"ERR_RELAYED_DIAL",ERR_DIALED_SELF:"ERR_DIALED_SELF",ERR_DISCOVERED_SELF:"ERR_DISCOVERED_SELF",ERR_DUPLICATE_TRANSPORT:"ERR_DUPLICATE_TRANSPORT",ERR_ENCRYPTION_FAILED:"ERR_ENCRYPTION_FAILED",ERR_HOP_REQUEST_FAILED:"ERR_HOP_REQUEST_FAILED",ERR_INVALID_KEY:"ERR_INVALID_KEY",ERR_INVALID_MESSAGE:"ERR_INVALID_MESSAGE",ERR_INVALID_PARAMETERS:"ERR_INVALID_PARAMETERS",ERR_INVALID_PEER:"ERR_INVALID_PEER",ERR_MUXER_UNAVAILABLE:"ERR_MUXER_UNAVAILABLE",ERR_TIMEOUT:"ERR_TIMEOUT",ERR_TRANSPORT_UNAVAILABLE:"ERR_TRANSPORT_UNAVAILABLE",ERR_TRANSPORT_DIAL_FAILED:"ERR_TRANSPORT_DIAL_FAILED",ERR_UNSUPPORTED_PROTOCOL:"ERR_UNSUPPORTED_PROTOCOL",ERR_INVALID_MULTIADDR:"ERR_INVALID_MULTIADDR",ERR_SIGNATURE_NOT_VALID:"ERR_SIGNATURE_NOT_VALID"}},{}],"1obky":[function(e,t,r){"use strict";var i=e("protobufjs/minimal"),n=i.Reader,s=i.Writer,o=i.util,a=i.roots["libp2p-envelope"]||(i.roots["libp2p-envelope"]={});a.Envelope=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:i.publicKey=e.bytes();break;case 2:i.payloadType=e.bytes();break;case 3:i.payload=e.bytes();break;case 5:i.signature=e.bytes();break;default:e.skipType(7&s)}}return i},e.fromObject=function(e){if(e instanceof a.Envelope)return e;var t=new a.Envelope;return null!=e.publicKey&&("string"==typeof e.publicKey?o.base64.decode(e.publicKey,t.publicKey=o.newBuffer(o.base64.length(e.publicKey)),0):e.publicKey.length&&(t.publicKey=e.publicKey)),null!=e.payloadType&&("string"==typeof e.payloadType?o.base64.decode(e.payloadType,t.payloadType=o.newBuffer(o.base64.length(e.payloadType)),0):e.payloadType.length&&(t.payloadType=e.payloadType)),null!=e.payload&&("string"==typeof e.payload?o.base64.decode(e.payload,t.payload=o.newBuffer(o.base64.length(e.payload)),0):e.payload.length&&(t.payload=e.payload)),null!=e.signature&&("string"==typeof e.signature?o.base64.decode(e.signature,t.signature=o.newBuffer(o.base64.length(e.signature)),0):e.signature.length&&(t.signature=e.signature)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.publicKey="":(r.publicKey=[],t.bytes!==Array&&(r.publicKey=o.newBuffer(r.publicKey))),t.bytes===String?r.payloadType="":(r.payloadType=[],t.bytes!==Array&&(r.payloadType=o.newBuffer(r.payloadType))),t.bytes===String?r.payload="":(r.payload=[],t.bytes!==Array&&(r.payload=o.newBuffer(r.payload))),t.bytes===String?r.signature="":(r.signature=[],t.bytes!==Array&&(r.signature=o.newBuffer(r.signature)))),null!=e.publicKey&&e.hasOwnProperty("publicKey")&&(r.publicKey=t.bytes===String?o.base64.encode(e.publicKey,0,e.publicKey.length):t.bytes===Array?Array.prototype.slice.call(e.publicKey):e.publicKey),null!=e.payloadType&&e.hasOwnProperty("payloadType")&&(r.payloadType=t.bytes===String?o.base64.encode(e.payloadType,0,e.payloadType.length):t.bytes===Array?Array.prototype.slice.call(e.payloadType):e.payloadType),null!=e.payload&&e.hasOwnProperty("payload")&&(r.payload=t.bytes===String?o.base64.encode(e.payload,0,e.payload.length):t.bytes===Array?Array.prototype.slice.call(e.payload):e.payload),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?o.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e}(),t.exports=a},{"protobufjs/minimal":"grAXL"}],jgA5e:[function(e,t,r){"use strict";const i=e("peer-id"),{base58btc:n}=e("multiformats/bases/base58"),{default:s}=e("p-queue"),o=e("p-defer"),a=e("debug"),c=a("libp2p-delegated-peer-routing");c.error=a("libp2p-delegated-peer-routing:error");t.exports=class{constructor(e){if(null==e)throw new Error("missing ipfs http client");this._client=e,this._httpQueue=new s({concurrency:4});const{protocol:t,host:r,port:i}=e.getEndpointConfig();c(`enabled DelegatedPeerRouting via ${t}://${r}:${i}`)}async findPeer(e,t={}){let r=e;i.isPeerId(r)&&(r=e.toB58String()),c("findPeer starts: "+e),t.timeout=t.timeout||3e4;try{return await this._httpQueue.add((async()=>{const{addrs:i}=await this._client.dht.findPeer(r,{timeout:t.timeout});return{id:e,multiaddrs:i}}))}catch(e){if(e.message.includes("not found"))return;throw e}finally{c("findPeer finished: "+e)}}async*getClosestPeers(e,t={}){const r=n.encode(e).substring(1);c("getClosestPeers starts:",r),t.timeout=t.timeout||3e4;const s=o(),a=o();this._httpQueue.add((()=>(s.resolve(),a.promise)));try{await s.promise;const e=new Map;for await(const n of this._client.dht.query(r,{timeout:t.timeout}))switch(n.type){case 1:n.responses.forEach((t=>{e.set(t.id,{id:i.parse(t.id),multiaddrs:t.addrs})}));break;case 2:yield e.get(n.id.string)||{id:i.createFromCID(n.id),multiaddrs:[]};break;default:c("getClosestPeers unhandled response",n)}}catch(e){throw c.error("getClosestPeers errored:",e),e}finally{a.resolve(),c("getClosestPeers finished:",r)}}}},{"peer-id":"8Bdb3","multiformats/bases/base58":"4n7mA","p-queue":"biPlv","p-defer":"5rKSv",debug:"bO5wM"}],gg6SI:[function(e,t,r){"use strict";const i=e("debug"),n=e("peer-id"),s=e("it-drain"),{default:o}=e("p-queue"),a=e("p-defer"),c=i("libp2p-delegated-content-routing");c.error=i("libp2p-delegated-content-routing:error");t.exports=class{constructor(e,t){if(null==e)throw new Error("missing self peerId");if(null==t)throw new Error("missing ipfs http client");this._client=t,this.peerId=e;const r={concurrency:4};this._httpQueue=new o(r),this._httpQueueRefs=new o(Object.assign({},r,{concurrency:2}));const{protocol:i,host:n,port:s}=t.getEndpointConfig();c(`enabled DelegatedContentRouting via ${i}://${n}:${s}`)}async*findProviders(e,t={}){c(`findProviders starts: ${e}`),t.timeout=t.timeout||3e4;let r=0;const i=a(),s=a();this._httpQueue.add((()=>(i.resolve(),s.promise)));try{await i.promise;for await(const{id:i,addrs:s}of this._client.dht.findProvs(e,{numProviders:t.numProviders,timeout:t.timeout}))yield{id:n.parse(i),multiaddrs:s},r++}catch(e){throw c.error("findProviders errored:",e),e}finally{s.resolve(),c(`findProviders finished: ${e} found ${r} providers`)}}async provide(e){c(`provide starts: ${e}`),await this._httpQueueRefs.add((async()=>{await this._client.block.stat(e),await s(this._client.dht.provide(e))})),c(`provide finished: ${e}`)}}},{debug:"bO5wM","peer-id":"8Bdb3","it-drain":"dKYhO","p-queue":"biPlv","p-defer":"5rKSv"}],h5Uk6:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/multibases"),n=e("ipfs-core-utils/multicodecs"),s=e("ipfs-core-utils/multihashes"),o=e("@ipld/dag-pb"),a=e("@ipld/dag-cbor"),c=e("multiformats/hashes/identity"),u=e("multiformats/basics"),l=e("./bitswap/index.js"),d=e("./block/index.js"),f=e("./bootstrap/index.js"),h=e("./config/index.js"),p=e("./dag/index.js"),g=e("./dht/index.js"),y=e("./diag/index.js"),m=e("./files/index.js"),b=e("./key/index.js"),v=e("./log/index.js"),w=e("./name/index.js"),_=e("./object/index.js"),E=e("./pin/index.js"),S=e("./pubsub/index.js"),T=e("./refs/index.js"),A=e("./repo/index.js"),k=e("./stats/index.js"),I=e("./swarm/index.js"),R=e("./add.js"),P=e("./add-all.js"),O=e("./cat.js"),C=e("./commands.js"),j=e("./dns.js"),D=e("./get-endpoint-config.js"),M=e("./get.js"),x=e("./id.js"),B=e("./is-online.js"),L=e("./ls.js"),N=e("./mount.js"),U=e("./ping.js"),F=e("./resolve.js"),K=e("./start.js"),z=e("./stop.js"),V=e("./version.js"),q=e("ipfs-utils/src/files/glob-source.js"),G=e("multiformats/cid"),H=e("multiaddr"),$=e("ipfs-utils/src/files/url-source.js");function W(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function Y(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var X=Y(o),Z=Y(a),Q=W(q),J=W($);const ee=Q.default;Object.defineProperty(r,"CID",{enumerable:!0,get:function(){return G.CID}}),Object.defineProperty(r,"multiaddr",{enumerable:!0,get:function(){return H.Multiaddr}}),Object.defineProperty(r,"urlSource",{enumerable:!0,get:function(){return J.default}}),r.create=function(e={}){const t={name:c.identity.name,code:c.identity.code,encode:e=>e,decode:e=>e},r=Object.values(u.bases);(e.ipld&&e.ipld.bases?e.ipld.bases:[]).forEach((e=>r.push(e)));const o=new i.Multibases({bases:r,loadBase:e.ipld&&e.ipld.loadBase}),a=Object.values(u.codecs);[X,Z,t].concat(e.ipld&&e.ipld.codecs||[]).forEach((e=>a.push(e)));const q=new n.Multicodecs({codecs:a,loadCodec:e.ipld&&e.ipld.loadCodec}),G=Object.values(u.hashes);(e.ipld&&e.ipld.hashers?e.ipld.hashers:[]).forEach((e=>G.push(e)));const H=new s.Multihashes({hashers:G,loadHasher:e.ipld&&e.ipld.loadHasher});return{add:R.createAdd(e),addAll:P.createAddAll(e),bitswap:l.createBitswap(e),block:d.createBlock(e),bootstrap:f.createBootstrap(e),cat:O.createCat(e),commands:C.createCommands(e),config:h.createConfig(e),dag:p.createDag(q,e),dht:g.createDht(e),diag:y.createDiag(e),dns:j.createDns(e),files:m.createFiles(e),get:M.createGet(e),getEndpointConfig:D.createGetEndpointConfig(e),id:x.createId(e),isOnline:B.createIsOnline(e),key:b.createKey(e),log:v.createLog(e),ls:L.createLs(e),mount:N.createMount(e),name:w.createName(e),object:_.createObject(q,e),pin:E.createPin(e),ping:U.createPing(e),pubsub:S.createPubsub(e),refs:T.createRefs(e),repo:A.createRepo(e),resolve:F.createResolve(e),start:K.createStart(e),stats:k.createStats(e),stop:z.createStop(e),swarm:I.createSwarm(e),version:V.createVersion(e),bases:o,codecs:q,hashers:H}},r.globSource=ee},{"ipfs-core-utils/multibases":"lr7wI","ipfs-core-utils/multicodecs":"4I7TQ","ipfs-core-utils/multihashes":"febSG","@ipld/dag-pb":"i2cdx","@ipld/dag-cbor":"3498i","multiformats/hashes/identity":"eYCZn","multiformats/basics":"lPcQG","./bitswap/index.js":"e1wIm","./block/index.js":"jb9Ty","./bootstrap/index.js":"94xQz","./config/index.js":"jQsLT","./dag/index.js":"alcVs","./dht/index.js":"l4zXl","./diag/index.js":"lYFrh","./files/index.js":"5SjY6","./key/index.js":"d23S0","./log/index.js":"dax7W","./name/index.js":"hAUWJ","./object/index.js":"lIWb3","./pin/index.js":"2EyML","./pubsub/index.js":"9yoEA","./refs/index.js":"6sM7A","./repo/index.js":"lf1uS","./stats/index.js":"8ekdG","./swarm/index.js":"9n7fV","./add.js":"bh9eV","./add-all.js":"dygjF","./cat.js":"37ULc","./commands.js":"d7oos","./dns.js":"6WsTM","./get-endpoint-config.js":"e09lW","./get.js":"9dl4d","./id.js":"iMd7i","./is-online.js":"1Ujko","./ls.js":"jIkVK","./mount.js":"5Ghx1","./ping.js":"fIZQw","./resolve.js":"fqXrw","./start.js":"4YTOj","./stop.js":"j2dHM","./version.js":"k3Foi","ipfs-utils/src/files/glob-source.js":"lHksA","multiformats/cid":"9ooAY",multiaddr:"8Mu1u","ipfs-utils/src/files/url-source.js":"jQSIS"}],lr7wI:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const i=e=>Promise.reject(new Error(`No base found for "${e}"`));r.Multibases=class{constructor(e){this._basesByName={},this._basesByPrefix={},this._loadBase=e.loadBase||i;for(const t of e.bases)this.addBase(t)}addBase(e){if(this._basesByName[e.name]||this._basesByPrefix[e.prefix])throw new Error(`Codec already exists for codec "${e.name}"`);this._basesByName[e.name]=e,this._basesByPrefix[e.prefix]=e}removeBase(e){delete this._basesByName[e.name],delete this._basesByPrefix[e.prefix]}async getBase(e){if(this._basesByName[e])return this._basesByName[e];if(this._basesByPrefix[e])return this._basesByPrefix[e];const t=await this._loadBase(e);return null==this._basesByName[t.name]&&null==this._basesByPrefix[t.prefix]&&this.addBase(t),t}listBases(){return Object.values(this._basesByName)}}},{}],"4I7TQ":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const i=e=>Promise.reject(new Error(`No codec found for "${e}"`));r.Multicodecs=class{constructor(e){this._codecsByName={},this._codecsByCode={},this._loadCodec=e.loadCodec||i;for(const t of e.codecs)this.addCodec(t)}addCodec(e){if(this._codecsByName[e.name]||this._codecsByCode[e.code])throw new Error(`Resolver already exists for codec "${e.name}"`);this._codecsByName[e.name]=e,this._codecsByCode[e.code]=e}removeCodec(e){delete this._codecsByName[e.name],delete this._codecsByCode[e.code]}async getCodec(e){const t="string"==typeof e?this._codecsByName:this._codecsByCode;if(t[e])return t[e];const r=await this._loadCodec(e);return null==t[e]&&this.addCodec(r),r}listCodecs(){return Object.values(this._codecsByName)}}},{}],febSG:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const i=e=>Promise.reject(new Error(`No hasher found for "${e}"`));r.Multihashes=class{constructor(e){this._hashersByName={},this._hashersByCode={},this._loadHasher=e.loadHasher||i;for(const t of e.hashers)this.addHasher(t)}addHasher(e){if(this._hashersByName[e.name]||this._hashersByCode[e.code])throw new Error(`Resolver already exists for codec "${e.name}"`);this._hashersByName[e.name]=e,this._hashersByCode[e.code]=e}removeHasher(e){delete this._hashersByName[e.name],delete this._hashersByCode[e.code]}async getHasher(e){const t="string"==typeof e?this._hashersByName:this._hashersByCode;if(t[e])return t[e];const r=await this._loadHasher(e);return null==t[e]&&this.addHasher(r),r}listHashers(){return Object.values(this._hashersByName)}}},{}],e1wIm:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./wantlist.js"),n=e("./wantlist-for-peer.js"),s=e("./stat.js"),o=e("./unwant.js");r.createBitswap=function(e){return{wantlist:i.createWantlist(e),wantlistForPeer:n.createWantlistForPeer(e),unwant:o.createUnwant(e),stat:s.createStat(e)}}},{"./wantlist.js":"hU5XK","./wantlist-for-peer.js":"9fQsQ","./stat.js":"3Q0KE","./unwant.js":"azoPb"}],hU5XK:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function(t={}){return((await(await e.post("bitswap/wantlist",{signal:t.signal,searchParams:s.toUrlSearchParams(t),headers:t.headers})).json()).Keys||[]).map((e=>i.CID.parse(e["/"])))}));r.createWantlist=o},{"multiformats/cid":"9ooAY","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],hR8g6:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./core.js");r.configure=e=>t=>e(new i.Client(t),t)},{"./core.js":"3XXp5"}],"3XXp5":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiaddr"),n=e("ipfs-utils/src/env.js"),s=e("parse-duration"),o=e("debug"),a=e("ipfs-utils/src/http.js"),c=e("merge-options"),u=e("ipfs-core-utils/to-url-string"),l=e("ipfs-core-utils/agent");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=d(s),h=d(o),p=d(a),g=d(c),y=d(l);const m=h.default("ipfs-http-client:lib:error-handler"),b=g.default.bind({ignoreUndefined:!0}),v=n.isBrowser||n.isWebWorker?location.protocol:"http",w=n.isBrowser||n.isWebWorker?location.hostname:"localhost",_=n.isBrowser||n.isWebWorker?location.port:"5001",E=async e=>{let t;try{if((e.headers.get("Content-Type")||"").startsWith("application/json")){const r=await e.json();m(r),t=r.Message||r.message}else t=await e.text()}catch(e){m("Failed to parse error response",e),t=e.message}let r=new p.default.HTTPError(e);throw t&&(t.includes("deadline has elapsed")&&(r=new p.default.TimeoutError),t&&t.includes("context deadline exceeded")&&(r=new p.default.TimeoutError)),t&&t.includes("request timed out")&&(r=new p.default.TimeoutError),t&&(r.message=t),r},S=/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,T=e=>e.replace(S,(function(e){return"-"+e.toLowerCase()}));class A extends p.default{constructor(e={}){const t=((e={})=>{let t,r,s={};if("string"==typeof e||i.Multiaddr.isMultiaddr(e))t=new URL(u.toUrlString(e));else if(e instanceof URL)t=e;else if("string"==typeof e.url||i.Multiaddr.isMultiaddr(e.url))t=new URL(u.toUrlString(e.url)),s=e;else if(e.url instanceof URL)t=e.url,s=e;else{s=e||{};const r=(s.protocol||v).replace(":",""),i=(s.host||w).split(":")[0],n=s.port||_;t=new URL(`${r}://${i}:${n}`)}if(s.apiPath?t.pathname=s.apiPath:"/"!==t.pathname&&void 0!==t.pathname||(t.pathname="api/v0"),n.isNode){const e=y.default(t);r=s.agent||new e({keepAlive:!0,maxSockets:6})}return{...s,host:t.host,protocol:t.protocol.replace(":",""),port:Number(t.port),apiPath:t.pathname,url:t,agent:r}})(e);var r;super({timeout:(r=t.timeout||0,("string"==typeof r?f.default(r):r)||void 0),headers:t.headers,base:`${t.url}`,handleError:E,transformSearchParams:e=>{const t=new URLSearchParams;for(const[r,i]of e)"undefined"!==i&&"null"!==i&&"signal"!==r&&t.append(T(r),i),"timeout"!==r||isNaN(i)||t.append(T(r),i);return t},agent:t.agent}),delete this.get,delete this.put,delete this.delete,delete this.options;const s=this.fetch;this.fetch=(e,r={})=>("string"!=typeof e||e.startsWith("/")||(e=`${t.url}/${e}`),s.call(this,e,b(r,{method:"POST"})))}}const k=p.default.HTTPError;r.Client=A,r.HTTPError=k,r.errorHandler=E},{multiaddr:"8Mu1u","ipfs-utils/src/env.js":"flyHr","parse-duration":"fGYtw",debug:"bO5wM","ipfs-utils/src/http.js":"ifXXn","merge-options":"fupyv","ipfs-core-utils/to-url-string":"aPEcT","ipfs-core-utils/agent":"lcuEJ"}],aPEcT:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiaddr");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=n(e("multiaddr-to-uri"));r.toUrlString=function(e){try{e=s.default(new i.Multiaddr(e))}catch(e){}return e=e.toString()}},{multiaddr:"8Mu1u","multiaddr-to-uri":"4PPH7"}],lcuEJ:[function(e,t,r){"use strict";t.exports=()=>{}},{}],fT4zz:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./mode-to-string.js"),n=e("./parse-mtime.js");r.toUrlSearchParams=function({arg:e,searchParams:t,hashAlg:r,mtime:s,mode:o,...a}={}){t&&(a={...a,...t}),r&&(a.hash=r),null!=s&&(s=n.parseMtime(s),a.mtime=s.secs,a.mtimeNsecs=s.nsecs),null!=o&&(a.mode=i.modeToString(o)),a.timeout&&!isNaN(a.timeout)&&(a.timeout=`${a.timeout}ms`),null==e?e=[]:Array.isArray(e)||(e=[e]);const c=new URLSearchParams(a);return e.forEach((e=>c.append("arg",e))),c}},{"./mode-to-string.js":"bbWaj","./parse-mtime.js":"aLNRF"}],bbWaj:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.modeToString=function(e){if(null!=e)return"string"==typeof e?e:e.toString(8).padStart(4,"0")}},{}],aLNRF:[function(e,t,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(r,"__esModule",{value:!0});var n=i(e("err-code"));r.parseMtime=function(e){if(null==e)return;let t;if(null!=e.secs&&(t={secs:e.secs,nsecs:e.nsecs}),null!=e.Seconds&&(t={secs:e.Seconds,nsecs:e.FractionalNanoseconds}),Array.isArray(e)&&(t={secs:e[0],nsecs:e[1]}),e instanceof Date){const r=e.getTime(),i=Math.floor(r/1e3);t={secs:i,nsecs:1e3*(r-1e3*i)}}if(Object.prototype.hasOwnProperty.call(t,"secs")){if(null!=t&&null!=t.nsecs&&(t.nsecs<0||t.nsecs>999999999))throw n.default(new Error("mtime-nsecs must be within the range [0,999999999]"),"ERR_INVALID_MTIME_NSECS");return t}}},{"err-code":"chZjB"}],"9fQsQ":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function(t,r={}){return((await(await e.post("bitswap/wantlist",{signal:r.signal,searchParams:s.toUrlSearchParams({...r,peer:t.toString()}),headers:r.headers})).json()).Keys||[]).map((e=>i.CID.parse(e["/"])))}));r.createWantlistForPeer=o},{"multiformats/cid":"9ooAY","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"3Q0KE":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function(t={}){const r=await e.post("bitswap/stat",{searchParams:s.toUrlSearchParams(t),signal:t.signal,headers:t.headers});return function(e){return{provideBufLen:e.ProvideBufLen,wantlist:(e.Wantlist||[]).map((e=>i.CID.parse(e["/"]))),peers:e.Peers||[],blocksReceived:BigInt(e.BlocksReceived),dataReceived:BigInt(e.DataReceived),blocksSent:BigInt(e.BlocksSent),dataSent:BigInt(e.DataSent),dupBlksReceived:BigInt(e.DupBlksReceived),dupDataReceived:BigInt(e.DupDataReceived)}}(await r.json())}));r.createStat=o},{"multiformats/cid":"9ooAY","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],azoPb:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async function(t,r={}){return(await e.post("bitswap/unwant",{signal:r.signal,searchParams:n.toUrlSearchParams({arg:t.toString(),...r}),headers:r.headers})).json()}));r.createUnwant=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],jb9Ty:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./get.js"),n=e("./put.js"),s=e("./rm.js"),o=e("./stat.js");r.createBlock=function(e){return{get:i.createGet(e),put:n.createPut(e),rm:s.createRm(e),stat:o.createStat(e)}}},{"./get.js":"818EH","./put.js":"aXuxp","./rm.js":"7gdfk","./stat.js":"h9r67"}],"818EH":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async function(t,r={}){const i=await e.post("block/get",{signal:r.signal,searchParams:n.toUrlSearchParams({arg:t.toString(),...r}),headers:r.headers});return new Uint8Array(await i.arrayBuffer())}));r.createGet=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],aXuxp:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("ipfs-core-utils/multipart-request"),s=e("../lib/configure.js"),o=e("../lib/to-url-search-params.js"),a=e("../lib/abort-signal.js"),c=e("native-abort-controller");const u=s.configure((e=>async function t(r,s={}){const u=new c.AbortController,l=a.abortSignal(u.signal,s.signal);let d;try{const t=await e.post("block/put",{signal:l,searchParams:o.toUrlSearchParams(s),...await n.multipartRequest(r,u,s.headers)});d=await t.json()}catch(e){if("dag-pb"===s.format)return t(r,{...s,format:"protobuf"});if("dag-cbor"===s.format)return t(r,{...s,format:"cbor"});throw e}return i.CID.parse(d.Key)}));r.createPut=u},{"multiformats/cid":"9ooAY","ipfs-core-utils/multipart-request":"7TICD","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz","../lib/abort-signal.js":"hzxSr","native-abort-controller":"6zwoZ"}],"7TICD":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./files/normalise-input.browser.js"),n=e("./mode-to-string.js");r.multipartRequest=async function(e,t,r={}){const s=[],o=new FormData;let a=0,c=0;for await(const{content:t,path:r,mode:u,mtime:l}of i.normaliseInput(e)){let e="";a>0&&(e=`-${a}`);let i=(t?"file":"dir")+e;const d=[];if(null!=u&&d.push(`mode=${n.modeToString(u)}`),null!=l){const{secs:e,nsecs:t}=l;d.push(`mtime=${e}`),null!=t&&d.push(`mtime-nsecs=${t}`)}if(d.length&&(i=`${i}?${d.join("&")}`),t){o.set(i,t,null!=r?encodeURIComponent(r):void 0);const e=c+t.size;s.push({name:r,start:c,end:e}),c=e}else{if(null==r)throw new Error("path or content or both must be set");o.set(i,new File([""],encodeURIComponent(r),{type:"application/x-directory"}))}a++}return{total:c,parts:s,headers:r,body:o}}},{"./files/normalise-input.browser.js":"67MIR","./mode-to-string.js":"laXQo"}],"67MIR":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./normalise-content.browser.js"),n=e("./normalise.js");r.normaliseInput=function(e){return n.normalise(e,i.normaliseContent)}},{"./normalise-content.browser.js":"fbARE","./normalise.js":"7hUEG"}],fbARE:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("err-code"),n=e("it-peekable"),s=e("browser-readablestream-to-it"),o=e("it-all"),a=e("./utils.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(i),l=c(n),d=c(s),f=c(o);async function h(e){const t=[];for await(const r of e)t.push(r);return new Blob(t)}r.normaliseContent=async function(e){if(a.isBytes(e))return new Blob([e]);if("string"==typeof e||e instanceof String)return new Blob([e.toString()]);if(a.isBlob(e))return e;if(a.isReadableStream(e)&&(e=d.default(e)),Symbol.iterator in e||Symbol.asyncIterator in e){const t=l.default(e),{value:r,done:i}=await t.peek();if(i)return h(t);if(t.push(r),Number.isInteger(r))return new Blob([Uint8Array.from(await f.default(t))]);if(a.isBytes(r)||"string"==typeof r||r instanceof String)return h(t)}throw u.default(new Error(`Unexpected input: ${e}`),"ERR_UNEXPECTED_INPUT")}},{"err-code":"chZjB","it-peekable":"bi9X1","browser-readablestream-to-it":"aUa4D","it-all":"iCXBu","./utils.js":"ded5K"}],laXQo:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.modeToString=function(e){if(null!=e)return"string"==typeof e?e:e.toString(8).padStart(4,"0")}},{}],hzxSr:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("any-signal");r.abortSignal=function(...e){return i.anySignal(function(e){return e.filter(Boolean)}(e))}},{"any-signal":"kXgRR"}],"7gdfk":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function*(t,r={}){Array.isArray(t)||(t=[t]);const i=await e.post("block/rm",{signal:r.signal,searchParams:s.toUrlSearchParams({arg:t.map((e=>e.toString())),"stream-channels":!0,...r}),headers:r.headers});for await(const e of i.ndjson())yield a(e)}));function a(e){const t={cid:i.CID.parse(e.Hash)};return e.Error&&(t.error=new Error(e.Error)),t}r.createRm=o},{"multiformats/cid":"9ooAY","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],h9r67:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function(t,r={}){const n=await e.post("block/stat",{signal:r.signal,searchParams:s.toUrlSearchParams({arg:t.toString(),...r}),headers:r.headers}),o=await n.json();return{cid:i.CID.parse(o.Key),size:o.Size}}));r.createStat=o},{"multiformats/cid":"9ooAY","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"94xQz":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./add.js"),n=e("./clear.js"),s=e("./list.js"),o=e("./reset.js"),a=e("./rm.js");r.createBootstrap=function(e){return{add:i.createAdd(e),clear:n.createClear(e),list:s.createList(e),reset:o.createReset(e),rm:a.createRm(e)}}},{"./add.js":"i6XDR","./clear.js":"89Gdv","./list.js":"4mZUF","./reset.js":"ldIgy","./rm.js":"5vusI"}],i6XDR:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js"),s=e("multiaddr");const o=i.configure((e=>async function(t,r={}){const i=await e.post("bootstrap/add",{signal:r.signal,searchParams:n.toUrlSearchParams({arg:t,...r}),headers:r.headers}),{Peers:o}=await i.json();return{Peers:o.map((e=>new s.Multiaddr(e)))}}));r.createAdd=o},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz",multiaddr:"8Mu1u"}],"89Gdv":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js"),s=e("multiaddr");const o=i.configure((e=>async function(t={}){const r=await e.post("bootstrap/rm",{signal:t.signal,searchParams:n.toUrlSearchParams({...t,all:!0}),headers:t.headers}),{Peers:i}=await r.json();return{Peers:i.map((e=>new s.Multiaddr(e)))}}));r.createClear=o},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz",multiaddr:"8Mu1u"}],"4mZUF":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js"),s=e("multiaddr");const o=i.configure((e=>async function(t={}){const r=await e.post("bootstrap/list",{signal:t.signal,searchParams:n.toUrlSearchParams(t),headers:t.headers}),{Peers:i}=await r.json();return{Peers:i.map((e=>new s.Multiaddr(e)))}}));r.createList=o},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz",multiaddr:"8Mu1u"}],ldIgy:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js"),s=e("multiaddr");const o=i.configure((e=>async function(t={}){const r=await e.post("bootstrap/add",{signal:t.signal,searchParams:n.toUrlSearchParams({...t,default:!0}),headers:t.headers}),{Peers:i}=await r.json();return{Peers:i.map((e=>new s.Multiaddr(e)))}}));r.createReset=o},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz",multiaddr:"8Mu1u"}],"5vusI":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js"),s=e("multiaddr");const o=i.configure((e=>async function(t,r={}){const i=await e.post("bootstrap/rm",{signal:r.signal,searchParams:n.toUrlSearchParams({arg:t,...r}),headers:r.headers}),{Peers:o}=await i.json();return{Peers:o.map((e=>new s.Multiaddr(e)))}}));r.createRm=o},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz",multiaddr:"8Mu1u"}],jQsLT:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./profiles/index.js"),n=e("./get.js"),s=e("./get-all.js"),o=e("./replace.js"),a=e("./set.js");r.createConfig=function(e){return{getAll:s.createGetAll(e),get:n.createGet(e),set:a.createSet(e),replace:o.createReplace(e),profiles:i.createProfiles(e)}}},{"./profiles/index.js":"h2X0u","./get.js":"7SQ8n","./get-all.js":"6OKA2","./replace.js":"2ISib","./set.js":"eroO0"}],h2X0u:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./apply.js"),n=e("./list.js");r.createProfiles=function(e){return{apply:i.createApply(e),list:n.createList(e)}}},{"./apply.js":"brNlE","./list.js":"bZlc4"}],brNlE:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../../lib/configure.js"),n=e("../../lib/to-url-search-params.js");const s=i.configure((e=>async function(t,r={}){const i=await e.post("config/profile/apply",{signal:r.signal,searchParams:n.toUrlSearchParams({arg:t,...r}),headers:r.headers}),s=await i.json();return{original:s.OldCfg,updated:s.NewCfg}}));r.createApply=s},{"../../lib/configure.js":"hR8g6","../../lib/to-url-search-params.js":"fT4zz"}],bZlc4:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../../lib/object-to-camel.js"),n=e("../../lib/configure.js"),s=e("../../lib/to-url-search-params.js");const o=n.configure((e=>async function(t={}){const r=await e.post("config/profile/list",{signal:t.signal,searchParams:s.toUrlSearchParams(t),headers:t.headers});return(await r.json()).map((e=>i.objectToCamel(e)))}));r.createList=o},{"../../lib/object-to-camel.js":"hdPx4","../../lib/configure.js":"hR8g6","../../lib/to-url-search-params.js":"fT4zz"}],hdPx4:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.objectToCamel=function(e){if(null==e)return e;const t=/^[A-Z]+$/;return Object.keys(e).reduce(((r,i)=>(t.test(i)?r[i.toLowerCase()]=e[i]:t.test(i[0])?r[i[0].toLowerCase()+i.slice(1)]=e[i]:r[i]=e[i],r)),{})}},{}],"7SQ8n":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async(t,r={})=>{if(!t)throw new Error("key argument is required");const i=await e.post("config",{signal:r.signal,searchParams:n.toUrlSearchParams({arg:t,...r}),headers:r.headers});return(await i.json()).Value}));r.createGet=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"6OKA2":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async(t={})=>{const r=await e.post("config/show",{signal:t.signal,searchParams:n.toUrlSearchParams({...t}),headers:t.headers});return await r.json()}));r.createGetAll=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"2ISib":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("uint8arrays/from-string"),n=e("ipfs-core-utils/multipart-request"),s=e("../lib/configure.js"),o=e("../lib/to-url-search-params.js"),a=e("../lib/abort-signal.js"),c=e("native-abort-controller");const u=s.configure((e=>async(t,r={})=>{const s=new c.AbortController,u=a.abortSignal(s.signal,r.signal),l=await e.post("config/replace",{signal:u,searchParams:o.toUrlSearchParams(r),...await n.multipartRequest(i.fromString(JSON.stringify(t)),s,r.headers)});await l.text()}));r.createReplace=u},{"uint8arrays/from-string":"dF7Y4","ipfs-core-utils/multipart-request":"7TICD","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz","../lib/abort-signal.js":"hzxSr","native-abort-controller":"6zwoZ"}],eroO0:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async(t,r,i={})=>{if("string"!=typeof t)throw new Error("Invalid key type");const s={...i,...o(t,r)},a=await e.post("config",{signal:i.signal,searchParams:n.toUrlSearchParams(s),headers:i.headers});await a.text()})),o=(e,t)=>{switch(typeof t){case"boolean":return{arg:[e,t.toString()],bool:!0};case"string":return{arg:[e,t]};default:return{arg:[e,JSON.stringify(t)],json:!0}}};r.createSet=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],alcVs:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./export.js"),n=e("./get.js"),s=e("./import.js"),o=e("./put.js"),a=e("./resolve.js");r.createDag=function(e,t){return{export:i.createExport(t),get:n.createGet(e,t),import:s.createImport(t),put:o.createPut(e,t),resolve:a.createResolve(t)}}},{"./export.js":"42FYP","./get.js":"1DVHz","./import.js":"91D00","./put.js":"e3DVQ","./resolve.js":"fYLE3"}],"42FYP":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async function*(t,r={}){const i=await e.post("dag/export",{signal:r.signal,searchParams:n.toUrlSearchParams({arg:t.toString()}),headers:r.headers});yield*i.iterator()}));r.createExport=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"1DVHz":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/resolve.js"),s=e("it-first"),o=e("it-last"),a=e("err-code"),c=e("../block/get.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=u(s),d=u(o),f=u(a);r.createGet=(e,t)=>i.configure(((t,r)=>{const i=c.createGet(r);return async(t,r={})=>{if(r.path){const s=r.localResolve?await l.default(n.resolve(t,r.path,e,i,r)):await d.default(n.resolve(t,r.path,e,i,r));if(!s)throw f.default(new Error("Not found"),"ERR_NOT_FOUND");return s}const s=await e.getCodec(t.code),o=await i(t,r);return{value:s.decode(o),remainderPath:""}}}))(t)},{"../lib/configure.js":"hR8g6","../lib/resolve.js":"7MeIb","it-first":"hBrkP","it-last":"cSXX9","err-code":"chZjB","../block/get.js":"818EH"}],"7MeIb":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=n(e("err-code"));r.resolve=async function*(e,t,r,n,o){const a=async e=>{const t=await r.getCodec(e.code),i=await n(e,o);return t.decode(i)},c=t.split("/").filter(Boolean);let u=await a(e),l=e;for(c.length||(yield{value:u,remainderPath:""});c.length;){const e=c.shift();if(!e)throw s.default(new Error(`Could not resolve path "${t}"`),"ERR_INVALID_PATH");if(!Object.prototype.hasOwnProperty.call(u,e))throw s.default(new Error(`no link named "${e}" under ${l}`),"ERR_NO_LINK");u=u[e],yield{value:u,remainderPath:c.join("/")};const r=i.CID.asCID(u);r&&(l=r,u=await a(u))}}},{"multiformats/cid":"9ooAY","err-code":"chZjB"}],"91D00":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js"),s=e("../lib/abort-signal.js"),o=e("ipfs-core-utils/multipart-request"),a=e("native-abort-controller"),c=e("multiformats/cid");const u=i.configure((e=>async function*(t,r={}){const i=new a.AbortController,u=s.abortSignal(i.signal,r.signal),{headers:l,body:d}=await o.multipartRequest(t,i,r.headers),f=await e.post("dag/import",{signal:u,headers:l,body:d,searchParams:n.toUrlSearchParams({"pin-roots":r.pinRoots})});for await(const{Root:e}of f.ndjson())if(void 0!==e){const{Cid:{"/":t},PinErrorMsg:r}=e;yield{root:{cid:c.CID.parse(t),pinErrorMsg:r}}}}));r.createImport=u},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz","../lib/abort-signal.js":"hzxSr","ipfs-core-utils/multipart-request":"7TICD","native-abort-controller":"6zwoZ","multiformats/cid":"9ooAY"}],e3DVQ:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../lib/configure.js"),s=e("ipfs-core-utils/multipart-request"),o=e("../lib/to-url-search-params.js"),a=e("../lib/abort-signal.js"),c=e("native-abort-controller");r.createPut=(e,t)=>n.configure((t=>async(r,n={})=>{const u={format:"dag-cbor",hashAlg:"sha2-256",inputEnc:"raw",...n},l=(await e.getCodec(u.format)).encode(r),d=new c.AbortController,f=a.abortSignal(d.signal,u.signal),h=await t.post("dag/put",{timeout:u.timeout,signal:f,searchParams:o.toUrlSearchParams(u),...await s.multipartRequest(l,d,u.headers)}),p=await h.json();return i.CID.parse(p.Cid["/"])}))(t)},{"multiformats/cid":"9ooAY","../lib/configure.js":"hR8g6","ipfs-core-utils/multipart-request":"7TICD","../lib/to-url-search-params.js":"fT4zz","../lib/abort-signal.js":"hzxSr","native-abort-controller":"6zwoZ"}],fYLE3:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async(t,r={})=>{const n=await e.post("dag/resolve",{signal:r.signal,searchParams:s.toUrlSearchParams({arg:`${t}${r.path?`/${r.path}`.replace(/\/[/]+/g,"/"):""}`,...r}),headers:r.headers}),o=await n.json();return{cid:i.CID.parse(o.Cid["/"]),remainderPath:o.RemPath}}));r.createResolve=o},{"multiformats/cid":"9ooAY","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],l4zXl:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./find-peer.js"),n=e("./find-provs.js"),s=e("./get.js"),o=e("./provide.js"),a=e("./put.js"),c=e("./query.js");r.createDht=function(e){return{findPeer:i.createFindPeer(e),findProvs:n.createFindProvs(e),get:s.createGet(e),provide:o.createProvide(e),put:a.createPut(e),query:c.createQuery(e)}}},{"./find-peer.js":"c2Je3","./find-provs.js":"Cn9mt","./get.js":"8ckSi","./provide.js":"i1las","./put.js":"fVqLD","./query.js":"aEVP8"}],c2Je3:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiaddr"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js"),o=e("./response-types.js");const a=n.configure((e=>async function(t,r={}){const n=await e.post("dht/findpeer",{signal:r.signal,searchParams:s.toUrlSearchParams({arg:t,...r}),headers:r.headers});for await(const e of n.ndjson())if(e.Type===o.FinalPeer&&e.Responses){const{ID:t,Addrs:r}=e.Responses[0];return{id:t,addrs:(r||[]).map((e=>new i.Multiaddr(e)))}}throw new Error("not found")}));r.createFindPeer=a},{multiaddr:"8Mu1u","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz","./response-types.js":"lyzlA"}],lyzlA:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.AddingPeer=6,r.DialingPeer=7,r.FinalPeer=2,r.PeerResponse=1,r.Provider=4,r.QueryError=3,r.SendingQuery=0,r.Value=5},{}],Cn9mt:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiaddr"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js"),o=e("./response-types.js");const a=n.configure((e=>async function*(t,r={}){const n=await e.post("dht/findprovs",{signal:r.signal,searchParams:s.toUrlSearchParams({arg:t.toString(),...r}),headers:r.headers});for await(const e of n.ndjson())if(e.Type===o.Provider&&e.Responses)for(const{ID:t,Addrs:r}of e.Responses)yield{id:t,addrs:(r||[]).map((e=>new i.Multiaddr(e)))}}));r.createFindProvs=a},{multiaddr:"8Mu1u","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz","./response-types.js":"lyzlA"}],"8ckSi":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js"),s=e("./response-types.js"),o=e("uint8arrays/from-string"),a=e("uint8arrays/to-string");const c=i.configure((e=>async function(t,r={}){const i=await e.post("dht/get",{signal:r.signal,searchParams:n.toUrlSearchParams({arg:t instanceof Uint8Array?a.toString(t):t,...r}),headers:r.headers});for await(const e of i.ndjson())if(e.Type===s.Value)return o.fromString(e.Extra,"base64pad");throw new Error("not found")}));r.createGet=c},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz","./response-types.js":"lyzlA","uint8arrays/from-string":"dF7Y4","uint8arrays/to-string":"hC8JB"}],i1las:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiaddr"),n=e("../lib/object-to-camel.js"),s=e("../lib/configure.js"),o=e("../lib/to-url-search-params.js");const a=s.configure((e=>async function*(t,r={recursive:!1}){const s=Array.isArray(t)?t:[t],a=await e.post("dht/provide",{signal:r.signal,searchParams:o.toUrlSearchParams({arg:s.map((e=>e.toString())),...r}),headers:r.headers});for await(let e of a.ndjson())e=n.objectToCamel(e),e.responses?e.responses=e.responses.map((({ID:e,Addrs:t})=>({id:e,addrs:(t||[]).map((e=>new i.Multiaddr(e)))}))):e.responses=[],yield e}));r.createProvide=a},{multiaddr:"8Mu1u","../lib/object-to-camel.js":"hdPx4","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],fVqLD:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiaddr"),n=e("../lib/object-to-camel.js"),s=e("../lib/configure.js"),o=e("../lib/to-url-search-params.js"),a=e("ipfs-core-utils/multipart-request"),c=e("../lib/abort-signal.js"),u=e("native-abort-controller"),l=e("uint8arrays/to-string");const d=s.configure((e=>async function*(t,r,s={}){const d=new u.AbortController,f=c.abortSignal(d.signal,s.signal),h=await e.post("dht/put",{signal:f,searchParams:o.toUrlSearchParams({arg:l.toString(t),...s}),...await a.multipartRequest(r,d,s.headers)});for await(let e of h.ndjson())e=n.objectToCamel(e),e.responses&&(e.responses=e.responses.map((({ID:e,Addrs:t})=>({id:e,addrs:(t||[]).map((e=>new i.Multiaddr(e)))})))),yield e}));r.createPut=d},{multiaddr:"8Mu1u","../lib/object-to-camel.js":"hdPx4","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz","ipfs-core-utils/multipart-request":"7TICD","../lib/abort-signal.js":"hzxSr","native-abort-controller":"6zwoZ","uint8arrays/to-string":"hC8JB"}],aEVP8:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiaddr"),n=e("../lib/object-to-camel.js"),s=e("../lib/configure.js"),o=e("../lib/to-url-search-params.js");const a=s.configure((e=>async function*(t,r={}){const s=await e.post("dht/query",{signal:r.signal,searchParams:o.toUrlSearchParams({arg:t.toString(),...r}),headers:r.headers});for await(let e of s.ndjson())e=n.objectToCamel(e),e.responses=(e.responses||[]).map((({ID:e,Addrs:t})=>({id:e,addrs:(t||[]).map((e=>new i.Multiaddr(e)))}))),yield e}));r.createQuery=a},{multiaddr:"8Mu1u","../lib/object-to-camel.js":"hdPx4","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],lYFrh:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./cmds.js"),n=e("./net.js"),s=e("./sys.js");r.createDiag=function(e){return{cmds:i.createCmds(e),net:n.createNet(e),sys:s.createSys(e)}}},{"./cmds.js":"l9zdD","./net.js":"6Ce1z","./sys.js":"ySsKi"}],l9zdD:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async function(t={}){return(await e.post("diag/cmds",{signal:t.signal,searchParams:n.toUrlSearchParams(t),headers:t.headers})).json()}));r.createCmds=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"6Ce1z":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async function(t={}){return(await e.post("diag/net",{signal:t.signal,searchParams:n.toUrlSearchParams(t),headers:t.headers})).json()}));r.createNet=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],ySsKi:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async function(t={}){return(await e.post("diag/sys",{signal:t.signal,searchParams:n.toUrlSearchParams(t),headers:t.headers})).json()}));r.createSys=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"5SjY6":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./chmod.js"),n=e("./cp.js"),s=e("./flush.js"),o=e("./ls.js"),a=e("./mkdir.js"),c=e("./mv.js"),u=e("./read.js"),l=e("./rm.js"),d=e("./stat.js"),f=e("./touch.js"),h=e("./write.js");r.createFiles=function(e){return{chmod:i.createChmod(e),cp:n.createCp(e),flush:s.createFlush(e),ls:o.createLs(e),mkdir:a.createMkdir(e),mv:c.createMv(e),read:u.createRead(e),rm:l.createRm(e),stat:d.createStat(e),touch:f.createTouch(e),write:h.createWrite(e)}}},{"./chmod.js":"i7Fmt","./cp.js":"5v5u2","./flush.js":"deUwB","./ls.js":"1dhdH","./mkdir.js":"iocNx","./mv.js":"jgv4R","./read.js":"2jkwj","./rm.js":"60cHB","./stat.js":"2InTg","./touch.js":"aa8jv","./write.js":"aw4qs"}],i7Fmt:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async function(t,r,i={}){const s=await e.post("files/chmod",{signal:i.signal,searchParams:n.toUrlSearchParams({arg:t,mode:r,...i}),headers:i.headers});await s.text()}));r.createChmod=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"5v5u2":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function(t,r,n={}){const o=Array.isArray(t)?t:[t],a=await e.post("files/cp",{signal:n.signal,searchParams:s.toUrlSearchParams({arg:o.concat(r).map((e=>i.CID.asCID(e)?`/ipfs/${e}`:e)),...n}),headers:n.headers});await a.text()}));r.createCp=o},{"multiformats/cid":"9ooAY","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],deUwB:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function(t,r={}){if(!t||"string"!=typeof t)throw new Error("ipfs.files.flush requires a path");const n=await e.post("files/flush",{signal:r.signal,searchParams:s.toUrlSearchParams({arg:t,...r}),headers:r.headers}),o=await n.json();return i.CID.parse(o.Cid)}));r.createFlush=o},{"multiformats/cid":"9ooAY","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"1dhdH":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../lib/object-to-camel-with-metadata.js"),s=e("../lib/configure.js"),o=e("../lib/to-url-search-params.js");const a=s.configure((e=>async function*(t,r={}){if(!t)throw new Error("ipfs.files.ls requires a path");const s=await e.post("files/ls",{signal:r.signal,searchParams:o.toUrlSearchParams({arg:i.CID.asCID(t)?`/ipfs/${t}`:t,long:!0,...r,stream:!0}),headers:r.headers});for await(const e of s.ndjson())if("Entries"in e)for(const t of e.Entries||[])yield c(n.objectToCamelWithMetadata(t));else yield c(n.objectToCamelWithMetadata(e))}));function c(e){return e.hash&&(e.cid=i.CID.parse(e.hash)),delete e.hash,e.type=1===e.type?"directory":"file",e}r.createLs=a},{"multiformats/cid":"9ooAY","../lib/object-to-camel-with-metadata.js":"1iQWC","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"1iQWC":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./object-to-camel.js");r.objectToCamelWithMetadata=function(e){const t=i.objectToCamel(e);return Object.prototype.hasOwnProperty.call(t,"mode")&&(t.mode=parseInt(t.mode,8)),Object.prototype.hasOwnProperty.call(t,"mtime")&&(t.mtime={secs:t.mtime,nsecs:t.mtimeNsecs||0},delete t.mtimeNsecs),t}},{"./object-to-camel.js":"hdPx4"}],iocNx:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async function(t,r={}){const i=await e.post("files/mkdir",{signal:r.signal,searchParams:n.toUrlSearchParams({arg:t,...r}),headers:r.headers});await i.text()}));r.createMkdir=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],jgv4R:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async function(t,r,i={}){Array.isArray(t)||(t=[t]);const s=await e.post("files/mv",{signal:i.signal,searchParams:n.toUrlSearchParams({arg:t.concat(r),...i}),headers:i.headers});await s.text()}));r.createMv=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"2jkwj":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=s(e("stream-to-it/source.js"));const a=i.configure((e=>async function*(t,r={}){const i=await e.post("files/read",{signal:r.signal,searchParams:n.toUrlSearchParams({arg:t,count:r.length,...r}),headers:r.headers});yield*o.default(i.body)}));r.createRead=a},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz","stream-to-it/source.js":"7664L"}],"7664L":[function(e,t,r){t.exports=e=>{if(e[Symbol.asyncIterator])return e;if(e.getReader)return async function*(){const t=e.getReader();try{for(;;){const{done:e,value:r}=await t.read();if(e)return;yield r}}finally{t.releaseLock()}}();throw new Error("unknown stream")}},{}],"60cHB":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async function(t,r={}){const i=await e.post("files/rm",{signal:r.signal,searchParams:n.toUrlSearchParams({arg:t,...r}),headers:r.headers});await i.text()}));r.createRm=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"2InTg":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../lib/object-to-camel-with-metadata.js"),s=e("../lib/configure.js"),o=e("../lib/to-url-search-params.js");const a=s.configure((e=>async function(t,r={}){const s=await e.post("files/stat",{signal:r.signal,searchParams:o.toUrlSearchParams({arg:t,...r}),headers:r.headers}),a=await s.json();return a.WithLocality=a.WithLocality||!1,(c=n.objectToCamelWithMetadata(a)).cid=i.CID.parse(c.hash),delete c.hash,c;var c}));r.createStat=a},{"multiformats/cid":"9ooAY","../lib/object-to-camel-with-metadata.js":"1iQWC","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],aa8jv:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async function(t,r={}){const i=await e.post("files/touch",{signal:r.signal,searchParams:n.toUrlSearchParams({arg:t,...r}),headers:r.headers});await i.text()}));r.createTouch=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],aw4qs:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/mode-to-string.js"),n=e("../lib/parse-mtime.js"),s=e("../lib/configure.js"),o=e("ipfs-core-utils/multipart-request"),a=e("../lib/to-url-search-params.js"),c=e("../lib/abort-signal.js"),u=e("native-abort-controller");const l=s.configure((e=>async function(t,r,s={}){const l=new u.AbortController,d=c.abortSignal(l.signal,s.signal),f=await e.post("files/write",{signal:d,searchParams:a.toUrlSearchParams({arg:t,streamChannels:!0,count:s.length,...s}),...await o.multipartRequest({content:r,path:"arg",mode:i.modeToString(s.mode),mtime:n.parseMtime(s.mtime)},l,s.headers)});await f.text()}));r.createWrite=l},{"../lib/mode-to-string.js":"bbWaj","../lib/parse-mtime.js":"aLNRF","../lib/configure.js":"hR8g6","ipfs-core-utils/multipart-request":"7TICD","../lib/to-url-search-params.js":"fT4zz","../lib/abort-signal.js":"hzxSr","native-abort-controller":"6zwoZ"}],d23S0:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./export.js"),n=e("./gen.js"),s=e("./import.js"),o=e("./info.js"),a=e("./list.js"),c=e("./rename.js"),u=e("./rm.js");r.createKey=function(e){return{export:i.createExport(e),gen:n.createGen(e),import:s.createImport(e),info:o.createInfo(e),list:a.createList(e),rename:c.createRename(e),rm:u.createRm(e)}}},{"./export.js":"kC3hv","./gen.js":"ezvwT","./import.js":"liRPy","./info.js":"4TCmX","./list.js":"91GPg","./rename.js":"etz52","./rm.js":"lHlAl"}],kC3hv:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=n(e("err-code"));const o=i.configure((e=>async(e,t,r={})=>{throw s.default(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")}));r.createExport=o},{"../lib/configure.js":"hR8g6","err-code":"chZjB"}],ezvwT:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/object-to-camel.js"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function(t,r={type:"rsa",size:2048}){const n=await e.post("key/gen",{signal:r.signal,searchParams:s.toUrlSearchParams({arg:t,...r}),headers:r.headers}),o=await n.json();return i.objectToCamel(o)}));r.createGen=o},{"../lib/object-to-camel.js":"hdPx4","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],liRPy:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/object-to-camel.js"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function(t,r,n,o={}){const a=await e.post("key/import",{signal:o.signal,searchParams:s.toUrlSearchParams({arg:t,pem:r,password:n,...o}),headers:o.headers}),c=await a.json();return i.objectToCamel(c)}));r.createImport=o},{"../lib/object-to-camel.js":"hdPx4","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"4TCmX":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=n(e("err-code"));const o=i.configure((e=>async(e,t={})=>{throw s.default(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")}));r.createInfo=o},{"../lib/configure.js":"hR8g6","err-code":"chZjB"}],"91GPg":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/object-to-camel.js"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function(t={}){const r=await e.post("key/list",{signal:t.signal,searchParams:s.toUrlSearchParams(t),headers:t.headers});return((await r.json()).Keys||[]).map((e=>i.objectToCamel(e)))}));r.createList=o},{"../lib/object-to-camel.js":"hdPx4","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],etz52:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/object-to-camel.js"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function(t,r,n={}){const o=await e.post("key/rename",{signal:n.signal,searchParams:s.toUrlSearchParams({arg:[t,r],...n}),headers:n.headers});return i.objectToCamel(await o.json())}));r.createRename=o},{"../lib/object-to-camel.js":"hdPx4","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],lHlAl:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/object-to-camel.js"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function(t,r={}){const n=await e.post("key/rm",{signal:r.signal,searchParams:s.toUrlSearchParams({arg:t,...r}),headers:r.headers}),o=await n.json();return i.objectToCamel(o.Keys[0])}));r.createRm=o},{"../lib/object-to-camel.js":"hdPx4","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],dax7W:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./level.js"),n=e("./ls.js"),s=e("./tail.js");r.createLog=function(e){return{level:i.createLevel(e),ls:n.createLs(e),tail:s.createTail(e)}}},{"./level.js":"1Z9n5","./ls.js":"7ctbp","./tail.js":"3faFf"}],"1Z9n5":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/object-to-camel.js"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function(t,r,n={}){const o=await e.post("log/level",{signal:n.signal,searchParams:s.toUrlSearchParams({arg:[t,r],...n}),headers:n.headers});return i.objectToCamel(await o.json())}));r.createLevel=o},{"../lib/object-to-camel.js":"hdPx4","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"7ctbp":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async function(t={}){const r=await e.post("log/ls",{signal:t.signal,searchParams:n.toUrlSearchParams(t),headers:t.headers});return(await r.json()).Strings}));r.createLs=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"3faFf":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async function*(t={}){const r=await e.post("log/tail",{signal:t.signal,searchParams:n.toUrlSearchParams(t),headers:t.headers});yield*r.ndjson()}));r.createTail=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],hAUWJ:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./publish.js"),n=e("./resolve.js"),s=e("./pubsub/index.js");r.createName=function(e){return{publish:i.createPublish(e),resolve:n.createResolve(e),pubsub:s.createPubsub(e)}}},{"./publish.js":"kB8Vy","./resolve.js":"jDw6l","./pubsub/index.js":"1TMtb"}],kB8Vy:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/object-to-camel.js"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function(t,r={}){const n=await e.post("name/publish",{signal:r.signal,searchParams:s.toUrlSearchParams({arg:`${t}`,...r}),headers:r.headers});return i.objectToCamel(await n.json())}));r.createPublish=o},{"../lib/object-to-camel.js":"hdPx4","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],jDw6l:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async function*(t,r={}){const i=await e.post("name/resolve",{signal:r.signal,searchParams:n.toUrlSearchParams({arg:t,stream:!0,...r}),headers:r.headers});for await(const e of i.ndjson())yield e.Path}));r.createResolve=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"1TMtb":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./cancel.js"),n=e("./state.js"),s=e("./subs.js");r.createPubsub=function(e){return{cancel:i.createCancel(e),state:n.createState(e),subs:s.createSubs(e)}}},{"./cancel.js":"0ogCj","./state.js":"9oBIl","./subs.js":"eKxDJ"}],"0ogCj":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../../lib/object-to-camel.js"),n=e("../../lib/configure.js"),s=e("../../lib/to-url-search-params.js");const o=n.configure((e=>async function(t,r={}){const n=await e.post("name/pubsub/cancel",{signal:r.signal,searchParams:s.toUrlSearchParams({arg:t,...r}),headers:r.headers});return i.objectToCamel(await n.json())}));r.createCancel=o},{"../../lib/object-to-camel.js":"hdPx4","../../lib/configure.js":"hR8g6","../../lib/to-url-search-params.js":"fT4zz"}],"9oBIl":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../../lib/object-to-camel.js"),n=e("../../lib/configure.js"),s=e("../../lib/to-url-search-params.js");const o=n.configure((e=>async function(t={}){const r=await e.post("name/pubsub/state",{signal:t.signal,searchParams:s.toUrlSearchParams(t),headers:t.headers});return i.objectToCamel(await r.json())}));r.createState=o},{"../../lib/object-to-camel.js":"hdPx4","../../lib/configure.js":"hR8g6","../../lib/to-url-search-params.js":"fT4zz"}],eKxDJ:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../../lib/configure.js"),n=e("../../lib/to-url-search-params.js");const s=i.configure((e=>async function(t={}){const r=await e.post("name/pubsub/subs",{signal:t.signal,searchParams:n.toUrlSearchParams(t),headers:t.headers});return(await r.json()).Strings||[]}));r.createSubs=s},{"../../lib/configure.js":"hR8g6","../../lib/to-url-search-params.js":"fT4zz"}],lIWb3:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./data.js"),n=e("./get.js"),s=e("./links.js"),o=e("./new.js"),a=e("./put.js"),c=e("./stat.js"),u=e("./patch/index.js");r.createObject=function(e,t){return{data:i.createData(t),get:n.createGet(t),links:s.createLinks(t),new:o.createNew(t),put:a.createPut(e,t),stat:c.createStat(t),patch:u.createPatch(t)}}},{"./data.js":"ef4Az","./get.js":"2uTHZ","./links.js":"10Mon","./new.js":"4VILN","./put.js":"3vtk9","./stat.js":"4TYop","./patch/index.js":"kOUgR"}],ef4Az:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function(t,r={}){const n=await e.post("object/data",{signal:r.signal,searchParams:s.toUrlSearchParams({arg:`${t instanceof Uint8Array?i.CID.decode(t):t}`,...r}),headers:r.headers}),o=await n.arrayBuffer();return new Uint8Array(o,0,o.byteLength)}));r.createData=o},{"multiformats/cid":"9ooAY","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"2uTHZ":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js"),o=e("uint8arrays/from-string");const a=n.configure((e=>async function(t,r={}){const n=await e.post("object/get",{signal:r.signal,searchParams:s.toUrlSearchParams({arg:`${t instanceof Uint8Array?i.CID.decode(t):t}`,dataEncoding:"base64",...r}),headers:r.headers}),a=await n.json();return{Data:o.fromString(a.Data,"base64pad"),Links:(a.Links||[]).map((e=>({Name:e.Name,Hash:i.CID.parse(e.Hash),Tsize:e.Size})))}}));r.createGet=a},{"multiformats/cid":"9ooAY","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz","uint8arrays/from-string":"dF7Y4"}],"10Mon":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function(t,r={}){const n=await e.post("object/links",{signal:r.signal,searchParams:s.toUrlSearchParams({arg:`${t instanceof Uint8Array?i.CID.decode(t):t}`,...r}),headers:r.headers});return((await n.json()).Links||[]).map((e=>({Name:e.Name,Tsize:e.Size,Hash:i.CID.parse(e.Hash)})))}));r.createLinks=o},{"multiformats/cid":"9ooAY","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"4VILN":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function(t={}){const r=await e.post("object/new",{signal:t.signal,searchParams:s.toUrlSearchParams({arg:t.template,...t}),headers:t.headers}),{Hash:n}=await r.json();return i.CID.parse(n)}));r.createNew=o},{"multiformats/cid":"9ooAY","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"3vtk9":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../dag/put.js");r.createPut=(e,t)=>i.configure((r=>{const i=n.createPut(e,t);return async function(e,t={}){return i(e,{...t,format:"dag-pb",hashAlg:"sha2-256",version:0})}}))(t)},{"../lib/configure.js":"hR8g6","../dag/put.js":"e3DVQ"}],"4TYop":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function(t,r={}){const n=await e.post("object/stat",{signal:r.signal,searchParams:s.toUrlSearchParams({arg:`${t}`,...r}),headers:r.headers}),o=await n.json();return{...o,Hash:i.CID.parse(o.Hash)}}));r.createStat=o},{"multiformats/cid":"9ooAY","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],kOUgR:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./add-link.js"),n=e("./append-data.js"),s=e("./rm-link.js"),o=e("./set-data.js");r.createPatch=function(e){return{addLink:i.createAddLink(e),appendData:n.createAppendData(e),rmLink:s.createRmLink(e),setData:o.createSetData(e)}}},{"./add-link.js":"9EUqN","./append-data.js":"2uXuE","./rm-link.js":"6Y2ZK","./set-data.js":"SCMuD"}],"9EUqN":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../../lib/configure.js"),s=e("../../lib/to-url-search-params.js");const o=n.configure((e=>async function(t,r,n={}){const o=await e.post("object/patch/add-link",{signal:n.signal,searchParams:s.toUrlSearchParams({arg:[`${t}`,r.Name||r.name||"",(r.Hash||r.cid||"").toString()||null],...n}),headers:n.headers}),{Hash:a}=await o.json();return i.CID.parse(a)}));r.createAddLink=o},{"multiformats/cid":"9ooAY","../../lib/configure.js":"hR8g6","../../lib/to-url-search-params.js":"fT4zz"}],"2uXuE":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("ipfs-core-utils/multipart-request"),s=e("../../lib/configure.js"),o=e("../../lib/to-url-search-params.js"),a=e("../../lib/abort-signal.js"),c=e("native-abort-controller");const u=s.configure((e=>async function(t,r,s={}){const u=new c.AbortController,l=a.abortSignal(u.signal,s.signal),d=await e.post("object/patch/append-data",{signal:l,searchParams:o.toUrlSearchParams({arg:`${t}`,...s}),...await n.multipartRequest(r,u,s.headers)}),{Hash:f}=await d.json();return i.CID.parse(f)}));r.createAppendData=u},{"multiformats/cid":"9ooAY","ipfs-core-utils/multipart-request":"7TICD","../../lib/configure.js":"hR8g6","../../lib/to-url-search-params.js":"fT4zz","../../lib/abort-signal.js":"hzxSr","native-abort-controller":"6zwoZ"}],"6Y2ZK":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../../lib/configure.js"),s=e("../../lib/to-url-search-params.js");const o=n.configure((e=>async function(t,r,n={}){const o=await e.post("object/patch/rm-link",{signal:n.signal,searchParams:s.toUrlSearchParams({arg:[`${t}`,r.Name||r.name||null],...n}),headers:n.headers}),{Hash:a}=await o.json();return i.CID.parse(a)}));r.createRmLink=o},{"multiformats/cid":"9ooAY","../../lib/configure.js":"hR8g6","../../lib/to-url-search-params.js":"fT4zz"}],SCMuD:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("ipfs-core-utils/multipart-request"),s=e("../../lib/configure.js"),o=e("../../lib/to-url-search-params.js"),a=e("../../lib/abort-signal.js"),c=e("native-abort-controller");const u=s.configure((e=>async function(t,r,s={}){const u=new c.AbortController,l=a.abortSignal(u.signal,s.signal),d=await e.post("object/patch/set-data",{signal:l,searchParams:o.toUrlSearchParams({arg:[`${t}`],...s}),...await n.multipartRequest(r,u,s.headers)}),{Hash:f}=await d.json();return i.CID.parse(f)}));r.createSetData=u},{"multiformats/cid":"9ooAY","ipfs-core-utils/multipart-request":"7TICD","../../lib/configure.js":"hR8g6","../../lib/to-url-search-params.js":"fT4zz","../../lib/abort-signal.js":"hzxSr","native-abort-controller":"6zwoZ"}],"2EyML":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./add-all.js"),n=e("./add.js"),s=e("./ls.js"),o=e("./rm-all.js"),a=e("./rm.js"),c=e("./remote/index.js");r.createPin=function(e){return{addAll:i.createAddAll(e),add:n.createAdd(e),ls:s.createLs(e),rmAll:o.createRmAll(e),rm:a.createRm(e),remote:c.createRemote(e)}}},{"./add-all.js":"6SsJV","./add.js":"gNAmm","./ls.js":"4xLZT","./rm-all.js":"1RTay","./rm.js":"iRwZg","./remote/index.js":"5Qqlr"}],"6SsJV":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../lib/configure.js"),s=e("ipfs-core-utils/pins/normalise-input"),o=e("../lib/to-url-search-params.js");const a=n.configure((e=>async function*(t,r={}){for await(const{path:n,recursive:a,metadata:c}of s.normaliseInput(t)){const t=await e.post("pin/add",{signal:r.signal,searchParams:o.toUrlSearchParams({...r,arg:n,recursive:a,metadata:c?JSON.stringify(c):void 0,stream:!0}),headers:r.headers});for await(const e of t.ndjson())if(e.Pins)for(const t of e.Pins)yield i.CID.parse(t);else yield i.CID.parse(e)}}));r.createAddAll=a},{"multiformats/cid":"9ooAY","../lib/configure.js":"hR8g6","ipfs-core-utils/pins/normalise-input":"4NDJq","../lib/to-url-search-params.js":"fT4zz"}],gNAmm:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./add-all.js"),n=e("it-last"),s=e("../lib/configure.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(n);r.createAdd=function(e){const t=i.createAddAll(e);return s.configure((()=>async function(e,r={}){return a.default(t([{path:e,...r}],r))}))(e)}},{"./add-all.js":"6SsJV","it-last":"cSXX9","../lib/configure.js":"hR8g6"}],"4xLZT":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");function o(e,t,r){const n={type:e,cid:i.CID.parse(t)};return r&&(n.metadata=r),n}const a=n.configure((e=>async function*(t={}){let r=[];t.paths&&(r=Array.isArray(t.paths)?t.paths:[t.paths]);const i=await e.post("pin/ls",{signal:t.signal,searchParams:s.toUrlSearchParams({...t,arg:r.map((e=>`${e}`)),stream:!0}),headers:t.headers});for await(const e of i.ndjson()){if(e.Keys){for(const t of Object.keys(e.Keys))yield o(e.Keys[t].Type,t,e.Keys[t].Metadata);return}yield o(e.Type,e.Cid,e.Metadata)}}));r.createLs=a},{"multiformats/cid":"9ooAY","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"1RTay":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../lib/configure.js"),s=e("ipfs-core-utils/pins/normalise-input"),o=e("../lib/to-url-search-params.js");const a=n.configure((e=>async function*(t,r={}){for await(const{path:n,recursive:a}of s.normaliseInput(t)){const t=new URLSearchParams(r.searchParams);t.append("arg",`${n}`),null!=a&&t.set("recursive",String(a));const s=await e.post("pin/rm",{signal:r.signal,headers:r.headers,searchParams:o.toUrlSearchParams({...r,arg:`${n}`,recursive:a})});for await(const e of s.ndjson())e.Pins?yield*e.Pins.map((e=>i.CID.parse(e))):yield i.CID.parse(e)}}));r.createRmAll=a},{"multiformats/cid":"9ooAY","../lib/configure.js":"hR8g6","ipfs-core-utils/pins/normalise-input":"4NDJq","../lib/to-url-search-params.js":"fT4zz"}],iRwZg:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./rm-all.js"),n=e("it-last"),s=e("../lib/configure.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(n);r.createRm=e=>{const t=i.createRmAll(e);return s.configure((()=>async function(e,r={}){return a.default(t([{path:e,...r}],r))}))(e)}},{"./rm-all.js":"1RTay","it-last":"cSXX9","../lib/configure.js":"hR8g6"}],"5Qqlr":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../../lib/core.js"),n=e("./add.js"),s=e("./ls.js"),o=e("./rm.js"),a=e("./rm-all.js"),c=e("./service/index.js");r.createRemote=function(e){const t=new i.Client(e);return{add:n.createAdd(t),ls:s.createLs(t),rm:o.createRm(t),rmAll:a.createRmAll(t),service:c.createService(e)}}},{"../../lib/core.js":"3XXp5","./add.js":"6QlyE","./ls.js":"jHl8Y","./rm.js":"1hrlp","./rm-all.js":"fIlTt","./service/index.js":"78IT1"}],"6QlyE":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./utils.js");r.createAdd=function(e){return async function(t,{timeout:r,signal:n,headers:s,...o}){const a=await e.post("pin/remote/add",{timeout:r,signal:n,headers:s,searchParams:i.encodeAddParams({cid:t,...o})});return i.decodePin(await a.json())}}},{"./utils.js":"bQgDT"}],bQgDT:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../../lib/to-url-search-params.js");const s=e=>{if("string"==typeof e&&""!==e)return e;throw new TypeError("service name must be passed")},o=e=>{if(i.CID.asCID(e))return e.toString();throw new TypeError("CID instance expected instead of "+typeof e)};r.decodePin=({Name:e,Status:t,Cid:r})=>({cid:i.CID.parse(r),name:e,status:t}),r.encodeAddParams=({cid:e,service:t,background:r,name:i,origins:a})=>{const c=n.toUrlSearchParams({arg:o(e),service:s(t),name:i,background:!!r||void 0});if(a)for(const e of a)c.append("origin",e.toString());return c},r.encodeCID=o,r.encodeQuery=({service:e,cid:t,name:r,status:i,all:a})=>{const c=n.toUrlSearchParams({service:s(e),name:r,force:!!a||void 0});if(t)for(const e of t)c.append("cid",o(e));if(i)for(const e of i)c.append("status",e);return c},r.encodeService=s},{"multiformats/cid":"9ooAY","../../lib/to-url-search-params.js":"fT4zz"}],jHl8Y:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./utils.js");r.createLs=function(e){return async function*({timeout:t,signal:r,headers:n,...s}){const o=await e.post("pin/remote/ls",{timeout:t,signal:r,headers:n,searchParams:i.encodeQuery(s)});for await(const e of o.ndjson())yield i.decodePin(e)}}},{"./utils.js":"bQgDT"}],"1hrlp":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./utils.js");r.createRm=function(e){return async function({timeout:t,signal:r,headers:n,...s}){await e.post("pin/remote/rm",{timeout:t,signal:r,headers:n,searchParams:i.encodeQuery({...s,all:!1})})}}},{"./utils.js":"bQgDT"}],fIlTt:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./utils.js");r.createRmAll=function(e){return async function({timeout:t,signal:r,headers:n,...s}){await e.post("pin/remote/rm",{timeout:t,signal:r,headers:n,searchParams:i.encodeQuery({...s,all:!0})})}}},{"./utils.js":"bQgDT"}],"78IT1":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../../../lib/core.js"),n=e("./add.js"),s=e("./ls.js"),o=e("./rm.js");r.createService=function(e){const t=new i.Client(e);return{add:n.createAdd(t),ls:s.createLs(t),rm:o.createRm(t)}}},{"../../../lib/core.js":"3XXp5","./add.js":"jw6p7","./ls.js":"d55dc","./rm.js":"5AjIT"}],jw6p7:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../../../lib/to-url-search-params.js"),n=e("./utils.js");r.createAdd=function(e){return async function(t,r){const{endpoint:s,key:o,headers:a,timeout:c,signal:u}=r;await e.post("pin/remote/service/add",{timeout:c,signal:u,searchParams:i.toUrlSearchParams({arg:[t,n.encodeEndpoint(s),o]}),headers:a})}}},{"../../../lib/to-url-search-params.js":"fT4zz","./utils.js":"6pYda"}],"6pYda":[function(e,t,r){"use strict";function i(e){switch(e.Status){case"valid":{const{Pinning:t,Pinned:r,Queued:i,Failed:n}=e.PinCount;return{status:"valid",pinCount:{queued:i,pinning:t,pinned:r,failed:n}}}case"invalid":return{status:"invalid"};default:return{status:e.Status}}}Object.defineProperty(r,"__esModule",{value:!0}),r.decodeRemoteService=function(e){return{service:e.Service,endpoint:new URL(e.ApiEndpoint),...e.Stat&&{stat:i(e.Stat)}}},r.decodeStat=i,r.encodeEndpoint=function(e){const t=String(e);if("undefined"===t)throw Error("endpoint is required");return"/"===t[t.length-1]?t.slice(0,-1):t}},{}],d55dc:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../../../lib/to-url-search-params.js"),n=e("./utils.js");r.createLs=function(e){return async function(t={}){const{stat:r,headers:s,timeout:o,signal:a}=t,c=await e.post("pin/remote/service/ls",{timeout:o,signal:a,headers:s,searchParams:!0===r?i.toUrlSearchParams({stat:r}):void 0}),{RemoteServices:u}=await c.json();return u.map(n.decodeRemoteService)}}},{"../../../lib/to-url-search-params.js":"fT4zz","./utils.js":"6pYda"}],"5AjIT":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../../../lib/to-url-search-params.js");r.createRm=function(e){return async function(t,r={}){await e.post("pin/remote/service/rm",{signal:r.signal,headers:r.headers,searchParams:i.toUrlSearchParams({arg:t})})}}},{"../../../lib/to-url-search-params.js":"fT4zz"}],"9yoEA":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./ls.js"),n=e("./peers.js"),s=e("./publish.js"),o=e("./subscribe.js"),a=e("./unsubscribe.js"),c=e("./subscription-tracker.js");r.createPubsub=function(e){const t=new c.SubscriptionTracker;return{ls:i.createLs(e),peers:n.createPeers(e),publish:s.createPublish(e),subscribe:o.createSubscribe(e,t),unsubscribe:a.createUnsubscribe(e,t)}}},{"./ls.js":"2yozO","./peers.js":"5ZIFR","./publish.js":"3DcXt","./subscribe.js":"02Av6","./unsubscribe.js":"97bmo","./subscription-tracker.js":"eg0Db"}],"2yozO":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async function(t={}){const{Strings:r}=await(await e.post("pubsub/ls",{signal:t.signal,searchParams:n.toUrlSearchParams(t),headers:t.headers})).json();return r||[]}));r.createLs=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"5ZIFR":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async function(t,r={}){const i=await e.post("pubsub/peers",{signal:r.signal,searchParams:n.toUrlSearchParams({arg:t,...r}),headers:r.headers}),{Strings:s}=await i.json();return s||[]}));r.createPeers=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"3DcXt":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js"),s=e("ipfs-core-utils/multipart-request"),o=e("../lib/abort-signal.js"),a=e("native-abort-controller");const c=i.configure((e=>async function(t,r,i={}){const c=n.toUrlSearchParams({arg:t,...i}),u=new a.AbortController,l=o.abortSignal(u.signal,i.signal),d=await e.post("pubsub/pub",{signal:l,searchParams:c,...await s.multipartRequest(r,u,i.headers)});await d.text()}));r.createPublish=c},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz","ipfs-core-utils/multipart-request":"7TICD","../lib/abort-signal.js":"hzxSr","native-abort-controller":"6zwoZ"}],"02Av6":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("uint8arrays/from-string"),n=e("uint8arrays/to-string"),s=e("debug"),o=e("../lib/configure.js"),a=e("../lib/to-url-search-params.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const u=c(s).default("ipfs-http-client:pubsub:subscribe");const l=e=>{switch(e.type){case"aborted":case"abort":return!0;default:return"AbortError"===e.name}};r.createSubscribe=(e,t)=>o.configure((e=>async function(r,s,o={}){let c,d;o.signal=t.subscribe(r,s,o.signal);const f=new Promise(((e,t)=>{c=e,d=t})),h=setTimeout((()=>c()),1e3);return e.post("pubsub/sub",{signal:o.signal,searchParams:a.toUrlSearchParams({arg:r,...o}),headers:o.headers}).catch((e=>{t.unsubscribe(r,s),d(e)})).then((e=>{clearTimeout(h),e&&(!async function(e,{onMessage:t,onEnd:r,onError:s}){s=s||u;try{for await(const r of e.ndjson())try{if(!r.from)continue;t({from:n.toString(i.fromString(r.from,"base64pad"),"base58btc"),data:i.fromString(r.data,"base64pad"),seqno:i.fromString(r.seqno,"base64pad"),topicIDs:r.topicIDs})}catch(e){e.message=`Failed to parse pubsub message: ${e.message}`,s(e,!1,r)}}catch(e){l(e)||s(e,!0)}finally{r()}}(e,{onMessage:s,onEnd:()=>t.unsubscribe(r,s),onError:o.onError}),c())})),f}))(e)},{"uint8arrays/from-string":"dF7Y4","uint8arrays/to-string":"hC8JB",debug:"bO5wM","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"97bmo":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});r.createUnsubscribe=(e,t)=>async function(e,r){t.unsubscribe(e,r)}},{}],eg0Db:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("native-abort-controller");r.SubscriptionTracker=class{constructor(){this._subs=new Map}subscribe(e,t,r){const n=this._subs.get(e)||[];if(n.find((e=>e.handler===t)))throw new Error(`Already subscribed to ${e} with this handler`);const s=new i.AbortController;return this._subs.set(e,[{handler:t,controller:s}].concat(n)),r&&r.addEventListener("abort",(()=>this.unsubscribe(e,t))),s.signal}unsubscribe(e,t){const r=this._subs.get(e)||[];let i;t?(this._subs.set(e,r.filter((e=>e.handler!==t))),i=r.filter((e=>e.handler===t))):(this._subs.set(e,[]),i=r),(this._subs.get(e)||[]).length||this._subs.delete(e),i.forEach((e=>e.controller.abort()))}}},{"native-abort-controller":"6zwoZ"}],"6sM7A":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../lib/object-to-camel.js"),s=e("../lib/configure.js"),o=e("../lib/to-url-search-params.js"),a=e("./local.js");const c=s.configure(((e,t)=>Object.assign((async function*(t,r={}){const s=Array.isArray(t)?t:[t],a=await e.post("refs",{signal:r.signal,searchParams:o.toUrlSearchParams({arg:s.map((e=>`${e instanceof Uint8Array?i.CID.decode(e):e}`)),...r}),headers:r.headers,transform:n.objectToCamel});yield*a.ndjson()}),{local:a.createLocal(t)})));r.createRefs=c},{"multiformats/cid":"9ooAY","../lib/object-to-camel.js":"hdPx4","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz","./local.js":"hVVLK"}],hVVLK:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/object-to-camel.js"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function*(t={}){const r=await e.post("refs/local",{signal:t.signal,transform:i.objectToCamel,searchParams:s.toUrlSearchParams(t),headers:t.headers});yield*r.ndjson()}));r.createLocal=o},{"../lib/object-to-camel.js":"hdPx4","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],lf1uS:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./gc.js"),n=e("./stat.js"),s=e("./version.js");r.createRepo=function(e){return{gc:i.createGc(e),stat:n.createStat(e),version:s.createVersion(e)}}},{"./gc.js":"5kVJA","./stat.js":"kW3mJ","./version.js":"bU0xW"}],"5kVJA":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function*(t={}){const r=await e.post("repo/gc",{signal:t.signal,searchParams:s.toUrlSearchParams(t),headers:t.headers,transform:e=>({err:e.Error?new Error(e.Error):null,cid:(e.Key||{})["/"]?i.CID.parse(e.Key["/"]):null})});yield*r.ndjson()}));r.createGc=o},{"multiformats/cid":"9ooAY","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],kW3mJ:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async function(t={}){const r=await e.post("repo/stat",{signal:t.signal,searchParams:n.toUrlSearchParams(t),headers:t.headers}),i=await r.json();return{numObjects:BigInt(i.NumObjects),repoSize:BigInt(i.RepoSize),repoPath:i.RepoPath,version:i.Version,storageMax:BigInt(i.StorageMax)}}));r.createStat=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],bU0xW:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async function(t={}){return(await(await e.post("repo/version",{signal:t.signal,searchParams:n.toUrlSearchParams(t),headers:t.headers})).json()).Version}));r.createVersion=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"8ekdG":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../bitswap/stat.js"),n=e("../repo/stat.js"),s=e("./bw.js");r.createStats=function(e){return{bitswap:i.createStat(e),repo:n.createStat(e),bw:s.createBw(e)}}},{"../bitswap/stat.js":"3Q0KE","../repo/stat.js":"kW3mJ","./bw.js":"cvdwA"}],cvdwA:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async function*(t={}){const r=await e.post("stats/bw",{signal:t.signal,searchParams:n.toUrlSearchParams(t),headers:t.headers,transform:e=>({totalIn:BigInt(e.TotalIn),totalOut:BigInt(e.TotalOut),rateIn:parseFloat(e.RateIn),rateOut:parseFloat(e.RateOut)})});yield*r.ndjson()}));r.createBw=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"9n7fV":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./addrs.js"),n=e("./connect.js"),s=e("./disconnect.js"),o=e("./local-addrs.js"),a=e("./peers.js");r.createSwarm=function(e){return{addrs:i.createAddrs(e),connect:n.createConnect(e),disconnect:s.createDisconnect(e),localAddrs:o.createLocalAddrs(e),peers:a.createPeers(e)}}},{"./addrs.js":"fxhEW","./connect.js":"cuaL2","./disconnect.js":"820vp","./local-addrs.js":"dEgBz","./peers.js":"jZx0P"}],fxhEW:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiaddr"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function(t={}){const r=await e.post("swarm/addrs",{signal:t.signal,searchParams:s.toUrlSearchParams(t),headers:t.headers}),{Addrs:n}=await r.json();return Object.keys(n).map((e=>({id:e,addrs:(n[e]||[]).map((e=>new i.Multiaddr(e)))})))}));r.createAddrs=o},{multiaddr:"8Mu1u","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],cuaL2:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async function(t,r={}){const i=await e.post("swarm/connect",{signal:r.signal,searchParams:n.toUrlSearchParams({arg:t,...r}),headers:r.headers}),{Strings:s}=await i.json();return s||[]}));r.createConnect=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],"820vp":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../lib/configure.js"),n=e("../lib/to-url-search-params.js");const s=i.configure((e=>async function(t,r={}){const i=await e.post("swarm/disconnect",{signal:r.signal,searchParams:n.toUrlSearchParams({arg:t,...r}),headers:r.headers}),{Strings:s}=await i.json();return s||[]}));r.createDisconnect=s},{"../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],dEgBz:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiaddr"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function(t={}){const r=await e.post("swarm/addrs/local",{signal:t.signal,searchParams:s.toUrlSearchParams(t),headers:t.headers}),{Strings:n}=await r.json();return(n||[]).map((e=>new i.Multiaddr(e)))}));r.createLocalAddrs=o},{multiaddr:"8Mu1u","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],jZx0P:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiaddr"),n=e("../lib/configure.js"),s=e("../lib/to-url-search-params.js");const o=n.configure((e=>async function(t={}){const r=await e.post("swarm/peers",{signal:t.signal,searchParams:s.toUrlSearchParams(t),headers:t.headers}),{Peers:n}=await r.json();return(n||[]).map((e=>({addr:new i.Multiaddr(e.Addr),peer:e.Peer,muxer:e.Muxer,latency:e.Latency,streams:e.Streams,direction:null==e.Direction?void 0:0===e.Direction?"inbound":"outbound"})))}));r.createPeers=o},{multiaddr:"8Mu1u","../lib/configure.js":"hR8g6","../lib/to-url-search-params.js":"fT4zz"}],bh9eV:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./add-all.js"),n=e("it-last"),s=e("./lib/configure.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(n);r.createAdd=function(e){const t=i.createAddAll(e);return s.configure((()=>async function(e,r={}){return await a.default(t(e,r))}))(e)}},{"./add-all.js":"dygjF","it-last":"cSXX9","./lib/configure.js":"hR8g6"}],dygjF:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("./lib/object-to-camel.js"),s=e("./lib/configure.js"),o=e("ipfs-core-utils/multipart-request"),a=e("./lib/to-url-search-params.js"),c=e("./lib/abort-signal.js"),u=e("native-abort-controller");const l=s.configure((e=>async function*(t,r={}){const i=new u.AbortController,s=c.abortSignal(i.signal,r.signal),{headers:l,body:f,total:p,parts:g}=await o.multipartRequest(t,i,r.headers),[y,m]="function"==typeof r.progress?d(p,g,r.progress):[void 0,void 0],b=await e.post("add",{searchParams:a.toUrlSearchParams({"stream-channels":!0,...r,progress:Boolean(y)}),onUploadProgress:m,signal:s,headers:l,body:f});for await(let e of b.ndjson())e=n.objectToCamel(e),void 0!==e.hash?yield h(e):y&&y(e.bytes||0,e.name)})),d=(e,t,r)=>t?[void 0,f(e,t,r)]:[r,void 0],f=(e,t,r)=>{let i=0;const n=t.length;return({loaded:s,total:o})=>{const a=Math.floor(s/o*e);for(;iasync function*(t,r={}){const i=await e.post("cat",{signal:r.signal,searchParams:n.toUrlSearchParams({arg:t.toString(),...r}),headers:r.headers});yield*i.iterator()}));r.createCat=s},{"./lib/configure.js":"hR8g6","./lib/to-url-search-params.js":"fT4zz"}],d7oos:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./lib/configure.js"),n=e("./lib/to-url-search-params.js");const s=i.configure((e=>async(t={})=>(await e.post("commands",{signal:t.signal,searchParams:n.toUrlSearchParams(t),headers:t.headers})).json()));r.createCommands=s},{"./lib/configure.js":"hR8g6","./lib/to-url-search-params.js":"fT4zz"}],"6WsTM":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./lib/configure.js"),n=e("./lib/to-url-search-params.js");const s=i.configure((e=>async(t,r={})=>{const i=await e.post("dns",{signal:r.signal,searchParams:n.toUrlSearchParams({arg:t,...r}),headers:r.headers});return(await i.json()).Path}));r.createDns=s},{"./lib/configure.js":"hR8g6","./lib/to-url-search-params.js":"fT4zz"}],e09lW:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const i=e("./lib/configure.js").configure((e=>()=>{const t=new URL(e.opts.base||"");return{host:t.hostname,port:t.port,protocol:t.protocol,pathname:t.pathname,"api-path":t.pathname}}));r.createGetEndpointConfig=i},{"./lib/configure.js":"hR8g6"}],"9dl4d":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("./lib/configure.js"),s=e("./lib/to-url-search-params.js");const o=n.configure((e=>async function*(t,r={}){const n={arg:`${t instanceof Uint8Array?i.CID.decode(t):t}`,...r};n.compressionLevel&&(n["compression-level"]=n.compressionLevel,delete n.compressionLevel);const o=await e.post("get",{signal:r.signal,searchParams:s.toUrlSearchParams(n),headers:r.headers});yield*o.iterator()}));r.createGet=o},{"multiformats/cid":"9ooAY","./lib/configure.js":"hR8g6","./lib/to-url-search-params.js":"fT4zz"}],iMd7i:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./lib/object-to-camel.js"),n=e("multiaddr"),s=e("./lib/configure.js"),o=e("./lib/to-url-search-params.js");const a=s.configure((e=>async function(t={}){const r=await e.post("id",{signal:t.signal,searchParams:o.toUrlSearchParams({arg:t.peerId?t.peerId.toString():void 0,...t}),headers:t.headers}),s=await r.json(),a={...i.objectToCamel(s)};return a.addresses&&(a.addresses=a.addresses.map((e=>new n.Multiaddr(e)))),a}));r.createId=a},{"./lib/object-to-camel.js":"hdPx4",multiaddr:"8Mu1u","./lib/configure.js":"hR8g6","./lib/to-url-search-params.js":"fT4zz"}],"1Ujko":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./id.js");r.createIsOnline=e=>{const t=i.createId(e);return async function(e={}){const r=await t(e);return Boolean(r&&r.addresses&&r.addresses.length)}}},{"./id.js":"iMd7i"}],jIkVK:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("./lib/configure.js"),s=e("./lib/to-url-search-params.js"),o=e("./files/stat.js");const a=n.configure(((e,t)=>async function*(r,n={}){const a=`${r instanceof Uint8Array?i.CID.decode(r):r}`;async function u(e){let r=e.Hash;if(r.includes("/")){const e=r.startsWith("/ipfs/")?r:`/ipfs/${r}`;r=(await o.createStat(t)(e)).cid}else r=i.CID.parse(r);const n={name:e.Name,path:a+(e.Name?`/${e.Name}`:""),size:e.Size,cid:r,type:c(e)};return e.Mode&&(n.mode=parseInt(e.Mode,8)),void 0!==e.Mtime&&null!==e.Mtime&&(n.mtime={secs:e.Mtime},void 0!==e.MtimeNsecs&&null!==e.MtimeNsecs&&(n.mtime.nsecs=e.MtimeNsecs)),n}const l=await e.post("ls",{signal:n.signal,searchParams:s.toUrlSearchParams({arg:a,...n}),headers:n.headers});for await(let e of l.ndjson()){if(e=e.Objects,!e)throw new Error("expected .Objects in results");if(e=e[0],!e)throw new Error("expected one array in results.Objects");const t=e.Links;if(!Array.isArray(t))throw new Error("expected one array in results.Objects[0].Links");if(!t.length)return void(yield u(e));yield*t.map(u)}}));function c(e){switch(e.Type){case 1:case 5:return"dir";default:return"file"}}r.createLs=a},{"multiformats/cid":"9ooAY","./lib/configure.js":"hR8g6","./lib/to-url-search-params.js":"fT4zz","./files/stat.js":"2InTg"}],"5Ghx1":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./lib/object-to-camel.js"),n=e("./lib/configure.js"),s=e("./lib/to-url-search-params.js");const o=n.configure((e=>async function(t={}){const r=await e.post("dns",{signal:t.signal,searchParams:s.toUrlSearchParams(t),headers:t.headers});return i.objectToCamel(await r.json())}));r.createMount=o},{"./lib/object-to-camel.js":"hdPx4","./lib/configure.js":"hR8g6","./lib/to-url-search-params.js":"fT4zz"}],fIZQw:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./lib/object-to-camel.js"),n=e("./lib/configure.js"),s=e("./lib/to-url-search-params.js");const o=n.configure((e=>async function*(t,r={}){const n=await e.post("ping",{signal:r.signal,searchParams:s.toUrlSearchParams({arg:`${t}`,...r}),headers:r.headers,transform:i.objectToCamel});yield*n.ndjson()}));r.createPing=o},{"./lib/object-to-camel.js":"hdPx4","./lib/configure.js":"hR8g6","./lib/to-url-search-params.js":"fT4zz"}],fqXrw:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./lib/configure.js"),n=e("./lib/to-url-search-params.js");const s=i.configure((e=>async function(t,r={}){const i=await e.post("resolve",{signal:r.signal,searchParams:n.toUrlSearchParams({arg:t,...r}),headers:r.headers}),{Path:s}=await i.json();return s}));r.createResolve=s},{"./lib/configure.js":"hR8g6","./lib/to-url-search-params.js":"fT4zz"}],"4YTOj":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./lib/configure.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=n(e("err-code"));const o=i.configure((e=>async(e={})=>{throw s.default(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")}));r.createStart=o},{"./lib/configure.js":"hR8g6","err-code":"chZjB"}],j2dHM:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./lib/configure.js"),n=e("./lib/to-url-search-params.js");const s=i.configure((e=>async function(t={}){const r=await e.post("shutdown",{signal:t.signal,searchParams:n.toUrlSearchParams(t),headers:t.headers});await r.text()}));r.createStop=s},{"./lib/configure.js":"hR8g6","./lib/to-url-search-params.js":"fT4zz"}],k3Foi:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./lib/object-to-camel.js"),n=e("./lib/configure.js"),s=e("./lib/to-url-search-params.js");const o=n.configure((e=>async function(t={}){const r=await e.post("version",{signal:t.signal,searchParams:s.toUrlSearchParams(t),headers:t.headers});return{...i.objectToCamel(await r.json()),"ipfs-http-client":"1.0.0"}}));r.createVersion=o},{"./lib/object-to-camel.js":"hdPx4","./lib/configure.js":"hR8g6","./lib/to-url-search-params.js":"fT4zz"}],jQSIS:[function(e,t,r){"use strict";const i=e("../http");async function*n(e,t){const r=new i,n=await r.get(e,t);yield*n.iterator()}t.exports=(e,t)=>({path:decodeURIComponent(new URL(e).pathname.split("/").pop()||""),content:n(e,t)})},{"../http":"ifXXn"}],eStoI:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("libp2p-websockets"),n=e("libp2p-webrtc-star"),s=e("libp2p-mplex"),o=e("@chainsafe/libp2p-noise"),a=e("libp2p-kad-dht"),c=e("libp2p-gossipsub"),u=e("./utils/ipns.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=l(i),f=l(n),h=l(s),p=l(a),g=l(c);r.libp2pConfig=function(){return{dialer:{maxParallelDials:150,maxDialsPerPeer:4,dialTimeout:1e4},modules:{transport:[d.default,f.default],streamMuxer:[h.default],connEncryption:[o.NOISE],peerDiscovery:[],dht:p.default,pubsub:g.default},config:{peerDiscovery:{autoDial:!0,bootstrap:{enabled:!0},webRTCStar:{enabled:!0}},dht:{kBucketSize:20,enabled:!1,clientMode:!0,randomWalk:{enabled:!1},validators:{ipns:u.validator},selectors:{ipns:u.selector}},pubsub:{enabled:!0,emitSelf:!0},nat:{enabled:!1}},metrics:{enabled:!0},peerStore:{persistence:!0,threshold:1}}}},{"libp2p-websockets":"e2AFa","libp2p-webrtc-star":"jtxJ4","libp2p-mplex":"6n2fc","@chainsafe/libp2p-noise":"5JB8e","libp2p-kad-dht":"lEgzz","libp2p-gossipsub":"eSowE","./utils/ipns.js":"2X3ZY"}],e2AFa:[function(e,t,r){"use strict";const i=e("it-ws/client"),n=e("class-is"),s=e("multiaddr-to-uri"),{AbortError:o}=e("abortable-iterator"),a=e("p-defer"),c=e("debug"),u=c("libp2p:websockets");u.error=c("libp2p:websockets:error");const l=e("ipfs-utils/src/env"),d=e("./listener"),f=e("./socket-to-conn"),h=e("./filters");t.exports=n(class{constructor({upgrader:e,filter:t}){if(!e)throw new Error("An upgrader must be provided. See https://github.com/libp2p/interface-transport#upgrader.");this._upgrader=e,this._filter=t}async dial(e,t={}){u("dialing %s",e);const r=await this._connect(e,t),i=f(r,{remoteAddr:e,signal:t.signal});u("new outbound connection %s",i.remoteAddr);const n=await this._upgrader.upgradeOutbound(i);return u("outbound connection %s upgraded",i.remoteAddr),n}async _connect(e,t={}){if(t.signal&&t.signal.aborted)throw new o;const r=e.toOptions();u("dialing %s:%s",r.host,r.port);const n=a(),c=e=>{const t=`connection error: ${e.message}`;u.error(t),n.reject(e)},l=i(s(e),Object.assign({binary:!0},t));if(l.socket.on?l.socket.on("error",c):l.socket.onerror=c,!t.signal)return await Promise.race([l.connected(),n.promise]),u("connected %s",e),l;let d;const f=new Promise(((e,r)=>{if(d=()=>{r(new o),setTimeout((()=>{l.close()}))},t.signal.aborted)return d();t.signal.addEventListener("abort",d)}));try{await Promise.race([f,n.promise,l.connected()])}finally{t.signal.removeEventListener("abort",d)}return u("connected %s",e),l}createListener(e={},t){return"function"==typeof e&&(t=e,e={}),d({handler:t,upgrader:this._upgrader},e)}filter(e){return e=Array.isArray(e)?e:[e],this._filter?this._filter(e):l.isBrowser||l.isWebWorker?h.dnsWss(e):h.all(e)}},{className:"WebSockets",symbolName:"@libp2p/js-libp2p-websockets/websockets"})},{"it-ws/client":"3ilsV","class-is":"gx31A","multiaddr-to-uri":"4PPH7","abortable-iterator":"awlU8","p-defer":"5rKSv",debug:"bO5wM","ipfs-utils/src/env":"flyHr","./listener":"8AR2t","./socket-to-conn":"9P0w8","./filters":"f6X4K"}],"3ilsV":[function(e,t,r){"use strict";var i=e("./web-socket"),n=e("./duplex"),s=e("./ws-url");t.exports=function(e,t={}){const r="undefined"==typeof window?{}:window.location,o=s(e,r),a=new i(o,t.websocket),c=n(a,t);return c.remoteAddress=o,c.close=()=>new Promise(((e,t)=>{a.addEventListener("close",e),a.close()})),c.destroy=()=>{a.terminate?a.terminate():a.close()},c.socket=a,c},t.exports.connect=t.exports},{"./web-socket":"S1OKn","./duplex":"l5069","./ws-url":"kgph9"}],S1OKn:[function(e,t,r){t.exports="undefined"==typeof WebSocket?e("ws"):WebSocket},{ws:"lHksA"}],l5069:[function(e,t,r){const i=e("./source"),n=e("./sink");t.exports=(e,t)=>{(t=t||{}).binaryType?e.binaryType=t.binaryType:t.binary&&(e.binaryType="arraybuffer");const r={sink:n(e,t),source:i(e,t),connected:()=>r.source.connected()};return r}},{"./source":"2FpyK","./sink":"6GqBJ"}],"2FpyK":[function(e,t,r){const{Buffer:i}=e("buffer"),{EventIterator:n}=e("event-iterator");t.exports=e=>{const t=e.removeEventListener||e.removeListener,r=async function*(){const r=new n((({push:r,stop:i,fail:n})=>(e.addEventListener("message",r),e.addEventListener("error",n),e.addEventListener("close",i),()=>{t.call(e,"message",r),t.call(e,"error",n),t.call(e,"close",i)})),{highWaterMark:1/0});for await(const{data:e}of r)yield(s=e,s instanceof ArrayBuffer||null!=s&&null!=s.constructor&&"ArrayBuffer"===s.constructor.name&&"number"==typeof s.byteLength?i.from(e):e);var s}();let s,o=1===e.readyState;return e.addEventListener("open",(()=>{o=!0,s=null})),e.addEventListener("close",(()=>{o=!1,s=null})),e.addEventListener("error",(e=>{o||(s=e)})),r.connected=()=>new Promise(((r,i)=>{if(o)return r();if(s)return i(s);const n=r=>{t.call(e,"open",a),t.call(e,"error",c),r()},a=()=>n(r),c=e=>n((()=>i(e)));e.addEventListener("open",a),e.addEventListener("error",c)})),r}},{buffer:"etowf","event-iterator":"atALZ"}],atALZ:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const i=e("./event-iterator");r.EventIterator=i.EventIterator,r.subscribe=function(e,t,r){return new i.EventIterator((({push:r})=>(this.addEventListener(e,r,t),()=>this.removeEventListener(e,r,t))),r)},r.default=i.EventIterator},{"./event-iterator":"eQdTI"}],eQdTI:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});class i{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(e){if(this.isStopped)return;const t={value:e,done:!1};if(this.pullQueue.length){const e=this.pullQueue.shift();e&&e.resolve(t)}else this.pushQueue.push(Promise.resolve(t)),void 0!==this.highWaterMark&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn(`EventIterator queue reached ${this.pushQueue.length} items`))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(const e of this.pullQueue)e.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(e){if(!this.isStopped)if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(const t of this.pullQueue)t.reject(e);this.pullQueue.length=0}else{const t=Promise.reject(e);t.catch((()=>{})),this.pushQueue.push(t)}}remove(){Promise.resolve().then((()=>{this.removeCallback&&this.removeCallback()}))}[Symbol.asyncIterator](){return{next:e=>{const t=this.pushQueue.shift();return t?(void 0!==this.lowWaterMark&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),t):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise(((e,t)=>{this.pullQueue.push({resolve:e,reject:t})}))},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}}class n{constructor(e,{highWaterMark:t=100,lowWaterMark:r=1}={}){const n=new i;n.highWaterMark=t,n.lowWaterMark=r,n.removeCallback=e({push:e=>n.push(e),stop:()=>n.stop(),fail:e=>n.fail(e),on:(e,t)=>{n.eventHandlers[e]=t}})||(()=>{}),this[Symbol.asyncIterator]=()=>n[Symbol.asyncIterator](),Object.freeze(this)}}r.EventIterator=n,r.default=n},{}],"6GqBJ":[function(e,t,r){const i=e("./ready");t.exports=(e,t)=>((t=t||{}).closeOnEnd=!1!==t.closeOnEnd,async r=>{for await(const t of r){try{await i(e)}catch(e){if("socket closed"===e.message)break;throw e}e.send(t)}if(t.closeOnEnd&&e.readyState<=1)return new Promise(((t,r)=>{e.addEventListener("close",(e=>{if(e.wasClean||1006===e.code)t();else{const t=Object.assign(new Error("ws error"),{event:e});r(t)}})),setTimeout((()=>e.close()))}))})},{"./ready":"3cCUJ"}],"3cCUJ":[function(e,t,r){t.exports=async e=>{if(e.readyState>=2)throw new Error("socket closed");if(1!==e.readyState)return new Promise(((t,r)=>{const i=e&&(e.removeEventListener||e.removeListener);function n(){"function"==typeof i&&(i.call(e,"open",s),i.call(e,"error",o))}function s(){n(),t()}function o(e){n(),r(e)}e.addEventListener("open",s),e.addEventListener("error",o)}))}},{}],kgph9:[function(e,t,r){const{relative:i}=e("iso-url"),n={http:"ws",https:"wss"};t.exports=(e,t)=>i(e,t,n,"ws")},{"iso-url":"86VPZ"}],"8AR2t":[function(e,t,r){"use strict";t.exports=function(){throw new Error("WebSocket Servers can not be created in the browser!")}},{}],"9P0w8":[function(e,t,r){"use strict";const i=e("abortable-iterator"),{CLOSE_TIMEOUT:n}=e("./constants"),s=e("libp2p-utils/src/ip-port-to-multiaddr"),o=e("p-timeout"),a=e("debug"),c=a("libp2p:websockets:socket");c.error=a("libp2p:websockets:socket:error"),t.exports=(e,t={})=>{const r={async sink(r){t.signal&&(r=i(r,t.signal));try{await e.sink(async function*(){for await(const e of r)yield e instanceof Uint8Array?e:e.slice()}())}catch(e){"aborted"!==e.type&&c.error(e)}},source:t.signal?i(e.source,t.signal):e.source,conn:e,localAddr:t.localAddr||(e.localAddress&&e.localPort?s(e.localAddress,e.localPort):void 0),remoteAddr:t.remoteAddr||s(e.remoteAddress,e.remotePort),timeline:{open:Date.now()},async close(){const t=Date.now();try{await o(e.close(),n)}catch(i){const{host:n,port:s}=r.remoteAddr.toOptions();c("timeout closing stream to %s:%s after %dms, destroying it manually",n,s,Date.now()-t),e.destroy()}finally{r.timeline.close=Date.now()}}};return e.socket.once&&e.socket.once("close",(()=>{r.timeline.close||(r.timeline.close=Date.now())})),r}},{"abortable-iterator":"awlU8","./constants":"7O7y1","libp2p-utils/src/ip-port-to-multiaddr":"WM46A","p-timeout":"hP9Ay",debug:"bO5wM"}],"7O7y1":[function(e,t,r){"use strict";r.CODE_P2P=421,r.CODE_CIRCUIT=290,r.CODE_TCP=6,r.CODE_WS=477,r.CODE_WSS=478,r.CLOSE_TIMEOUT=2e3},{}],WM46A:[function(e,t,r){"use strict";const i=e("debug"),n=Object.assign(i("libp2p:ip-port-to-multiaddr"),{error:i("libp2p:ip-port-to-multiaddr:err")}),{Multiaddr:s}=e("multiaddr"),o=e("err-code"),{Address4:a,Address6:c}=e("ip-address"),u={ERR_INVALID_IP_PARAMETER:"ERR_INVALID_IP_PARAMETER",ERR_INVALID_PORT_PARAMETER:"ERR_INVALID_PORT_PARAMETER",ERR_INVALID_IP:"ERR_INVALID_IP"};t.exports=function(e,t){if("string"!=typeof e)throw o(new Error(`invalid ip provided: ${e}`),u.ERR_INVALID_IP_PARAMETER);if("string"==typeof t&&(t=parseInt(t)),isNaN(t))throw o(new Error(`invalid port provided: ${t}`),u.ERR_INVALID_PORT_PARAMETER);try{return new a(e),new s(`/ip4/${e}/tcp/${t}`)}catch{}try{const r=new c(e);return r.is4()?new s(`/ip4/${r.to4().correctForm()}/tcp/${t}`):new s(`/ip6/${e}/tcp/${t}`)}catch(r){const i=`invalid ip:port for creating a multiaddr: ${e}:${t}`;throw n.error(i),o(new Error(i),u.ERR_INVALID_IP)}},t.exports.Errors=u},{debug:"bO5wM",multiaddr:"8Mu1u","err-code":"chZjB","ip-address":"14vMS"}],"14vMS":[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"Address4",(()=>n.Address4)),i.export(r,"Address6",(()=>s.Address6)),i.export(r,"AddressError",(()=>o.AddressError)),i.export(r,"v6",(()=>a));var n=e("./lib/ipv4"),s=e("./lib/ipv6"),o=e("./lib/address-error");const a={helpers:e("./lib/v6/helpers")}},{"./lib/ipv4":"blUQX","./lib/ipv6":"a8cEK","./lib/address-error":"fmci6","./lib/v6/helpers":"hT0Uq","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],blUQX:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"Address4",(()=>u));var n=e("./common"),s=e("./v4/constants"),o=e("./address-error"),a=e("jsbn"),c=e("sprintf-js");class u{constructor(e){this.groups=s.GROUPS,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=n.isCorrect(s.BITS),this.isInSubnet=n.isInSubnet,this.address=e;const t=s.RE_SUBNET_STRING.exec(e);if(t){if(this.parsedSubnet=t[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,this.subnetMask<0||this.subnetMask>s.BITS)throw new o.AddressError("Invalid subnet mask.");e=e.replace(s.RE_SUBNET_STRING,"")}this.addressMinusSuffix=e,this.parsedAddress=this.parse(e)}static isValid(e){try{return new u(e),!0}catch(e){return!1}}parse(e){const t=e.split(".");if(!e.match(s.RE_ADDRESS))throw new o.AddressError("Invalid IPv4 address.");return t}correctForm(){return this.parsedAddress.map((e=>parseInt(e,10))).join(".")}static fromHex(e){const t=e.replace(/:/g,"").padStart(8,"0"),r=[];let i;for(i=0;i<8;i+=2){const e=t.slice(i,i+2);r.push(parseInt(e,16))}return new u(r.join("."))}static fromInteger(e){return u.fromHex(e.toString(16))}static fromArpa(e){const t=e.replace(/(\.in-addr\.arpa)?\.$/,"").split(".").reverse().join(".");return new u(t)}toHex(){return this.parsedAddress.map((e=>c.sprintf("%02x",parseInt(e,10)))).join(":")}toArray(){return this.parsedAddress.map((e=>parseInt(e,10)))}toGroup6(){const e=[];let t;for(t=0;tc.sprintf("%02x",parseInt(e,10)))).join(""),16)}_startAddress(){return new a.BigInteger(this.mask()+"0".repeat(s.BITS-this.subnetMask),2)}startAddress(){return u.fromBigInteger(this._startAddress())}startAddressExclusive(){const e=new a.BigInteger("1");return u.fromBigInteger(this._startAddress().add(e))}_endAddress(){return new a.BigInteger(this.mask()+"1".repeat(s.BITS-this.subnetMask),2)}endAddress(){return u.fromBigInteger(this._endAddress())}endAddressExclusive(){const e=new a.BigInteger("1");return u.fromBigInteger(this._endAddress().subtract(e))}static fromBigInteger(e){return u.fromInteger(parseInt(e.toString(),10))}mask(e){return void 0===e&&(e=this.subnetMask),this.getBitsBase2(0,e)}getBitsBase2(e,t){return this.binaryZeroPad().slice(e,t)}reverseForm(e){e||(e={});const t=this.correctForm().split(".").reverse().join(".");return e.omitSuffix?t:c.sprintf("%s.in-addr.arpa.",t)}isMulticast(){return this.isInSubnet(new u("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(s.BITS,"0")}groupForV6(){const e=this.parsedAddress;return this.address.replace(s.RE_ADDRESS,c.sprintf('%s.%s',e.slice(0,2).join("."),e.slice(2,4).join(".")))}}},{"./common":"6mE8e","./v4/constants":"7d2VV","./address-error":"fmci6",jsbn:"cmpQN","sprintf-js":"5O475","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],"6mE8e":[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");function n(e){return!(this.subnetMaskn)),i.export(r,"isCorrect",(()=>s))},{"@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],"7d2VV":[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"BITS",(()=>n)),i.export(r,"GROUPS",(()=>s)),i.export(r,"RE_ADDRESS",(()=>o)),i.export(r,"RE_SUBNET_STRING",(()=>a));const n=32,s=4,o=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g,a=/\/\d{1,2}$/},{"@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],fmci6:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"AddressError",(()=>n));class n extends Error{constructor(e,t){super(e),this.name="AddressError",null!==t&&(this.parseMessage=t)}}},{"@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],cmpQN:[function(e,t,r){(function(){var e;function i(e,t,r){null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function n(){return new i(null)}var s="undefined"!=typeof navigator;s&&"Microsoft Internet Explorer"==navigator.appName?(i.prototype.am=function(e,t,r,i,n,s){for(var o=32767&t,a=t>>15;--s>=0;){var c=32767&this[e],u=this[e++]>>15,l=a*c+u*o;n=((c=o*c+((32767&l)<<15)+r[i]+(1073741823&n))>>>30)+(l>>>15)+a*u+(n>>>30),r[i++]=1073741823&c}return n},e=30):s&&"Netscape"!=navigator.appName?(i.prototype.am=function(e,t,r,i,n,s){for(;--s>=0;){var o=t*this[e++]+r[i]+n;n=Math.floor(o/67108864),r[i++]=67108863&o}return n},e=26):(i.prototype.am=function(e,t,r,i,n,s){for(var o=16383&t,a=t>>14;--s>=0;){var c=16383&this[e],u=this[e++]>>14,l=a*c+u*o;n=((c=o*c+((16383&l)<<14)+r[i]+n)>>28)+(l>>14)+a*u,r[i++]=268435455&c}return n},e=28),i.prototype.DB=e,i.prototype.DM=(1<>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function h(e){this.m=e}function p(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function w(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function _(){}function E(e){return e}function S(e){this.r2=n(),this.q3=n(),i.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}h.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},h.prototype.revert=function(e){return e},h.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},h.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},h.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},p.prototype.convert=function(e){var t=n();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(i.ZERO)>0&&this.m.subTo(t,t),t},p.prototype.revert=function(e){var t=n();return e.copyTo(t),this.reduce(t),t},p.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,i,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},p.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},p.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},i.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},i.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0},i.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,s=!1,o=0;--n>=0;){var a=8==r?255&e[n]:l(e,n);a<0?"-"==e.charAt(n)&&(s=!0):(s=!1,0==o?this[this.t++]=a:o+r>this.DB?(this[this.t-1]|=(a&(1<>this.DB-o):this[this.t-1]|=a<=this.DB&&(o-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t},i.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s},i.prototype.drShiftTo=function(e,t){for(var r=e;r=0;--r)t[r+o+1]=this[r]>>n|a,a=(this[r]&s)<=0;--r)t[r]=0;t[o]=a,t.t=this.t+o+1,t.s=this.s,t.clamp()},i.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var i=e%this.DB,n=this.DB-i,s=(1<>i;for(var o=r+1;o>i;i>0&&(t[this.t-r-1]|=(this.s&s)<>=this.DB;if(e.t>=this.DB;i+=this.s}else{for(i+=this.s;r>=this.DB;i-=e.s}t.s=i<0?-1:0,i<-1?t[r++]=this.DV+i:i>0&&(t[r++]=i),t.t=r,t.clamp()},i.prototype.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),s=r.t;for(t.t=s+n.t;--s>=0;)t[s]=0;for(s=0;s=0;)e[r]=0;for(r=0;r=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()},i.prototype.divRemTo=function(e,t,r){var s=e.abs();if(!(s.t<=0)){var o=this.abs();if(o.t0?(s.lShiftTo(l,a),o.lShiftTo(l,r)):(s.copyTo(a),o.copyTo(r));var d=a.t,h=a[d-1];if(0!=h){var p=h*(1<1?a[d-2]>>this.F2:0),g=this.FV/p,y=(1<=0&&(r[r.t++]=1,r.subTo(w,r)),i.ONE.dlShiftTo(d,w),w.subTo(a,a);a.t=0;){var _=r[--b]==h?this.DM:Math.floor(r[b]*g+(r[b-1]+m)*y);if((r[b]+=a.am(0,_,r,v,0,d))<_)for(a.dlShiftTo(v,w),r.subTo(w,r);r[b]<--_;)r.subTo(w,r)}null!=t&&(r.drShiftTo(d,t),c!=u&&i.ZERO.subTo(t,t)),r.t=d,r.clamp(),l>0&&r.rShiftTo(l,r),c<0&&i.ZERO.subTo(r,r)}}},i.prototype.invDigit=function(){if(this.t<1)return 0;var e=this[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},i.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},i.prototype.exp=function(e,t){if(e>4294967295||e<1)return i.ONE;var r=n(),s=n(),o=t.convert(this),a=f(e)-1;for(o.copyTo(r);--a>=0;)if(t.sqrTo(r,s),(e&1<0)t.mulTo(s,o,r);else{var c=r;r=s,s=c}return t.revert(r)},i.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,i=(1<0)for(a>a)>0&&(n=!0,s=u(r));o>=0;)a>(a+=this.DB-t)):(r=this[o]>>(a-=t)&i,a<=0&&(a+=this.DB,--o)),r>0&&(n=!0),n&&(s+=u(r));return n?s:"0"},i.prototype.negate=function(){var e=n();return i.ZERO.subTo(this,e),e},i.prototype.abs=function(){return this.s<0?this.negate():this},i.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0},i.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+f(this[this.t-1]^this.s&this.DM)},i.prototype.mod=function(e){var t=n();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(i.ZERO)>0&&e.subTo(t,t),t},i.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new h(t):new p(t),this.exp(e,r)},i.ZERO=d(0),i.ONE=d(1),_.prototype.convert=E,_.prototype.revert=E,_.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},_.prototype.sqrTo=function(e,t){e.squareTo(t)},S.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=n();return e.copyTo(t),this.reduce(t),t},S.prototype.revert=function(e){return e},S.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},S.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},S.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var T,A,k,I=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],R=67108864/I[I.length-1];function P(){var e;e=(new Date).getTime(),A[k++]^=255&e,A[k++]^=e>>8&255,A[k++]^=e>>16&255,A[k++]^=e>>24&255,k>=B&&(k-=B)}if(i.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},i.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),i=d(r),s=n(),o=n(),a="";for(this.divRemTo(i,s,o);s.signum()>0;)a=(r+o.intValue()).toString(e).substr(1)+a,s.divRemTo(i,s,o);return o.intValue().toString(e)+a},i.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),s=!1,o=0,a=0,c=0;c=r&&(this.dMultiply(n),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(t,o)),this.dAddOffset(a,0)),s&&i.ZERO.subTo(this,this)},i.prototype.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(i.ONE.shiftLeft(e-1),y,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(i.ONE.shiftLeft(e-1),this);else{var n=new Array,s=7&e;n.length=1+(e>>3),t.nextBytes(n),s>0?n[0]&=(1<>=this.DB;if(e.t>=this.DB;i+=this.s}else{for(i+=this.s;r>=this.DB;i+=e.s}t.s=i<0?-1:0,i>0?t[r++]=i:i<-1&&(t[r++]=this.DV+i),t.t=r,t.clamp()},i.prototype.dMultiply=function(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},i.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},i.prototype.multiplyLowerTo=function(e,t,r){var i,n=Math.min(this.t+e.t,t);for(r.s=0,r.t=n;n>0;)r[--n]=0;for(i=r.t-this.t;n=0;)r[i]=0;for(i=Math.max(t-this.t,0);i0)if(0==t)r=this[0]%e;else for(var i=this.t-1;i>=0;--i)r=(t*r+this[i])%e;return r},i.prototype.millerRabin=function(e){var t=this.subtract(i.ONE),r=t.getLowestSetBit();if(r<=0)return!1;var s=t.shiftRight(r);(e=e+1>>1)>I.length&&(e=I.length);for(var o=n(),a=0;a>24},i.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},i.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},i.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,i=this.DB-e*this.DB%8,n=0;if(e-- >0)for(i>i)!=(this.s&this.DM)>>i&&(t[n++]=r|this.s<=0;)i<8?(r=(this[e]&(1<>(i+=this.DB-8)):(r=this[e]>>(i-=8)&255,i<=0&&(i+=this.DB,--e)),0!=(128&r)&&(r|=-256),0==n&&(128&this.s)!=(128&r)&&++n,(n>0||r!=this.s)&&(t[n++]=r);return t},i.prototype.equals=function(e){return 0==this.compareTo(e)},i.prototype.min=function(e){return this.compareTo(e)<0?this:e},i.prototype.max=function(e){return this.compareTo(e)>0?this:e},i.prototype.and=function(e){var t=n();return this.bitwiseTo(e,g,t),t},i.prototype.or=function(e){var t=n();return this.bitwiseTo(e,y,t),t},i.prototype.xor=function(e){var t=n();return this.bitwiseTo(e,m,t),t},i.prototype.andNot=function(e){var t=n();return this.bitwiseTo(e,b,t),t},i.prototype.not=function(){for(var e=n(),t=0;t=this.t?0!=this.s:0!=(this[t]&1<1){var g=n();for(i.sqrTo(a[1],g);c<=l;)a[c]=n(),i.mulTo(g,a[c-2],a[c]),c+=2}var y,m,b=e.t-1,v=!0,w=n();for(s=f(e[b])-1;b>=0;){for(s>=u?y=e[b]>>s-u&l:(y=(e[b]&(1<0&&(y|=e[b-1]>>this.DB+s-u)),c=r;0==(1&y);)y>>=1,--c;if((s-=c)<0&&(s+=this.DB,--b),v)a[y].copyTo(o),v=!1;else{for(;c>1;)i.sqrTo(o,w),i.sqrTo(w,o),c-=2;c>0?i.sqrTo(o,w):(m=o,o=w,w=m),i.mulTo(w,a[y],o)}for(;b>=0&&0==(e[b]&1<=0?(r.subTo(n,r),t&&s.subTo(a,s),o.subTo(c,o)):(n.subTo(r,n),t&&a.subTo(s,a),c.subTo(o,c))}return 0!=n.compareTo(i.ONE)?i.ZERO:c.compareTo(e)>=0?c.subtract(e):c.signum()<0?(c.addTo(e,c),c.signum()<0?c.add(e):c):c},i.prototype.pow=function(e){return this.exp(e,new _)},i.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var i=t;t=r,r=i}var n=t.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return t;for(n0&&(t.rShiftTo(s,t),r.rShiftTo(s,r));t.signum()>0;)(n=t.getLowestSetBit())>0&&t.rShiftTo(n,t),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},i.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r[0]<=I[I.length-1]){for(t=0;t>>8,A[k++]=255&O;k=0,P()}function D(){if(null==T){for(P(),(T=new x).init(A),k=0;k=0),a.type){case"b":n=parseInt(n,10).toString(2);break;case"c":n=String.fromCharCode(parseInt(n,10));break;case"d":case"i":n=parseInt(n,10);break;case"j":n=JSON.stringify(n,null,a.width?parseInt(a.width):0);break;case"e":n=a.precision?parseFloat(n).toExponential(a.precision):parseFloat(n).toExponential();break;case"f":n=a.precision?parseFloat(n).toFixed(a.precision):parseFloat(n);break;case"g":n=a.precision?String(Number(n.toPrecision(a.precision))):parseFloat(n);break;case"o":n=(parseInt(n,10)>>>0).toString(8);break;case"s":n=String(n),n=a.precision?n.substring(0,a.precision):n;break;case"t":n=String(!!n),n=a.precision?n.substring(0,a.precision):n;break;case"T":n=Object.prototype.toString.call(n).slice(8,-1).toLowerCase(),n=a.precision?n.substring(0,a.precision):n;break;case"u":n=parseInt(n,10)>>>0;break;case"v":n=n.valueOf(),n=a.precision?n.substring(0,a.precision):n;break;case"x":n=(parseInt(n,10)>>>0).toString(16);break;case"X":n=(parseInt(n,10)>>>0).toString(16).toUpperCase()}e.json.test(a.type)?g+=n:(!e.number.test(a.type)||d&&!a.sign?f="":(f=d?"+":"-",n=n.toString().replace(e.sign,"")),u=a.pad_char?"0"===a.pad_char?"0":a.pad_char.charAt(1):" ",l=a.width-(f+n).length,c=a.width&&l>0?u.repeat(l):"",g+=a.align?f+n+c:"0"===u?f+c+n:c+f+n)}return g}var s=Object.create(null);function o(t){if(s[t])return s[t];for(var r,i=t,n=[],o=0;i;){if(null!==(r=e.text.exec(i)))n.push(r[0]);else if(null!==(r=e.modulo.exec(i)))n.push("%");else{if(null===(r=e.placeholder.exec(i)))throw new SyntaxError("[sprintf] unexpected placeholder");if(r[2]){o|=1;var a=[],c=r[2],u=[];if(null===(u=e.key.exec(c)))throw new SyntaxError("[sprintf] failed to parse named argument key");for(a.push(u[1]);""!==(c=c.substring(u[0].length));)if(null!==(u=e.key_access.exec(c)))a.push(u[1]);else{if(null===(u=e.index_access.exec(c)))throw new SyntaxError("[sprintf] failed to parse named argument key");a.push(u[1])}r[2]=a}else o|=2;if(3===o)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");n.push({placeholder:r[0],param_no:r[1],keys:r[2],sign:r[3],pad_char:r[4],align:r[5],width:r[6],precision:r[7],type:r[8]})}i=i.substring(r[0].length)}return s[t]=n}void 0!==r&&(r.sprintf=t,r.vsprintf=i),"undefined"!=typeof window&&(window.sprintf=t,window.vsprintf=i,"function"==typeof define&&define.amd&&define((function(){return{sprintf:t,vsprintf:i}})))}()},{}],a8cEK:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"Address6",(()=>m));var n=e("./common"),s=e("./v4/constants"),o=e("./v6/constants"),a=e("./v6/helpers"),c=e("./ipv4"),u=e("./v6/regular-expressions"),l=e("./address-error"),d=e("jsbn"),f=e("sprintf-js");function h(e){if(!e)throw new Error("Assertion failed.")}function p(e){return e=(e=e.replace(/^(0{1,})([1-9]+)$/,'$1$2')).replace(/^(0{1,})(0)$/,'$1$2')}function g(e){return f.sprintf("%04x",parseInt(e,16))}function y(e){return 255&e}class m{constructor(e,t){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=n.isInSubnet,this.isCorrect=n.isCorrect(o.BITS),this.groups=void 0===t?o.GROUPS:t,this.address=e;const r=o.RE_SUBNET_STRING.exec(e);if(r){if(this.parsedSubnet=r[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,Number.isNaN(this.subnetMask)||this.subnetMask<0||this.subnetMask>o.BITS)throw new l.AddressError("Invalid subnet mask.");e=e.replace(o.RE_SUBNET_STRING,"")}else if(/\//.test(e))throw new l.AddressError("Invalid subnet mask.");const i=o.RE_ZONE_STRING.exec(e);i&&(this.zone=i[0],e=e.replace(o.RE_ZONE_STRING,"")),this.addressMinusSuffix=e,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(e){try{return new m(e),!0}catch(e){return!1}}static fromBigInteger(e){const t=e.toString(16).padStart(32,"0"),r=[];let i;for(i=0;i65536)&&(i=null)):i=null,{address:new m(t),port:i}}static fromAddress4(e){const t=new c.Address4(e),r=o.BITS-(s.BITS-t.subnetMask);return new m(`::ffff:${t.correctForm()}/${r}`)}static fromArpa(e){let t=e.replace(/(\.ip6\.arpa)?\.$/,"");if(63!==t.length)throw new l.AddressError("Invalid 'ip6.arpa' form.");const r=t.split(".").reverse();for(let e=7;e>0;e--){const t=4*e;r.splice(t,0,":")}return t=r.join(""),new m(t)}microsoftTranscription(){return f.sprintf("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))}mask(e=this.subnetMask){return this.getBitsBase2(0,e)}possibleSubnets(e=128){const t=o.BITS-this.subnetMask-Math.abs(e-o.BITS);return t<0?"0":function(e){const t=/(\d+)(\d{3})/;for(;t.test(e);)e=e.replace(t,"$1,$2");return e}(new d.BigInteger("2",10).pow(t).toString(10))}_startAddress(){return new d.BigInteger(this.mask()+"0".repeat(o.BITS-this.subnetMask),2)}startAddress(){return m.fromBigInteger(this._startAddress())}startAddressExclusive(){const e=new d.BigInteger("1");return m.fromBigInteger(this._startAddress().add(e))}_endAddress(){return new d.BigInteger(this.mask()+"1".repeat(o.BITS-this.subnetMask),2)}endAddress(){return m.fromBigInteger(this._endAddress())}endAddressExclusive(){const e=new d.BigInteger("1");return m.fromBigInteger(this._endAddress().subtract(e))}getScope(){let e=o.SCOPES[this.getBits(12,16).intValue()];return"Global unicast"===this.getType()&&"Link local"!==e&&(e="Global"),e||"Unknown"}getType(){for(const e of Object.keys(o.TYPES))if(this.isInSubnet(new m(e)))return o.TYPES[e];return"Global unicast"}getBits(e,t){return new d.BigInteger(this.getBitsBase2(e,t),2)}getBitsBase2(e,t){return this.binaryZeroPad().slice(e,t)}getBitsBase16(e,t){const r=t-e;if(r%4!=0)throw new Error("Length of bits to retrieve must be divisible by four");return this.getBits(e,t).toString(16).padStart(r/4,"0")}getBitsPastSubnet(){return this.getBitsBase2(this.subnetMask,o.BITS)}reverseForm(e){e||(e={});const t=Math.floor(this.subnetMask/4),r=this.canonicalForm().replace(/:/g,"").split("").slice(0,t).reverse().join(".");return t>0?e.omitSuffix?r:f.sprintf("%s.ip6.arpa.",r):e.omitSuffix?"":"ip6.arpa."}correctForm(){let e,t=[],r=0;const i=[];for(e=0;e0&&(r>1&&i.push([e-r,e-1]),r=0)}r>1&&i.push([this.parsedAddress.length-r,this.parsedAddress.length-1]);const n=i.map((e=>e[1]-e[0]+1));if(i.length>0){const e=n.indexOf(Math.max(...n));t=function(e,t){const r=[],i=[];let n;for(n=0;nt[1]&&i.push(e[n]);return r.concat(["compact"]).concat(i)}(this.parsedAddress,i[e])}else t=this.parsedAddress;for(e=0;e1?"s":"",t.join("")),e.replace(o.RE_BAD_CHARACTERS,'$1'));const r=e.match(o.RE_BAD_ADDRESS);if(r)throw new l.AddressError(f.sprintf("Address failed regex: %s",r.join("")),e.replace(o.RE_BAD_ADDRESS,'$1'));let i=[];const n=e.split("::");if(2===n.length){let e=n[0].split(":"),t=n[1].split(":");1===e.length&&""===e[0]&&(e=[]),1===t.length&&""===t[0]&&(t=[]);const r=this.groups-(e.length+t.length);if(!r)throw new l.AddressError("Error parsing groups");this.elidedGroups=r,this.elisionBegin=e.length,this.elisionEnd=e.length+this.elidedGroups,i=i.concat(e);for(let e=0;ef.sprintf("%x",parseInt(e,16)))),i.length!==this.groups)throw new l.AddressError("Incorrect number of groups found");return i}canonicalForm(){return this.parsedAddress.map(g).join(":")}decimal(){return this.parsedAddress.map((e=>f.sprintf("%05d",parseInt(e,16)))).join(":")}bigInteger(){return new d.BigInteger(this.parsedAddress.map(g).join(""),16)}to4(){const e=this.binaryZeroPad().split("");return c.Address4.fromHex(new d.BigInteger(e.slice(96,128).join(""),2).toString(16))}to4in6(){const e=this.to4(),t=new m(this.parsedAddress.slice(0,6).join(":"),6).correctForm();let r="";return/:$/.test(t)||(r=":"),t+r+e.address}inspectTeredo(){const e=this.getBitsBase16(0,32),t=this.getBits(80,96).xor(new d.BigInteger("ffff",16)).toString(),r=c.Address4.fromHex(this.getBitsBase16(32,64)),i=c.Address4.fromHex(this.getBits(96,128).xor(new d.BigInteger("ffffffff",16)).toString(16)),n=this.getBits(64,80),s=this.getBitsBase2(64,80),o=n.testBit(15),a=n.testBit(14),u=n.testBit(8),l=n.testBit(9),h=new d.BigInteger(s.slice(2,6)+s.slice(8,16),2).toString(10);return{prefix:f.sprintf("%s:%s",e.slice(0,4),e.slice(4,8)),server4:r.address,client4:i.address,flags:s,coneNat:o,microsoft:{reserved:a,universalLocal:l,groupIndividual:u,nonce:h},udpPort:t}}inspect6to4(){const e=this.getBitsBase16(0,16),t=c.Address4.fromHex(this.getBitsBase16(16,48));return{prefix:f.sprintf("%s",e.slice(0,4)),gateway:t.address}}to6to4(){if(!this.is4())return null;const e=["2002",this.getBitsBase16(96,112),this.getBitsBase16(112,128),"","/16"].join(":");return new m(e)}toByteArray(){const e=this.bigInteger().toByteArray();return 17===e.length&&0===e[0]?e.slice(1):e}toUnsignedByteArray(){return this.toByteArray().map(y)}static fromByteArray(e){return this.fromUnsignedByteArray(e.map(y))}static fromUnsignedByteArray(e){const t=new d.BigInteger("256",10);let r=new d.BigInteger("0",10),i=new d.BigInteger("1",10);for(let n=e.length-1;n>=0;n--)r=r.add(i.multiply(new d.BigInteger(e[n].toString(10),10))),i=i.multiply(t);return m.fromBigInteger(r)}isCanonical(){return this.addressMinusSuffix===this.canonicalForm()}isLinkLocal(){return"1111111010000000000000000000000000000000000000000000000000000000"===this.getBitsBase2(0,64)}isMulticast(){return"Multicast"===this.getType()}is4(){return this.v4}isTeredo(){return this.isInSubnet(new m("2001::/32"))}is6to4(){return this.isInSubnet(new m("2002::/16"))}isLoopback(){return"Loopback"===this.getType()}href(e){return e=void 0===e?"":f.sprintf(":%s",e),f.sprintf("http://[%s]%s/",this.correctForm(),e)}link(e){e||(e={}),void 0===e.className&&(e.className=""),void 0===e.prefix&&(e.prefix="/#address="),void 0===e.v4&&(e.v4=!1);let t=this.correctForm;return e.v4&&(t=this.to4in6),e.className?f.sprintf('%2$s',e.prefix,t.call(this),e.className):f.sprintf('%2$s',e.prefix,t.call(this))}group(){if(0===this.elidedGroups)return a.simpleGroup(this.address).join(":");h("number"==typeof this.elidedGroups),h("number"==typeof this.elisionBegin);const e=[],[t,r]=this.address.split("::");t.length?e.push(...a.simpleGroup(t)):e.push("");const i=["hover-group"];for(let e=this.elisionBegin;e',i.join(" "))),r.length?e.push(...a.simpleGroup(r,this.elisionEnd)):e.push(""),this.is4()&&(h(this.address4 instanceof c.Address4),e.pop(),e.push(this.address4.groupForV6())),e.join(":")}regularExpressionString(e=!1){let t=[];const r=new m(this.correctForm());if(0===r.elidedGroups)t.push(u.simpleRegularExpression(r.parsedAddress));else if(r.elidedGroups===o.GROUPS)t.push(u.possibleElisions(o.GROUPS));else{const e=r.address.split("::");e[0].length&&t.push(u.simpleRegularExpression(e[0].split(":"))),h("number"==typeof r.elidedGroups),t.push(u.possibleElisions(r.elidedGroups,0!==e[0].length,0!==e[1].length)),e[1].length&&t.push(u.simpleRegularExpression(e[1].split(":"))),t=[t.join(":")]}return e||(t=["(?=^|",u.ADDRESS_BOUNDARY,"|[^\\w\\:])(",...t,")(?=[^\\w\\:]|",u.ADDRESS_BOUNDARY,"|$)"]),t.join("")}regularExpression(e=!1){return new RegExp(this.regularExpressionString(e),"i")}}},{"./common":"6mE8e","./v4/constants":"7d2VV","./v6/constants":"5lfrn","./v6/helpers":"hT0Uq","./ipv4":"blUQX","./v6/regular-expressions":"cbb6J","./address-error":"fmci6",jsbn:"cmpQN","sprintf-js":"5O475","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],"5lfrn":[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"BITS",(()=>n)),i.export(r,"GROUPS",(()=>s)),i.export(r,"SCOPES",(()=>o)),i.export(r,"TYPES",(()=>a)),i.export(r,"RE_BAD_CHARACTERS",(()=>c)),i.export(r,"RE_BAD_ADDRESS",(()=>u)),i.export(r,"RE_SUBNET_STRING",(()=>l)),i.export(r,"RE_ZONE_STRING",(()=>d)),i.export(r,"RE_URL",(()=>f)),i.export(r,"RE_URL_WITH_PORT",(()=>h));const n=128,s=8,o={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"},a={"ff01::1/128":"Multicast (All nodes on this interface)","ff01::2/128":"Multicast (All routers on this interface)","ff02::1/128":"Multicast (All nodes on this link)","ff02::2/128":"Multicast (All routers on this link)","ff05::2/128":"Multicast (All routers in this site)","ff02::5/128":"Multicast (OSPFv3 AllSPF routers)","ff02::6/128":"Multicast (OSPFv3 AllDR routers)","ff02::9/128":"Multicast (RIP routers)","ff02::a/128":"Multicast (EIGRP routers)","ff02::d/128":"Multicast (PIM routers)","ff02::16/128":"Multicast (MLDv2 reports)","ff01::fb/128":"Multicast (mDNSv6)","ff02::fb/128":"Multicast (mDNSv6)","ff05::fb/128":"Multicast (mDNSv6)","ff02::1:2/128":"Multicast (All DHCP servers and relay agents on this link)","ff05::1:2/128":"Multicast (All DHCP servers and relay agents in this site)","ff02::1:3/128":"Multicast (All DHCP servers on this link)","ff05::1:3/128":"Multicast (All DHCP servers in this site)","::/128":"Unspecified","::1/128":"Loopback","ff00::/8":"Multicast","fe80::/10":"Link-local unicast"},c=/([^0-9a-f:/%])/gi,u=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,l=/\/\d{1,3}(?=%|$)/,d=/%.*$/,f=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/),h=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/)},{"@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],hT0Uq:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"spanAllZeroes",(()=>s)),i.export(r,"spanAll",(()=>o)),i.export(r,"spanLeadingZeroes",(()=>c)),i.export(r,"simpleGroup",(()=>u));var n=e("sprintf-js");function s(e){return e.replace(/(0+)/g,'$1')}function o(e,t=0){return e.split("").map(((e,r)=>n.sprintf('%s',e,r+t,s(e)))).join("")}function a(e){return e.replace(/^(0+)/,'$1')}function c(e){return e.split(":").map((e=>a(e))).join(":")}function u(e,t=0){return e.split(":").map(((e,r)=>/group-v4/.test(e)?e:n.sprintf('%s',r+t,a(e))))}},{"sprintf-js":"5O475","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],cbb6J:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"groupPossibilities",(()=>o)),i.export(r,"padGroup",(()=>a)),i.export(r,"ADDRESS_BOUNDARY",(()=>c)),i.export(r,"simpleRegularExpression",(()=>u)),i.export(r,"possibleElisions",(()=>l));var n=e("./constants"),s=e("sprintf-js");function o(e){return s.sprintf("(%s)",e.join("|"))}function a(e){return e.length<4?s.sprintf("0{0,%d}%s",4-e.length,e):e}const c="[^A-Fa-f0-9:]";function u(e){const t=[];e.forEach(((e,r)=>{0===parseInt(e,16)&&t.push(r)}));const r=t.map((t=>e.map(((e,r)=>{if(r===t){const t=0===r||r===n.GROUPS-1?":":"";return o([a(e),t])}return a(e)})).join(":")));return r.push(e.map(a).join(":")),o(r)}function l(e,t,r){const i=t?"":":",n=r?"":":",a=[];t||r||a.push("::"),t&&r&&a.push(""),(r&&!t||!r&&t)&&a.push(":"),a.push(s.sprintf("%s(:0{1,4}){1,%d}",i,e-1)),a.push(s.sprintf("(0{1,4}:){1,%d}%s",e-1,n)),a.push(s.sprintf("(0{1,4}:){%d}0{1,4}",e-1));for(let t=1;t{let s;const o=new Promise(((o,a)=>{if("number"!=typeof t||t<0)throw new TypeError("Expected `milliseconds` to be a positive number");t!==1/0?(n={customTimers:{setTimeout:setTimeout,clearTimeout:clearTimeout},...n},s=n.customTimers.setTimeout.call(void 0,(()=>{if("function"==typeof r){try{o(r())}catch(e){a(e)}return}const n=r instanceof Error?r:new i("string"==typeof r?r:`Promise timed out after ${t} milliseconds`);"function"==typeof e.cancel&&e.cancel(),a(n)}),t),(async()=>{try{o(await e)}catch(e){a(e)}finally{n.customTimers.clearTimeout.call(void 0,s)}})()):o(e)}));return o.clear=()=>{clearTimeout(s),s=void 0},o};t.exports=n,t.exports.default=n,t.exports.TimeoutError=i},{}],f6X4K:[function(e,t,r){"use strict";const i=e("mafmt"),{CODE_CIRCUIT:n,CODE_P2P:s,CODE_TCP:o,CODE_WS:a,CODE_WSS:c}=e("./constants");t.exports={all:e=>e.filter((e=>{if(e.protoCodes().includes(n))return!1;const t=e.decapsulateCode(s);return i.WebSockets.matches(t)||i.WebSocketsSecure.matches(t)})),dnsWss:e=>e.filter((e=>{if(e.protoCodes().includes(n))return!1;const t=e.decapsulateCode(s);return i.WebSocketsSecure.matches(t)&&i.DNS.matches(t.decapsulateCode(o).decapsulateCode(c))})),dnsWsOrWss:e=>e.filter((e=>{if(e.protoCodes().includes(n))return!1;const t=e.decapsulateCode(s);return i.WebSockets.matches(t)?i.DNS.matches(t.decapsulateCode(o).decapsulateCode(a)):i.WebSocketsSecure.matches(t)&&i.DNS.matches(t.decapsulateCode(o).decapsulateCode(c))}))}},{mafmt:"l1lok","./constants":"7O7y1"}],jtxJ4:[function(e,t,r){"use strict";const i=e("debug"),n=i("libp2p:webrtc-star");n.error=i("libp2p:webrtc-star:error");const{EventEmitter:s}=e("events"),o=e("err-code"),a=e("class-is"),{AbortError:c}=e("abortable-iterator"),u=e("libp2p-webrtc-peer"),{supportsWebRTCDataChannels:l}=e("ipfs-utils/src/supports"),{Multiaddr:d}=e("multiaddr"),f=e("mafmt"),h=e("peer-id"),{CODE_CIRCUIT:p}=e("./constants"),g=e("./listener"),y=e("./socket-to-conn"),{cleanMultiaddr:m,cleanUrlSIO:b}=e("./utils");function v(){}t.exports=a(class{constructor(e={}){if(!e.upgrader)throw new Error("An upgrader must be provided. See https://github.com/libp2p/interface-transport#upgrader.");this._upgrader=e.upgrader,this.sioOptions={transports:["websocket"],"force new connection":!0},e.wrtc&&(this.wrtc=e.wrtc),this.sigReferences=new Map,this.discovery=new s,this.discovery.tag="webRTCStar",this.discovery._isStarted=!1,this.discovery.start=()=>{this.discovery._isStarted=!0},this.discovery.stop=()=>{this.discovery._isStarted=!1},this._peerDiscovered=this._peerDiscovered.bind(this)}async dial(e,t={}){const r=await this._connect(e,t),i=y(r,{remoteAddr:e,signal:t.signal});n("new outbound connection %s",i.remoteAddr);const s=await this._upgrader.upgradeOutbound(i);return n("outbound connection %s upgraded",i.remoteAddr),s}_connect(e,t={}){if(t.signal&&t.signal.aborted)throw new c;const r={initiator:!0,trickle:!1,...t.spOptions||{}};this.wrtc&&(r.wrtc=this.wrtc);const i=e.toOptions(),s=(~~(1e9*Math.random())).toString(36)+Date.now();return new Promise(((a,l)=>{const d=this.sigReferences.get(b(e));if(!d||!d.listener)return l(o(new Error("unknown signal server to use"),"ERR_UNKNOWN_SIGNAL_SERVER"));const f=d.listener.io,h=Date.now();let p;n("dialing %s:%s",i.host,i.port);const g=new u(r),y=e=>{if(!p){const t=`connection error ${i.host}:${i.port}: ${e.message}`;n.error(t),_(e)}},m=()=>{n("connnection timeout %s:%s",i.host,i.port);const e=o(new Error(`connection timeout after ${Date.now()-h}ms`),"ERR_CONNECT_TIMEOUT");g.emit("error",e)},v=()=>{p=!0,n("connection opened %s:%s",i.host,i.port),_(null)},w=()=>{n.error("connection aborted %s:%s",i.host,i.port),g.destroy(),_(new c)},_=e=>{g.removeListener("timeout",m),g.removeListener("connect",v),t.signal&&t.signal.removeEventListener("abort",w),e?l(e):a(g)};g.on("error",y),g.once("timeout",m),g.once("connect",v),g.on("close",(()=>{g.removeListener("error",y)})),t.signal&&t.signal.addEventListener("abort",w),g.on("signal",(t=>{f.emit("ss-handshake",{intentId:s,srcMultiaddr:d.signallingAddr.toString(),dstMultiaddr:e.toString(),signal:t})})),f.on("ws-handshake",(e=>{e.intentId===s&&e.err&&(g.destroy(),l(o(e.err instanceof Error?e.err:new Error(e.err),"ERR_SIGNALLING_FAILED"))),e.intentId===s&&e.answer&&!g.destroyed&&g.signal(e.signal)}))}))}createListener(e={},t){if(!l&&!this.wrtc)throw o(new Error("no WebRTC support"),"ERR_NO_WEBRTC_SUPPORT");return"function"==typeof e&&(t=e,e={}),g({handler:t=t||v,upgrader:this._upgrader},this,e)}filter(e){return(e=Array.isArray(e)?e:[e]).filter((e=>!e.protoCodes().includes(p)&&f.WebRTCStar.matches(e)))}_peerDiscovered(e){if(!this.discovery._isStarted)return;n("Peer Discovered:",e),e=m(e);const t=new d(e),r=h.createFromB58String(t.getPeerId());this.discovery.emit("peer",{id:r,multiaddrs:[t]})}},{className:"WebRTCStar",symbolName:"@libp2p/js-libp2p-webrtc-star/webrtcstar"})},{debug:"bO5wM",events:"g82pp","err-code":"chZjB","class-is":"gx31A","abortable-iterator":"awlU8","libp2p-webrtc-peer":"kt3eh","ipfs-utils/src/supports":"3yyjP",multiaddr:"8Mu1u",mafmt:"l1lok","peer-id":"8Bdb3","./constants":"1IQXV","./listener":"bN3Nc","./socket-to-conn":"heHOu","./utils":"kfyaq"}],kt3eh:[function(e,t,r){ /*! simple-peer. MIT License. Feross Aboukhadijeh */var i=e("debug")("simple-peer"),n=e("get-browser-rtc"),s=e("randombytes"),o=e("readable-stream"),a=e("queue-microtask"),c=e("err-code"),u=65536;function l(e){return e.replace(/a=ice-options:trickle\s\n/g,"")}class d extends o.Duplex{constructor(e){if(super(e=Object.assign({allowHalfOpen:!1},e)),this._id=s(4).toString("hex").slice(0,7),this._debug("new peer %o",e),this.channelName=e.initiator?e.channelName||s(20).toString("hex"):null,this.initiator=e.initiator||!1,this.channelConfig=e.channelConfig||d.channelConfig,this.negotiated=this.channelConfig.negotiated,this.config=Object.assign({},d.config,e.config),this.offerOptions=e.offerOptions||{},this.answerOptions=e.answerOptions||{},this.sdpTransform=e.sdpTransform||(e=>e),this.streams=e.streams||(e.stream?[e.stream]:[]),this.trickle=void 0===e.trickle||e.trickle,this.allowHalfTrickle=void 0!==e.allowHalfTrickle&&e.allowHalfTrickle,this.iceCompleteTimeout=e.iceCompleteTimeout||5e3,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=e.wrtc&&"object"==typeof e.wrtc?e.wrtc:n(),!this._wrtc)throw"undefined"==typeof window?c(new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"),"ERR_WEBRTC_SUPPORT"):c(new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!this.negotiated&&!this.initiator,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._firstStable=!0,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(e){return void a((()=>this.destroy(c(e,"ERR_PC_CONSTRUCTOR"))))}this._isReactNativeWebrtc="number"==typeof this._pc._peerConnectionId,this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=e=>{this._onIceCandidate(e)},this.initiator||this.negotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=e=>{this._setupData(e)},this.streams&&this.streams.forEach((e=>{this.addStream(e)})),this._pc.ontrack=e=>{this._onTrack(e)},this.initiator&&this._needsNegotiation(),this._onFinishBound=()=>{this._onFinish()},this.once("finish",this._onFinishBound)}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&"open"===this._channel.readyState}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(e){if(this.destroyed)throw c(new Error("cannot signal after peer is destroyed"),"ERR_SIGNALING");if("string"==typeof e)try{e=JSON.parse(e)}catch(t){e={}}this._debug("signal()"),e.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),e.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(e.transceiverRequest.kind,e.transceiverRequest.init)),e.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(e.candidate):this._pendingCandidates.push(e.candidate)),e.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(e)).then((()=>{this.destroyed||(this._pendingCandidates.forEach((e=>{this._addIceCandidate(e)})),this._pendingCandidates=[],"offer"===this._pc.remoteDescription.type&&this._createAnswer())})).catch((e=>{this.destroy(c(e,"ERR_SET_REMOTE_DESCRIPTION"))})),e.sdp||e.candidate||e.renegotiate||e.transceiverRequest||this.destroy(c(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}_addIceCandidate(e){var t=new this._wrtc.RTCIceCandidate(e);this._pc.addIceCandidate(t).catch((e=>{var r;!t.address||t.address.endsWith(".local")?(r="Ignoring unsupported ICE candidate.",console.warn(r)):this.destroy(c(e,"ERR_ADD_ICE_CANDIDATE"))}))}send(e){this._channel.send(e)}addTransceiver(e,t){if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(e,t),this._needsNegotiation()}catch(e){this.destroy(c(e,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{transceiverRequest:{kind:e,init:t}})}addStream(e){this._debug("addStream()"),e.getTracks().forEach((t=>{this.addTrack(t,e)}))}addTrack(e,t){this._debug("addTrack()");var r=this._senderMap.get(e)||new Map,i=r.get(t);if(i)throw i.removed?c(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):c(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED");i=this._pc.addTrack(e,t),r.set(t,i),this._senderMap.set(e,r),this._needsNegotiation()}replaceTrack(e,t,r){this._debug("replaceTrack()");var i=this._senderMap.get(e),n=i?i.get(r):null;if(!n)throw c(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");t&&this._senderMap.set(t,i),null!=n.replaceTrack?n.replaceTrack(t):this.destroy(c(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK"))}removeTrack(e,t){this._debug("removeSender()");var r=this._senderMap.get(e),i=r?r.get(t):null;if(!i)throw c(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{i.removed=!0,this._pc.removeTrack(i)}catch(e){"NS_ERROR_UNEXPECTED"===e.name?this._sendersAwaitingStable.push(i):this.destroy(c(e,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(e){this._debug("removeSenders()"),e.getTracks().forEach((t=>{this.removeTrack(t,e)}))}_needsNegotiation(){this._debug("_needsNegotiation"),this._batchedNegotiation||(this._batchedNegotiation=!0,a((()=>{this._batchedNegotiation=!1,this._debug("starting batched negotiation"),this.negotiate()})))}negotiate(){this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout((()=>{this._createOffer()}),0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{renegotiate:!0})),this._isNegotiating=!0}_destroy(e,t){if(this._debug("destroy (error: %s)",e&&(e.message||e)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch(e){}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch(e){}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,t(e)}_setupData(e){if(!e.channel)return this.destroy(c(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=e.channel,this._channel.binaryType="arraybuffer","number"==typeof this._channel.bufferedAmountLowThreshold&&(this._channel.bufferedAmountLowThreshold=u),this.channelName=this._channel.label,this._channel.onmessage=e=>{this._onChannelMessage(e)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=e=>{this.destroy(c(e,"ERR_DATA_CHANNEL"))};var t=!1;this._closingInterval=setInterval((()=>{this._channel&&"closing"===this._channel.readyState?(t&&this._onChannelClose(),t=!0):t=!1}),5e3)}_read(){}_write(e,t,r){if(this.destroyed)return r(c(new Error("cannot write after peer is destroyed"),"ERR_DATA_CHANNEL"));if(this._connected){try{this.send(e)}catch(e){return this.destroy(c(e,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>u?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=r):r(null)}else this._debug("write before connect"),this._chunk=e,this._cb=r}_onFinish(){if(this.destroyed)return;const e=()=>{setTimeout((()=>this.destroy()),1e3)};this._connected?e():this.once("connect",e)}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout((()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))}),this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then((e=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(e.sdp=l(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(!this.destroyed){var t=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:t.type,sdp:t.sdp})}};this._pc.setLocalDescription(e).then((()=>{this._debug("createOffer success"),this.destroyed||(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))})).catch((e=>{this.destroy(c(e,"ERR_SET_LOCAL_DESCRIPTION"))}))})).catch((e=>{this.destroy(c(e,"ERR_CREATE_OFFER"))}))}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach((e=>{e.mid||!e.sender.track||e.requested||(e.requested=!0,this.addTransceiver(e.sender.track.kind))}))}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then((e=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(e.sdp=l(e.sdp)),e.sdp=this.sdpTransform(e.sdp);const t=()=>{if(!this.destroyed){var t=this._pc.localDescription||e;this._debug("signal"),this.emit("signal",{type:t.type,sdp:t.sdp}),this.initiator||this._requestMissingTransceivers()}};this._pc.setLocalDescription(e).then((()=>{this.destroyed||(this.trickle||this._iceComplete?t():this.once("_iceComplete",t))})).catch((e=>{this.destroy(c(e,"ERR_SET_LOCAL_DESCRIPTION"))}))})).catch((e=>{this.destroy(c(e,"ERR_CREATE_ANSWER"))}))}_onConnectionStateChange(){this.destroyed||"failed"===this._pc.connectionState&&this.destroy(c(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(!this.destroyed){var e=this._pc.iceConnectionState,t=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",e,t),this.emit("iceStateChange",e,t),"connected"!==e&&"completed"!==e||(this._pcReady=!0,this._maybeReady()),"failed"===e&&this.destroy(c(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),"closed"===e&&this.destroy(c(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}}getStats(e){const t=e=>("[object Array]"===Object.prototype.toString.call(e.values)&&e.values.forEach((t=>{Object.assign(e,t)})),e);0===this._pc.getStats.length||this._isReactNativeWebrtc?this._pc.getStats().then((r=>{var i=[];r.forEach((e=>{i.push(t(e))})),e(null,i)}),(t=>e(t))):this._pc.getStats.length>0?this._pc.getStats((r=>{if(!this.destroyed){var i=[];r.result().forEach((e=>{var r={};e.names().forEach((t=>{r[t]=e.stat(t)})),r.id=e.id,r.type=e.type,r.timestamp=e.timestamp,i.push(t(r))})),e(null,i)}}),(t=>e(t))):e(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const e=()=>{this.destroyed||this.getStats(((t,r)=>{if(this.destroyed)return;t&&(r=[]);var i={},n={},s={},o=!1;r.forEach((e=>{"remotecandidate"!==e.type&&"remote-candidate"!==e.type||(i[e.id]=e),"localcandidate"!==e.type&&"local-candidate"!==e.type||(n[e.id]=e),"candidatepair"!==e.type&&"candidate-pair"!==e.type||(s[e.id]=e)}));const a=e=>{o=!0;var t=n[e.localCandidateId];t&&(t.ip||t.address)?(this.localAddress=t.ip||t.address,this.localPort=Number(t.port)):t&&t.ipAddress?(this.localAddress=t.ipAddress,this.localPort=Number(t.portNumber)):"string"==typeof e.googLocalAddress&&(t=e.googLocalAddress.split(":"),this.localAddress=t[0],this.localPort=Number(t[1])),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");var r=i[e.remoteCandidateId];r&&(r.ip||r.address)?(this.remoteAddress=r.ip||r.address,this.remotePort=Number(r.port)):r&&r.ipAddress?(this.remoteAddress=r.ipAddress,this.remotePort=Number(r.portNumber)):"string"==typeof e.googRemoteAddress&&(r=e.googRemoteAddress.split(":"),this.remoteAddress=r[0],this.remotePort=Number(r[1])),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(r.forEach((e=>{"transport"===e.type&&e.selectedCandidatePairId&&a(s[e.selectedCandidatePairId]),("googCandidatePair"===e.type&&"true"===e.googActiveConnection||("candidatepair"===e.type||"candidate-pair"===e.type)&&e.selected)&&a(e)})),o||Object.keys(s).length&&!Object.keys(n).length){if(this._connecting=!1,this._connected=!0,this._chunk){try{this.send(this._chunk)}catch(t){return this.destroy(c(t,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');var u=this._cb;this._cb=null,u(null)}"number"!=typeof this._channel.bufferedAmountLowThreshold&&(this._interval=setInterval((()=>this._onInterval()),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")}else setTimeout(e,100)}))};e()}_onInterval(){!this._cb||!this._channel||this._channel.bufferedAmount>u||this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||("stable"!==this._pc.signalingState||this._firstStable||(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach((e=>{this._pc.removeTrack(e),this._queuedNegotiation=!0})),this._sendersAwaitingStable=[],this._queuedNegotiation&&(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()),this._debug("negotiate"),this.emit("negotiate")),this._firstStable=!1,this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(e){this.destroyed||(e.candidate&&this.trickle?this.emit("signal",{candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):e.candidate||this._iceComplete||(this._iceComplete=!0,this.emit("_iceComplete")),e.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(e){if(!this.destroyed){var t=e.data;t instanceof ArrayBuffer&&(t=new Uint8Array(t)),this.push(t)}}_onChannelBufferedAmountLow(){if(!this.destroyed&&this._cb){this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);var e=this._cb;this._cb=null,e(null)}}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(e){this.destroyed||e.streams.forEach((t=>{this._debug("on track"),this.emit("track",e.track,t),this._remoteTracks.push({track:e.track,stream:t}),this._remoteStreams.some((e=>e.id===t.id))||(this._remoteStreams.push(t),a((()=>{this.emit("stream",t)})))}))}_debug(){var e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],i.apply(null,e)}}d.WEBRTC_SUPPORT=!!n(),d.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},d.channelConfig={},t.exports=d},{debug:"bO5wM","get-browser-rtc":"k3B3j",randombytes:"jH1v5","readable-stream":"w0M38","queue-microtask":"3aIgO","err-code":"l0zxT"}],k3B3j:[function(e,t,r){t.exports=function(){if("undefined"==typeof globalThis)return null;var e={RTCPeerConnection:globalThis.RTCPeerConnection||globalThis.mozRTCPeerConnection||globalThis.webkitRTCPeerConnection,RTCSessionDescription:globalThis.RTCSessionDescription||globalThis.mozRTCSessionDescription||globalThis.webkitRTCSessionDescription,RTCIceCandidate:globalThis.RTCIceCandidate||globalThis.mozRTCIceCandidate||globalThis.webkitRTCIceCandidate};return e.RTCPeerConnection?e:null}},{}],jH1v5:[function(e,t,r){var i=e("process"),n=arguments[3],s=65536,o=4294967295;function a(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}var c=e("safe-buffer").Buffer,u=n.crypto||n.msCrypto;function l(e,t){if(e>o)throw new RangeError("requested too many random bytes");var r=c.allocUnsafe(e);if(e>0)if(e>s)for(var n=0;n{const p=new i;let g,y;return p.__connections=[],p.__spChannels=new Map,p.__pendingIntents=new Map,p.listen=i=>{if(g)throw o(new Error("listener already in use"),"ERR_ALREADY_LISTENING");const m=u();let b;g=i,b=!i.protoCodes().includes(f)&&t.localPeer?i.encapsulate(`/p2p/${t.localPeer.toB58String()}`):i,p.on("error",(()=>m.reject())),y=d(i),s("Dialing to Signalling Server on: "+y),p.io=a.connect(y,h);return p.io.once("connect_error",(e=>m.reject(e))),p.io.once("error",(e=>{p.emit("error",e),p.emit("close")})),p.io.on("ws-handshake",(o=>{if(o.answer||o.err||!o.intentId)return;const a=o.intentId;let u=p.__pendingIntents.get(a);u||(u=[],p.__pendingIntents.set(a,u));let d=p.__spChannels.get(a);if(d)return void d.signal(o.signal);if("offer"!==o.signal.type)return void u.push(o);const h={trickle:!1,...n};r.wrtc&&(h.wrtc=r.wrtc),d=new c(h);const g=e=>{s.error("incoming connection errored",e)};d.on("error",g),d.once("close",((...e)=>{d.removeListener("error",g)})),d.on("signal",(e=>{o.signal=e,o.answer=!0,p.io.emit("ss-handshake",o)})),d.signal(o.signal);for(const e of u)d.signal(e.signal);p.__pendingIntents.set(a,[]),d.once("connect",(async()=>{const r=l(d);let n;s("new inbound connection %s",r.remoteAddr);try{n=await t.upgradeInbound(r)}catch(e){return s.error("inbound connection failed to upgrade",e),r.close()}if(!n.remoteAddr)try{n.remoteAddr=i.decapsulateCode(f).encapsulate(`/p2p/${n.remotePeer.toB58String()}`)}catch(e){s.error("could not determine remote address",e)}s("inbound connection %s upgraded",r.remoteAddr),function(e,t,r){e.__connections.push(t);const i=()=>{e.__connections=e.__connections.filter((e=>e!==t)),e.__spChannels.delete(r),e.__pendingIntents.delete(r)};t.conn.once("close",i)}(p,r,a),p.emit("connection",n),e(n)})),p.__spChannels.set(a,d)})),p.io.on("ws-peer",r._peerDiscovered),p.io.on("connect",(()=>{p.io.emit("ss-join",b.toString())})),p.io.once("connect",(()=>{p.emit("listening"),m.resolve()})),r.sigReferences.set(y,{listener:p,signallingAddr:b}),m.promise},p.close=async()=>{const e=r.sigReferences.get(y);e&&e.listener.io&&(e.listener.io.emit("ss-leave"),e.listener.io.close()),await Promise.all(p.__connections.map((e=>e.close()))),p.emit("close"),p.removeAllListeners(),g=void 0,r.sigReferences.delete(y)},p.getAddrs=()=>[g],p}},{events:"g82pp",debug:"bO5wM","err-code":"chZjB","socket.io-client":"iolK3","libp2p-webrtc-peer":"kt3eh","p-defer":"5rKSv","./socket-to-conn":"heHOu","./utils":"kfyaq","./constants":"1IQXV"}],iolK3:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"protocol",(()=>a.protocol)),i.export(r,"Manager",(()=>s.Manager)),i.export(r,"Socket",(()=>o.Socket)),i.export(r,"io",(()=>u)),i.export(r,"connect",(()=>u)),i.export(r,"default",(()=>u));var n=e("./url.js"),s=e("./manager.js"),o=e("./socket.js"),a=e("socket.io-parser");const c={};function u(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};const r=n.url(e,t.path||"/socket.io"),i=r.source,o=r.id,a=r.path,u=c[o]&&a in c[o].nsps;let l;return t.forceNew||t["force new connection"]||!1===t.multiplex||u?l=new s.Manager(i,t):(c[o]||(c[o]=new s.Manager(i,t)),l=c[o]),r.query&&!t.query&&(t.query=r.queryKey),l.socket(r.path,t)}Object.assign(u,{Manager:s.Manager,Socket:o.Socket,io:u,connect:u})},{"./url.js":"hHJao","./manager.js":"2S1kn","./socket.js":"6OhON","socket.io-parser":"5avRb","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],hHJao:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"url",(()=>o));var n=e("parseuri"),s=i.interopDefault(n);function o(e,t="",r){let i=e;r=r||"undefined"!=typeof location&&location,null==e&&(e=r.protocol+"//"+r.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?r.protocol+e:r.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==r?r.protocol+"//"+e:"https://"+e),i=s.default(e)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";const n=-1!==i.host.indexOf(":")?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+n+":"+i.port+t,i.href=i.protocol+"://"+n+(r&&r.port===i.port?"":":"+i.port),i}},{parseuri:"iXBlw","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],iXBlw:[function(e,t,r){var i=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,n=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];t.exports=function(e){var t=e,r=e.indexOf("["),s=e.indexOf("]");-1!=r&&-1!=s&&(e=e.substring(0,r)+e.substring(r,s).replace(/:/g,";")+e.substring(s,e.length));for(var o,a,c=i.exec(e||""),u={},l=14;l--;)u[n[l]]=c[l]||"";return-1!=r&&-1!=s&&(u.source=t,u.host=u.host.substring(1,u.host.length-1).replace(/;/g,":"),u.authority=u.authority.replace("[","").replace("]","").replace(/;/g,":"),u.ipv6uri=!0),u.pathNames=function(e,t){var r=/\/{2,9}/g,i=t.replace(r,"/").split("/");"/"!=t.substr(0,1)&&0!==t.length||i.splice(0,1);"/"==t.substr(t.length-1,1)&&i.splice(i.length-1,1);return i}(0,u.path),u.queryKey=(o=u.query,a={},o.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,r){t&&(a[t]=r)})),a),u}},{}],"2S1kn":[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"Manager",(()=>d));var n=e("engine.io-client"),s=e("./socket.js"),o=e("socket.io-parser"),a=e("./on.js"),c=e("backo2"),u=i.interopDefault(c),l=e("@socket.io/component-emitter");class d extends l.Emitter{constructor(e,t){var r;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,n.installTimerFunctions(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(r=t.randomizationFactor)&&void 0!==r?r:.5),this.backoff=new u.default({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const i=t.parser||o;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new n.Socket(this.uri,this.opts);const t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const i=a.on(t,"open",(function(){r.onopen(),e&&e()})),s=a.on(t,"error",(t=>{r.cleanup(),r._readyState="closed",this.emitReserved("error",t),e?e(t):r.maybeReconnectOnOpen()}));if(!1!==this._timeout){const e=this._timeout;0===e&&i();const r=this.setTimeoutFn((()=>{i(),t.close(),t.emit("error",new Error("timeout"))}),e);this.opts.autoUnref&&r.unref(),this.subs.push((function(){clearTimeout(r)}))}return this.subs.push(i),this.subs.push(s),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(a.on(e,"ping",this.onping.bind(this)),a.on(e,"data",this.ondata.bind(this)),a.on(e,"error",this.onerror.bind(this)),a.on(e,"close",this.onclose.bind(this)),a.on(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){this.decoder.add(e)}ondecoded(e){this.emitReserved("packet",e)}onerror(e){this.emitReserved("error",e)}socket(e,t){let r=this.nsps[e];return r||(r=new s.Socket(this,e,t),this.nsps[e]=r),r}_destroy(e){const t=Object.keys(this.nsps);for(const e of t){if(this.nsps[e].active)return}this._close()}_packet(e){const t=this.encoder.encode(e);for(let r=0;re())),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn((()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open((t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):e.onreconnect()})))}),t);this.opts.autoUnref&&r.unref(),this.subs.push((function(){clearTimeout(r)}))}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}},{"engine.io-client":"3bSox","./socket.js":"6OhON","socket.io-parser":"5avRb","./on.js":"8c8jd",backo2:"jE9JM","@socket.io/component-emitter":"kYHC2","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],"3bSox":[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"Socket",(()=>n.Socket)),i.export(r,"protocol",(()=>c)),i.export(r,"Transport",(()=>s.Transport)),i.export(r,"transports",(()=>o.transports)),i.export(r,"installTimerFunctions",(()=>a.installTimerFunctions));var n=e("./socket.js"),s=e("./transport.js"),o=e("./transports/index.js"),a=e("./util.js");const c=n.Socket.protocol},{"./socket.js":"7OyJL","./transport.js":"jdgVA","./transports/index.js":"ae41u","./util.js":"hj4iM","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],"7OyJL":[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"Socket",(()=>f));var n=e("./transports/index.js"),s=e("./util.js"),o=e("parseqs"),a=i.interopDefault(o),c=e("parseuri"),u=i.interopDefault(c),l=e("@socket.io/component-emitter"),d=e("engine.io-parser");class f extends l.Emitter{constructor(e,t={}){super(),e&&"object"==typeof e&&(t=e,e=null),e?(e=u.default(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=u.default(t.host).host),s.installTimerFunctions(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket"],this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},t),this.opts.path=this.opts.path.replace(/\/$/,"")+"/","string"==typeof this.opts.query&&(this.opts.query=a.default.decode(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&addEventListener("beforeunload",(()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())}),!1),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close")},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const t=function(e){const t={};for(let r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}(this.opts.query);t.EIO=d.protocol,t.transport=e,this.id&&(t.sid=this.id);const r=Object.assign({},this.opts.transportOptions[e],this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return new n.transports[e](r)}open(){let e;if(this.opts.rememberUpgrade&&f.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(()=>{this.onClose("transport close")}))}probe(e){let t=this.createTransport(e),r=!1;f.priorWebsocketSuccess=!1;const i=()=>{r||(t.send([{type:"ping",data:"probe"}]),t.once("packet",(e=>{if(!r)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;f.priorWebsocketSuccess="websocket"===t.name,this.transport.pause((()=>{r||"closed"!==this.readyState&&(u(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())}))}else{const e=new Error("probe error");e.transport=t.name,this.emitReserved("upgradeError",e)}})))};function n(){r||(r=!0,u(),t.close(),t=null)}const s=e=>{const r=new Error("probe error: "+e);r.transport=t.name,n(),this.emitReserved("upgradeError",r)};function o(){s("transport closed")}function a(){s("socket closed")}function c(e){t&&e.name!==t.name&&n()}const u=()=>{t.removeListener("open",i),t.removeListener("error",s),t.removeListener("close",o),this.off("close",a),this.off("upgrading",c)};t.once("open",i),t.once("error",s),t.once("close",o),this.once("close",a),this.once("upgrading",c),t.open()}onOpen(){if(this.readyState="open",f.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade&&this.transport.pause){let e=0;const t=this.upgrades.length;for(;e{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){"closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emitReserved("flush"))}write(e,t,r){return this.sendPacket("message",e,t,r),this}send(e,t,r){return this.sendPacket("message",e,t,r),this}sendPacket(e,t,r,i){if("function"==typeof t&&(i=t,t=void 0),"function"==typeof r&&(i=r,r=null),"closing"===this.readyState||"closed"===this.readyState)return;(r=r||{}).compress=!1!==r.compress;const n={type:e,data:t,options:r};this.emitReserved("packetCreate",n),this.writeBuffer.push(n),i&&this.once("flush",i),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},r=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?r():e()})):this.upgrading?r():e()),this}onError(e){f.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&removeEventListener("offline",this.offlineEventListener,!1),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let r=0;const i=e.length;for(;rs));var n=e("./polling-xhr.js");const s={websocket:e("./websocket.js").WS,polling:n.XHR}},{"./polling-xhr.js":"amf1l","./websocket.js":"iYHZM","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],amf1l:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"XHR",(()=>h)),i.export(r,"Request",(()=>p));var n=e("./xmlhttprequest.js"),s=i.interopDefault(n),o=e("../globalThis.js"),a=i.interopDefault(o),c=e("../util.js"),u=e("@socket.io/component-emitter"),l=e("./polling.js");function d(){}const f=null!=new s.default({xdomain:!1}).responseType;class h extends l.Polling{constructor(e){if(super(e),"undefined"!=typeof location){const t="https:"===location.protocol;let r=location.port;r||(r=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||r!==e.port,this.xs=e.secure!==t}const t=e&&e.forceBase64;this.supportsBinary=f&&!t}request(e={}){return Object.assign(e,{xd:this.xd,xs:this.xs},this.opts),new p(this.uri(),e)}doWrite(e,t){const r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",(e=>{this.onError("xhr post error",e)}))}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(e=>{this.onError("xhr poll error",e)})),this.pollXhr=e}}class p extends u.Emitter{constructor(e,t){super(),c.installTimerFunctions(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.async=!1!==t.async,this.data=void 0!==t.data?t.data:null,this.create()}create(){const e=c.pick(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this.opts.xd,e.xscheme=!!this.opts.xs;const t=this.xhr=new s.default(e);try{t.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){t.setDisableHeaderCheck&&t.setDisableHeaderCheck(!0);for(let e in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(e)&&t.setRequestHeader(e,this.opts.extraHeaders[e])}}catch(e){}if("POST"===this.method)try{t.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{t.setRequestHeader("Accept","*/*")}catch(e){}"withCredentials"in t&&(t.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(t.timeout=this.opts.requestTimeout),t.onreadystatechange=()=>{4===t.readyState&&(200===t.status||1223===t.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof t.status?t.status:0)}),0))},t.send(this.data)}catch(e){return void this.setTimeoutFn((()=>{this.onError(e)}),0)}"undefined"!=typeof document&&(this.index=p.requestsCount++,p.requests[this.index]=this)}onSuccess(){this.emit("success"),this.cleanup()}onData(e){this.emit("data",e),this.onSuccess()}onError(e){this.emit("error",e),this.cleanup(!0)}cleanup(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=d,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete p.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;null!==e&&this.onData(e)}abort(){this.cleanup()}}if(p.requestsCount=0,p.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",g);else if("function"==typeof addEventListener){const e="onpagehide"in a.default?"pagehide":"unload";addEventListener(e,g,!1)}function g(){for(let e in p.requests)p.requests.hasOwnProperty(e)&&p.requests[e].abort()}},{"./xmlhttprequest.js":"fZPB9","../globalThis.js":"fLI8m","../util.js":"hj4iM","@socket.io/component-emitter":"kYHC2","./polling.js":"kT6ee","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],fZPB9:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r);var n=e("has-cors"),s=i.interopDefault(n),o=e("../globalThis.js"),a=i.interopDefault(o);r.default=function(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||s.default))return new XMLHttpRequest}catch(e){}if(!t)try{return new(a.default[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}},{"has-cors":"f7en3","../globalThis.js":"fLI8m","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],f7en3:[function(e,t,r){try{t.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){t.exports=!1}},{}],fLI8m:[function(e,t,r){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(r),r.default="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")()},{"@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],hj4iM:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"pick",(()=>o)),i.export(r,"installTimerFunctions",(()=>u));var n=e("./globalThis.js"),s=i.interopDefault(n);function o(e,...t){return t.reduce(((t,r)=>(e.hasOwnProperty(r)&&(t[r]=e[r]),t)),{})}const a=setTimeout,c=clearTimeout;function u(e,t){t.useNativeTimers?(e.setTimeoutFn=a.bind(s.default),e.clearTimeoutFn=c.bind(s.default)):(e.setTimeoutFn=setTimeout.bind(s.default),e.clearTimeoutFn=clearTimeout.bind(s.default))}},{"./globalThis.js":"fLI8m","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],kYHC2:[function(e,t,r){function i(e){if(e)return function(e){for(var t in i.prototype)e[t]=i.prototype[t];return e}(e)}r.Emitter=i,i.prototype.on=i.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},i.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this},i.prototype.off=i.prototype.removeListener=i.prototype.removeAllListeners=i.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,i=this._callbacks["$"+e];if(!i)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var n=0;nl));var n=e("../transport.js"),s=e("yeast"),o=i.interopDefault(s),a=e("parseqs"),c=i.interopDefault(a),u=e("engine.io-parser");class l extends n.Transport{constructor(){super(...arguments),this.polling=!1}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let e=0;this.polling&&(e++,this.once("pollComplete",(function(){--e||t()}))),this.writable||(e++,this.once("drain",(function(){--e||t()})))}else t()}poll(){this.polling=!0,this.doPoll(),this.emit("poll")}onData(e){u.decodePayload(e,this.socket.binaryType).forEach((e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose(),!1;this.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}write(e){this.writable=!1,u.encodePayload(e,(e=>{this.doWrite(e,(()=>{this.writable=!0,this.emit("drain")}))}))}uri(){let e=this.query||{};const t=this.opts.secure?"https":"http";let r="";!1!==this.opts.timestampRequests&&(e[this.opts.timestampParam]=o.default()),this.supportsBinary||e.sid||(e.b64=1),this.opts.port&&("https"===t&&443!==Number(this.opts.port)||"http"===t&&80!==Number(this.opts.port))&&(r=":"+this.opts.port);const i=c.default.encode(e);return t+"://"+(-1!==this.opts.hostname.indexOf(":")?"["+this.opts.hostname+"]":this.opts.hostname)+r+this.opts.path+(i.length?"?"+i:"")}}},{"../transport.js":"jdgVA",yeast:"da0sk",parseqs:"kg931","engine.io-parser":"mMYXv","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],jdgVA:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"Transport",(()=>a));var n=e("engine.io-parser"),s=e("@socket.io/component-emitter"),o=e("./util.js");class a extends s.Emitter{constructor(e){super(),this.writable=!1,o.installTimerFunctions(this,e),this.opts=e,this.query=e.query,this.readyState="",this.socket=e.socket}onError(e,t){const r=new Error(e);return r.type="TransportError",r.description=t,super.emit("error",r),this}open(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emit("open")}onData(e){const t=n.decodePacket(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emit("packet",e)}onClose(){this.readyState="closed",super.emit("close")}}},{"engine.io-parser":"mMYXv","@socket.io/component-emitter":"kYHC2","./util.js":"hj4iM","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],mMYXv:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"protocol",(()=>d)),i.export(r,"encodePacket",(()=>s.default)),i.export(r,"encodePayload",(()=>u)),i.export(r,"decodePacket",(()=>a.default)),i.export(r,"decodePayload",(()=>l));var n=e("./encodePacket.js"),s=i.interopDefault(n),o=e("./decodePacket.js"),a=i.interopDefault(o);const c=String.fromCharCode(30),u=(e,t)=>{const r=e.length,i=new Array(r);let n=0;e.forEach(((e,o)=>{s.default(e,!1,(e=>{i[o]=e,++n===r&&t(i.join(c))}))}))},l=(e,t)=>{const r=e.split(c),i=[];for(let e=0;e{const r=new FileReader;return r.onload=function(){const e=r.result.split(",")[1];t("b"+e)},r.readAsDataURL(e)};r.default=({type:e,data:t},r,a)=>{return n&&t instanceof Blob?r?a(t):o(t,a):s&&(t instanceof ArrayBuffer||(c=t,"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(c):c&&c.buffer instanceof ArrayBuffer))?r?a(t):o(new Blob([t]),a):a(i.PACKET_TYPES[e]+(t||""));var c}},{"./commons.js":"2D0Nf","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],"2D0Nf":[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"PACKET_TYPES",(()=>n)),i.export(r,"PACKET_TYPES_REVERSE",(()=>s)),i.export(r,"ERROR_PACKET",(()=>o));const n=Object.create(null);n.open="0",n.close="1",n.ping="2",n.pong="3",n.message="4",n.upgrade="5",n.noop="6";const s=Object.create(null);Object.keys(n).forEach((e=>{s[n[e]]=e}));const o={type:"error",data:"parser error"}},{"@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],dGiro:[function(e,t,r){e("@parcel/transformer-js/src/esmodule-helpers.js").defineInteropFlag(r);var i=e("./commons.js"),n=e("base64-arraybuffer");const s="function"==typeof ArrayBuffer,o=(e,t)=>{if(s){const r=n.decode(e);return a(r,t)}return{base64:!0,data:e}},a=(e,t)=>"blob"===t&&e instanceof ArrayBuffer?new Blob([e]):e;r.default=(e,t)=>{if("string"!=typeof e)return{type:"message",data:a(e,t)};const r=e.charAt(0);if("b"===r)return{type:"message",data:o(e.substring(1),t)};return i.PACKET_TYPES_REVERSE[r]?e.length>1?{type:i.PACKET_TYPES_REVERSE[r],data:e.substring(1)}:{type:i.PACKET_TYPES_REVERSE[r]}:i.ERROR_PACKET}},{"./commons.js":"2D0Nf","base64-arraybuffer":"h2Zgn","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],h2Zgn:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"decode",(()=>c)),i.export(r,"encode",(()=>a));for(var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s="undefined"==typeof Uint8Array?[]:new Uint8Array(256),o=0;o>2],s+=n[(3&r[t])<<4|r[t+1]>>4],s+=n[(15&r[t+1])<<2|r[t+2]>>6],s+=n[63&r[t+2]];return i%3==2?s=s.substring(0,s.length-1)+"=":i%3==1&&(s=s.substring(0,s.length-2)+"=="),s},c=function(e){var t,r,i,n,o,a=.75*e.length,c=e.length,u=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var l=new ArrayBuffer(a),d=new Uint8Array(l);for(t=0;t>4,d[u++]=(15&i)<<4|n>>2,d[u++]=(3&n)<<6|63&o;return l}},{"@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],da0sk:[function(e,t,r){"use strict";var i,n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),s={},o=0,a=0;function c(e){var t="";do{t=n[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}function u(){var e=c(+new Date);return e!==i?(o=0,i=e):e+"."+c(o++)}for(;a<64;a++)s[n[a]]=a;u.encode=c,u.decode=function(e){var t=0;for(a=0;ap));var n=e("../transport.js"),s=e("parseqs"),o=i.interopDefault(s),a=e("yeast"),c=i.interopDefault(a),u=e("../util.js"),l=e("./websocket-constructor.js"),d=e("engine.io-parser"),f=e("buffer").Buffer;const h="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class p extends n.Transport{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,r=h?{}:u.pick(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=l.usingBrowserWebSocket&&!h?t?new l.WebSocket(e,t):new l.WebSocket(e):new l.WebSocket(e,t,r)}catch(e){return this.emit("error",e)}this.ws.binaryType=this.socket.binaryType||l.defaultBinaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=this.onClose.bind(this),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t{const t={};if(!l.usingBrowserWebSocket&&(r.options&&(t.compress=r.options.compress),this.opts.perMessageDeflate)){("string"==typeof e?f.byteLength(e):e.length){this.writable=!0,this.emit("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){let e=this.query||{};const t=this.opts.secure?"wss":"ws";let r="";this.opts.port&&("wss"===t&&443!==Number(this.opts.port)||"ws"===t&&80!==Number(this.opts.port))&&(r=":"+this.opts.port),this.opts.timestampRequests&&(e[this.opts.timestampParam]=c.default()),this.supportsBinary||(e.b64=1);const i=o.default.encode(e);return t+"://"+(-1!==this.opts.hostname.indexOf(":")?"["+this.opts.hostname+"]":this.opts.hostname)+r+this.opts.path+(i.length?"?"+i:"")}check(){return!(!l.WebSocket||"__initialize"in l.WebSocket&&this.name===p.prototype.name)}}},{buffer:"etowf","../transport.js":"jdgVA",parseqs:"kg931",yeast:"da0sk","../util.js":"hj4iM","./websocket-constructor.js":"eTlGe","engine.io-parser":"mMYXv","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],eTlGe:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"nextTick",(()=>o)),i.export(r,"WebSocket",(()=>a)),i.export(r,"usingBrowserWebSocket",(()=>c)),i.export(r,"defaultBinaryType",(()=>u));var n=e("../globalThis.js"),s=i.interopDefault(n);const o="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),a=s.default.WebSocket||s.default.MozWebSocket,c=!0,u="arraybuffer"},{"../globalThis.js":"fLI8m","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],"6OhON":[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"Socket",(()=>c));var n=e("socket.io-parser"),s=e("./on.js"),o=e("@socket.io/component-emitter");const a=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class c extends o.Emitter{constructor(e,t,r){super(),this.connected=!1,this.disconnected=!0,this.receiveBuffer=[],this.sendBuffer=[],this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,r&&r.auth&&(this.auth=r.auth),this.io._autoConnect&&this.open()}subEvents(){if(this.subs)return;const e=this.io;this.subs=[s.on(e,"open",this.onopen.bind(this)),s.on(e,"packet",this.onpacket.bind(this)),s.on(e,"error",this.onerror.bind(this)),s.on(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(a.hasOwnProperty(e))throw new Error('"'+e+'" is a reserved event name');t.unshift(e);const r={type:n.PacketType.EVENT,data:t,options:{}};if(r.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++,i=t.pop();this._registerAckCallback(e,i),r.id=e}const i=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!i||!this.connected)||(this.connected?this.packet(r):this.sendBuffer.push(r)),this.flags={},this}_registerAckCallback(e,t){const r=this.flags.timeout;if(void 0===r)return void(this.acks[e]=t);const i=this.io.setTimeoutFn((()=>{delete this.acks[e];for(let t=0;t{this.io.clearTimeoutFn(i),t.apply(this,[null,...e])}}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){"function"==typeof this.auth?this.auth((e=>{this.packet({type:n.PacketType.CONNECT,data:e})})):this.packet({type:n.PacketType.CONNECT,data:this.auth})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e){this.connected=!1,this.disconnected=!0,delete this.id,this.emitReserved("disconnect",e)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case n.PacketType.CONNECT:if(e.data&&e.data.sid){const t=e.data.sid;this.onconnect(t)}else this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case n.PacketType.EVENT:case n.PacketType.BINARY_EVENT:this.onevent(e);break;case n.PacketType.ACK:case n.PacketType.BINARY_ACK:this.onack(e);break;case n.PacketType.DISCONNECT:this.ondisconnect();break;case n.PacketType.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const r of t)r.apply(this,e)}super.emit.apply(this,e)}ack(e){const t=this;let r=!1;return function(...i){r||(r=!0,t.packet({type:n.PacketType.ACK,id:e,data:i}))}}onack(e){const t=this.acks[e.id];"function"==typeof t&&(t.apply(this,e.data),delete this.acks[e.id])}onconnect(e){this.id=e,this.connected=!0,this.disconnected=!1,this.emitBuffered(),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach((e=>this.emitEvent(e))),this.receiveBuffer=[],this.sendBuffer.forEach((e=>this.packet(e))),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((e=>e())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:n.PacketType.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let r=0;ra)),i.export(r,"PacketType",(()=>c)),i.export(r,"Encoder",(()=>l)),i.export(r,"Decoder",(()=>d));var n=e("@socket.io/component-emitter"),s=e("./binary.js"),o=e("./is-binary.js");const a=5;var c,u;(u=c||(c={}))[u.CONNECT=0]="CONNECT",u[u.DISCONNECT=1]="DISCONNECT",u[u.EVENT=2]="EVENT",u[u.ACK=3]="ACK",u[u.CONNECT_ERROR=4]="CONNECT_ERROR",u[u.BINARY_EVENT=5]="BINARY_EVENT",u[u.BINARY_ACK=6]="BINARY_ACK";class l{encode(e){return e.type!==c.EVENT&&e.type!==c.ACK||!o.hasBinary(e)?[this.encodeAsString(e)]:(e.type=e.type===c.EVENT?c.BINARY_EVENT:c.BINARY_ACK,this.encodeAsBinary(e))}encodeAsString(e){let t=""+e.type;return e.type!==c.BINARY_EVENT&&e.type!==c.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data)),t}encodeAsBinary(e){const t=s.deconstructPacket(e),r=this.encodeAsString(t.packet),i=t.buffers;return i.unshift(r),i}}class d extends n.Emitter{constructor(){super()}add(e){let t;if("string"==typeof e)t=this.decodeString(e),t.type===c.BINARY_EVENT||t.type===c.BINARY_ACK?(this.reconstructor=new f(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t);else{if(!o.isBinary(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const r={type:Number(e.charAt(0))};if(void 0===c[r.type])throw new Error("unknown packet type "+r.type);if(r.type===c.BINARY_EVENT||r.type===c.BINARY_ACK){const i=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const n=e.substring(i,t);if(n!=Number(n)||"-"!==e.charAt(t))throw new Error("Illegal attachments");r.attachments=Number(n)}if("/"===e.charAt(t+1)){const i=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}r.nsp=e.substring(i,t)}else r.nsp="/";const i=e.charAt(t+1);if(""!==i&&Number(i)==i){const i=t+1;for(;++t;){const r=e.charAt(t);if(null==r||Number(r)!=r){--t;break}if(t===e.length)break}r.id=Number(e.substring(i,t+1))}if(e.charAt(++t)){const i=function(e){try{return JSON.parse(e)}catch(e){return!1}}(e.substr(t));if(!d.isPayloadValid(r.type,i))throw new Error("invalid payload");r.data=i}return r}static isPayloadValid(e,t){switch(e){case c.CONNECT:return"object"==typeof t;case c.DISCONNECT:return void 0===t;case c.CONNECT_ERROR:return"string"==typeof t||"object"==typeof t;case c.EVENT:case c.BINARY_EVENT:return Array.isArray(t)&&t.length>0;case c.ACK:case c.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&this.reconstructor.finishedReconstruction()}}class f{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=s.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}},{"@socket.io/component-emitter":"kYHC2","./binary.js":"c0isJ","./is-binary.js":"2y0fk","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],c0isJ:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"deconstructPacket",(()=>s)),i.export(r,"reconstructPacket",(()=>a));var n=e("./is-binary.js");function s(e){const t=[],r=e.data,i=e;return i.data=o(r,t),i.attachments=t.length,{packet:i,buffers:t}}function o(e,t){if(!e)return e;if(n.isBinary(e)){const r={_placeholder:!0,num:t.length};return t.push(e),r}if(Array.isArray(e)){const r=new Array(e.length);for(let i=0;ic)),i.export(r,"hasBinary",(()=>u));const n="function"==typeof ArrayBuffer,s=Object.prototype.toString,o="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===s.call(Blob),a="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===s.call(File);function c(e){return n&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||o&&e instanceof Blob||a&&e instanceof File}function u(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,r=e.length;tn))},{"@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],jE9JM:[function(e,t,r){function i(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}t.exports=i,i.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-r:e+r}return 0|Math.min(e,this.max)},i.prototype.reset=function(){this.attempts=0},i.prototype.setMin=function(e){this.ms=e},i.prototype.setMax=function(e){this.max=e},i.prototype.setJitter=function(e){this.jitter=e}},{}],heHOu:[function(e,t,r){"use strict";const i=e("abortable-iterator"),n=e("stream-to-it"),{CLOSE_TIMEOUT:s}=e("./constants"),o=e("libp2p-utils/src/ip-port-to-multiaddr"),a=e("debug"),c=a("libp2p:webrtc-star:socket");c.error=a("libp2p:webrtc-star:socket:error");const u=(e,t)=>{if(e&&t)try{return o(e,t)}catch(e){return c.error(e),o("0.0.0.0",t)}};t.exports=(e,t={})=>{const{sink:r,source:o}=n.duplex(e),a=t.remoteAddr||u(e.remoteAddress,e.remotePort),l=u(e.localAddress,e.localPort),d={async sink(e){t.signal&&(e=i(e,t.signal));try{await r(async function*(){for await(const t of e)yield t instanceof Uint8Array?t:t.slice()}())}catch(e){"aborted"!==e.type&&c.error(e)}},source:t.signal?i(o,t.signal):o,conn:e,localAddr:l,remoteAddr:a,timeline:{open:Date.now()},close(){if(!e.destroyed)return new Promise(((t,r)=>{const i=Date.now(),n=setTimeout((()=>{if(d.remoteAddr){const{host:e,port:t}=d.remoteAddr.toOptions();c("timeout closing socket to %s:%s after %dms, destroying it manually",e,t,Date.now()-i)}e.destroyed||e.destroy()}),s);e.once("close",(()=>{t()})),e.end((e=>{if(clearTimeout(n),d.timeline.close=Date.now(),e)return r(e)}))}))}};return e.once("close",(()=>{d.timeline.close||(d.timeline.close=Date.now())})),d}},{"abortable-iterator":"awlU8","stream-to-it":"8tF2x","./constants":"1IQXV","libp2p-utils/src/ip-port-to-multiaddr":"WM46A",debug:"bO5wM"}],"8tF2x":[function(e,t,r){t.exports=e("./source"),t.exports.source=e("./source"),t.exports.sink=e("./sink"),t.exports.transform=e("./transform"),t.exports.duplex=e("./duplex")},{"./source":"7664L","./sink":"5VmJ6","./transform":"9Vbep","./duplex":"dkoqM"}],"5VmJ6":[function(e,t,r){const i=e("get-iterator");t.exports=e=>async t=>{t=i(t);const r=e=>{"function"==typeof e.return&&e.return()};let n=null,s=null;const o=e=>{n=e,s&&s(e),r(t)};let a=null,c=!1;const u=()=>{c=!0,a&&a()};let l=null,d=!1;const f=()=>{d=!0,l&&l()};let h=null;const p=()=>{h&&h()};e.once("error",o),e.once("close",u),e.once("finish",f);try{for await(const r of t){if(!e.writable||e.destroyed||n)break;!1===e.write(r)&&await new Promise(((t,r)=>{a=h=t,s=r,e.once("drain",p)}))}}catch(t){n||e.destroy(),n=t}try{if(e.writable&&e.end(),await(r(t),new Promise(((e,t)=>{if(c||d||n)return e();l=a=e,s=t}))),n)throw n}finally{e.removeListener("error",o),e.removeListener("close",u),e.removeListener("finish",f),e.removeListener("drain",p)}}},{"get-iterator":"li8y1"}],"9Vbep":[function(e,t,r){const i=e("./duplex");t.exports=e=>async function*(t){const r=i(e);let n;if(r.sink(t).catch((e=>{n=e})),yield*r.source,n)throw n}},{"./duplex":"dkoqM"}],dkoqM:[function(e,t,r){const i=e("./sink"),n=e("./source");t.exports=e=>({sink:i(e),source:n(e)})},{"./sink":"5VmJ6","./source":"7664L"}],kfyaq:[function(e,t,r){"use strict";const{Multiaddr:i}=e("multiaddr");t.exports={cleanUrlSIO:function(e){const t=e.toString().split("/"),r=e.protos()[1].name,n=e.protos()[2].name,s=e.stringTuples()[1][1];if("tcp"!==r||"ws"!==n&&"wss"!==n)throw new Error("invalid multiaddr: "+e.toString());return i.isName(e)?"ws"===n?"http://"+t[2]+("80"===s?"":":"+s):"wss"===n?"https://"+t[2]+("443"===s?"":":"+s):void 0:"http://"+t[2]+":"+t[4]},cleanMultiaddr:function(e){const t="/libp2p-webrtc-star";if(-1!==e.indexOf(t)){e=e.substring(t.length,e.length);let r=new i(e);const n=r.stringTuples().filter((e=>421===e[0]))[0];r=r.decapsulate("p2p"),r=r.encapsulate("/p2p-webrtc-star"),r=r.encapsulate(`/p2p/${n[1]}`),e=r.toString()}return e}}},{multiaddr:"8Mu1u"}],"6n2fc":[function(e,t,r){"use strict";t.exports=e("./mplex")},{"./mplex":"bdx0L"}],bdx0L:[function(e,t,r){"use strict";const i=e("it-pipe"),n=e("it-pushable"),s=e("debug")("libp2p:mplex"),o=e("abortable-iterator"),a=e("./coder"),c=e("./restrict-size"),{MessageTypes:u,MessageTypeNames:l}=e("./message-types"),d=e("./stream");class f{constructor(e){e="function"==typeof(e=e||{})?{onStream:e}:e,this._streamId=0,this._streams={initiators:new Map,receivers:new Map},this._options=e,this.sink=this._createSink(),this.source=this._createSource(),this.onStream=e.onStream,this.onStreamEnd=e.onStreamEnd}get streams(){const e=[];return this._streams.initiators.forEach((t=>{e.push(t)})),this._streams.receivers.forEach((t=>{e.push(t)})),e}newStream(e){const t=this._streamId++;e=null==e?t.toString():String(e);const r=this._streams.initiators;return this._newStream({id:t,name:e,type:"initiator",registry:r})}_newReceiverStream({id:e,name:t}){const r=this._streams.receivers;return this._newStream({id:e,name:t,type:"receiver",registry:r})}_newStream({id:e,name:t,type:r,registry:i}){if(i.has(e))throw new Error(`${r} stream ${e} already exists!`);s("new %s stream %s %s",r,e,t);const n=d({id:e,name:t,send:i=>(s.enabled&&s("%s stream %s %s send",r,e,t,{...i,type:l[i.type],data:i.data&&i.data.slice()}),this.source.push(i)),type:r,onEnd:()=>{s("%s stream %s %s ended",r,e,t),i.delete(e),this.onStreamEnd&&this.onStreamEnd(n)},maxMsgSize:this._options.maxMsgSize});return i.set(e,n),n}_createSink(){return async e=>{this._options.signal&&(e=o(e,this._options.signal));try{await i(e,a.decode,c(this._options.maxMsgSize),(async e=>{for await(const t of e)for(const e of t)this._handleIncoming(e)}))}catch(e){return s("error in sink",e),this.source.end(e)}this.source.end()}}_createSource(){const e=n({onEnd:e=>{const{initiators:t,receivers:r}=this._streams;for(const r of t.values())r.abort(e);for(const t of r.values())t.abort(e)},writev:!0});return Object.assign(a.encode(e),{push:e.push,end:e.end,return:e.return})}_handleIncoming({id:e,type:t,data:r}){if(s.enabled&&s("incoming message",{id:e,type:l[t],data:r.slice()}),t===u.NEW_STREAM&&this.onStream){const t=this._newReceiverStream({id:e,name:r.toString()});return this.onStream(t)}const i=(1&t?this._streams.initiators:this._streams.receivers).get(e);if(!i)return s("missing stream %s",e);switch(t){case u.MESSAGE_INITIATOR:case u.MESSAGE_RECEIVER:i.source.push(r);break;case u.CLOSE_INITIATOR:case u.CLOSE_RECEIVER:i.close();break;case u.RESET_INITIATOR:case u.RESET_RECEIVER:i.reset();break;default:s("unknown message type %s",t)}}}f.multicodec="/mplex/6.7.0",t.exports=f},{"it-pipe":"giKBQ","it-pushable":"bnpei",debug:"bO5wM","abortable-iterator":"awlU8","./coder":"7KKkK","./restrict-size":"aHge1","./message-types":"guJdt","./stream":"eKb79"}],"7KKkK":[function(e,t,r){"use strict";r.encode=e("./encode"),r.decode=e("./decode")},{"./encode":"7SPKN","./decode":"5DYd5"}],"7SPKN":[function(e,t,r){"use strict";const i=e("varint"),n=e("bl/BufferList"),s=10240;const o=new class{constructor(){this._pool=new Uint8Array(s),this._poolOffset=0}write(e){const t=this._pool;let r=this._poolOffset;i.encode(e.id<<3|e.type,t,r),r+=i.encode.bytes,i.encode(e.data?e.data.length:0,t,r),r+=i.encode.bytes;const n=t.subarray(this._poolOffset,r);return s-r<100?(this._pool=new Uint8Array(s),this._poolOffset=0):this._poolOffset=r,e.data?[n,e.data]:n}};t.exports=e=>async function*(){for await(const t of e)Array.isArray(t)?yield new n(t.map((e=>o.write(e)))):yield new n(o.write(t))}()},{varint:"aN1CO","bl/BufferList":"im7j6"}],"5DYd5":[function(e,t,r){"use strict";const i=e("varint"),n=e("bl/BufferList");t.exports=e=>async function*(){const t=new s;for await(const r of e){const e=t.write(r);e.length&&(yield e)}}();class s{constructor(){this._buffer=new n,this._bufferProxy=new Proxy({},{get:(e,t)=>"l"===t[0]?this._buffer[t]:this._buffer.get(parseInt(t))}),this._headerInfo=null}write(e){if(!e||!e.length)return[];this._buffer.append(e);const t=[];for(;;){if(!this._headerInfo)try{this._headerInfo=this._decodeHeader(this._bufferProxy)}catch(e){break}const{id:e,type:r,length:i,offset:n}=this._headerInfo;if(this._buffer.length-n>3,type:7&t,offset:r,length:n}}}},{varint:"aN1CO","bl/BufferList":"im7j6"}],aHge1:[function(e,t,r){"use strict";const i=1048576;t.exports=e=>{e=e||i;const t=t=>{if(t.data&&t.data.length>e)throw Object.assign(new Error("message size too large!"),{code:"ERR_MSG_TOO_BIG"})};return e=>async function*(){for await(const r of e)Array.isArray(r)?r.forEach(t):t(r),yield r}()},t.exports.MAX_MSG_SIZE=i},{}],guJdt:[function(e,t,r){"use strict";const i=Object.freeze({NEW_STREAM:0,MESSAGE_RECEIVER:1,MESSAGE_INITIATOR:2,CLOSE_RECEIVER:3,CLOSE_INITIATOR:4,RESET_RECEIVER:5,RESET_INITIATOR:6});r.MessageTypes=i,r.InitiatorMessageTypes=Object.freeze({NEW_STREAM:i.NEW_STREAM,MESSAGE:i.MESSAGE_INITIATOR,CLOSE:i.CLOSE_INITIATOR,RESET:i.RESET_INITIATOR}),r.ReceiverMessageTypes=Object.freeze({MESSAGE:i.MESSAGE_RECEIVER,CLOSE:i.CLOSE_RECEIVER,RESET:i.RESET_RECEIVER}),r.MessageTypeNames=Object.freeze(Object.entries(i).reduce(((e,t)=>(e[t[1]]=t[0],e)),{}))},{}],eKb79:[function(e,t,r){"use strict";const i=e("abortable-iterator"),n=e("abort-controller"),s=e("debug")("libp2p:mplex:stream"),o=e("it-pushable"),a=e("bl/BufferList"),c=e("err-code"),{MAX_MSG_SIZE:u}=e("./restrict-size"),{InitiatorMessageTypes:l,ReceiverMessageTypes:d}=e("./message-types"),f="ERR_MPLEX_STREAM_RESET";t.exports=({id:e,name:t,send:r,onEnd:h=(()=>{}),type:p="initiator",maxMsgSize:g=u})=>{const y=new n,m=new n,b="initiator"===p?l:d,v="initiator"===p?`i${e}`:`r${e}`;t=String(null==t?e:t);let w,_=!1,E=!1;const S=e=>{E||(E=!0,s("%s stream %s sink end",p,t,e),e&&!w&&(w=e),_&&(T.timeline.close=Date.now(),h(w)))},T={close:()=>T.source.end(),abort:e=>{s("%s stream %s abort",p,t,e),T.source.end(e),y.abort(),S(e)},reset:()=>{const e=c(new Error("stream reset"),f);m.abort(),T.source.end(e),S(e)},sink:async n=>{n=i(n,[{signal:y.signal,options:{abortMessage:"stream aborted",abortCode:"ERR_MPLEX_STREAM_ABORT"}},{signal:m.signal,options:{abortMessage:"stream reset",abortCode:f}}]),"initiator"===p&&r({id:e,type:b.NEW_STREAM,data:t});try{for await(let t of n)for(;t.length;){if(t.length<=g){r({id:e,type:b.MESSAGE,data:t});break}t=a.isBufferList(t)?t:new a(t),r({id:e,type:b.MESSAGE,data:t.shallowSlice(0,g)}),t.consume(g)}}catch(i){return i.code===f?s("%s stream %s reset",p,t):(s("%s stream %s error",p,t,i),r({id:e,type:b.RESET})),T.source.end(i),S(i)}r({id:e,type:b.CLOSE}),S()},source:o((e=>{_||(_=!0,s("%s stream %s source end",p,t,e),e&&!w&&(w=e),E&&(T.timeline.close=Date.now(),h(w)))})),timeline:{open:Date.now(),close:null},id:v};return T}},{"abortable-iterator":"awlU8","abort-controller":"lNJ7z",debug:"bO5wM","it-pushable":"bnpei","bl/BufferList":"im7j6","err-code":"chZjB","./restrict-size":"aHge1","./message-types":"guJdt"}],"5JB8e":[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),r.NOISE=void 0;const s=e("./noise");n(e("./noise"),r),r.NOISE=new s.Noise},{"./noise":"j7J44"}],j7J44:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.Noise=void 0;const a=s(e("@stablelib/x25519")),c=e("buffer"),u=o(e("it-pb-rpc")),l=o(e("it-pair/duplex")),d=o(e("it-buffer")),f=o(e("it-pipe")),h=e("it-length-prefixed"),p=e("./handshake-xx"),g=e("./handshake-ik"),y=e("./handshake-xx-fallback"),m=e("./utils"),b=e("./encoder"),v=e("./crypto"),w=e("./keycache"),_=e("./logger"),E=e("./constants");r.Noise=class{constructor(e,t){if(this.protocol="/noise",this.prologue=c.Buffer.alloc(0),this.earlyData=null!=t?t:c.Buffer.alloc(0),this.useNoisePipes=!1,e){const t=a.generateKeyPairFromSeed(e);this.staticKeys={privateKey:c.Buffer.from(t.secretKey.buffer,t.secretKey.byteOffset,t.secretKey.length),publicKey:c.Buffer.from(t.publicKey.buffer,t.publicKey.byteOffset,t.publicKey.length)}}else this.staticKeys=m.generateKeypair()}async secureOutbound(e,t,r){const i=u.default(t,{lengthEncoder:b.uint16BEEncode,lengthDecoder:b.uint16BEDecode,maxDataLength:E.NOISE_MSG_MAX_LENGTH_BYTES}),n=await this.performHandshake({connection:i,isInitiator:!0,localPeer:e,remotePeer:r});return{conn:await this.createSecureConnection(i,n),remoteEarlyData:n.remoteEarlyData,remotePeer:n.remotePeer}}async secureInbound(e,t,r){const i=u.default(t,{lengthEncoder:b.uint16BEEncode,lengthDecoder:b.uint16BEDecode,maxDataLength:E.NOISE_MSG_MAX_LENGTH_BYTES}),n=await this.performHandshake({connection:i,isInitiator:!1,localPeer:e,remotePeer:r});return{conn:await this.createSecureConnection(i,n),remoteEarlyData:n.remoteEarlyData,remotePeer:n.remotePeer}}async performHandshake(e){var t;const r=await m.getPayload(e.localPeer,this.staticKeys.publicKey,this.earlyData);let i=this.useNoisePipes;if(e.isInitiator&&null===w.KeyCache.load(e.remotePeer)&&(i=!1),!i)return await this.performXXHandshake(e,r);{const{remotePeer:i,connection:n,isInitiator:s}=e,o=new g.IKHandshake(s,r,this.prologue,this.staticKeys,n,null!==(t=w.KeyCache.load(e.remotePeer))&&void 0!==t?t:c.Buffer.alloc(32),i);try{return await this.performIKHandshake(o)}catch(t){let i;return e.isInitiator&&(i=o.getLocalEphemeralKeys()),await this.performXXFallbackHandshake(e,r,t.initialMsg,i)}}}async performXXFallbackHandshake(e,t,r,i){const{isInitiator:n,remotePeer:s,connection:o}=e,a=new y.XXFallbackHandshake(n,t,this.prologue,this.staticKeys,o,r,s,i);try{await a.propose(),await a.exchange(),await a.finish()}catch(e){_.logger(e);throw new Error(`Error occurred during XX Fallback handshake: ${e.message}`)}return a}async performXXHandshake(e,t){const{isInitiator:r,remotePeer:i,connection:n}=e,s=new p.XXHandshake(r,t,this.prologue,this.staticKeys,n,i);try{await s.propose(),await s.exchange(),await s.finish(),this.useNoisePipes&&s.remotePeer&&w.KeyCache.store(s.remotePeer,s.getRemoteStaticKey())}catch(e){throw new Error(`Error occurred during XX handshake: ${e.message}`)}return s}async performIKHandshake(e){return await e.stage0(),await e.stage1(),e}async createSecureConnection(e,t){const[r,i]=l.default(),n=e.unwrap();return await f.default(r,d.default,v.encryptStream(t),h.encode({lengthEncoder:b.uint16BEEncode}),n,h.decode({lengthDecoder:b.uint16BEDecode}),d.default,v.decryptStream(t),r),i}}},{"@stablelib/x25519":"5PJXv",buffer:"etowf","it-pb-rpc":"1VNxb","it-pair/duplex":"i2hGG","it-buffer":"jQv22","it-pipe":"giKBQ","it-length-prefixed":"3yxIE","./handshake-xx":"aO5Kw","./handshake-ik":"6aLUa","./handshake-xx-fallback":"3Y81f","./utils":"hkQyI","./encoder":"fJwxo","./crypto":"fylsy","./keycache":"8Z0xy","./logger":"iHFBc","./constants":"dt6rC"}],"5PJXv":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("@stablelib/random"),n=e("@stablelib/wipe");function s(e){var t=new Float64Array(16);if(e)for(var r=0;r=0;--b){var v=r[b>>>3]>>>(7&b)&1;u(n,o,v),u(p,g,v),l(y,n,p),d(n,n,p),l(p,o,g),d(o,o,g),h(g,y),h(m,n),f(n,p,n),f(p,o,y),l(y,n,p),d(n,n,p),h(o,n),d(p,g,m),f(n,p,a),l(n,n,g),f(p,p,n),f(n,g,m),f(g,o,i),h(o,y),u(n,o,v),u(p,g,v)}for(b=0;b<16;b++)i[b+16]=n[b],i[b+32]=p[b],i[b+48]=o[b],i[b+64]=g[b];var w=i.subarray(32),_=i.subarray(16);!function(e,t){for(var r=s(),i=0;i<16;i++)r[i]=t[i];for(i=253;i>=0;i--)h(r,r),2!==i&&4!==i&&f(r,r,t);for(i=0;i<16;i++)e[i]=r[i]}(w,w),f(_,_,w);var E=new Uint8Array(32);return function(e,t){for(var r=s(),i=s(),n=0;n<16;n++)i[n]=t[n];c(i),c(i),c(i);for(var o=0;o<2;o++){for(r[0]=i[0]-65517,n=1;n<15;n++)r[n]=i[n]-65535-(r[n-1]>>16&1),r[n-1]&=65535;r[15]=i[15]-32767-(r[14]>>16&1);var a=r[15]>>16&1;r[14]&=65535,u(i,r,1-a)}for(n=0;n<16;n++)e[2*n]=255&i[n],e[2*n+1]=i[n]>>8}(E,_),E}function g(e){return p(e,o)}function y(e){if(e.length!==r.SECRET_KEY_LENGTH)throw new Error("x25519: seed must be "+r.SECRET_KEY_LENGTH+" bytes");var t=new Uint8Array(e);return{publicKey:g(t),secretKey:t}}r.scalarMult=p,r.scalarMultBase=g,r.generateKeyPairFromSeed=y,r.generateKeyPair=function(e){var t=i.randomBytes(32,e),r=y(t);return n.wipe(t),r},r.sharedKey=function(e,t,i){if(void 0===i&&(i=!1),e.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(t.length!==r.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");var n=p(e,t);if(i){for(var s=0,o=0;o256)throw new Error("randomString charset is too long");for(var n="",c=t.length,u=256-256%c;e>0;){for(var l=o(Math.ceil(256*e/u),i),d=0;d0;d++){var f=l[d];f>>8,t[r+1]=e>>>0,t}function s(e,t,r){return void 0===t&&(t=new Uint8Array(2)),void 0===r&&(r=0),t[r+0]=e>>>0,t[r+1]=e>>>8,t}function o(e,t){return void 0===t&&(t=0),e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function a(e,t){return void 0===t&&(t=0),(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function c(e,t){return void 0===t&&(t=0),e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]}function u(e,t){return void 0===t&&(t=0),(e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t])>>>0}function l(e,t,r){return void 0===t&&(t=new Uint8Array(4)),void 0===r&&(r=0),t[r+0]=e>>>24,t[r+1]=e>>>16,t[r+2]=e>>>8,t[r+3]=e>>>0,t}function d(e,t,r){return void 0===t&&(t=new Uint8Array(4)),void 0===r&&(r=0),t[r+0]=e>>>0,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24,t}function f(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),l(e/4294967296>>>0,t,r),l(e>>>0,t,r+4),t}function h(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),d(e>>>0,t,r),d(e/4294967296>>>0,t,r+4),t}r.readInt16BE=function(e,t){return void 0===t&&(t=0),(e[t+0]<<8|e[t+1])<<16>>16},r.readUint16BE=function(e,t){return void 0===t&&(t=0),(e[t+0]<<8|e[t+1])>>>0},r.readInt16LE=function(e,t){return void 0===t&&(t=0),(e[t+1]<<8|e[t])<<16>>16},r.readUint16LE=function(e,t){return void 0===t&&(t=0),(e[t+1]<<8|e[t])>>>0},r.writeUint16BE=n,r.writeInt16BE=n,r.writeUint16LE=s,r.writeInt16LE=s,r.readInt32BE=o,r.readUint32BE=a,r.readInt32LE=c,r.readUint32LE=u,r.writeUint32BE=l,r.writeInt32BE=l,r.writeUint32LE=d,r.writeInt32LE=d,r.readInt64BE=function(e,t){void 0===t&&(t=0);var r=o(e,t),i=o(e,t+4);return 4294967296*r+i-4294967296*(i>>31)},r.readUint64BE=function(e,t){return void 0===t&&(t=0),4294967296*a(e,t)+a(e,t+4)},r.readInt64LE=function(e,t){void 0===t&&(t=0);var r=c(e,t);return 4294967296*c(e,t+4)+r-4294967296*(r>>31)},r.readUint64LE=function(e,t){void 0===t&&(t=0);var r=u(e,t);return 4294967296*u(e,t+4)+r},r.writeUint64BE=f,r.writeInt64BE=f,r.writeUint64LE=h,r.writeInt64LE=h,r.readUintBE=function(e,t,r){if(void 0===r&&(r=0),e%8!=0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(e/8>t.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,s=e/8+r-1;s>=r;s--)i+=t[s]*n,n*=256;return i},r.readUintLE=function(e,t,r){if(void 0===r&&(r=0),e%8!=0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(e/8>t.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,s=r;s=n;o--)r[o]=t/s&255,s*=256;return r},r.writeUintLE=function(e,t,r,n){if(void 0===r&&(r=new Uint8Array(e/8)),void 0===n&&(n=0),e%8!=0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!i.isSafeInteger(t))throw new Error("writeUintLE value must be an integer");for(var s=1,o=n;o>>16&65535)*i+r*(t>>>16&65535)<<16>>>0)|0},r.add=function(e,t){return e+t|0},r.sub=function(e,t){return e-t|0},r.rotl=function(e,t){return e<>>32-t},r.rotr=function(e,t){return e<<32-t|e>>>t},r.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},r.MAX_SAFE_INTEGER=9007199254740991,r.isSafeInteger=function(e){return r.isInteger(e)&&e>=-r.MAX_SAFE_INTEGER&&e<=r.MAX_SAFE_INTEGER}},{}],"1VNxb":[function(e,t,r){"use strict";const i=e("is-buffer"),n=e("it-handshake"),s=e("it-length-prefixed");t.exports=(e,t={})=>{const r=n(e),o=s.decode.fromReader(r.reader,t);let a=!1;const c={read:async e=>{const{value:t,done:i}=await r.reader.next(e);if(i&&t.length{const{value:e,done:t}=await o.next();if(a=t,!e)throw new Error("Value is null");return e},readPB:async e=>{const t=await c.readLP();if(!t)throw new Error("Value is null");const r=i(t)?t:t.slice();return e.decode(r)},write:e=>{r.writer.push(e)},writeLP:e=>{c.write(s.encode.single(e,t))},writePB:(e,t)=>{c.writeLP(t.encode(e))},pb:e=>({read:()=>c.readPB(e),write:t=>c.writePB(t,e)}),unwrap:()=>(r.rest(),r.stream)};return c}},{"is-buffer":"5yoKf","it-handshake":"5ZBDe","it-length-prefixed":"3yxIE"}],"5ZBDe":[function(e,t,r){"use strict";const i=e("it-reader"),n=e("it-pushable"),s=e("p-defer");t.exports=e=>{const t=n(),r=i(e.source),o=s();let a;const c=e.sink(async function*(){yield*t;const e=await o.promise;yield*e}());c.catch((e=>{a=e}));return{reader:r,writer:t,stream:{sink:e=>a?Promise.reject(a):(o.resolve(e),c),source:r},rest:()=>t.end(),write:t.push,read:async()=>(await r.next()).value}}},{"it-reader":"btxDo","it-pushable":"bnpei","p-defer":"5rKSv"}],i2hGG:[function(e,t,r){var i=e("./");t.exports=function(){var e=i(),t=i();return[{source:e.source,sink:t.sink},{source:t.source,sink:e.sink}]}},{"./":"hvKe2"}],hvKe2:[function(e,t,r){"use strict";const i=e("get-iterator");t.exports=function(){let e,t;return{sink:async r=>{if(e)throw new Error("already piped");e=i(r),t&&t(e)},source:{[Symbol.asyncIterator](){return this},next:()=>e?e.next():new Promise((e=>{t=r=>{t=null,e(r.next())}}))}}}},{"get-iterator":"li8y1"}],jQv22:[function(e,t,r){"use strict";const{Buffer:i}=e("buffer"),n=e("bl/BufferList");t.exports=async function*(e){for await(const t of e)i.isBuffer(t)?yield t:n.isBufferList(t)?yield t.slice():yield i.from(t)},t.exports.toBuffer=t.exports,t.exports.toList=async function*(e){for await(const t of e)i.isBuffer(t)?yield(new n).append(t):n.isBufferList(t)?yield t:yield(new n).append(i.from(t))}},{buffer:"etowf","bl/BufferList":"im7j6"}],aO5Kw:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.XXHandshake=void 0;const i=e("buffer"),n=e("./handshakes/xx"),s=e("./utils"),o=e("./logger"),a=e("./encoder");r.XXHandshake=class{constructor(e,t,r,s,o,a,c){this.isInitiator=e,this.payload=t,this.prologue=r,this.staticKeypair=s,this.connection=o,a&&(this.remotePeer=a),this.xx=null!=c?c:new n.XX,this.session=this.xx.initSession(this.isInitiator,this.prologue,this.staticKeypair),this.remoteEarlyData=i.Buffer.alloc(0)}async propose(){if(o.logLocalStaticKeys(this.session.hs.s),this.isInitiator){o.logger("Stage 0 - Initiator starting to send first message.");const e=this.xx.sendMessage(this.session,i.Buffer.alloc(0));this.connection.writeLP(a.encode0(e)),o.logger("Stage 0 - Initiator finished sending first message."),o.logLocalEphemeralKeys(this.session.hs.e)}else{o.logger("Stage 0 - Responder waiting to receive first message...");const e=a.decode0((await this.connection.readLP()).slice()),{valid:t}=this.xx.recvMessage(this.session,e);if(!t)throw new Error("xx handshake stage 0 validation fail");o.logger("Stage 0 - Responder received first message."),o.logRemoteEphemeralKey(this.session.hs.re)}}async exchange(){if(this.isInitiator){o.logger("Stage 1 - Initiator waiting to receive first message from responder...");const e=a.decode1((await this.connection.readLP()).slice()),{plaintext:t,valid:r}=this.xx.recvMessage(this.session,e);if(!r)throw new Error("xx handshake stage 1 validation fail");o.logger("Stage 1 - Initiator received the message."),o.logRemoteEphemeralKey(this.session.hs.re),o.logRemoteStaticKey(this.session.hs.rs),o.logger("Initiator going to check remote's signature...");try{const r=await s.decodePayload(t);this.remotePeer=this.remotePeer||await s.getPeerIdFromPayload(r),this.remotePeer=await s.verifySignedPayload(e.ns,r,this.remotePeer),this.setRemoteEarlyData(r.data)}catch(e){throw new Error(`Error occurred while verifying signed payload: ${e.message}`)}o.logger("All good with the signature!")}else{o.logger("Stage 1 - Responder sending out first message with signed payload and static key.");const e=this.xx.sendMessage(this.session,this.payload);this.connection.writeLP(a.encode1(e)),o.logger("Stage 1 - Responder sent the second handshake message with signed payload."),o.logLocalEphemeralKeys(this.session.hs.e)}}async finish(){if(this.isInitiator){o.logger("Stage 2 - Initiator sending third handshake message.");const e=this.xx.sendMessage(this.session,this.payload);this.connection.writeLP(a.encode2(e)),o.logger("Stage 2 - Initiator sent message with signed payload.")}else{o.logger("Stage 2 - Responder waiting for third handshake message...");const e=a.decode2((await this.connection.readLP()).slice()),{plaintext:t,valid:r}=this.xx.recvMessage(this.session,e);if(!r)throw new Error("xx handshake stage 2 validation fail");o.logger("Stage 2 - Responder received the message, finished handshake.");try{const e=await s.decodePayload(t);this.remotePeer=this.remotePeer||await s.getPeerIdFromPayload(e),await s.verifySignedPayload(this.session.hs.rs,e,this.remotePeer),this.setRemoteEarlyData(e.data)}catch(e){throw new Error(`Error occurred while verifying signed payload: ${e.message}`)}}o.logCipherState(this.session)}encrypt(e,t){const r=this.getCS(t);return this.xx.encryptWithAd(r,i.Buffer.alloc(0),e)}decrypt(e,t){const r=this.getCS(t,!1);return this.xx.decryptWithAd(r,i.Buffer.alloc(0),e)}getRemoteStaticKey(){return this.session.hs.rs}getCS(e,t=!0){if(!e.cs1||!e.cs2)throw new Error("Handshake not completed properly, cipher state does not exist.");return this.isInitiator?t?e.cs1:e.cs2:t?e.cs2:e.cs1}setRemoteEarlyData(e){e&&(this.remoteEarlyData=i.Buffer.from(e.buffer,e.byteOffset,e.length))}}},{buffer:"etowf","./handshakes/xx":"9a2BV","./utils":"hkQyI","./logger":"iHFBc","./encoder":"fJwxo"}],"9a2BV":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.XX=void 0;const i=e("buffer"),n=e("../utils"),s=e("./abstract-handshake");class o extends s.AbstractHandshake{initializeInitiator(e,t,r,n){const s=this.initializeSymmetric("Noise_XX_25519_ChaChaPoly_SHA256");this.mixHash(s,e);return{ss:s,s:t,rs:r,psk:n,re:i.Buffer.alloc(32)}}initializeResponder(e,t,r,n){const s=this.initializeSymmetric("Noise_XX_25519_ChaChaPoly_SHA256");this.mixHash(s,e);return{ss:s,s:t,rs:r,psk:n,re:i.Buffer.alloc(32)}}writeMessageA(e,t,r){const s=i.Buffer.alloc(0);e.e=void 0!==r?r:n.generateKeypair();const o=e.e.publicKey;this.mixHash(e.ss,o);return{ne:o,ns:s,ciphertext:this.encryptAndHash(e.ss,t)}}writeMessageB(e,t){e.e=n.generateKeypair();const r=e.e.publicKey;this.mixHash(e.ss,r),this.mixKey(e.ss,this.dh(e.e.privateKey,e.re));const s=i.Buffer.from(e.s.publicKey),o=this.encryptAndHash(e.ss,s);this.mixKey(e.ss,this.dh(e.s.privateKey,e.re));return{ne:r,ns:o,ciphertext:this.encryptAndHash(e.ss,t)}}writeMessageC(e,t){const r=i.Buffer.from(e.s.publicKey),n=this.encryptAndHash(e.ss,r);this.mixKey(e.ss,this.dh(e.s.privateKey,e.re));const s=this.encryptAndHash(e.ss,t),o={ne:this.createEmptyKey(),ns:n,ciphertext:s},{cs1:a,cs2:c}=this.split(e.ss);return{h:e.ss.h,messageBuffer:o,cs1:a,cs2:c}}readMessageA(e,t){return n.isValidPublicKey(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),this.decryptAndHash(e.ss,t.ciphertext)}readMessageB(e,t){if(n.isValidPublicKey(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),!e.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(e.ss,this.dh(e.e.privateKey,e.re));const{plaintext:r,valid:i}=this.decryptAndHash(e.ss,t.ns);i&&32===r.length&&n.isValidPublicKey(r)&&(e.rs=r),this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const{plaintext:s,valid:o}=this.decryptAndHash(e.ss,t.ciphertext);return{plaintext:s,valid:i&&o}}readMessageC(e,t){const{plaintext:r,valid:i}=this.decryptAndHash(e.ss,t.ns);if(i&&32===r.length&&n.isValidPublicKey(r)&&(e.rs=r),!e.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const{plaintext:s,valid:o}=this.decryptAndHash(e.ss,t.ciphertext),{cs1:a,cs2:c}=this.split(e.ss);return{h:e.ss.h,plaintext:s,valid:i&&o,cs1:a,cs2:c}}initSession(e,t,r){const n=this.createEmptyKey(),s=i.Buffer.alloc(32);let o;return o=e?this.initializeInitiator(t,r,s,n):this.initializeResponder(t,r,s,n),{hs:o,i:e,mc:0}}sendMessage(e,t,r){let i;if(0===e.mc)i=this.writeMessageA(e.hs,t,r);else if(1===e.mc)i=this.writeMessageB(e.hs,t);else if(2===e.mc){const{h:r,messageBuffer:n,cs1:s,cs2:o}=this.writeMessageC(e.hs,t);i=n,e.h=r,e.cs1=s,e.cs2=o}else{if(!(e.mc>2))throw new Error("Session invalid.");if(e.i){if(!e.cs1)throw new Error("CS1 (cipher state) is not defined");i=this.writeMessageRegular(e.cs1,t)}else{if(!e.cs2)throw new Error("CS2 (cipher state) is not defined");i=this.writeMessageRegular(e.cs2,t)}}return e.mc++,i}recvMessage(e,t){let r=i.Buffer.alloc(0),n=!1;if(0===e.mc)({plaintext:r,valid:n}=this.readMessageA(e.hs,t));else if(1===e.mc)({plaintext:r,valid:n}=this.readMessageB(e.hs,t));else if(2===e.mc){const{h:i,plaintext:s,valid:o,cs1:a,cs2:c}=this.readMessageC(e.hs,t);r=s,n=o,e.h=i,e.cs1=a,e.cs2=c}return e.mc++,{plaintext:r,valid:n}}}r.XX=o},{buffer:"etowf","../utils":"hkQyI","./abstract-handshake":"8oSG2"}],hkQyI:[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.isValidPublicKey=r.getHkdf=r.verifySignedPayload=r.getHandshakePayload=r.decodePayload=r.getPeerIdFromPayload=r.signPayload=r.createHandshakePayload=r.getPayload=r.generateKeypair=void 0;const a=e("@stablelib/hkdf"),c=e("@stablelib/sha256"),u=s(e("@stablelib/x25519")),l=e("buffer"),d=o(e("peer-id")),f=e("libp2p-crypto"),h=e("./proto/payload"),p=e("uint8arrays/equals"),g=h.pb.NoiseHandshakePayload;function y(e,t,r){const i=g.create({identityKey:l.Buffer.from(e),identitySig:t,data:null!=r?r:null});return l.Buffer.from(g.encode(i).finish())}async function m(e,t){return l.Buffer.from(await e.privKey.sign(t))}function b(e){return l.Buffer.concat([l.Buffer.from("noise-libp2p-static-key:"),e])}r.generateKeypair=function(){const e=u.generateKeyPair();return{publicKey:l.Buffer.from(e.publicKey.buffer,e.publicKey.byteOffset,e.publicKey.length),privateKey:l.Buffer.from(e.secretKey.buffer,e.secretKey.byteOffset,e.secretKey.length)}},r.getPayload=async function(e,t,r){const i=await m(e,b(t)),n=null!=r?r:l.Buffer.alloc(0);return y(e.marshalPubKey(),i,n)},r.createHandshakePayload=y,r.signPayload=m,r.getPeerIdFromPayload=async function(e){return await d.default.createFromPubKey(l.Buffer.from(e.identityKey))},r.decodePayload=function(e){return g.toObject(g.decode(l.Buffer.from(e)))},r.getHandshakePayload=b,r.verifySignedPayload=async function(e,t,r){const i=l.Buffer.from(t.identityKey);if(!await async function(e,t){const r=await d.default.createFromPubKey(t);return p.equals(r.id,e)}(r.id,i))throw new Error("Peer ID doesn't match libp2p public key.");const n=b(e),s=f.keys.unmarshalPublicKey(i);if(!t.identitySig||!s.verify(n,l.Buffer.from(t.identitySig)))throw new Error("Static key doesn't match to peer that signed payload!");return await d.default.createFromPubKey(i)},r.getHkdf=function(e,t){const r=new a.HKDF(c.SHA256,t,e).expand(96),i=l.Buffer.from(r.buffer,r.byteOffset,r.length);return[i.slice(0,32),i.slice(32,64),i.slice(64,96)]},r.isValidPublicKey=function(e){return!!l.Buffer.isBuffer(e)&&32===e.length}},{"@stablelib/hkdf":"2qV77","@stablelib/sha256":"9CBdD","@stablelib/x25519":"5PJXv",buffer:"etowf","peer-id":"8Bdb3","libp2p-crypto":"bb1cb","./proto/payload":"cBkC4","uint8arrays/equals":"eY3cX"}],"2qV77":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("@stablelib/hmac"),n=e("@stablelib/wipe"),s=function(){function e(e,t,r,n){void 0===r&&(r=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var s=i.hmac(this._hash,r,t);this._hmac=new i.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return e.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(0===e)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},e.prototype.expand=function(e){for(var t=new Uint8Array(e),r=0;rthis.blockSize?this._inner.update(t).finish(r).clean():r.set(t);for(var n=0;n>>8}Object.defineProperty(r,"__esModule",{value:!0}),r.select=function(e,t,r){return~(e-1)&t|e-1&r},r.lessOrEqual=function(e,t){return(0|e)-(0|t)-1>>>31&1},r.compare=i,r.equal=function(e,t){return 0!==e.length&&0!==t.length&&0!==i(e,t)}},{}],"9CBdD":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("@stablelib/binary"),n=e("@stablelib/wipe");r.DIGEST_LENGTH=32,r.BLOCK_SIZE=64;var s=function(){function e(){this.digestLength=r.DIGEST_LENGTH,this.blockSize=r.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return e.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},e.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},e.prototype.clean=function(){n.wipe(this._buffer),n.wipe(this._temp),this.reset()},e.prototype.update=function(e,t){if(void 0===t&&(t=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var r=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[r++],t--;this._bufferLength===this.blockSize&&(a(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(r=a(this._temp,this._state,e,r,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[r++],t--;return this},e.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,r=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%64<56?64:128;this._buffer[r]=128;for(var c=r+1;c0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},e.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},e.prototype.cleanSavedState=function(e){n.wipe(e.state),e.buffer&&n.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},e}();r.SHA256=s;var o=new Int32Array([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]);function a(e,t,r,n,s){for(;s>=64;){for(var a=t[0],c=t[1],u=t[2],l=t[3],d=t[4],f=t[5],h=t[6],p=t[7],g=0;g<16;g++){var y=n+4*g;e[g]=i.readUint32BE(r,y)}for(g=16;g<64;g++){var m=e[g-2],b=(m>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,v=((m=e[g-15])>>>7|m<<25)^(m>>>18|m<<14)^m>>>3;e[g]=(b+e[g-7]|0)+(v+e[g-16]|0)}for(g=0;g<64;g++){b=(((d>>>6|d<<26)^(d>>>11|d<<21)^(d>>>25|d<<7))+(d&f^~d&h)|0)+(p+(o[g]+e[g]|0)|0)|0,v=((a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10))+(a&c^a&u^c&u)|0;p=h,h=f,f=d,d=l+b|0,l=u,u=c,c=a,a=b+v|0}t[0]+=a,t[1]+=c,t[2]+=u,t[3]+=l,t[4]+=d,t[5]+=f,t[6]+=h,t[7]+=p,n+=64,s-=64}return n}r.hash=function(e){var t=new s;t.update(e);var r=t.digest();return t.clean(),r}},{"@stablelib/binary":"h0oFL","@stablelib/wipe":"4bsjy"}],cBkC4:[function(e,t,r){"use strict";var i;i=function(e){var t,r=e.Reader,i=e.Writer,n=e.util,s=e.roots["libp2p-noise"]||(e.roots["libp2p-noise"]={});return s.pb=((t={}).NoiseHandshakePayload=function(){function t(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:n.identityKey=e.bytes();break;case 2:n.identitySig=e.bytes();break;case 3:n.data=e.bytes();break;default:e.skipType(7&o)}}return n},t.decodeDelimited=function(e){return e instanceof r||(e=new r(e)),this.decode(e,e.uint32())},t.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.identityKey&&e.hasOwnProperty("identityKey")&&!(e.identityKey&&"number"==typeof e.identityKey.length||n.isString(e.identityKey))?"identityKey: buffer expected":null!=e.identitySig&&e.hasOwnProperty("identitySig")&&!(e.identitySig&&"number"==typeof e.identitySig.length||n.isString(e.identitySig))?"identitySig: buffer expected":null!=e.data&&e.hasOwnProperty("data")&&!(e.data&&"number"==typeof e.data.length||n.isString(e.data))?"data: buffer expected":null},t.fromObject=function(e){if(e instanceof s.pb.NoiseHandshakePayload)return e;var t=new s.pb.NoiseHandshakePayload;return null!=e.identityKey&&("string"==typeof e.identityKey?n.base64.decode(e.identityKey,t.identityKey=n.newBuffer(n.base64.length(e.identityKey)),0):e.identityKey.length&&(t.identityKey=e.identityKey)),null!=e.identitySig&&("string"==typeof e.identitySig?n.base64.decode(e.identitySig,t.identitySig=n.newBuffer(n.base64.length(e.identitySig)),0):e.identitySig.length&&(t.identitySig=e.identitySig)),null!=e.data&&("string"==typeof e.data?n.base64.decode(e.data,t.data=n.newBuffer(n.base64.length(e.data)),0):e.data.length&&(t.data=e.data)),t},t.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.identityKey="":(r.identityKey=[],t.bytes!==Array&&(r.identityKey=n.newBuffer(r.identityKey))),t.bytes===String?r.identitySig="":(r.identitySig=[],t.bytes!==Array&&(r.identitySig=n.newBuffer(r.identitySig))),t.bytes===String?r.data="":(r.data=[],t.bytes!==Array&&(r.data=n.newBuffer(r.data)))),null!=e.identityKey&&e.hasOwnProperty("identityKey")&&(r.identityKey=t.bytes===String?n.base64.encode(e.identityKey,0,e.identityKey.length):t.bytes===Array?Array.prototype.slice.call(e.identityKey):e.identityKey),null!=e.identitySig&&e.hasOwnProperty("identitySig")&&(r.identitySig=t.bytes===String?n.base64.encode(e.identitySig,0,e.identitySig.length):t.bytes===Array?Array.prototype.slice.call(e.identitySig):e.identitySig),null!=e.data&&e.hasOwnProperty("data")&&(r.data=t.bytes===String?n.base64.encode(e.data,0,e.data.length):t.bytes===Array?Array.prototype.slice.call(e.data):e.data),r},t.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},t}(),t),s},"function"==typeof define&&define.amd?define(["protobufjs/minimal"],i):"function"==typeof e&&"object"==typeof t&&t&&t.exports&&(t.exports=i(e("protobufjs/minimal")))},{"protobufjs/minimal":"grAXL"}],"8oSG2":[function(e,t,r){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&i(t,e,r);return n(t,e),t};Object.defineProperty(r,"__esModule",{value:!0}),r.AbstractHandshake=r.MIN_NONCE=void 0;const o=e("buffer"),a=s(e("@stablelib/x25519")),c=s(e("@stablelib/sha256")),u=e("@stablelib/chacha20poly1305"),l=e("../utils"),d=e("../logger");r.MIN_NONCE=0;r.AbstractHandshake=class{encryptWithAd(e,t,r){const i=this.encrypt(e.k,e.n,t,r);return this.setNonce(e,this.incrementNonce(e.n)),i}decryptWithAd(e,t,r){const{plaintext:i,valid:n}=this.decrypt(e.k,e.n,t,r);return this.setNonce(e,this.incrementNonce(e.n)),{plaintext:i,valid:n}}hasKey(e){return!this.isEmptyKey(e.k)}setNonce(e,t){e.n=t}createEmptyKey(){return o.Buffer.alloc(32)}isEmptyKey(e){return this.createEmptyKey().equals(e)}incrementNonce(e){return e+1}nonceToBytes(e){const t=o.Buffer.alloc(12);return t.writeUInt32LE(e,4),t}encrypt(e,t,r,i){const n=this.nonceToBytes(t),s=new u.ChaCha20Poly1305(e).seal(n,i,r);return o.Buffer.from(s.buffer,s.byteOffset,s.length)}encryptAndHash(e,t){let r;return r=this.hasKey(e.cs)?this.encryptWithAd(e.cs,e.h,t):t,this.mixHash(e,r),r}decrypt(e,t,r,i){const n=this.nonceToBytes(t),s=new u.ChaCha20Poly1305(e).open(n,i,r);return s?{plaintext:o.Buffer.from(s.buffer,s.byteOffset,s.length),valid:!0}:{plaintext:o.Buffer.from(""),valid:!1}}decryptAndHash(e,t){let r,i=!0;return this.hasKey(e.cs)?({plaintext:r,valid:i}=this.decryptWithAd(e.cs,e.h,t)):r=t,this.mixHash(e,t),{plaintext:r,valid:i}}dh(e,t){try{const r=a.sharedKey(e,t),i=o.Buffer.from(r.buffer,r.byteOffset,r.length),n=o.Buffer.alloc(32);return i.copy(n),n}catch(e){return d.logger(e.message),o.Buffer.alloc(32)}}mixHash(e,t){e.h=this.getHash(e.h,t)}getHash(e,t){const r=c.hash(o.Buffer.from([...e,...t]));return o.Buffer.from(r.buffer,r.byteOffset,r.length)}mixKey(e,t){const[r,i]=l.getHkdf(e.ck,t);e.cs=this.initializeKey(i),e.ck=r}initializeKey(e){return{k:e,n:r.MIN_NONCE}}initializeSymmetric(e){const t=o.Buffer.from(e,"utf-8"),r=this.hashProtocolName(t),i=r,n=this.createEmptyKey();return{cs:this.initializeKey(n),ck:i,h:r}}hashProtocolName(e){if(e.length<=32){const t=o.Buffer.alloc(32);return e.copy(t),t}return this.getHash(e,o.Buffer.alloc(0))}split(e){const[t,r]=l.getHkdf(e.ck,o.Buffer.alloc(0));return{cs1:this.initializeKey(t),cs2:this.initializeKey(r)}}writeMessageRegular(e,t){const r=this.encryptWithAd(e,o.Buffer.alloc(0),t);return{ne:this.createEmptyKey(),ns:o.Buffer.alloc(0),ciphertext:r}}readMessageRegular(e,t){return this.decryptWithAd(e,o.Buffer.alloc(0),t.ciphertext)}}},{buffer:"etowf","@stablelib/x25519":"5PJXv","@stablelib/sha256":"9CBdD","@stablelib/chacha20poly1305":"buhYd","../utils":"hkQyI","../logger":"iHFBc"}],buhYd:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("@stablelib/chacha"),n=e("@stablelib/poly1305"),s=e("@stablelib/wipe"),o=e("@stablelib/binary"),a=e("@stablelib/constant-time");r.KEY_LENGTH=32,r.NONCE_LENGTH=12,r.TAG_LENGTH=16;var c=new Uint8Array(16),u=function(){function e(e){if(this.nonceLength=r.NONCE_LENGTH,this.tagLength=r.TAG_LENGTH,e.length!==r.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}return e.prototype.seal=function(e,t,r,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var o=new Uint8Array(16);o.set(e,o.length-e.length);var a=new Uint8Array(32);i.stream(this._key,o,a,4);var c,u=t.length+this.tagLength;if(n){if(n.length!==u)throw new Error("ChaCha20Poly1305: incorrect destination length");c=n}else c=new Uint8Array(u);return i.streamXOR(this._key,o,t,c,4),this._authenticate(c.subarray(c.length-this.tagLength,c.length),a,c.subarray(0,c.length-this.tagLength),r),s.wipe(o),c},e.prototype.open=function(e,t,r,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length0&&a.update(c.subarray(i.length%16))),a.update(r),r.length%16>0&&a.update(c.subarray(r.length%16));var u=new Uint8Array(8);i&&o.writeUint64LE(i.length,u),a.update(u),o.writeUint64LE(r.length,u),a.update(u);for(var l=a.digest(),d=0;d>>16|j<<16)|0)>>>20|T<<12,A=(A^=P=P+(D=(D^=_=_+A|0)>>>16|D<<16)|0)>>>20|A<<12,k=(k^=O=O+(M=(M^=E=E+k|0)>>>16|M<<16)|0)>>>20|k<<12,I=(I^=C=C+(x=(x^=S=S+I|0)>>>16|x<<16)|0)>>>20|I<<12,k=(k^=O=O+(M=(M^=E=E+k|0)>>>24|M<<8)|0)>>>25|k<<7,I=(I^=C=C+(x=(x^=S=S+I|0)>>>24|x<<8)|0)>>>25|I<<7,A=(A^=P=P+(D=(D^=_=_+A|0)>>>24|D<<8)|0)>>>25|A<<7,T=(T^=R=R+(j=(j^=w=w+T|0)>>>24|j<<8)|0)>>>25|T<<7,A=(A^=O=O+(x=(x^=w=w+A|0)>>>16|x<<16)|0)>>>20|A<<12,k=(k^=C=C+(j=(j^=_=_+k|0)>>>16|j<<16)|0)>>>20|k<<12,I=(I^=R=R+(D=(D^=E=E+I|0)>>>16|D<<16)|0)>>>20|I<<12,T=(T^=P=P+(M=(M^=S=S+T|0)>>>16|M<<16)|0)>>>20|T<<12,I=(I^=R=R+(D=(D^=E=E+I|0)>>>24|D<<8)|0)>>>25|I<<7,T=(T^=P=P+(M=(M^=S=S+T|0)>>>24|M<<8)|0)>>>25|T<<7,k=(k^=C=C+(j=(j^=_=_+k|0)>>>24|j<<8)|0)>>>25|k<<7,A=(A^=O=O+(x=(x^=w=w+A|0)>>>24|x<<8)|0)>>>25|A<<7;i.writeUint32LE(w+n|0,e,0),i.writeUint32LE(_+s|0,e,4),i.writeUint32LE(E+o|0,e,8),i.writeUint32LE(S+a|0,e,12),i.writeUint32LE(T+c|0,e,16),i.writeUint32LE(A+u|0,e,20),i.writeUint32LE(k+l|0,e,24),i.writeUint32LE(I+d|0,e,28),i.writeUint32LE(R+f|0,e,32),i.writeUint32LE(P+h|0,e,36),i.writeUint32LE(O+p|0,e,40),i.writeUint32LE(C+g|0,e,44),i.writeUint32LE(j+y|0,e,48),i.writeUint32LE(D+m|0,e,52),i.writeUint32LE(M+b|0,e,56),i.writeUint32LE(x+v|0,e,60)}function o(e,t,r,i,o){if(void 0===o&&(o=0),32!==e.length)throw new Error("ChaCha: key size must be 32 bytes");if(i.length>>=8,t++;if(i>0)throw new Error("ChaCha: counter overflow")}r.streamXOR=o,r.stream=function(e,t,r,i){return void 0===i&&(i=0),n.wipe(r),o(e,t,r,r,i)}},{"@stablelib/binary":"h0oFL","@stablelib/wipe":"4bsjy"}],"8r9OD":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("@stablelib/constant-time"),n=e("@stablelib/wipe");r.DIGEST_LENGTH=16;var s=function(){function e(e){this.digestLength=r.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var t=e[0]|e[1]<<8;this._r[0]=8191&t;var i=e[2]|e[3]<<8;this._r[1]=8191&(t>>>13|i<<3);var n=e[4]|e[5]<<8;this._r[2]=7939&(i>>>10|n<<6);var s=e[6]|e[7]<<8;this._r[3]=8191&(n>>>7|s<<9);var o=e[8]|e[9]<<8;this._r[4]=255&(s>>>4|o<<12),this._r[5]=o>>>1&8190;var a=e[10]|e[11]<<8;this._r[6]=8191&(o>>>14|a<<2);var c=e[12]|e[13]<<8;this._r[7]=8065&(a>>>11|c<<5);var u=e[14]|e[15]<<8;this._r[8]=8191&(c>>>8|u<<8),this._r[9]=u>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}return e.prototype._blocks=function(e,t,r){for(var i=this._fin?0:2048,n=this._h[0],s=this._h[1],o=this._h[2],a=this._h[3],c=this._h[4],u=this._h[5],l=this._h[6],d=this._h[7],f=this._h[8],h=this._h[9],p=this._r[0],g=this._r[1],y=this._r[2],m=this._r[3],b=this._r[4],v=this._r[5],w=this._r[6],_=this._r[7],E=this._r[8],S=this._r[9];r>=16;){var T=e[t+0]|e[t+1]<<8;n+=8191&T;var A=e[t+2]|e[t+3]<<8;s+=8191&(T>>>13|A<<3);var k=e[t+4]|e[t+5]<<8;o+=8191&(A>>>10|k<<6);var I=e[t+6]|e[t+7]<<8;a+=8191&(k>>>7|I<<9);var R=e[t+8]|e[t+9]<<8;c+=8191&(I>>>4|R<<12),u+=R>>>1&8191;var P=e[t+10]|e[t+11]<<8;l+=8191&(R>>>14|P<<2);var O=e[t+12]|e[t+13]<<8;d+=8191&(P>>>11|O<<5);var C=e[t+14]|e[t+15]<<8,j=0,D=j;D+=n*p,D+=s*(5*S),D+=o*(5*E),D+=a*(5*_),j=(D+=c*(5*w))>>>13,D&=8191,D+=u*(5*v),D+=l*(5*b),D+=d*(5*m),D+=(f+=8191&(O>>>8|C<<8))*(5*y);var M=j+=(D+=(h+=C>>>5|i)*(5*g))>>>13;M+=n*g,M+=s*p,M+=o*(5*S),M+=a*(5*E),j=(M+=c*(5*_))>>>13,M&=8191,M+=u*(5*w),M+=l*(5*v),M+=d*(5*b),M+=f*(5*m),j+=(M+=h*(5*y))>>>13,M&=8191;var x=j;x+=n*y,x+=s*g,x+=o*p,x+=a*(5*S),j=(x+=c*(5*E))>>>13,x&=8191,x+=u*(5*_),x+=l*(5*w),x+=d*(5*v),x+=f*(5*b);var B=j+=(x+=h*(5*m))>>>13;B+=n*m,B+=s*y,B+=o*g,B+=a*p,j=(B+=c*(5*S))>>>13,B&=8191,B+=u*(5*E),B+=l*(5*_),B+=d*(5*w),B+=f*(5*v);var L=j+=(B+=h*(5*b))>>>13;L+=n*b,L+=s*m,L+=o*y,L+=a*g,j=(L+=c*p)>>>13,L&=8191,L+=u*(5*S),L+=l*(5*E),L+=d*(5*_),L+=f*(5*w);var N=j+=(L+=h*(5*v))>>>13;N+=n*v,N+=s*b,N+=o*m,N+=a*y,j=(N+=c*g)>>>13,N&=8191,N+=u*p,N+=l*(5*S),N+=d*(5*E),N+=f*(5*_);var U=j+=(N+=h*(5*w))>>>13;U+=n*w,U+=s*v,U+=o*b,U+=a*m,j=(U+=c*y)>>>13,U&=8191,U+=u*g,U+=l*p,U+=d*(5*S),U+=f*(5*E);var F=j+=(U+=h*(5*_))>>>13;F+=n*_,F+=s*w,F+=o*v,F+=a*b,j=(F+=c*m)>>>13,F&=8191,F+=u*y,F+=l*g,F+=d*p,F+=f*(5*S);var K=j+=(F+=h*(5*E))>>>13;K+=n*E,K+=s*_,K+=o*w,K+=a*v,j=(K+=c*b)>>>13,K&=8191,K+=u*m,K+=l*y,K+=d*g,K+=f*p;var z=j+=(K+=h*(5*S))>>>13;z+=n*S,z+=s*E,z+=o*_,z+=a*w,j=(z+=c*v)>>>13,z&=8191,z+=u*b,z+=l*m,z+=d*y,z+=f*g,n=D=8191&(j=(j=((j+=(z+=h*p)>>>13)<<2)+j|0)+(D&=8191)|0),s=M+=j>>>=13,o=x&=8191,a=B&=8191,c=L&=8191,u=N&=8191,l=U&=8191,d=F&=8191,f=K&=8191,h=z&=8191,t+=16,r-=16}this._h[0]=n,this._h[1]=s,this._h[2]=o,this._h[3]=a,this._h[4]=c,this._h[5]=u,this._h[6]=l,this._h[7]=d,this._h[8]=f,this._h[9]=h},e.prototype.finish=function(e,t){void 0===t&&(t=0);var r,i,n,s,o=new Uint16Array(10);if(this._leftover){for(s=this._leftover,this._buffer[s++]=1;s<16;s++)this._buffer[s]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(r=this._h[1]>>>13,this._h[1]&=8191,s=2;s<10;s++)this._h[s]+=r,r=this._h[s]>>>13,this._h[s]&=8191;for(this._h[0]+=5*r,r=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=r,r=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=r,o[0]=this._h[0]+5,r=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this._h[s]+r,r=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,i=(1^r)-1,s=0;s<10;s++)o[s]&=i;for(i=~i,s=0;s<10;s++)this._h[s]=this._h[s]&i|o[s];for(this._h[0]=65535&(this._h[0]|this._h[1]<<13),this._h[1]=65535&(this._h[1]>>>3|this._h[2]<<10),this._h[2]=65535&(this._h[2]>>>6|this._h[3]<<7),this._h[3]=65535&(this._h[3]>>>9|this._h[4]<<4),this._h[4]=65535&(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14),this._h[5]=65535&(this._h[6]>>>2|this._h[7]<<11),this._h[6]=65535&(this._h[7]>>>5|this._h[8]<<8),this._h[7]=65535&(this._h[8]>>>8|this._h[9]<<5),n=this._h[0]+this._pad[0],this._h[0]=65535&n,s=1;s<8;s++)n=(this._h[s]+this._pad[s]|0)+(n>>>16)|0,this._h[s]=65535&n;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this},e.prototype.update=function(e){var t,r=0,i=e.length;if(this._leftover){(t=16-this._leftover)>i&&(t=i);for(var n=0;n=16&&(t=i-i%16,this._blocks(e,r,t),r+=t,i-=t),i){for(n=0;n{},r.logLocalStaticKeys=function(e){o(`LOCAL_STATIC_PUBLIC_KEY ${e.publicKey.toString("hex")}`),o(`LOCAL_STATIC_PRIVATE_KEY ${e.privateKey.toString("hex")}`)},r.logLocalEphemeralKeys=function(e){e?(o(`LOCAL_PUBLIC_EPHEMERAL_KEY ${e.publicKey.toString("hex")}`),o(`LOCAL_PRIVATE_EPHEMERAL_KEY ${e.privateKey.toString("hex")}`)):o("Missing local ephemeral keys.")},r.logRemoteStaticKey=function(e){o(`REMOTE_STATIC_PUBLIC_KEY ${e.toString("hex")}`)},r.logRemoteEphemeralKey=function(e){o(`REMOTE_EPHEMERAL_PUBLIC_KEY ${e.toString("hex")}`)},r.logCipherState=function(e){e.cs1&&e.cs2?(o(`CIPHER_STATE_1 ${e.cs1.n} ${e.cs1.k.toString("hex")}`),o(`CIPHER_STATE_2 ${e.cs2.n} ${e.cs2.k.toString("hex")}`)):o("Missing cipher state.")}},{debug:"bO5wM","./constants":"dt6rC"}],dt6rC:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.DUMP_SESSION_KEYS=r.NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG=r.NOISE_MSG_MAX_LENGTH_BYTES=void 0,r.NOISE_MSG_MAX_LENGTH_BYTES=65535,r.NOISE_MSG_MAX_LENGTH_BYTES_WITHOUT_TAG=r.NOISE_MSG_MAX_LENGTH_BYTES-16,r.DUMP_SESSION_KEYS=void 0},{}],fJwxo:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.decode2=r.decode1=r.decode0=r.encode2=r.encode1=r.encode0=r.uint16BEDecode=r.uint16BEEncode=void 0;const i=e("buffer");r.uint16BEEncode=(e,t,r)=>((t=t||i.Buffer.allocUnsafe(2)).writeUInt16BE(e,r),t),r.uint16BEEncode.bytes=2;r.uint16BEDecode=e=>{if(e.length<2)throw RangeError("Could not decode int16BE");return e.readUInt16BE(0)},r.uint16BEDecode.bytes=2,r.encode0=function(e){return i.Buffer.concat([e.ne,e.ciphertext])},r.encode1=function(e){return i.Buffer.concat([e.ne,e.ns,e.ciphertext])},r.encode2=function(e){return i.Buffer.concat([e.ns,e.ciphertext])},r.decode0=function(e){if(e.length<32)throw new Error("Cannot decode stage 0 MessageBuffer: length less than 32 bytes.");return{ne:e.slice(0,32),ciphertext:e.slice(32,e.length),ns:i.Buffer.alloc(0)}},r.decode1=function(e){if(e.length<80)throw new Error("Cannot decode stage 1 MessageBuffer: length less than 80 bytes.");return{ne:e.slice(0,32),ns:e.slice(32,80),ciphertext:e.slice(80,e.length)}},r.decode2=function(e){if(e.length<48)throw new Error("Cannot decode stage 2 MessageBuffer: length less than 48 bytes.");return{ne:i.Buffer.alloc(0),ns:e.slice(0,48),ciphertext:e.slice(48,e.length)}}},{buffer:"etowf"}],"6aLUa":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.IKHandshake=void 0;const i=e("./handshakes/ik"),n=e("buffer"),s=e("./encoder"),o=e("./utils"),a=e("./errors"),c=e("./logger");r.IKHandshake=class{constructor(e,t,r,s,o,a,c,u){this.isInitiator=e,this.payload=n.Buffer.from(t),this.prologue=r,this.staticKeypair=s,this.connection=o,c&&(this.remotePeer=c),this.ik=null!=u?u:new i.IK,this.session=this.ik.initSession(this.isInitiator,this.prologue,this.staticKeypair,a),this.remoteEarlyData=n.Buffer.alloc(0)}async stage0(){if(c.logLocalStaticKeys(this.session.hs.s),c.logRemoteStaticKey(this.session.hs.rs),this.isInitiator){c.logger("IK Stage 0 - Initiator sending message...");const e=this.ik.sendMessage(this.session,this.payload);this.connection.writeLP(s.encode1(e)),c.logger("IK Stage 0 - Initiator sent message."),c.logLocalEphemeralKeys(this.session.hs.e)}else{c.logger("IK Stage 0 - Responder receiving message...");const e=await this.connection.readLP();try{const t=s.decode1(e.slice()),{plaintext:r,valid:i}=this.ik.recvMessage(this.session,t);if(!i)throw new Error("ik handshake stage 0 decryption validation fail");c.logger("IK Stage 0 - Responder got message, going to verify payload.");const n=await o.decodePayload(r);this.remotePeer=this.remotePeer||await o.getPeerIdFromPayload(n),await o.verifySignedPayload(this.session.hs.rs,n,this.remotePeer),this.setRemoteEarlyData(n.data),c.logger("IK Stage 0 - Responder successfully verified payload!"),c.logRemoteEphemeralKey(this.session.hs.re)}catch(t){const r=t;throw c.logger("Responder breaking up with IK handshake in stage 0."),new a.FailedIKError(e,`Error occurred while verifying initiator's signed payload: ${r.message}`)}}}async stage1(){if(this.isInitiator){c.logger("IK Stage 1 - Initiator receiving message...");const e=(await this.connection.readLP()).slice(),t=s.decode0(n.Buffer.from(e)),{plaintext:r,valid:i}=this.ik.recvMessage(this.session,t);c.logger("IK Stage 1 - Initiator got message, going to verify payload.");try{if(!i)throw new Error("ik stage 1 decryption validation fail");const e=await o.decodePayload(r);this.remotePeer=this.remotePeer||await o.getPeerIdFromPayload(e),await o.verifySignedPayload(t.ns.slice(0,32),e,this.remotePeer),this.setRemoteEarlyData(e.data),c.logger("IK Stage 1 - Initiator successfully verified payload!"),c.logRemoteEphemeralKey(this.session.hs.re)}catch(t){const r=t;throw c.logger("Initiator breaking up with IK handshake in stage 1."),new a.FailedIKError(e,`Error occurred while verifying responder's signed payload: ${r.message}`)}}else{c.logger("IK Stage 1 - Responder sending message...");const e=this.ik.sendMessage(this.session,this.payload);this.connection.writeLP(s.encode0(e)),c.logger("IK Stage 1 - Responder sent message..."),c.logLocalEphemeralKeys(this.session.hs.e)}c.logCipherState(this.session)}decrypt(e,t){const r=this.getCS(t,!1);return this.ik.decryptWithAd(r,n.Buffer.alloc(0),e)}encrypt(e,t){const r=this.getCS(t);return this.ik.encryptWithAd(r,n.Buffer.alloc(0),e)}getLocalEphemeralKeys(){if(!this.session.hs.e)throw new Error("Ephemeral keys do not exist.");return this.session.hs.e}getCS(e,t=!0){if(!e.cs1||!e.cs2)throw new Error("Handshake not completed properly, cipher state does not exist.");return this.isInitiator?t?e.cs1:e.cs2:t?e.cs2:e.cs1}setRemoteEarlyData(e){e&&(this.remoteEarlyData=n.Buffer.from(e.buffer,e.byteOffset,e.length))}}},{"./handshakes/ik":"hBdbp",buffer:"etowf","./encoder":"fJwxo","./utils":"hkQyI","./errors":"7MQBJ","./logger":"iHFBc"}],hBdbp:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.IK=void 0;const i=e("buffer"),n=e("../utils"),s=e("./abstract-handshake");class o extends s.AbstractHandshake{initSession(e,t,r,i){const n=this.createEmptyKey();let s;return s=e?this.initializeInitiator(t,r,i,n):this.initializeResponder(t,r,i,n),{hs:s,i:e,mc:0}}sendMessage(e,t){let r;if(0===e.mc)r=this.writeMessageA(e.hs,t);else if(1===e.mc){const{messageBuffer:i,h:n,cs1:s,cs2:o}=this.writeMessageB(e.hs,t);r=i,e.h=n,e.cs1=s,e.cs2=o}else{if(!(e.mc>1))throw new Error("Session invalid.");if(e.i){if(!e.cs1)throw new Error("CS1 (cipher state) is not defined");r=this.writeMessageRegular(e.cs1,t)}else{if(!e.cs2)throw new Error("CS2 (cipher state) is not defined");r=this.writeMessageRegular(e.cs2,t)}}return e.mc++,r}recvMessage(e,t){let r=i.Buffer.alloc(0),n=!1;if(0===e.mc&&({plaintext:r,valid:n}=this.readMessageA(e.hs,t)),1===e.mc){const{plaintext:i,valid:s,h:o,cs1:a,cs2:c}=this.readMessageB(e.hs,t);r=i,n=s,e.h=o,e.cs1=a,e.cs2=c}return e.mc++,{plaintext:r,valid:n}}writeMessageA(e,t){e.e=n.generateKeypair();const r=e.e.publicKey;this.mixHash(e.ss,r),this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const s=i.Buffer.from(e.s.publicKey),o=this.encryptAndHash(e.ss,s);this.mixKey(e.ss,this.dh(e.s.privateKey,e.rs));return{ne:r,ns:o,ciphertext:this.encryptAndHash(e.ss,t)}}writeMessageB(e,t){e.e=n.generateKeypair();const r=e.e.publicKey;this.mixHash(e.ss,r),this.mixKey(e.ss,this.dh(e.e.privateKey,e.re)),this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const i=this.encryptAndHash(e.ss,t),s={ne:r,ns:this.createEmptyKey(),ciphertext:i},{cs1:o,cs2:a}=this.split(e.ss);return{messageBuffer:s,cs1:o,cs2:a,h:e.ss.h}}readMessageA(e,t){n.isValidPublicKey(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),this.mixKey(e.ss,this.dh(e.s.privateKey,e.re));const{plaintext:r,valid:i}=this.decryptAndHash(e.ss,t.ns);i&&32===r.length&&n.isValidPublicKey(r)&&(e.rs=r),this.mixKey(e.ss,this.dh(e.s.privateKey,e.rs));const{plaintext:s,valid:o}=this.decryptAndHash(e.ss,t.ciphertext);return{plaintext:s,valid:i&&o}}readMessageB(e,t){if(n.isValidPublicKey(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),!e.e)throw new Error("Handshake state should contain ephemeral key by now.");this.mixKey(e.ss,this.dh(e.e.privateKey,e.re)),this.mixKey(e.ss,this.dh(e.s.privateKey,e.re));const{plaintext:r,valid:i}=this.decryptAndHash(e.ss,t.ciphertext),{cs1:s,cs2:o}=this.split(e.ss);return{h:e.ss.h,valid:i,plaintext:r,cs1:s,cs2:o}}initializeInitiator(e,t,r,n){const s=this.initializeSymmetric("Noise_IK_25519_ChaChaPoly_SHA256");this.mixHash(s,e),this.mixHash(s,r);return{ss:s,s:t,rs:r,re:i.Buffer.alloc(32),psk:n}}initializeResponder(e,t,r,n){const s=this.initializeSymmetric("Noise_IK_25519_ChaChaPoly_SHA256");this.mixHash(s,e),this.mixHash(s,t.publicKey);return{ss:s,s:t,rs:r,re:i.Buffer.alloc(32),psk:n}}}r.IK=o},{buffer:"etowf","../utils":"hkQyI","./abstract-handshake":"8oSG2"}],"7MQBJ":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.FailedIKError=void 0;class i extends Error{constructor(e,t){super(t),this.initialMsg=e,this.name="FailedIKhandshake"}}r.FailedIKError=i},{}],"3Y81f":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.XXFallbackHandshake=void 0;const i=e("buffer"),n=e("./handshake-xx"),s=e("./utils"),o=e("./logger"),a=e("./encoder");class c extends n.XXHandshake{constructor(e,t,r,i,n,s,o,a,c){super(e,t,r,i,n,o,c),a&&(this.ephemeralKeys=a),this.initialMsg=s}async propose(){if(this.isInitiator)this.xx.sendMessage(this.session,i.Buffer.alloc(0),this.ephemeralKeys),o.logger("XX Fallback Stage 0 - Initialized state as the first message was sent by initiator."),o.logLocalEphemeralKeys(this.session.hs.e);else{o.logger("XX Fallback Stage 0 - Responder decoding initial msg from IK.");const e=a.decode0(this.initialMsg),{valid:t}=this.xx.recvMessage(this.session,{ne:e.ne,ns:i.Buffer.alloc(0),ciphertext:i.Buffer.alloc(0)});if(!t)throw new Error("xx fallback stage 0 decryption validation fail");o.logger("XX Fallback Stage 0 - Responder used received message from IK."),o.logRemoteEphemeralKey(this.session.hs.re)}}async exchange(){if(this.isInitiator){const e=a.decode1(this.initialMsg),{plaintext:t,valid:r}=this.xx.recvMessage(this.session,e);if(!r)throw new Error("xx fallback stage 1 decryption validation fail");o.logger("XX Fallback Stage 1 - Initiator used received message from IK."),o.logRemoteEphemeralKey(this.session.hs.re),o.logRemoteStaticKey(this.session.hs.rs),o.logger("Initiator going to check remote's signature...");try{const e=await s.decodePayload(t);this.remotePeer=this.remotePeer||await s.getPeerIdFromPayload(e),await s.verifySignedPayload(this.session.hs.rs,e,this.remotePeer),this.setRemoteEarlyData(e.data)}catch(e){throw new Error(`Error occurred while verifying signed payload from responder: ${e.message}`)}o.logger("All good with the signature!")}else o.logger("XX Fallback Stage 1 - Responder start"),await super.exchange(),o.logger("XX Fallback Stage 1 - Responder end")}}r.XXFallbackHandshake=c},{buffer:"etowf","./handshake-xx":"aO5Kw","./utils":"hkQyI","./logger":"iHFBc","./encoder":"fJwxo"}],fylsy:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.decryptStream=r.encryptStream=void 0;const i=e("buffer"),n=e("./constants");r.encryptStream=function(e){return async function*(t){for await(const r of t){const t=i.Buffer.from(r.buffer,r.byteOffset,r.length);for(let r=0;rt.length&&(i=t.length);const s=e.encrypt(t.slice(r,i),e.session);yield s}}}},r.decryptStream=function(e){return async function*(t){for await(const r of t){const t=i.Buffer.from(r.buffer,r.byteOffset,r.length);for(let r=0;rt.length&&(i=t.length);const s=t.slice(r,i),{plaintext:o,valid:a}=await e.decrypt(s,e.session);if(!a)throw new Error("Failed to validate decrypted chunk");yield o}}}}},{buffer:"etowf","./constants":"dt6rC"}],"8Z0xy":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.KeyCache=void 0;const i=new class{constructor(){this.storage=new Map}store(e,t){this.storage.set(e.id,t)}load(e){var t;return e&&null!==(t=this.storage.get(e.id))&&void 0!==t?t:null}resetStorage(){this.storage.clear()}};r.KeyCache=i},{}],lEgzz:[function(e,t,r){"use strict";const{EventEmitter:i}=e("events"),n=e("err-code"),s=e("libp2p-record"),{MemoryDatastore:o}=e("datastore-core/memory"),{equals:a}=e("uint8arrays/equals"),{toString:c}=e("uint8arrays/to-string"),u=e("./routing-table"),l=e("./utils"),d=e("./constants"),f=e("./network"),h=e("./content-fetching"),p=e("./content-routing"),g=e("./peer-routing"),y=e("./message"),m=e("./providers"),b=e("./query-manager"),v=s.Record;t.exports=class extends i{constructor({libp2p:e,dialer:t,peerId:r,peerStore:i,registrar:n,protocolPrefix:a="/ipfs",forceProtocolLegacy:c=!1,datastore:y=new o,kBucketSize:v=d.K,clientMode:w=!1,concurrency:_=d.ALPHA,validators:E={},selectors:S={},onPut:T=(()=>{}),onRemove:A=(()=>{})}){if(super(),!t)throw new Error("libp2p-kad-dht requires an instance of Dialer");this.libp2p=e,this.dialer=t,this.peerId=r,this.peerStore=i,this.registrar=n,this.protocol=a+(c?"":d.PROTOCOL_DHT),this.kBucketSize=v,this._clientMode=w,this.concurrency=_,this.disjointPaths=Math.ceil(this.kBucketSize/2),this.routingTable=new u(this,{kBucketSize:this.kBucketSize}),this.datastore=y,this.providers=new m(this.datastore,this.peerId),this.validators={pk:s.validator.validators.pk,...E},this.selectors={pk:s.selection.selectors.pk,...S},this.network=new f(this),this._log=l.logger(this.peerId),this._queryManager=new b,this._running=!1,this.contentFetching=h(this),this.contentRouting=p(this),this.peerRouting=g(this),this.onPut=T,this.onRemove=A}get isStarted(){return this._running}start(){return this._running=!0,Promise.all([this.providers.start(),this._queryManager.start(),this.network.start(),this.routingTable.start()])}stop(){return this._running=!1,Promise.all([this.providers.stop(),this._queryManager.stop(),this.network.stop(),this.routingTable.stop()])}async put(e,t,r={}){return this.contentFetching.put(e,t,r)}async get(e,t={}){return this.contentFetching.get(e,t)}async getMany(e,t,r={}){return this.contentFetching.getMany(e,t,r)}async removeLocal(e){this._log(`removeLocal: ${c(e,"base32")}`);const t=l.bufferToKey(e);try{await this.datastore.delete(t)}catch(e){if("ERR_NOT_FOUND"===e.code)return;throw e}}async _putLocal(e,t){this._log(`_putLocal: ${c(e,"base32")}`);const r=l.bufferToKey(e);await this.datastore.put(r,t)}async provide(e){return this.contentRouting.provide(e)}async*findProviders(e,t={timeout:6e3,maxNumProviders:5}){for await(const r of this.contentRouting.findProviders(e,t))yield r}async findPeer(e,t={timeout:6e4}){return this.peerRouting.findPeer(e,t)}async*getClosestPeers(e,t={shallow:!1}){yield*this.peerRouting.getClosestPeers(e,t)}getPublicKey(e){return this.peerRouting.getPublicKey(e)}_peerDiscovered(e,t){this.emit("peer",{id:e,multiaddrs:t})}async _nearestPeersToQuery(e){const t=await l.convertBuffer(e.key);return this.routingTable.closestPeers(t,this.kBucketSize).map((e=>{const t=this.peerStore.get(e);return{id:e,multiaddrs:t?t.addresses.map((e=>e.multiaddr)):[]}}))}async _betterPeersToQuery(e,t){this._log("betterPeersToQuery");return(await this._nearestPeersToQuery(e)).filter((e=>this._isSelf(e.id)?(this._log.error("trying to return self as closer"),!1):!e.id.isEqual(t)))}async _checkLocalDatastore(e){this._log(`checkLocalDatastore: ${c(e)} %b`,e);const t=l.bufferToKey(e);let r;try{r=await this.datastore.get(t)}catch(e){if("ERR_NOT_FOUND"===e.code)return;throw e}const i=v.deserialize(r);if(!i)throw n(new Error("Invalid record"),"ERR_INVALID_RECORD");return null==i.timeReceived||l.now()-i.timeReceived.getTime()>d.MAX_RECORD_AGE?(await this.datastore.delete(t),void this.onRemove(i)):i}async _add(e){await this.routingTable.add(e)}async _verifyRecordLocally(e){this._log("verifyRecordLocally"),await s.validator.verifyRecord(this.validators,e)}_isSelf(e){return e&&a(this.peerId.id,e.id)}async _putValueToPeer(e,t,r){const i=new y(y.TYPES.PUT_VALUE,e,0);i.record=v.deserialize(t);const s=await this.network.sendRequest(r,i);if(s.record&&!a(s.record.value,v.deserialize(t).value))throw n(new Error("value not put correctly"),"ERR_PUT_VALUE_INVALID")}async _getValueOrPeers(e,t){const r=await this._getValueSingle(e,t),i=r.closerPeers,s=r.record;if(s){try{await this._verifyRecordOnline(s)}catch(e){const t="invalid record received, discarded";throw this._log(t),n(new Error(t),"ERR_INVALID_RECORD")}return{record:s,peers:i}}if(i.length>0)return{peers:i};throw n(new Error("Not found"),"ERR_NOT_FOUND")}async _getValueSingle(e,t){const r=new y(y.TYPES.GET_VALUE,t,0);return this.network.sendRequest(e,r)}async _verifyRecordOnline(e){await s.validator.verifyRecord(this.validators,e)}},t.exports.multicodec="/ipfs"+d.PROTOCOL_DHT},{events:"g82pp","err-code":"chZjB","libp2p-record":"h5gPS","datastore-core/memory":"farQr","uint8arrays/equals":"eY3cX","uint8arrays/to-string":"hC8JB","./routing-table":"6K2UO","./utils":"eTk1n","./constants":"4YMVW","./network":"4PJUJ","./content-fetching":"7ohZp","./content-routing":"bDSmy","./peer-routing":"nezkB","./message":"dWtGc","./providers":"lunE9","./query-manager":"9th0A"}],"6K2UO":[function(e,t,r){"use strict";const i=e("k-bucket"),{xor:n}=e("uint8arrays/xor"),s=e("./generated-prefix-list.json"),{sha256:o}=e("multiformats/hashes/sha2"),a=e("libp2p-crypto"),c=e("peer-id"),u=e("../utils"),l=e("debug"),d=Object.assign(l("libp2p:dht:routing-table"),{error:l("libp2p:dht:routing-table:error")}),f=e("it-length");t.exports=class{constructor(e,{kBucketSize:t,refreshInterval:r}={}){this.peerId=e.peerId,this.dht=e,this._kBucketSize=t||20,this._refreshInterval=r||3e4,this.kb=new i({numberOfNodesPerKBucket:this._kBucketSize,numberOfNodesToPing:1}),this.commonPrefixLengthRefreshedAt=[],this._refreshTable=this._refreshTable.bind(this),this._onPing=this._onPing.bind(this)}async start(){this.kb.localNodeId=await u.convertPeerId(this.peerId),this.kb.on("ping",this._onPing),await this._refreshTable(!0)}async stop(){this._refreshTimeoutId&&clearTimeout(this._refreshTimeoutId)}async _refreshTable(e){d("refreshing routing table");const t=this._maxCommonPrefix(),r=this._getTrackedCommonPrefixLengthsForRefresh(t);d(`max common prefix length ${t}`),d(`tracked CPLs [ ${r.map((e=>`${e.getFullYear()}-${(e.getMonth()+1).toString().padStart(2,"0")}-${e.getDate().toString().padStart(2,"0")} ${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}:${e.getSeconds().toString().padStart(2,"0")}`)).join(", ")} ]`),await Promise.all(r.map((async(i,n)=>{try{if(await this._refreshCommonPrefixLength(n,i,!0===e),0===this._numPeersForCpl(t)){const t=Math.min(2*(n+1),r.length-1);for(let r=n+1;rDate.now()-this._refreshInterval)return void d(`not running refresh for cpl ${e} as time since last refresh not above interval`);const i=await this._generateRandomPeerId(e);d(`starting refreshing cpl ${e} with key ${i.toB58String()} (routing table size was ${this.kb.count()})`);const n=await f(this.dht.getClosestPeers(i.toBytes(),{}));d(`found ${n} peers that were close to imaginary peer ${i.toB58String()}`),d(`finished refreshing cpl ${e} with key ${i.toB58String()} (routing table size was ${this.kb.count()})`)}_getTrackedCommonPrefixLengthsForRefresh(e){e>15&&(e=15);const t=[];for(let r=0;r<=e;r++)t[r]=this.commonPrefixLengthRefreshedAt[r]||new Date;return t}async _generateRandomPeerId(e){const t=a.randomBytes(2),r=(t[1]<<8)+t[0],i=await this._makePeerId(this.kb.localNodeId,r,e);return c.createFromBytes(i)}async _makePeerId(e,t,r){if(r>15)throw new Error("Cannot generate peer ID for common prefix length greater than 15");const i=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint16(0,!1),n=65535<<16-(r+1),a=s[(i^32768>>r)&n|t&~n],c=new ArrayBuffer(34),u=new DataView(c,0,c.byteLength);return u.setUint8(0,o.code),u.setUint8(1,32),u.setUint32(2,a,!1),new Uint8Array(u.buffer,u.byteOffset,u.byteLength)}_maxCommonPrefix(){if(!this.kb.localNodeId)return 0;let e=0;for(const t of this._prefixLengths())t>e&&(e=t);return e}_numPeersForCpl(e){let t=0;for(const r of this._prefixLengths())r===e&&t++;return t}*_prefixLengths(){for(const{id:e}of this.kb.toIterable()){const t=n(this.kb.localNodeId,e);let r=0;for(const e of t){if(0!==e)break;r++}yield r}}_onPing(e,t){const r=e[0];r&&this.kb.remove(r.id),this.kb.add(t)}get size(){return this.kb.count()}async find(e){const t=await u.convertPeerId(e),r=this.closestPeer(t);if(r&&e.equals(r))return r}closestPeer(e){const t=this.closestPeers(e,1);if(t.length>0)return t[0]}closestPeers(e,t){return this.kb.closest(e,t).map((e=>e.peer))}async add(e){const t=await u.convertPeerId(e);this.kb.add({id:t,peer:e})}async remove(e){const t=await u.convertPeerId(e);this.kb.remove(t)}}},{"k-bucket":"6o2Us","uint8arrays/xor":"6wTd5","./generated-prefix-list.json":"15vmo","multiformats/hashes/sha2":"7i9MT","libp2p-crypto":"bb1cb","peer-id":"8Bdb3","../utils":"eTk1n",debug:"bO5wM","it-length":"6ksGI"}],"6o2Us":[function(e,t,r){"use strict";const i=e("randombytes"),{EventEmitter:n}=e("events");function s(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0,i=e.length;rt.vectorClock?e:t}static distance(e,t){let r=0,i=0;const n=Math.min(e.length,t.length),s=Math.max(e.length,t.length);for(;i=0?(this._update(r,i,e),this):r.contacts.length0&&r.length[this.distance(t.id,e),t])).sort(((e,t)=>e[0]-t[0])).slice(0,t).map((e=>e[1]))}count(){let e=0;for(const t=[this.root];t.length>0;){const r=t.pop();null===r.contacts?t.push(r.right,r.left):e+=r.contacts.length}return e}_determineNode(e,t,r){const i=r>>3,n=r%8;if(t.length<=i&&0!==n)return e.left;return t[i]&1<<7-n?e.right:e.left}get(e){o("id",e);let t=0,r=this.root;for(;null===r.contacts;)r=this._determineNode(r,e,t++);const i=this._indexOf(r,e);return i>=0?r.contacts[i]:null}_indexOf(e,t){for(let r=0;r=0){const e=r.contacts.splice(i,1)[0];this.emit("removed",e)}return this}_split(e,t){e.left={contacts:[],dontSplit:!1,left:null,right:null},e.right={contacts:[],dontSplit:!1,left:null,right:null};for(const r of e.contacts)this._determineNode(e,r.id,t).contacts.push(r);e.contacts=null;const r=this._determineNode(e,this.localNodeId,t);(e.left===r?e.right:e.left).dontSplit=!0}toArray(){let e=[];for(const t=[this.root];t.length>0;){const r=t.pop();null===r.contacts?t.push(r.right,r.left):e=e.concat(r.contacts)}return e}*toIterable(){for(const e=[this.root];e.length>0;){const t=e.pop();null===t.contacts?e.push(t.right,t.left):yield*t.contacts}}_update(e,t,r){if(!s(e.contacts[t].id,r.id))throw new Error("wrong index for _update");const i=e.contacts[t],n=this.arbiter(i,r);n===i&&i!==r||(e.contacts.splice(t,1),e.contacts.push(n),this.emit("updated",i,n))}}t.exports=a},{randombytes:"jH1v5",events:"g82pp"}],"6wTd5":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.xor=function(e,t){if(e.length!==t.length)throw new Error("Inputs should have the same length");const r=new Uint8Array(e.length);for(let i=0;i(await n.digest(e)).digest,r.convertPeerId=async e=>(await n.digest(e.id)).digest,r.bufferToKey=e=>new o("/"+r.encodeBase32(e),!1),r.keyForPublicKey=e=>g([h("/pk/"),e.id]),r.isPublicKeyKey=e=>"/pk/"===p(e.slice(0,4)),r.fromPublicKeyKey=e=>new d(e.slice(4)),r.now=()=>Date.now(),r.encodeBase32=e=>p(e,"base32"),r.decodeBase32=e=>h(e,"base32"),r.sortClosestPeers=async(e,t)=>(await u(e,(async e=>{const i=await r.convertPeerId(e);return{peer:e,distance:a(i,t)}}))).sort(r.xorCompare).map((e=>e.peer)),r.xorCompare=(e,t)=>c(e.distance,t.distance),r.pathSize=(e,t)=>Math.ceil(e/t),r.createPutRecord=(e,t)=>{const r=new Date;return new l(e,t,r).serialize()},r.logger=(e,t)=>{const r=["libp2p","dht"];t&&r.push(t),e&&r.push(`${e.toB58String().slice(0,8)}`),i.formatters.b=e=>s.baseEncode(e);return Object.assign(i(r.join(":")),{error:i(r.concat(["error"]).join(":"))})},r.TimeoutError=class extends Error{get code(){return"ETIMEDOUT"}},r.withTimeout=(e,t)=>async function(...r){if(!t)return e(...r);let i;try{i=await y(e(...r),t)}catch(e){if(e instanceof y.TimeoutError)throw f(e,"ETIMEDOUT");throw e}return i},r.mapParallel=async function(e,t){const r=[];for await(const i of e)r.push(t(i));return Promise.all(r)}},{debug:"bO5wM","multiformats/hashes/sha2":"7i9MT","multiformats/bases/base58":"4n7mA","interface-datastore/key":"9hGOz","uint8arrays/xor":"6wTd5","uint8arrays/compare":"2xv9i","p-map":"ccWP1","libp2p-record":"h5gPS","peer-id":"8Bdb3","err-code":"chZjB","uint8arrays/from-string":"dF7Y4","uint8arrays/to-string":"hC8JB","uint8arrays/concat":"4EBjG","p-timeout":"hP9Ay"}],ccWP1:[function(e,t,r){"use strict";const i=e("aggregate-error");t.exports=async(e,t,{concurrency:r=1/0,stopOnError:n=!0}={})=>new Promise(((s,o)=>{if("function"!=typeof t)throw new TypeError("Mapper function is required");if(!Number.isSafeInteger(r)&&r!==1/0||!(r>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${r}\` (${typeof r})`);const a=[],c=[],u=e[Symbol.iterator]();let l=!1,d=!1,f=0,h=0;const p=()=>{if(l)return;const e=u.next(),r=h;if(h++,e.done)return d=!0,void(0===f&&(n||0===c.length?s(a):o(new i(c))));f++,(async()=>{try{const i=await e.value;a[r]=await t(i,r),f--,p()}catch(e){n?(l=!0,o(e)):(c.push(e),f--,p())}})()};for(let e=0;ee instanceof Error?e:null!==e&&"object"==typeof e?Object.assign(new Error(e.message),e):new Error(e)))).map((e=>"string"==typeof e.stack?n(e.stack).replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g,""):String(e))).join("\n");t="\n"+i(t,4),super(t),this.name="AggregateError",Object.defineProperty(this,"_errors",{value:e})}*[Symbol.iterator](){for(const e of this._errors)yield e}}t.exports=s},{"indent-string":"hRid0","clean-stack":"eUSPW"}],hRid0:[function(e,t,r){"use strict";t.exports=(e,t=1,r)=>{if(r={indent:" ",includeEmptyLines:!1,...r},"string"!=typeof e)throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof e}\``);if("number"!=typeof t)throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof t}\``);if("string"!=typeof r.indent)throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof r.indent}\``);if(0===t)return e;const i=r.includeEmptyLines?/^/gm:/^(?!\s*$)/gm;return e.replace(i,r.indent.repeat(t))}},{}],eUSPW:[function(e,t,r){"use strict";const i=e("os"),n=/\s+at.*(?:\(|\s)(.*)\)?/,s=/^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)\.js:\d+:\d+)|native)/,o=void 0===i.homedir?"":i.homedir();t.exports=(e,t)=>(t=Object.assign({pretty:!1},t),e.replace(/\\/g,"/").split("\n").filter((e=>{const t=e.match(n);if(null===t||!t[1])return!0;const r=t[1];return!r.includes(".app/Contents/Resources/electron.asar")&&!r.includes(".app/Contents/Resources/default_app.asar")&&!s.test(r)})).filter((e=>""!==e.trim())).map((e=>t.pretty?e.replace(n,((e,t)=>e.replace(t,t.replace(o,"~")))):e)).join("\n"))},{os:"lHksA"}],"4YMVW":[function(e,t,r){"use strict";const i=r.second=1e3,n=r.minute=60*i,s=r.hour=60*n;r.MAX_RECORD_AGE=36*s,r.PROTOCOL_DHT="/kad/1.0.0",r.PROVIDERS_KEY_PREFIX="/providers/",r.PROVIDERS_LRU_CACHE_SIZE=256,r.PROVIDERS_VALIDITY=24*s,r.PROVIDERS_CLEANUP_INTERVAL=s,r.READ_MESSAGE_TIMEOUT=10*i,r.GET_MANY_RECORD_COUNT=16,r.K=20,r.ALPHA=3},{}],"4PJUJ":[function(e,t,r){"use strict";const i=e("err-code"),{pipe:n}=e("it-pipe"),s=e("it-length-prefixed"),o=e("p-timeout"),{consume:a}=e("streaming-iterables"),c=e("it-first"),u=e("libp2p-interfaces/src/topology/multicodec-topology"),l=e("./rpc"),d=e("./constants"),f=e("./message"),h=e("./utils");t.exports=class{constructor(e){this.dht=e,this.readMessageTimeout=d.READ_MESSAGE_TIMEOUT,this._log=h.logger(this.dht.peerId,"net"),this._rpc=l(this.dht),this._onPeerConnected=this._onPeerConnected.bind(this),this._running=!1}start(){if(this._running)return;if(!this.dht.isStarted)throw i(new Error("Can not start network"),"ERR_CANNOT_START_NETWORK");this._running=!0,!1===this.dht._clientMode&&this.dht.registrar.handle(this.dht.protocol,this._rpc);const e=new u({multicodecs:[this.dht.protocol],handlers:{onConnect:this._onPeerConnected,onDisconnect:()=>{}}});this._registrarId=this.dht.registrar.register(e)}stop(){(this.dht.isStarted||this.isStarted)&&(this._running=!1,this._registrarId&&this.dht.registrar.unregister(this._registrarId))}get isStarted(){return this._running}get isConnected(){return this.dht.isStarted&&this.isStarted}async _onPeerConnected(e){await this.dht._add(e),this._log("added to the routing table: %s",e.toB58String())}async sendRequest(e,t){if(!this.isConnected)throw i(new Error("Network is offline"),"ERR_NETWORK_OFFLINE");const r=e.toB58String();this._log("sending to: %s",r);let n=this.dht.registrar.connectionManager.get(e);n||(n=await this.dht.dialer.connectToPeer(e));const{stream:s}=await n.newStream(this.dht.protocol);return this._writeReadMessage(s,t.serialize())}async sendMessage(e,t){if(!this.isConnected)throw i(new Error("Network is offline"),"ERR_NETWORK_OFFLINE");const r=e.toB58String();this._log("sending to: %s",r);let n=this.dht.registrar.connectionManager.get(e);n||(n=await this.dht.dialer.connectToPeer(e));const{stream:s}=await n.newStream(this.dht.protocol);return this._writeMessage(s,t.serialize())}async _writeReadMessage(e,t){return o(async function(e,t){const r=await n([t],s.encode(),e,s.decode(),(async e=>{const t=await c(e);if(t)return t.slice()}));if(0===r.length)throw i(new Error("No message received"),"ERR_NO_MESSAGE_RECEIVED");return f.deserialize(r)}(e,t),this.readMessageTimeout)}_writeMessage(e,t){return n([t],s.encode(),e,a)}}},{"err-code":"chZjB","it-pipe":"giKBQ","it-length-prefixed":"3yxIE","p-timeout":"hP9Ay","streaming-iterables":"jrrai","it-first":"hBrkP","libp2p-interfaces/src/topology/multicodec-topology":"52SML","./rpc":"8GalW","./constants":"4YMVW","./message":"dWtGc","./utils":"eTk1n"}],jrrai:[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"batch",(()=>s)),i.export(r,"buffer",(()=>u)),i.export(r,"collect",(()=>l)),i.export(r,"concat",(()=>d)),i.export(r,"consume",(()=>f)),i.export(r,"filter",(()=>p)),i.export(r,"flatMap",(()=>b)),i.export(r,"flatTransform",(()=>w)),i.export(r,"flatten",(()=>g)),i.export(r,"fromStream",(()=>E)),i.export(r,"getIterator",(()=>o)),i.export(r,"map",(()=>m)),i.export(r,"merge",(()=>S)),i.export(r,"parallelFlatMap",(()=>k)),i.export(r,"parallelMap",(()=>A)),i.export(r,"parallelMerge",(()=>I)),i.export(r,"pipeline",(()=>T)),i.export(r,"reduce",(()=>P)),i.export(r,"take",(()=>O)),i.export(r,"tap",(()=>j)),i.export(r,"time",(()=>M)),i.export(r,"transform",(()=>B)),i.export(r,"writeToStream",(()=>N));var n=e("process");function s(e,t){return void 0===t?t=>s(e,t):t[Symbol.asyncIterator]?async function*(e,t){let r=[];for await(const i of t)r.push(i),r.length===e&&(yield r,r=[]);r.length>0&&(yield r)}(e,t):function*(e,t){let r=[];for(const i of t)r.push(i),r.length===e&&(yield r,r=[]);r.length>0&&(yield r)}(e,t)}function o(e){if("function"==typeof e.next)return e;if("function"==typeof e[Symbol.iterator])return e[Symbol.iterator]();if("function"==typeof e[Symbol.asyncIterator])return e[Symbol.asyncIterator]();throw new TypeError('"values" does not to conform to any of the iterator or iterable protocols')}function a(){let e,t;return{promise:new Promise(((r,i)=>{t=r,e=i})),reject:e,resolve:t}}function c(e,t){const r=o(t),i=[],n=[];let s=!1,c=!1;async function u(){if(!c&&!(s||i.length>=e)){s=!0;try{const{done:e,value:t}=await r.next();e?c=!0:i.push({value:t})}catch(e){c=!0,i.push({error:e})}!function(){for(;n.length>0&&i.length>0;){const e=n.shift(),{error:t,value:r}=i.shift();t?e.reject(t):e.resolve({done:!1,value:r})}for(;n.length>0&&c;){const{resolve:e}=n.shift();e({done:!0,value:void 0})}}(),s=!1,u()}}const l={next:async function(){if(i.length>0){const{error:e,value:t}=i.shift();if(e)throw e;return u(),{done:!1,value:t}}if(c)return{done:!0,value:void 0};const e=a();return n.push(e),u(),e.promise},[Symbol.asyncIterator]:()=>l};return l}function u(e,t){return void 0===t?t=>u(e,t):0===e?t:t[Symbol.asyncIterator]?c(e,t):function*(e,t){const r=[];let i;try{for(const i of t)r.push(i),r.length<=e||(yield r.shift())}catch(e){i=e}for(const e of r)yield e;if(i)throw i}(e,t)}function l(e){return e[Symbol.asyncIterator]?async function(e){const t=[];for await(const r of e)t.push(r);return t}(e):Array.from(e)}function d(...e){return e.find((e=>void 0!==e[Symbol.asyncIterator]))?async function*(e){for await(const t of e)yield*t}(e):function*(e){for(const t of e)yield*t}(e)}function f(e){if(e[Symbol.asyncIterator])return async function(e){for await(const t of e);}(e);for(const t of e);}async function*h(e,t){for await(const r of t)await e(r)&&(yield r)}function p(e,t){return void 0===t?t=>h(e,t):h(e,t)}async function*g(e){for await(const t of e)t&&"string"!=typeof t&&(t[Symbol.iterator]||t[Symbol.asyncIterator])?yield*g(t):yield t}async function*y(e,t){for await(const r of t)yield await e(r)}function m(e,t){return void 0===t?t=>y(e,t):y(e,t)}function b(e,t){return void 0===t?t=>b(e,t):p((e=>null!=e),g(m(e,t)))}function v(e,t,r){const i=o(r),n=[],s=[];let c=!1,u=!1,l=0,d=null;function f(){for(;s.length>0&&n.length>0;){const{resolve:e}=s.shift();e({done:!1,value:n.shift()})}for(;s.length>0&&0===l&&c;){const{resolve:e,reject:t}=s.shift();d?(t(d),d=null):e({done:!0,value:void 0})}}async function h(){if(c)f();else if(!(u||l+n.length>=e)){u=!0,l++;try{const{done:e,value:r}=await i.next();e?(c=!0,l--,f()):async function(e){try{const r=await t(e);if(r&&r[Symbol.asyncIterator])for await(const e of r)n.push(e);else n.push(r)}catch(e){c=!0,d=e}l--,f(),h()}(r)}catch(e){c=!0,l--,d=e,f()}u=!1,h()}}const p={next:async function(){if(0===n.length){const e=a();return s.push(e),h(),e.promise}const e=n.shift();return h(),{done:!1,value:e}},[Symbol.asyncIterator]:()=>p};return p}function w(e,t,r){return void 0===t?(t,r)=>r?w(e,t,r):w(e,t):void 0===r?r=>w(e,t,r):p((e=>null!=e),g(v(e,t,r)))}async function _(e){return new Promise((t=>{e.once("readable",(()=>{t()}))}))}function E(e){return"function"==typeof e[Symbol.asyncIterator]?e:async function*(e){for(;;){const t=e.read();if(null===t){if(e._readableState.ended)break;await _(e)}else yield t}}(e)}async function*S(...e){const t=new Set(e.map(o));for(;t.size>0;)for(const e of t){const r=await e.next();r.done?t.delete(e):yield r.value}}function T(e,...t){let r=e();for(const e of t)r=e(r);return r}function A(e,t,r){return void 0===t?(t,r)=>A(e,t,r):void 0===r?r=>A(e,t,r):1===e?m(t,r):async function*(e,t,r){let i=null;const n=o(T((()=>r),u(1),(async function*(e){for await(const t of e){if(i)return;yield t}}),m((e=>({value:t(e)}))),u(e-1)));for(;;){const{value:e,done:t}=await n.next();if(t)break;try{const t=await e.value;i||(yield t)}catch(e){i=e}}if(i)throw i}(e,t,r)}function k(e,t,r){return void 0===t?(t,r)=>r?k(e,t,r):k(e,t):void 0===r?r=>k(e,t,r):p((e=>null!=e),g(A(e,t,r)))}async function*I(...e){const t=e.map(o),r=new Set,i=new Map;let n=null,s=null,a=null;const c=e=>{n=e,s&&s(e)},u=e=>{a&&a(e)},l=e=>{const t=Promise.resolve(e.next()).then((async({done:n,value:s})=>{n||i.set(e,s),r.delete(t)}));r.add(t),t.then(u,c)};for(const e of t)l(e);for(;;){if(0===r.size&&0===i.size)return;await new Promise(((e,t)=>{if(n&&t(n),i.size>0)return e();a=e,s=t}));for(const[e,t]of i)i.delete(e),yield t,l(e)}}async function R(e,t,r){let i=t;for await(const t of r)i=await e(i,t);return i}function P(e,t,r){return void 0===t?(t,r)=>r?R(e,t,r):P(e,t):void 0===r?r=>P(e,t,r):R(e,t,r)}function O(e,t){return void 0===t?t=>O(e,t):t[Symbol.asyncIterator]?async function*(e,t){let r=0;for await(const i of t)if(yield await i,r++,r>=e)break}(e,t):function*(e,t){let r=0;for(const i of t)if(yield i,r++,r>=e)break}(e,t)}async function*C(e,t){for await(const r of t)await e(r),yield r}function j(e,t){return void 0===t?t=>C(e,t):C(e,t)}function D(e,t){let r=e[0]+t[0],i=e[1]+t[1];if(i>=1e9){const e=i%1e9;r+=(i-e)/1e9,i=e}return[r,i]}function M(e={},t){return void 0===t?t=>M(e,t):void 0!==t[Symbol.asyncIterator]?async function*(e,t){const r=t[Symbol.asyncIterator]();let i=[0,0];for(;;){const t=n.hrtime(),{value:s,done:o}=await r.next(),a=n.hrtime(t);if(i=D(i,a),e.progress&&e.progress(a,i),o)return e.total&&e.total(i),s;yield s}}(e,t):function*(e,t){const r=t[Symbol.iterator]();let i=[0,0];for(;;){const t=n.hrtime(),{value:s,done:o}=r.next(),a=n.hrtime(t);if(i=D(i,a),e.progress&&e.progress(a,i),o)return e.total&&e.total(i),s;yield s}}(e,t)}function x(e,t,r){const i=o(r),n=[],s=[];let c=!1,u=!1,l=0,d=null;function f(){for(;s.length>0&&n.length>0;){const{resolve:e}=s.shift();e({done:!1,value:n.shift()})}for(;s.length>0&&0===l&&c;){const{resolve:e,reject:t}=s.shift();d?(t(d),d=null):e({done:!0,value:void 0})}}async function h(){if(c)f();else if(!(u||l+n.length>=e)){u=!0,l++;try{const{done:e,value:r}=await i.next();e?(c=!0,l--,f()):async function(e){try{const r=await t(e);n.push(r)}catch(e){c=!0,d=e}l--,f(),h()}(r)}catch(e){c=!0,l--,d=e,f()}u=!1,h()}}const p={next:async function(){if(0===n.length){const e=a();return s.push(e),h(),e.promise}const e=n.shift();return h(),{done:!1,value:e}},[Symbol.asyncIterator]:()=>p};return p}function B(e,t,r){return void 0===t?(t,r)=>r?B(e,t,r):B(e,t):void 0===r?r=>B(e,t,r):x(e,t,r)}async function L(e,t){let r=null,i=null,n=null;const s=e=>{r=e,i&&i(e)},o=()=>{n&&n()};e.once("error",s);for await(const s of t)if(!1===e.write(s)&&await new Promise(((t,s)=>{if(r)return s(r);e.once("drain",o),n=t,i=s})),r)break;if(e.removeListener("error",s),e.removeListener("drain",o),r)throw r}function N(e,t){return void 0===t?t=>L(e,t):L(e,t)}},{process:"bjUAi","@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],"8GalW":[function(e,t,r){"use strict";const{pipe:i}=e("it-pipe"),n=e("it-length-prefixed"),s=e("../message"),o=e("./handlers"),a=e("../utils");t.exports=e=>{const t=a.logger(e.peerId,"rpc"),r=o(e);async function c(i,n){const s=r(n.type);try{await e._add(i)}catch(e){t.error("Failed to update the kbucket store",e)}if(s)return s(i,n);t.error(`no handler found for message type: ${n.type}`)}return async function({stream:r,connection:o}){const a=o.remotePeer;try{await e._add(a)}catch(e){t.error(e)}const u=a.toB58String();t("from: %s",u),await i(r.source,n.decode(),(e=>async function*(){for await(const t of e){const e=s.deserialize(t.slice()),r=await c(a,e);r&&(yield r.serialize())}}()),n.encode(),r.sink)}}},{"it-pipe":"giKBQ","it-length-prefixed":"3yxIE","../message":"dWtGc","./handlers":"jYQNr","../utils":"eTk1n"}],dWtGc:[function(e,t,r){"use strict";const i=e("peer-id"),{Multiaddr:n}=e("multiaddr"),{Record:s}=e("libp2p-record"),o=e("./dht"),a=o.Message.MessageType,c=o.Message.ConnectionType;class u{constructor(e,t,r){if(t&&!(t instanceof Uint8Array))throw new Error("Key must be a Uint8Array");this.type=e,this.key=t,this._clusterLevelRaw=r,this.closerPeers=[],this.providerPeers=[],this.record=void 0}get clusterLevel(){const e=this._clusterLevelRaw-1;return e<0?0:e}set clusterLevel(e){this._clusterLevelRaw=e}serialize(){const e={key:this.key,type:this.type,clusterLevelRaw:this._clusterLevelRaw,closerPeers:this.closerPeers.map(l),providerPeers:this.providerPeers.map(l),record:void 0};return this.record&&(this.record instanceof Uint8Array?e.record=this.record:e.record=this.record.serialize()),o.Message.encode(e).finish()}static deserialize(e){const t=o.Message.decode(e),r=new u(t.type||0,t.key||Uint8Array.from([]),t.clusterLevelRaw||0);return r.closerPeers=t.closerPeers.map(d),r.providerPeers=t.providerPeers.map(d),t.record&&t.record.length&&(r.record=s.deserialize(t.record)),r}}function l(e){return{id:e.id.id,addrs:(e.multiaddrs||[]).map((e=>e.bytes)),connection:c.CONNECTED}}function d(e){return{id:new i(e.id),multiaddrs:(e.addrs||[]).map((e=>new n(e)))}}u.TYPES=a,u.CONNECTION_TYPES=c,t.exports=u},{"peer-id":"8Bdb3",multiaddr:"8Mu1u","libp2p-record":"h5gPS","./dht":"xqrwr"}],xqrwr:[function(e,t,r){"use strict";var i=e("protobufjs/minimal"),n=i.Reader,s=i.Writer,o=i.util,a=i.roots["libp2p-dht-message"]||(i.roots["libp2p-dht-message"]={});a.Record=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:i.key=e.bytes();break;case 2:i.value=e.bytes();break;case 3:i.author=e.bytes();break;case 4:i.signature=e.bytes();break;case 5:i.timeReceived=e.string();break;default:e.skipType(7&s)}}return i},e.fromObject=function(e){if(e instanceof a.Record)return e;var t=new a.Record;return null!=e.key&&("string"==typeof e.key?o.base64.decode(e.key,t.key=o.newBuffer(o.base64.length(e.key)),0):e.key.length&&(t.key=e.key)),null!=e.value&&("string"==typeof e.value?o.base64.decode(e.value,t.value=o.newBuffer(o.base64.length(e.value)),0):e.value.length&&(t.value=e.value)),null!=e.author&&("string"==typeof e.author?o.base64.decode(e.author,t.author=o.newBuffer(o.base64.length(e.author)),0):e.author.length&&(t.author=e.author)),null!=e.signature&&("string"==typeof e.signature?o.base64.decode(e.signature,t.signature=o.newBuffer(o.base64.length(e.signature)),0):e.signature.length&&(t.signature=e.signature)),null!=e.timeReceived&&(t.timeReceived=String(e.timeReceived)),t},e.toObject=function(e,t){t||(t={});var r={};return null!=e.key&&e.hasOwnProperty("key")&&(r.key=t.bytes===String?o.base64.encode(e.key,0,e.key.length):t.bytes===Array?Array.prototype.slice.call(e.key):e.key,t.oneofs&&(r._key="key")),null!=e.value&&e.hasOwnProperty("value")&&(r.value=t.bytes===String?o.base64.encode(e.value,0,e.value.length):t.bytes===Array?Array.prototype.slice.call(e.value):e.value,t.oneofs&&(r._value="value")),null!=e.author&&e.hasOwnProperty("author")&&(r.author=t.bytes===String?o.base64.encode(e.author,0,e.author.length):t.bytes===Array?Array.prototype.slice.call(e.author):e.author,t.oneofs&&(r._author="author")),null!=e.signature&&e.hasOwnProperty("signature")&&(r.signature=t.bytes===String?o.base64.encode(e.signature,0,e.signature.length):t.bytes===Array?Array.prototype.slice.call(e.signature):e.signature,t.oneofs&&(r._signature="signature")),null!=e.timeReceived&&e.hasOwnProperty("timeReceived")&&(r.timeReceived=e.timeReceived,t.oneofs&&(r._timeReceived="timeReceived")),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e}(),a.Message=function(){function e(e){if(this.closerPeers=[],this.providerPeers=[],e)for(var t=Object.keys(e),r=0;r>>3){case 1:i.type=e.int32();break;case 10:i.clusterLevelRaw=e.int32();break;case 2:i.key=e.bytes();break;case 3:i.record=e.bytes();break;case 8:i.closerPeers&&i.closerPeers.length||(i.closerPeers=[]),i.closerPeers.push(a.Message.Peer.decode(e,e.uint32()));break;case 9:i.providerPeers&&i.providerPeers.length||(i.providerPeers=[]),i.providerPeers.push(a.Message.Peer.decode(e,e.uint32()));break;default:e.skipType(7&s)}}return i},e.fromObject=function(e){if(e instanceof a.Message)return e;var t=new a.Message;switch(e.type){case"PUT_VALUE":case 0:t.type=0;break;case"GET_VALUE":case 1:t.type=1;break;case"ADD_PROVIDER":case 2:t.type=2;break;case"GET_PROVIDERS":case 3:t.type=3;break;case"FIND_NODE":case 4:t.type=4;break;case"PING":case 5:t.type=5}if(null!=e.clusterLevelRaw&&(t.clusterLevelRaw=0|e.clusterLevelRaw),null!=e.key&&("string"==typeof e.key?o.base64.decode(e.key,t.key=o.newBuffer(o.base64.length(e.key)),0):e.key.length&&(t.key=e.key)),null!=e.record&&("string"==typeof e.record?o.base64.decode(e.record,t.record=o.newBuffer(o.base64.length(e.record)),0):e.record.length&&(t.record=e.record)),e.closerPeers){if(!Array.isArray(e.closerPeers))throw TypeError(".Message.closerPeers: array expected");t.closerPeers=[];for(var r=0;r>>3){case 1:i.id=e.bytes();break;case 2:i.addrs&&i.addrs.length||(i.addrs=[]),i.addrs.push(e.bytes());break;case 3:i.connection=e.int32();break;default:e.skipType(7&s)}}return i},e.fromObject=function(e){if(e instanceof a.Message.Peer)return e;var t=new a.Message.Peer;if(null!=e.id&&("string"==typeof e.id?o.base64.decode(e.id,t.id=o.newBuffer(o.base64.length(e.id)),0):e.id.length&&(t.id=e.id)),e.addrs){if(!Array.isArray(e.addrs))throw TypeError(".Message.Peer.addrs: array expected");t.addrs=[];for(var r=0;r{const r={[i.GET_VALUE]:e("./get-value")(t),[i.PUT_VALUE]:e("./put-value")(t),[i.FIND_NODE]:e("./find-node")(t),[i.ADD_PROVIDER]:e("./add-provider")(t),[i.GET_PROVIDERS]:e("./get-providers")(t),[i.PING]:e("./ping")(t)};return function(e){return r[e]}}},{"../../message":"dWtGc","./get-value":"fhqbS","./put-value":"7V6R3","./find-node":"i6Wjq","./add-provider":"7ShND","./get-providers":"1f7P5","./ping":"2BfBU"}],fhqbS:[function(e,t,r){"use strict";const{Record:i}=e("libp2p-record"),n=e("err-code"),s=e("../../message"),o=e("../../utils");t.exports=e=>{const t=o.logger(e.peerId,"rpc:get-value");return async function(r,a){const c=a.key;if(t("key: %b",c),!c||0===c.length)throw n(new Error("Invalid key"),"ERR_INVALID_KEY");const u=new s(s.TYPES.GET_VALUE,c,a.clusterLevel);if(o.isPublicKeyKey(c)){t("is public key");const r=o.fromPublicKeyKey(c);let n;if(e._isSelf(r))n=e.peerId;else{const t=e.peerStore.get(r);n=t&&t.id}if(n&&n.pubKey)return t("returning found public key"),u.record=new i(c,n.pubKey.bytes),u}const[l,d]=await Promise.all([e._checkLocalDatastore(c),e._betterPeersToQuery(a,r)]);return l&&(t("got record"),u.record=l),d.length>0&&(t("got closer %s",d.length),u.closerPeers=d),u}}},{"libp2p-record":"h5gPS","err-code":"chZjB","../../message":"dWtGc","../../utils":"eTk1n"}],"7V6R3":[function(e,t,r){"use strict";const i=e("../../utils"),n=e("err-code");t.exports=e=>{const t=i.logger(e.peerId,"rpc:put-value");return async function(r,s){const o=s.key;t("key: %b",o);const a=s.record;if(!a){const e=`Empty record from: ${r.toB58String()}`;throw t.error(e),n(new Error(e),"ERR_EMPTY_RECORD")}await e._verifyRecordLocally(a),a.timeReceived=new Date;const c=i.bufferToKey(a.key);return await e.datastore.put(c,a.serialize()),e.onPut(a,r),s}}},{"../../utils":"eTk1n","err-code":"chZjB"}],i6Wjq:[function(e,t,r){"use strict";const{equals:i}=e("uint8arrays/equals"),n=e("../../message"),s=e("../../utils");t.exports=e=>{const t=s.logger(e.peerId,"rpc:find-node");return async function(r,s){let o;t("start"),o=i(s.key,e.peerId.id)?[{id:e.peerId,multiaddrs:e.libp2p.multiaddrs}]:await e._betterPeersToQuery(s,r);const a=new n(s.type,new Uint8Array(0),s.clusterLevel);return o.length>0?a.closerPeers=o:t("handle FindNode %s: could not find anything",r.toB58String()),a}}},{"uint8arrays/equals":"eY3cX","../../message":"dWtGc","../../utils":"eTk1n"}],"7ShND":[function(e,t,r){"use strict";const{CID:i}=e("multiformats/cid"),n=e("err-code"),s=e("../../utils");t.exports=e=>{const t=s.logger(e.peerId,"rpc:add-provider");return async function(r,s){if(t("start"),!s.key||0===s.key.length)throw n(new Error("Missing key"),"ERR_MISSING_KEY");let o;try{o=i.decode(s.key)}catch(e){const t=`Invalid CID: ${e.message}`;throw n(new Error(t),"ERR_INVALID_CID")}return s.providerPeers.forEach((i=>{if(i.id.isEqual(r)){if(!(i.multiaddrs.length<1))return t("received provider %s for %s (addrs %s)",r.toB58String(),o.toString(),i.multiaddrs.map((e=>e.toString()))),e._isSelf(i.id)?void 0:(e.peerStore.addressBook.add(i.id,i.multiaddrs),e.providers.addProvider(o,i.id));t("no valid addresses for provider %s. Ignore",r.toB58String())}else t("invalid provider peer %s from %s",i.id.toB58String(),r.toB58String())})),e.providers.addProvider(o,r)}}},{"multiformats/cid":"9ooAY","err-code":"chZjB","../../utils":"eTk1n"}],"1f7P5":[function(e,t,r){"use strict";const{CID:i}=e("multiformats/cid"),n=e("err-code"),s=e("../../message"),o=e("../../utils");t.exports=e=>{const t=o.logger(e.peerId,"rpc:get-providers");return async function(r,a){let c;try{c=i.decode(a.key)}catch(e){throw n(new Error(`Invalid CID: ${e.message}`),"ERR_INVALID_CID")}t("%s",c.toString());const u=o.bufferToKey(c.bytes),[l,d,f]=await Promise.all([e.datastore.has(u),e.providers.getProviders(c),e._betterPeersToQuery(a,r)]),h=d.map((e=>({id:e,multiaddrs:[]}))),p=f.map((e=>({id:e.id,multiaddrs:[]})));l&&h.push({id:e.peerId,multiaddrs:[]});const g=new s(a.type,a.key,a.clusterLevel);return h.length>0&&(g.providerPeers=h),p.length>0&&(g.closerPeers=p),t("got %s providers %s closerPeers",h.length,p.length),g}}},{"multiformats/cid":"9ooAY","err-code":"chZjB","../../message":"dWtGc","../../utils":"eTk1n"}],"2BfBU":[function(e,t,r){"use strict";const i=e("../../utils");t.exports=e=>{const t=i.logger(e.peerId,"rpc:ping");return function(e,r){return t("from %s",e.toB58String()),r}}},{"../../utils":"eTk1n"}],"7ohZp":[function(e,t,r){"use strict";const i=e("err-code"),n=e("p-timeout"),{equals:s}=e("uint8arrays/equals"),{toString:o}=e("uint8arrays/to-string"),a=e("libp2p-record"),c=e("../constants"),u=e("../query"),l=e("../utils"),d=a.Record;t.exports=e=>{const t=async(t,r)=>e.datastore.put(l.bufferToKey(t),r);return{_putLocal:async(e,r)=>t(e,r),async put(r,n,s={}){e._log("PutValue %b",r);const o=await l.createPutRecord(r,n);await t(r,o);let a=0,c=0;await l.mapParallel(e.getClosestPeers(r,{shallow:!0}),(async t=>{try{a+=1,await e._putValueToPeer(r,o,t),c+=1}catch(r){e._log.error("Failed to put to peer (%b): %s",t.id,r)}}));const u=s.minPeers||a;if(u>c){const t=i(new Error(`Failed to put value to enough peers: ${c}/${u}`),"ERR_NOT_ENOUGH_PUT_PEERS");throw e._log.error(t),t}},async get(t,r={}){r.timeout=r.timeout||c.minute,e._log("_get %b",t);const n=await e.getMany(t,c.GET_MANY_RECORD_COUNT,r),o=n.map((e=>e.val));let u=0;try{u=a.selection.bestRecord(e.selectors,t,o)}catch(e){if("ERR_NO_SELECTOR_FUNCTION_FOR_RECORD_KEY"!==e.code)throw e}const d=o[u];if(e._log("GetValue %b %s",t,d),!d)throw i(new Error("best value was not found"),"ERR_NOT_FOUND");return await(async(t,r,i)=>{const n=await l.createPutRecord(t,i);return Promise.all(r.map((async r=>{if(!s(r.val,i))if(e._isSelf(r.from))try{await e._putLocal(t,n)}catch(t){e._log.error("Failed error correcting self",t)}else try{await e._putValueToPeer(t,n,r.from)}catch(t){e._log.error("Failed error correcting entry",t)}})))})(t,n,d),d},async getMany(t,r,s={}){s.timeout=s.timeout||c.minute,e._log("getMany %b (%s)",t,r);const a=[];let f;try{f=await(async t=>{e._log(`getLocal ${o(t,"base32")}`);const r=await e.datastore.get(l.bufferToKey(t));e._log(`found ${o(t,"base32")} in local datastore`);const i=d.deserialize(r);return await e._verifyRecordLocally(i),i})(t)}catch(e){if(0===r)throw e}if(f&&a.push({val:f.value,from:e.peerId}),a.length>=r)return a;const h=await l.convertBuffer(t),p=e.routingTable.closestPeers(h,e.kBucketSize);if(e._log("peers in rt: %d",p.length),0===p.length){const t="Failed to lookup key! No peers from routing table!";if(e._log.error(t),0===a.length)throw i(new Error(t),"ERR_NO_PEERS_IN_ROUTING_TABLE");return a}const g=a.length;const y=new u(e,t,(function(i,n){const s=l.pathSize(r-g,n);let o=0;return async function(r){let i,n,c;try{const s=await e._getValueOrPeers(r,t);i=s.record,n=s.peers}catch(e){if("ERR_INVALID_RECORD"!==e.code)throw e;c=e}const u={closerPeers:n};return i&&i.value?(a.push({val:i.value,from:r}),o++):c&&(a.push({err:c,from:r}),o++),o>=s&&(u.pathComplete=!0),u}}));try{await n(y.run(p),s.timeout)}catch(e){if(0===a.length)throw e}finally{y.stop()}return a}}}},{"err-code":"chZjB","p-timeout":"hP9Ay","uint8arrays/equals":"eY3cX","uint8arrays/to-string":"hC8JB","libp2p-record":"h5gPS","../constants":"4YMVW","../query":"jOM9h","../utils":"eTk1n"}],jOM9h:[function(e,t,r){"use strict";const{base58btc:i}=e("multiformats/bases/base58"),n=e("../utils"),s=e("./run");t.exports=class{constructor(e,t,r){this.dht=e,this.key=t,this.makePath=r,this._log=n.logger(this.dht.peerId,"query:"+i.baseEncode(t)),this.running=!1,this._onStart=this._onStart.bind(this),this._onComplete=this._onComplete.bind(this)}async run(e){return this.dht._queryManager.running?0===e.length?(this._log.error("Running query with no peers"),{finalSet:new Set,paths:[]}):(this._run=new s(this),this._log(`query running with K=${this.dht.kBucketSize}, A=${this.dht.concurrency}, D=${Math.min(this.dht.disjointPaths,e.length)}`),this._run.once("start",this._onStart),this._run.once("complete",this._onComplete),this._run.execute(e)):(this._log.error("Attempt to run query after shutdown"),{finalSet:new Set,paths:[]})}_onStart(){this.running=!0,this._startTime=Date.now(),this._log("query:start"),this.dht._queryManager.queryStarted(this)}_onComplete(){this.stop()}stop(){this._log(`query:done in ${Date.now()-(this._startTime||0)}ms`),this._run&&this._log(`${this._run.errors.length} of ${this._run.peersSeen.size} peers errored (${this._run.errors.length/this._run.peersSeen.size*100}% fail rate)`),this.running&&(this.running=!1,this._run&&(this._run.removeListener("start",this._onStart),this._run.removeListener("complete",this._onComplete),this._run.stop()),this.dht._queryManager.queryCompleted(this))}}},{"multiformats/bases/base58":"4n7mA","../utils":"eTk1n","./run":"gHPwC"}],gHPwC:[function(e,t,r){"use strict";const i=e("../peer-list/peer-distance-list"),n=e("events"),s=e("./path"),o=e("./worker-queue"),a=e("../utils");t.exports=class extends n{constructor(e){super(),this.query=e,this.running=!1,this.workers=[],this.peersSeen=new Set,this.errors=[],this.peersQueried=null}stop(){if(this.running){this.running=!1;for(const e of this.workers)e.stop()}}async execute(e){const t=[],r=Math.min(this.query.dht.disjointPaths,e.length);for(let e=0;e{t[i%r].addInitialPeer(e)})),await this.executePaths(t);const i={finalSet:new Set(this.peersQueried&&this.peersQueried.peers),paths:[]};for(const e of t)e.res&&(e.res.pathComplete||e.res.queryComplete)&&(e.res.success=!0,i.paths.push(e.res));return i}async executePaths(e){this.running=!0,this.emit("start");try{await Promise.all(e.map((e=>e.execute())))}finally{this.stop(),this.emit("complete")}if(this.errors.length===this.peersSeen.size)throw this.errors[0]}async workerQueue(e){await this.init(),await this.startWorker(e)}async startWorker(e){const t=new o(this.query.dht,this,e,this.query._log);this.workers.push(t),await t.execute()}async init(){this.peersQueried||(this.peersQueriedPromise?await this.peersQueriedPromise:(this.peersQueriedPromise=(async()=>{const e=await a.convertBuffer(this.query.key);this.peersQueried=new i(e,this.query.dht.kBucketSize)})(),await this.peersQueriedPromise,delete this.peersQueriedPromise))}async continueQuerying(e){if(this.peersQueried&&this.peersQueried.lengthe.peerId))}async add(e){if(this.peerDistances.find((t=>s(t.peerId.id,e.id))))return;const t=await i.convertPeerId(e),r={peerId:e,distance:a(this.originDhtKey,t)};this.peerDistances.push(r),this.peerDistances.sort(((e,t)=>o(e.distance,t.distance))),this.peerDistances=this.peerDistances.slice(0,this.capacity)}async anyCloser(e){if(!e.length)return!1;if(!this.length)return!0;const t=await n(e,(e=>i.convertPeerId(e))),r=this.peerDistances[this.peerDistances.length-1].distance;for(const e of t){const t=a(this.originDhtKey,e);if(o(t,r)<0)return!0}return!1}}},{"../utils":"eTk1n","p-map":"ccWP1","uint8arrays/equals":"eY3cX","uint8arrays/compare":"2xv9i","uint8arrays/xor":"6wTd5"}],jyTZo:[function(e,t,r){"use strict";const i=e("../peer-list/peer-queue"),n=e("../utils");t.exports=class{constructor(e,t){if(this.run=e,this.queryFunc=n.withTimeout(t,3e4),!this.queryFunc)throw new Error("Path requires a `queryFn` to be specified");if("function"!=typeof this.queryFunc)throw new Error("Path expected `queryFn` to be a function. Got "+typeof this.queryFunc);this.initialPeers=[],this.peersToQuery=null,this.res=null}addInitialPeer(e){this.initialPeers.push(e)}async execute(){const e=await i.fromKey(this.run.query.key);this.peersToQuery=e,await Promise.all(this.initialPeers.map((e=>this.addPeerToQuery(e)))),await this.run.workerQueue(this)}async addPeerToQuery(e){this.run.query.dht._isSelf(e)||this.run.peersSeen.has(e.toB58String())||this.peersToQuery&&await this.peersToQuery.enqueue(e)}}},{"../peer-list/peer-queue":"2hgn1","../utils":"eTk1n"}],"2hgn1":[function(e,t,r){"use strict";const i=e("heap"),{xor:n}=e("uint8arrays/xor"),s=e("debug"),o=e("../utils"),a=s("libp2p:dht:peer-queue");class c{static async fromPeerId(e){const t=await o.convertPeerId(e);return new c(t)}static async fromKey(e){const t=await o.convertBuffer(e);return new c(t)}constructor(e){a("create: %b",e),this.from=e,this.heap=new i(o.xorCompare)}async enqueue(e){a("enqueue %s",e.toB58String());const t=await o.convertPeerId(e),r={id:e,distance:n(this.from,t)};this.heap.push(r)}dequeue(){const e=this.heap.pop();return a("dequeue %s",e.id.toB58String()),e.id}get length(){return this.heap.size()}}t.exports=c},{heap:"lhu6N","uint8arrays/xor":"6wTd5",debug:"bO5wM","../utils":"eTk1n"}],lhu6N:[function(e,t,r){t.exports=e("./lib/heap")},{"./lib/heap":"bAELV"}],bAELV:[function(e,t,r){(function(){var e,i,n,s,o,a,c,u,l,d,f,h,p,g,y,m,b;n=Math.floor,d=Math.min,i=function(e,t){return et?1:0},l=function(e,t,r,s,o){var a;if(null==r&&(r=0),null==o&&(o=i),r<0)throw new Error("lo must be non-negative");for(null==s&&(s=e.length);rr;0<=r?t++:t--)u.push(t);return u}.apply(this).reverse()).length;sg;0<=g?++f:--f)y.push(o(e,r));return y},g=function(e,t,r,n){var s,o,a;for(null==n&&(n=i),s=e[r];r>t&&n(s,o=e[a=r-1>>1])<0;)e[r]=o,r=a;return e[r]=s},y=function(e,t,r){var n,s,o,a,c;for(null==r&&(r=i),s=e.length,c=t,o=e[t],n=2*t+1;n{this.path.peersToQuery&&!this.path.peersToQuery.length&&(this.log("queue:drain"),this.stop())})),e.on("next",(()=>{this.running&&e.pendinge.running)).length),this.execution&&(e?this.execution.reject(e):this.execution.resolve()))}async execute(){this.running=!0,this.execution=null;const e=new Promise(((e,t)=>{this.execution={resolve:e,reject:t}}));this.fill(),await e}fill(){if(this.path.peersToQuery)for(;this.queue.pending+this.queue.size0;){const e=this.path.peersToQuery.dequeue();this.queuedPeerIds.add(e),this.queue.add((()=>this.processNext(e).catch((e=>{this.log.error("queue",e),this.stop(e)})).finally((()=>{this.queuedPeerIds.delete(e)}))))}}async processNext(e){if(!this.running)return;if(this.run.peersSeen.has(e.toB58String()))return;let t,r,i,n;try{t=await this.run.continueQuerying(this)}catch(e){r=e}if(this.running){if(r)throw r;if(t){if(!this.run.peersSeen.has(e.toB58String())){this.run.peersSeen.add(e.toB58String()),this.log("queue:work");try{i=await this.execQuery(e)}catch(e){n=e}if(this.running){if(this.log("queue:work:done",n,i),n)throw n;if(i&&i.queryComplete)return this.log("query:complete"),void this.run.stop();i&&i.pathComplete&&this.stop()}}}else this.stop()}}async execQuery(e){let t,r;try{t=await this.path.queryFunc(e)}catch(e){r=e}if(this.running)if(r)this.run.errors.push(r);else if(this.run.peersQueried&&await this.run.peersQueried.add(e),t){if(t.pathComplete||t.queryComplete)return this.path.res=t,{pathComplete:t.pathComplete,queryComplete:t.queryComplete};if(t.closerPeers&&t.closerPeers.length>0){const e=async e=>{this.dht._isSelf(e.id)||(this.dht._peerDiscovered(e.id,e.multiaddrs),await this.path.addPeerToQuery(e.id))};await Promise.all(t.closerPeers.map(e))}}}}},{"p-queue":"biPlv"}],bDSmy:[function(e,t,r){"use strict";const i=e("err-code"),n=e("p-timeout"),s=e("../constants"),o=e("../peer-list/limited-peer-list"),a=e("../message"),c=e("../query"),u=e("../utils");t.exports=e=>({async provide(t){e._log(`provide: ${t}`);const r=[];await e.providers.addProvider(t,e.peerId);const n=e.libp2p?e.libp2p.multiaddrs:[],s=new a(a.TYPES.ADD_PROVIDER,t.bytes,0);if(s.providerPeers=[{id:e.peerId,multiaddrs:n}],await u.mapParallel(e.getClosestPeers(t.bytes),(async function(i){e._log(`putProvider ${t} to ${i.toB58String()}`);try{await e.network.sendMessage(i,s)}catch(e){r.push(e)}})),r.length)throw i(new Error(`Failed to provide to ${r.length} of ${e.kBucketSize} peers`),"ERR_SOME_PROVIDES_FAILED",{errors:r})},async*findProviders(t,r={timeout:6e4,maxNumProviders:5}){const i=r.timeout||s.minute,l=r.maxNumProviders||s.K;e._log(`findProviders ${t}`);const d=new o(l);if((await e.providers.getProviders(t)).forEach((t=>{const r=e.peerStore.get(t);r?d.push({id:r.id,multiaddrs:r.addresses.map((e=>e.multiaddr))}):d.push({id:t,multiaddrs:[]})})),d.length>=l){for(const e of d.toArray())yield e;return}const f=[];const h=new c(e,t.bytes,(function(r,i){const n=u.pathSize(l-d.length,i),s=new o(n);return f.push(s),async function(r){const i=await(async(t,r)=>{const i=new a(a.TYPES.GET_PROVIDERS,r.bytes,0);return e.network.sendRequest(t,i)})(r,t),o=i.providerPeers;return e._log(`Found ${o.length} provider entries for ${t}`),o.forEach((e=>{s.push({...e})})),s.length>=n?{pathComplete:!0}:{closerPeers:i.closerPeers}}})),p=e.routingTable.closestPeers(t.bytes,e.kBucketSize);try{await n(h.run(p),i)}catch(e){if(e.name!==n.TimeoutError.name)throw e}finally{h.stop()}f.forEach((e=>{e.toArray().forEach((e=>{d.push(e)}))}));for(const e of d.toArray())yield e}})},{"err-code":"chZjB","p-timeout":"hP9Ay","../constants":"4YMVW","../peer-list/limited-peer-list":"lGgEB","../message":"dWtGc","../query":"jOM9h","../utils":"eTk1n"}],lGgEB:[function(e,t,r){"use strict";const i=e(".");t.exports=class extends i{constructor(e){super(),this.limit=e}push(e){return this.lengtht.id.equals(e)));return Boolean(t)}toArray(){return this.list.slice()}pop(){return this.list.pop()}get length(){return this.list.length}}},{}],nezkB:[function(e,t,r){"use strict";const i=e("err-code"),n=e("p-timeout"),s=e("peer-id"),o=e("libp2p-crypto"),{toString:a}=e("uint8arrays/to-string"),c=e("../constants"),u=e("../message"),l=e("../query"),d=e("../utils");t.exports=e=>{const t=async t=>{const r=d.keyForPublicKey(t),n=await(async(t,r)=>{const i=new u(u.TYPES.GET_VALUE,r,0);return e.network.sendRequest(t,i)})(t,r);if(!n.record||!n.record.value)throw i(new Error(`Node not responding with its public key: ${t.toB58String()}`),"ERR_INVALID_RECORD");const o=await s.createFromPubKey(n.record.value);if(!o.equals(t))throw i(new Error("public key does not match id"),"ERR_PUBLIC_KEY_DOES_NOT_MATCH_ID");return o.pubKey};return{async _findPeerSingle(t,r){e._log("findPeerSingle %s",t.toB58String());const i=new u(u.TYPES.FIND_NODE,r.id,0);return e.network.sendRequest(t,i)},async findPeer(t,r={timeout:6e4}){r.timeout=r.timeout||c.minute,e._log("findPeer %s",t.toB58String());const s=await(async t=>{e._log(`findPeerLocal ${t.toB58String()}`);const r=await e.routingTable.find(t),i=r&&e.peerStore.get(r);if(i)return{id:i.id,multiaddrs:i.addresses.map((e=>e.multiaddr))}})(t);if(null!=s)return e._log("found local"),s;const o=await d.convertPeerId(t),a=e.routingTable.closestPeers(o,e.kBucketSize);if(0===a.length)throw i(new Error("Peer lookup failed"),"ERR_LOOKUP_FAILED");if(a.find((e=>e.isEqual(t)))){const r=e.peerStore.get(t);if(r)return e._log("found in peerStore"),{id:r.id,multiaddrs:r.addresses.map((e=>e.multiaddr))}}const u=new l(e,t.id,(()=>async e=>{const r=await this._findPeerSingle(e,t),i=r.closerPeers.find((e=>e.id.isEqual(t)));return i?{peer:i,queryComplete:!0}:{closerPeers:r.closerPeers}}));let f;try{f=await n(u.run(a),r.timeout)}finally{u.stop()}let h=!1;if(f.paths.forEach((t=>{t.success&&t.peer&&(h=!0,e.peerStore.addressBook.add(t.peer.id,t.peer.multiaddrs))})),e._log("findPeer %s: %s",t.toB58String(),h),!h)throw i(new Error("No peer found"),"ERR_NOT_FOUND");const p=e.peerStore.get(t);if(!p)throw i(new Error("No peer found in peer store"),"ERR_NOT_FOUND");return{id:p.id,multiaddrs:p.addresses.map((e=>e.multiaddr))}},async*getClosestPeers(t,r={shallow:!1}){e._log("getClosestPeers to %b",t);const i=await d.convertBuffer(t),n=e.routingTable.closestPeers(i,e.kBucketSize),o=new l(e,t,(()=>async i=>{const n=await(async(t,r)=>(e._log(`closerPeersSingle ${a(t,"base32")} from ${r.toB58String()}`),(await e.peerRouting._findPeerSingle(r,new s(t))).closerPeers.filter((t=>!e._isSelf(t.id))).map((t=>(e.peerStore.addressBook.add(t.id,t.multiaddrs),t)))))(t,i);return{closerPeers:n,pathComplete:!!r.shallow||void 0}})),c=await o.run(n);if(!c||!c.finalSet)return[];const u=await d.sortClosestPeers(Array.from(c.finalSet),i);for(const t of u.slice(0,e.kBucketSize))yield t},async getPublicKey(r){e._log("getPublicKey %s",r.toB58String());const i=e.peerStore.get(r);if(i&&i.id.pubKey)return e._log("getPublicKey: found local copy"),i.id.pubKey;let n;try{n=await t(r)}catch(t){const i=d.keyForPublicKey(r),s=await e.get(i);n=o.keys.unmarshalPublicKey(s)}const a=new s(r.id,void 0,n),c=(i&&i.addresses||[]).map((e=>e.multiaddr));return e.peerStore.addressBook.add(a,c),e.peerStore.keyBook.set(a,n),n}}}},{"err-code":"chZjB","p-timeout":"hP9Ay","peer-id":"8Bdb3","libp2p-crypto":"bb1cb","uint8arrays/to-string":"hC8JB","../constants":"4YMVW","../message":"dWtGc","../query":"jOM9h","../utils":"eTk1n"}],lunE9:[function(e,t,r){"use strict";const i=e("hashlru"),n=e("varint"),s=e("peer-id"),{Key:o}=e("interface-datastore/key"),{default:a}=e("p-queue"),c=e("./constants"),u=e("./utils");function l(e){return e="string"==typeof e?e:u.encodeBase32(e.bytes),c.PROVIDERS_KEY_PREFIX+e}function d(e){const t=e.toString().split("/");if(4!==t.length)throw new Error("incorrectly formatted provider entry key in datastore: "+e);return{cid:t[2],peerId:t[3]}}function f(e){return n.decode(e)}t.exports=class{constructor(e,t,r){this.datastore=e,this._log=u.logger(t,"providers"),this.cleanupInterval=c.PROVIDERS_CLEANUP_INTERVAL,this.provideValidity=c.PROVIDERS_VALIDITY,this.lruCacheSize=r||c.PROVIDERS_LRU_CACHE_SIZE,this.providers=i(this.lruCacheSize),this.syncQueue=new a({concurrency:1})}start(){this._started||(this._started=!0,this._cleaner=setInterval((()=>this._cleanup()),this.cleanupInterval))}stop(){this._started=!1,this._cleaner&&(clearInterval(this._cleaner),this._cleaner=null)}_cleanup(){return this.syncQueue.add((async()=>{this._log("start cleanup");const e=Date.now();let t=0,r=0;const i=new Map,n=this.datastore.batch(),s=this.datastore.query({prefix:c.PROVIDERS_KEY_PREFIX});for await(const e of s)try{const{cid:s,peerId:o}=d(e.key),a=f(e.value),c=Date.now(),u=c-a,l=u>this.provideValidity;if(this._log("comparing: %d - %d = %d > %d %s",c,a,u,this.provideValidity,l?"(expired)":""),l){r++,n.delete(e.key);const t=i.get(s)||new Set;t.add(o),i.set(s,t)}t++}catch(e){this._log.error(e.message)}this._log("deleting %d / %d entries",r,t),i.size&&await n.commit();for(const[e,t]of i){const r=l(e),i=this.providers.get(r);if(i){for(const e of t)i.delete(e);0===i.size?this.providers.remove(r):this.providers.set(r,i)}}this._log("Cleanup successful (%dms)",Date.now()-e)}))}async _getProvidersMap(e){const t=l(e);let r=this.providers.get(t);return r||(r=await async function(e,t){const r=new Map,i=e.query({prefix:l(t)});for await(const e of i){const{peerId:t}=d(e.key);r.set(t,f(e.value))}return r}(this.datastore,e),this.providers.set(t,r)),r}async addProvider(e,t){return this.syncQueue.add((async()=>{this._log("addProvider %s",e.toString());const r=await this._getProvidersMap(e);this._log("loaded %s provs",r.size);const i=new Date;r.set(u.encodeBase32(t.id),i);const s=l(e);return this.providers.set(s,r),async function(e,t,r,i){const s=[l(t),"/",u.encodeBase32(r.id)].join(""),a=new o(s),c=Uint8Array.from(n.encode(i.getTime()));return e.put(a,c)}(this.datastore,e,t,i)}))}async getProviders(e){return this.syncQueue.add((async()=>{this._log("getProviders %s",e.toString());return[...(await this._getProvidersMap(e)).keys()].map((e=>new s(u.decodeBase32(e))))}))}}},{hashlru:"kBj5c",varint:"aN1CO","peer-id":"8Bdb3","interface-datastore/key":"9hGOz","p-queue":"biPlv","./constants":"4YMVW","./utils":"eTk1n"}],"9th0A":[function(e,t,r){"use strict";t.exports=class{constructor(){this.queries=new Set,this.running=!1}queryStarted(e){this.queries.add(e)}queryCompleted(e){this.queries.delete(e)}start(){this.running=!0}stop(){this.running=!1;for(const e of this.queries)e.stop();this.queries.clear()}}},{}],"2X3ZY":[function(e,t,r){"use strict";function i(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}Object.defineProperty(r,"__esModule",{value:!0});var n=i(e("ipns"));const s={func:(e,t)=>n.validator.validate(t,e)};r.selector=function(e,t){return n.validator.select(t[0],t[1])},r.validator=s},{ipns:"7rNAT"}],hla2J:[function(e,t,r){"use strict";const i=e("peer-id"),{Multiaddr:n}=e("multiaddr"),s=e("mafmt"),{EventEmitter:o}=e("events"),a=e("debug"),c=Object.assign(a("libp2p:bootstrap"),{error:a("libp2p:bootstrap:error")});(t.exports=class extends o{constructor(e={list:[]}){if(!e.list||!e.list.length)throw new Error("Bootstrap requires a list of peer addresses");super(),this._list=e.list,this._interval=e.interval||1e4,this._timer=null}start(){this._timer||(this._timer=setInterval((()=>this._discoverBootstrapPeers()),this._interval),c("Starting bootstrap node discovery"),this._discoverBootstrapPeers())}_discoverBootstrapPeers(){this._timer&&this._list.forEach((e=>{if(!s.P2P.matches(e))return c.error("Invalid multiaddr");const t=new n(e),r=t.getPeerId();if(!r)return void c.error("Invalid bootstrap multiaddr without peer id");const o=i.createFromB58String(r);try{this.emit("peer",{id:o,multiaddrs:[t]})}catch(e){c.error("Invalid bootstrap peer id",e)}}))}stop(){this._timer&&clearInterval(this._timer),this._timer=null}}).tag="bootstrap"},{"peer-id":"8Bdb3",multiaddr:"8Mu1u",mafmt:"l1lok",events:"g82pp",debug:"bO5wM"}],"757Qe":[function(e,t,r){"use strict";const i=e("debug"),n=Object.assign(i("libp2p"),{error:i("libp2p:err")}),{EventEmitter:s}=e("events"),o=e("err-code"),a=e("peer-id"),{Multiaddr:c}=e("multiaddr"),u=e("./peer-routing"),l=e("./content-routing"),d=e("./get-peer"),{validate:f}=e("./config"),{codes:h,messages:p}=e("./errors"),g=e("./address-manager"),y=e("./connection-manager"),m=e("./circuit/transport"),b=e("./circuit"),v=e("./dialer"),w=e("./keychain"),_=e("./metrics"),E=e("./transport-manager"),S=e("./upgrader"),T=e("./peer-store"),A=e("./pubsub-adapter"),k=e("./peer-store/persistent"),I=e("./registrar"),R=e("./ping"),P=e("./identify"),O=e("./nat-manager"),{updateSelfPeerRecord:C}=e("./record/utils");class j extends s{static async create(e){if(e.peerId)return new j(e);const t=await a.create();return e.peerId=t,new j(e)}constructor(e){if(super(),this._options=f(e),this.peerId=this._options.peerId,this.datastore=this._options.datastore,this.peerStore=this.datastore&&this._options.peerStore.persistence?new k({peerId:this.peerId,datastore:this.datastore,...this._options.peerStore}):new T({peerId:this.peerId}),this.addresses=this._options.addresses,this.addressManager=new g(this.peerId,this._options.addresses),this.addressManager.on("change:addresses",(()=>{C(this).catch((e=>{n.error("Error updating self peer record",e)}))})),this._modules=this._options.modules,this._config=this._options.config,this._transport=[],this._discovery=new Map,this.connectionManager=new y(this,{autoDial:this._config.peerDiscovery.autoDial,...this._options.connectionManager}),this._options.metrics.enabled&&(this.metrics=new _({...this._options.metrics,connectionManager:this.connectionManager})),this._options.keychain&&this._options.keychain.datastore){n("creating keychain");const e=w.generateOptions();this.keychain=new w(this._options.keychain.datastore,{...e,...this._options.keychain}),n("keychain constructed")}if(this.upgrader=new S({localPeer:this.peerId,metrics:this.metrics,onConnection:e=>this.connectionManager.onConnect(e),onConnectionEnd:e=>this.connectionManager.onDisconnect(e)}),this.transportManager=new E({libp2p:this,upgrader:this.upgrader,faultTolerance:this._options.transportManager.faultTolerance}),this.natManager=new O({peerId:this.peerId,addressManager:this.addressManager,transportManager:this.transportManager,...this._options.config.nat}),this.registrar=new I({peerStore:this.peerStore,connectionManager:this.connectionManager}),this.handle=this.handle.bind(this),this.registrar.handle=this.handle,!this._modules.connEncryption||!this._modules.connEncryption.length)throw o(new Error(p.CONN_ENCRYPTION_REQUIRED),h.CONN_ENCRYPTION_REQUIRED);if(this._modules.connEncryption.forEach((e=>{this.upgrader.cryptos.set(e.protocol,e)})),this.dialer=new v({transportManager:this.transportManager,peerStore:this.peerStore,...this._options.dialer}),this._modules.transport.forEach((e=>{const t=e.prototype[Symbol.toStringTag],r=this._config.transport[t];this.transportManager.add(t,e,r)})),this._config.relay.enabled&&(this.transportManager.add(m.prototype[Symbol.toStringTag],m),this.relay=new b(this)),this._modules.streamMuxer){this._modules.streamMuxer.forEach((e=>{this.upgrader.muxers.set(e.multicodec,e)})),this.identifyService=new P({libp2p:this}),this.handle(Object.values(P.getProtocolStr(this)),this.identifyService.handleMessage)}if(this._modules.connProtector)this.upgrader.protector=this._modules.connProtector;else if(void 0!==globalThis.process&&globalThis.process.env&&globalThis.process.env.LIBP2P_FORCE_PNET)throw new Error("Private network is enforced, but no protector was provided");if(this._modules.dht){const e=this._modules.dht;this._dht=new e({libp2p:this,dialer:this.dialer,peerId:this.peerId,peerStore:this.peerStore,registrar:this.registrar,datastore:this.datastore,...this._config.dht})}if(this._modules.pubsub){const e=this._modules.pubsub;this.pubsub=A(e,this,this._config.pubsub)}this.peerRouting=new u(this),this.contentRouting=new l(this),R.mount(this),this._onDiscoveryPeer=this._onDiscoveryPeer.bind(this)}emit(e,...t){return"error"!==e||this._events.error?super.emit(e,...t):(n.error(t),!1)}async start(){n("libp2p is starting");try{await this._onStarting(),await this._onDidStart(),n("libp2p has started")}catch(e){throw this.emit("error",e),n.error("An error occurred starting libp2p",e),await this.stop(),e}}async stop(){n("libp2p is stopping");try{this._isStarted=!1,this.relay&&this.relay.stop(),this.peerRouting.stop();for(const e of this._discovery.values())e.removeListener("peer",this._onDiscoveryPeer);await Promise.all(Array.from(this._discovery.values(),(e=>e.stop()))),this._discovery=new Map,await this.peerStore.stop(),await this.connectionManager.stop(),await Promise.all([this.pubsub&&this.pubsub.stop(),this._dht&&this._dht.stop(),this.metrics&&this.metrics.stop()]),await this.natManager.stop(),await this.transportManager.close(),R.unmount(this),this.dialer.destroy()}catch(e){e&&(n.error(e),this.emit("error",e))}n("libp2p has stopped")}async loadKeychain(){if(this.keychain)try{await this.keychain.findKeyByName("self")}catch(e){await this.keychain.importPeer("self",this.peerId)}}isStarted(){return this._isStarted}get connections(){return this.connectionManager.connections}dial(e,t){return this._dial(e,t)}async dialProtocol(e,t,r){if(!t||!t.length)throw o(new Error("no protocols were provided to open a stream"),h.ERR_INVALID_PROTOCOLS_FOR_STREAM);return(await this._dial(e,r)).newStream(t)}async _dial(e,t){const{id:r,multiaddrs:i}=d(e);if(r.equals(this.peerId))throw o(new Error("Cannot dial self"),h.ERR_DIALED_SELF);let n=this.connectionManager.get(r);return n?i&&this.peerStore.addressBook.add(r,i):n=await this.dialer.connectToPeer(e,t),n}get multiaddrs(){let e=this.addressManager.getAnnounceAddrs().map((e=>e.toString()));e.length||(e=this.transportManager.getAddrs().map((e=>e.toString()))),e=e.concat(this.addressManager.getObservedAddrs().map((e=>e.toString())));const t=this._options.addresses.announceFilter,r=new Set(e);return t(Array.from(r).map((e=>new c(e))))}async hangUp(e){const{id:t}=d(e),r=this.connectionManager.connections.get(t.toB58String());r&&await Promise.all(r.map((e=>e.close())))}ping(e){const{id:t,multiaddrs:r}=d(e);return R(this,r?r[0]:t)}handle(e,t){(e=Array.isArray(e)?e:[e]).forEach((e=>{this.upgrader.protocols.set(e,t)})),this.peerStore.protoBook.add(this.peerId,e)}unhandle(e){(e=Array.isArray(e)?e:[e]).forEach((e=>{this.upgrader.protocols.delete(e)})),this.peerStore.protoBook.remove(this.peerId,e)}async _onStarting(){const e=this.addressManager.getListenAddrs();await this.transportManager.listen(e),this.natManager.start(),await this.peerStore.start(),this._config.pubsub.enabled&&this.pubsub&&this.pubsub.start(),this._config.dht.enabled&&(this._dht&&this._dht.start(),this._dht.on("peer",this._onDiscoveryPeer)),this.metrics&&this.metrics.start()}async _onDidStart(){this._isStarted=!0,this.peerStore.on("peer",(e=>{this.emit("peer:discovery",e),this._maybeConnect(e)}));for(const e of this.peerStore.peers.values())this.emit("peer:discovery",e.id);this.connectionManager.start(),await this._setupPeerDiscovery(),this.relay&&this.relay.start(),this.peerRouting.start()}_onDiscoveryPeer(e){e.id.toB58String()!==this.peerId.toB58String()?(e.multiaddrs&&this.peerStore.addressBook.add(e.id,e.multiaddrs),e.protocols&&this.peerStore.protoBook.set(e.id,e.protocols)):n.error(new Error(h.ERR_DISCOVERED_SELF))}async _maybeConnect(e){if(!0===this._config.peerDiscovery.autoDial&&!this.connectionManager.get(e)){if((this._options.connectionManager.minConnections||0)>this.connectionManager.size){n("connecting to discovered peer %s",e.toB58String());try{await this.dialer.connectToPeer(e)}catch(t){n.error(`could not connect to discovered peer ${e.toB58String()} with ${t}`)}}}}async _setupPeerDiscovery(){const e=e=>{let t={enabled:!0};if(e.tag&&this._config.peerDiscovery&&this._config.peerDiscovery[e.tag]&&(t={...t,...this._config.peerDiscovery[e.tag]}),t.enabled&&!this._discovery.has(e.tag)){let r;r="function"==typeof e?new e(Object.assign({},t,{peerId:this.peerId,libp2p:this})):e,r.on("peer",this._onDiscoveryPeer),this._discovery.set(e.tag,r)}};for(const t of this._modules.peerDiscovery||[])e(t);for(const t of this.transportManager.getTransports())t.discovery&&e(t.discovery);await Promise.all(Array.from(this._discovery.values(),(e=>e.start())))}}t.exports=j},{debug:"bO5wM",events:"g82pp","err-code":"chZjB","peer-id":"8Bdb3",multiaddr:"8Mu1u","./peer-routing":"6b8mM","./content-routing":"hrRcA","./get-peer":"39nOe","./config":"aC5Bt","./errors":"3rNo5","./address-manager":"8bdzg","./connection-manager":"bZLZf","./circuit/transport":"2UjYE","./circuit":"hBCQx","./dialer":"kwWEi","./keychain":"f4Pg5","./metrics":"jy74B","./transport-manager":"7AeM0","./upgrader":"fdRaE","./peer-store":"hDFM8","./pubsub-adapter":"4AHRd","./peer-store/persistent":"kcKey","./registrar":"bUUbk","./ping":"azCOK","./identify":"jPbT6","./nat-manager":"1LCyC","./record/utils":"7dy3Z"}],"6b8mM":[function(e,t,r){"use strict";const i=e("debug"),n=Object.assign(i("libp2p:peer-routing"),{error:i("libp2p:peer-routing:err")}),s=e("err-code"),{storeAddresses:o,uniquePeers:a,requirePeers:c}=e("./content-routing/utils"),u=e("it-merge"),{pipe:l}=e("it-pipe"),d=e("it-first"),f=e("it-drain"),h=e("it-filter"),{setDelayedInterval:p,clearDelayedInterval:g}=e("set-delayed-interval");t.exports=class{constructor(e){this._peerId=e.peerId,this._peerStore=e.peerStore,this._routers=e._modules.peerRouting||[],e._dht&&e._config.dht.enabled&&this._routers.push(e._dht),this._refreshManagerOptions=e._options.peerRouting.refreshManager,this._findClosestPeersTask=this._findClosestPeersTask.bind(this)}start(){this._routers.length&&!this._timeoutId&&this._refreshManagerOptions.enabled&&(this._timeoutId=p(this._findClosestPeersTask,this._refreshManagerOptions.interval,this._refreshManagerOptions.bootDelay))}async _findClosestPeersTask(){try{await f(this.getClosestPeers(this._peerId.id))}catch(e){n.error(e)}}stop(){g(this._timeoutId)}async findPeer(e,t){if(!this._routers.length)throw s(new Error("No peer routers available"),"NO_ROUTERS_AVAILABLE");if(e.toB58String()===this._peerId.toB58String())throw s(new Error("Should not try to find self"),"ERR_FIND_SELF");const r=await l(u(...this._routers.map((r=>[r.findPeer(e,t)]))),(e=>h(e,Boolean)),(e=>o(e,this._peerStore)),(e=>d(e)));if(r)return r;throw s(new Error("not found"),"NOT_FOUND")}async*getClosestPeers(e,t={timeout:3e4}){if(!this._routers.length)throw s(new Error("No peer routers available"),"NO_ROUTERS_AVAILABLE");yield*l(u(...this._routers.map((r=>r.getClosestPeers(e,t)))),(e=>o(e,this._peerStore)),(e=>a(e)),(e=>c(e)))}}},{debug:"bO5wM","err-code":"chZjB","./content-routing/utils":"5SdWt","it-merge":"cPFu3","it-pipe":"giKBQ","it-first":"hBrkP","it-drain":"dKYhO","it-filter":"5LCTL","set-delayed-interval":"4OF34"}],"5SdWt":[function(e,t,r){"use strict";const i=e("err-code"),n=e("it-filter"),s=e("it-map"),o=e("it-take");t.exports={storeAddresses:function(e,t){return s(e,(e=>(t.addressBook.add(e.id,e.multiaddrs),e)))},uniquePeers:function(e){const t=new Set;return n(e,(e=>!t.has(e.id.toString())&&(t.add(e.id.toString()),!0)))},requirePeers:async function*(e,t=1){let r=0;for await(const t of e)r++,yield t;if(r{!async function(e,t,r){for(;i.get(r);){try{await e()}catch(e){setTimeout((()=>{throw e}),1);break}if(!i.get(r))break;await new Promise((e=>{const n=setTimeout(e,t);i.set(r,n)}))}}(e,t,n)}),r);return i.set(n,s),n},clearDelayedInterval:function(e){const t=i.get(e);t&&(clearTimeout(t),i.delete(e))}}},{}],hrRcA:[function(e,t,r){"use strict";const i=e("err-code"),{messages:n,codes:s}=e("../errors"),{storeAddresses:o,uniquePeers:a,requirePeers:c,maybeLimitSource:u}=e("./utils"),l=e("it-merge"),{pipe:d}=e("it-pipe");t.exports=class{constructor(e){this.libp2p=e,this.routers=e._modules.contentRouting||[],this.dht=e._dht,this.dht&&e._config.dht.enabled&&this.routers.push(this.dht)}async*findProviders(e,t={}){if(!this.routers.length)throw i(new Error("No content this.routers available"),"NO_ROUTERS_AVAILABLE");yield*d(l(...this.routers.map((r=>r.findProviders(e,t)))),(e=>o(e,this.libp2p.peerStore)),(e=>a(e)),(e=>u(e,t.maxNumProviders)),(e=>c(e)))}async provide(e){if(!this.routers.length)throw i(new Error("No content routers available"),"NO_ROUTERS_AVAILABLE");await Promise.all(this.routers.map((t=>t.provide(e))))}put(e,t,r){if(!this.libp2p.isStarted()||!this.dht.isStarted)throw i(new Error(n.NOT_STARTED_YET),s.DHT_NOT_STARTED);return this.dht.put(e,t,r)}get(e,t){if(!this.libp2p.isStarted()||!this.dht.isStarted)throw i(new Error(n.NOT_STARTED_YET),s.DHT_NOT_STARTED);return this.dht.get(e,t)}async getMany(e,t,r){if(!this.libp2p.isStarted()||!this.dht.isStarted)throw i(new Error(n.NOT_STARTED_YET),s.DHT_NOT_STARTED);return this.dht.getMany(e,t,r)}}},{"err-code":"chZjB","../errors":"3rNo5","./utils":"5SdWt","it-merge":"cPFu3","it-pipe":"giKBQ"}],"39nOe":[function(e,t,r){"use strict";const i=e("peer-id"),{Multiaddr:n}=e("multiaddr"),s=e("err-code"),{codes:o}=e("./errors");t.exports=function(e){let t;if("string"==typeof e&&(e=new n(e)),n.isMultiaddr(e)){t=e;const r=e.getPeerId();if(!r)throw s(new Error(`${e} does not have a valid peer type`),o.ERR_INVALID_MULTIADDR);try{e=i.createFromB58String(r)}catch(t){throw s(new Error(`${e} is not a valid peer type`),o.ERR_INVALID_MULTIADDR)}}return{id:e,multiaddrs:t?[t]:void 0}}},{"peer-id":"8Bdb3",multiaddr:"8Mu1u","err-code":"chZjB","./errors":"3rNo5"}],aC5Bt:[function(e,t,r){"use strict";const i=e("merge-options"),{dnsaddrResolver:n}=e("multiaddr/src/resolvers"),s=e("./constants"),{AGENT_VERSION:o}=e("./identify/consts"),a=e("./circuit/constants"),{publicAddressesFirst:c}=e("libp2p-utils/src/address-sort"),{FaultTolerance:u}=e("./transport-manager"),l={addresses:{listen:[],announce:[],noAnnounce:[],announceFilter:e=>e},connectionManager:{minConnections:25},transportManager:{faultTolerance:u.FATAL_ALL},dialer:{maxParallelDials:s.MAX_PARALLEL_DIALS,maxDialsPerPeer:s.MAX_PER_PEER_DIALS,dialTimeout:s.DIAL_TIMEOUT,resolvers:{dnsaddr:n},addressSorter:c},host:{agentVersion:o},metrics:{enabled:!1},peerStore:{persistence:!1,threshold:5},peerRouting:{refreshManager:{enabled:!0,interval:6e5,bootDelay:1e4}},config:{protocolPrefix:"ipfs",dht:{enabled:!1,kBucketSize:20,randomWalk:{enabled:!1,queriesPerPeriod:1,interval:3e5,timeout:1e4}},nat:{enabled:!0,ttl:7200,keepAlive:!0,gateway:null,externalIp:null,pmp:{enabled:!1}},peerDiscovery:{autoDial:!0},pubsub:{enabled:!0},relay:{enabled:!0,advertise:{bootDelay:a.ADVERTISE_BOOT_DELAY,enabled:!1,ttl:a.ADVERTISE_TTL},hop:{enabled:!1,active:!1},autoRelay:{enabled:!1,maxListeners:2}},transport:{}}};t.exports.validate=e=>{const t=i(l,e);if(t.modules.transport.length<1)throw new Error("'options.modules.transport' must contain at least 1 transport");return t}},{"merge-options":"fupyv","multiaddr/src/resolvers":"gzxe3","./constants":"92Vak","./identify/consts":"62PhM","./circuit/constants":"eXVcE","libp2p-utils/src/address-sort":"5uTJL","./transport-manager":"7AeM0"}],gzxe3:[function(e,t,r){"use strict";const i=e("../protocols-table"),{code:n}=i("dnsaddr");t.exports={dnsaddrResolver:async function(t){const r=new(e("./dns")),i=t.getPeerId(),[,s]=t.stringTuples().find((([e])=>e===n))||[];let o=(await r.resolveTxt(`_dnsaddr.${s}`)).flat().map((e=>e.split("=")[1]));return i&&(o=o.filter((e=>e.includes(i)))),o}}},{"../protocols-table":"5Z4cQ","./dns":"6yz41"}],"6yz41":[function(e,t,r){"use strict";const i=e("dns-over-http-resolver");t.exports=i},{"dns-over-http-resolver":"9Glvu"}],"9Glvu":[function(e,t,r){"use strict";const i=e("debug"),n=i("dns-over-http-resolver");n.error=i("dns-over-http-resolver:error");const s=e("receptacle"),o=e("./utils");class a{constructor({maxCache:e=100}={}){this._cache=new s({max:e}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"]}getServers(){return this._servers}_getShuffledServers(){const e=[].concat(this._servers);for(let t=e.length-1;t>0;t--){const r=Math.floor(Math.random()*t),i=e[t];e[t]=e[r],e[r]=i}return e}setServers(e){this._servers=e}resolve(e,t="A"){switch(t){case"A":return this.resolve4(e);case"AAAA":return this.resolve6(e);case"TXT":return this.resolveTxt(e);default:throw new Error(`${t} is not supported`)}}async resolve4(e){const t="A",r=this._cache.get(o.getCacheKey(e,t));if(r)return r;for(const r of this._getShuffledServers())try{const i=await o.fetch(o.buildResource({serverResolver:r,hostname:e,recordType:t})),n=await i.json(),s=n.Answer.map((e=>e.data)),a=Math.min(n.Answer.map((e=>e.TTL)));return this._cache.set(o.getCacheKey(e,t),s,{ttl:a}),s}catch(t){n.error(`${r} could not resolve ${e} record A`)}throw new Error(`Could not resolve ${e} record A`)}async resolve6(e){const t="AAAA",r=this._cache.get(o.getCacheKey(e,t));if(r)return r;for(const r of this._getShuffledServers())try{const i=await o.fetch(o.buildResource({serverResolver:r,hostname:e,recordType:t})),n=await i.json(),s=n.Answer.map((e=>e.data)),a=Math.min(n.Answer.map((e=>e.TTL)));return this._cache.set(o.getCacheKey(e,t),s,{ttl:a}),s}catch(t){n.error(`${r} could not resolve ${e} record AAAA`)}throw new Error(`Could not resolve ${e} record AAAA`)}async resolveTxt(e){const t="TXT",r=this._cache.get(o.getCacheKey(e,t));if(r)return r;for(const r of this._getShuffledServers())try{const i=await o.fetch(o.buildResource({serverResolver:r,hostname:e,recordType:t})),n=await i.json(),s=n.Answer.map((e=>[e.data.replace(/['"]+/g,"")])),a=Math.min(n.Answer.map((e=>e.TTL)));return this._cache.set(o.getCacheKey(e,t),s,{ttl:a}),s}catch(t){n.error(`${r} could not resolve ${e} record TXT`)}throw new Error(`Could not resolve ${e} record TXT`)}}a.Resolver=a,t.exports=a},{debug:"bO5wM",receptacle:"6A2bX","./utils":"jAL77"}],"6A2bX":[function(e,t,r){"use strict";t.exports=o;var i=e("ms"),n=o.prototype,s=new Date%1e9;function o(e){e=e||{},this.id=e.id||(1e9*Math.random()>>>0)+s++,this.max=e.max||1/0,this.items=e.items||[],this._lookup={},this.size=this.items.length,this.lastModified=new Date(e.lastModified||new Date);for(var t,r,i=this.items.length;i--;)t=this.items[i],r=new Date(t.expires)-new Date,this._lookup[t.key]=t,r>0?this.expire(t.key,r):r<=0&&this.delete(t.key)}n.has=function(e){return e in this._lookup},n.get=function(e){if(!this.has(e))return null;var t=this._lookup[e];return t.refresh&&this.expire(e,t.refresh),this.items.splice(this.items.indexOf(t),1),this.items.push(t),t.value},n.meta=function(e){if(!this.has(e))return null;var t=this._lookup[e];return"meta"in t?t.meta:null},n.set=function(e,t,r){var i=this._lookup[e],n=this._lookup[e]={key:e,value:t};return this.lastModified=new Date,i?(clearTimeout(i.timeout),this.items.splice(this.items.indexOf(i),1,n)):(this.size>=this.max&&this.delete(this.items[0].key),this.items.push(n),this.size++),r&&("ttl"in r&&this.expire(e,r.ttl),"meta"in r&&(n.meta=r.meta),r.refresh&&(n.refresh=r.ttl)),this},n.delete=function(e){var t=this._lookup[e];return!!t&&(this.lastModified=new Date,this.items.splice(this.items.indexOf(t),1),clearTimeout(t.timeout),delete this._lookup[e],this.size--,this)},n.expire=function(e,t){var r=t||0,n=this._lookup[e];if(!n)return this;if("string"==typeof r&&(r=i(t)),"number"!=typeof r)throw new TypeError("Expiration time must be a string or number.");return clearTimeout(n.timeout),n.timeout=setTimeout(this.delete.bind(this,n.key),r),n.expires=Number(new Date)+r,this},n.clear=function(){for(var e=this.items.length;e--;)this.delete(this.items[e].key);return this},n.toJSON=function(){for(var e,t=new Array(this.items.length),r=t.length;r--;)e=this.items[r],t[r]={key:e.key,meta:e.meta,value:e.value,expires:e.expires,refresh:e.refresh};return{id:this.id,max:isFinite(this.max)?this.max:void 0,lastModified:this.lastModified,items:t}}},{ms:"kjKOC"}],kjKOC:[function(e,t,r){var i=1e3,n=60*i,s=60*n,o=24*s,a=7*o,c=365.25*o;function u(e,t,r,i){var n=t>=1.5*r;return Math.round(e/r)+" "+i+(n?"s":"")}t.exports=function(e,t){t=t||{};var r,l,d=typeof e;if("string"===d&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return r*c;case"weeks":case"week":case"w":return r*a;case"days":case"day":case"d":return r*o;case"hours":case"hour":case"hrs":case"hr":case"h":return r*s;case"minutes":case"minute":case"mins":case"min":case"m":return r*n;case"seconds":case"second":case"secs":case"sec":case"s":return r*i;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===d&&isFinite(e))return t.long?(r=e,(l=Math.abs(r))>=o?u(r,l,o,"day"):l>=s?u(r,l,s,"hour"):l>=n?u(r,l,n,"minute"):l>=i?u(r,l,i,"second"):r+" ms"):function(e){var t=Math.abs(e);return t>=o?Math.round(e/o)+"d":t>=s?Math.round(e/s)+"h":t>=n?Math.round(e/n)+"m":t>=i?Math.round(e/i)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],jAL77:[function(e,t,r){"use strict";const{default:i,Headers:n}=e("native-fetch");t.exports={buildResource:function({serverResolver:e,hostname:t,recordType:r}){return`${e}?name=${t}&type=${r}`},fetch:function(e){return i(e,{headers:new n({accept:"application/dns-json"})})},getCacheKey:function(e,t){return`${t}_${e}`}}},{"native-fetch":"kdks4"}],"92Vak":[function(e,t,r){"use strict";t.exports={DIAL_TIMEOUT:3e4,MAX_PARALLEL_DIALS:100,MAX_PER_PEER_DIALS:4,MAX_ADDRS_TO_DIAL:25,METRICS:{computeThrottleMaxQueueSize:1e3,computeThrottleTimeout:2e3,movingAverageIntervals:[6e4,3e5,9e5],maxOldPeersRetention:50}}},{}],"62PhM":[function(e,t,r){"use strict";const i=e("../../package.json").version;t.exports.PROTOCOL_VERSION="ipfs/0.1.0",t.exports.AGENT_VERSION=`js-libp2p/${i}`,t.exports.MULTICODEC_IDENTIFY="/ipfs/id/1.0.0",t.exports.MULTICODEC_IDENTIFY_PUSH="/ipfs/id/push/1.0.0",t.exports.IDENTIFY_PROTOCOL_VERSION="0.1.0",t.exports.MULTICODEC_IDENTIFY_PROTOCOL_NAME="id",t.exports.MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME="id/push",t.exports.MULTICODEC_IDENTIFY_PROTOCOL_VERSION="1.0.0",t.exports.MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION="1.0.0"},{"../../package.json":"cq0b4"}],cq0b4:[function(e,t,r){t.exports=JSON.parse('{"name":"libp2p","version":"0.33.0","description":"JavaScript implementation of libp2p, a modular peer to peer network stack","leadMaintainer":"Jacob Heun ","main":"src/index.js","types":"dist/src/index.d.ts","typesVersions":{"*":{"src/*":["dist/src/*","dist/src/*/index"]}},"files":["dist","src"],"scripts":{"lint":"aegir lint","build":"aegir build","build:proto":"npm run build:proto:circuit && npm run build:proto:identify && npm run build:proto:plaintext && npm run build:proto:address-book && npm run build:proto:proto-book && npm run build:proto:peer-record && npm run build:proto:envelope","build:proto:circuit":"pbjs -t static-module -w commonjs -r libp2p-circuit --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/circuit/protocol/index.js ./src/circuit/protocol/index.proto","build:proto:identify":"pbjs -t static-module -w commonjs -r libp2p-identify --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/identify/message.js ./src/identify/message.proto","build:proto:plaintext":"pbjs -t static-module -w commonjs -r libp2p-plaintext --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/insecure/proto.js ./src/insecure/proto.proto","build:proto:address-book":"pbjs -t static-module -w commonjs -r libp2p-address-book --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/peer-store/persistent/pb/address-book.js ./src/peer-store/persistent/pb/address-book.proto","build:proto:proto-book":"pbjs -t static-module -w commonjs -r libp2p-proto-book --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/peer-store/persistent/pb/proto-book.js ./src/peer-store/persistent/pb/proto-book.proto","build:proto:peer-record":"pbjs -t static-module -w commonjs -r libp2p-peer-record --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/record/peer-record/peer-record.js ./src/record/peer-record/peer-record.proto","build:proto:envelope":"pbjs -t static-module -w commonjs -r libp2p-envelope --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/record/envelope/envelope.js ./src/record/envelope/envelope.proto","build:proto-types":"npm run build:proto-types:circuit && npm run build:proto-types:identify && npm run build:proto-types:plaintext && npm run build:proto-types:address-book && npm run build:proto-types:proto-book && npm run build:proto-types:peer-record && npm run build:proto-types:envelope","build:proto-types:circuit":"pbts -o src/circuit/protocol/index.d.ts src/circuit/protocol/index.js","build:proto-types:identify":"pbts -o src/identify/message.d.ts src/identify/message.js","build:proto-types:plaintext":"pbts -o src/insecure/proto.d.ts src/insecure/proto.js","build:proto-types:address-book":"pbts -o src/peer-store/persistent/pb/address-book.d.ts src/peer-store/persistent/pb/address-book.js","build:proto-types:proto-book":"pbts -o src/peer-store/persistent/pb/proto-book.d.ts src/peer-store/persistent/pb/proto-book.js","build:proto-types:peer-record":"pbts -o src/record/peer-record/peer-record.d.ts src/record/peer-record/peer-record.js","build:proto-types:envelope":"pbts -o src/record/envelope/envelope.d.ts src/record/envelope/envelope.js","test":"aegir test","test:ts":"aegir build --no-bundle && npm run test --prefix test/ts-use","test:node":"aegir test -t node -f \\"./test/**/*.{node,spec}.js\\"","test:browser":"aegir test -t browser","test:examples":"cd examples && npm run test:all","prepare":"aegir build --no-bundle","release":"aegir release -t node -t browser","release-minor":"aegir release --type minor -t node -t browser","release-major":"aegir release --type major -t node -t browser","coverage":"nyc --reporter=text --reporter=lcov npm run test:node"},"repository":{"type":"git","url":"https://github.com/libp2p/js-libp2p.git"},"keywords":["libp2p","network","p2p","peer","peer-to-peer","IPFS"],"bugs":{"url":"https://github.com/libp2p/js-libp2p/issues"},"homepage":"https://libp2p.io","license":"MIT","engines":{"node":">=14.0.0"},"browser":{"@motrix/nat-api":false},"eslintConfig":{"extends":"ipfs","ignorePatterns":["!.aegir.js","test/ts-use"]},"dependencies":{"abortable-iterator":"^3.0.0","@motrix/nat-api":"^0.3.1","@vascosantos/moving-average":"^1.1.0","abort-controller":"^3.0.0","aggregate-error":"^3.1.0","any-signal":"^2.1.1","bignumber.js":"^9.0.1","class-is":"^1.1.0","debug":"^4.3.1","err-code":"^3.0.0","es6-promisify":"^7.0.0","events":"^3.3.0","hashlru":"^2.3.0","interface-datastore":"^6.0.2","it-all":"^1.0.4","it-buffer":"^0.1.2","it-drain":"^1.0.3","it-filter":"^1.0.1","it-first":"^1.0.4","it-handshake":"^2.0.0","it-length-prefixed":"^5.0.2","it-map":"^1.0.4","it-merge":"^1.0.0","it-pipe":"^1.1.0","it-take":"^1.0.0","libp2p-crypto":"^0.19.4","libp2p-interfaces":"^1.0.0","libp2p-utils":"^0.4.0","mafmt":"^10.0.0","merge-options":"^3.0.4","multiaddr":"^10.0.0","multiformats":"^9.0.0","multistream-select":"^2.0.0","mutable-proxy":"^1.0.0","node-forge":"^0.10.0","p-any":"^3.0.0","p-fifo":"^1.0.0","p-retry":"^4.4.0","p-settle":"^4.1.1","peer-id":"^0.15.0","private-ip":"^2.1.0","protobufjs":"^6.10.2","retimer":"^3.0.0","sanitize-filename":"^1.6.3","set-delayed-interval":"^1.0.0","streaming-iterables":"^6.0.0","timeout-abort-controller":"^1.1.1","uint8arrays":"^3.0.0","varint":"^6.0.0","wherearewe":"^1.0.0","xsalsa20":"^1.1.0"},"devDependencies":{"@chainsafe/libp2p-noise":"^4.0.0","@nodeutils/defaults-deep":"^1.1.0","@types/es6-promisify":"^6.0.0","@types/node":"^16.0.1","@types/node-forge":"^0.10.1","@types/varint":"^6.0.0","aegir":"^33.1.1","buffer":"^6.0.3","datastore-core":"^6.0.7","delay":"^5.0.0","interop-libp2p":"^0.4.0","into-stream":"^7.0.0","ipfs-http-client":"^52.0.2","it-concat":"^2.0.0","it-pair":"^1.0.0","it-pushable":"^1.4.0","libp2p":".","libp2p-bootstrap":"^0.13.0","libp2p-delegated-content-routing":"^0.11.0","libp2p-delegated-peer-routing":"^0.10.0","libp2p-floodsub":"^0.27.0","libp2p-gossipsub":"^0.11.0","libp2p-interfaces-compliance-tests":"^1.0.0","libp2p-kad-dht":"^0.24.2","libp2p-mdns":"^0.17.0","libp2p-mplex":"^0.10.1","libp2p-tcp":"^0.17.0","libp2p-webrtc-star":"^0.23.0","libp2p-websockets":"^0.16.0","nock":"^13.0.3","p-defer":"^3.0.0","p-times":"^3.0.0","p-wait-for":"^3.2.0","rimraf":"^3.0.2","sinon":"^11.1.1","util":"^0.12.3"},"contributors":["Vasco Santos ","David Dias ","Jacob Heun ","Alex Potsides ","Alan Shaw ","Cayman ","Pedro Teixeira ","Friedel Ziegelmayer ","Maciej Krüger ","Hugo Dias ","Chris Dostert ","dirkmc ","Volker Mische ","zeim839 <50573884+zeim839@users.noreply.github.com>","Richard Littauer ","a1300 ","Ryan Bell ","ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ ","Franck Royer ","Thomas Eizinger ","Giovanni T. Parra ","acolytec3 <17355484+acolytec3@users.noreply.github.com>","Elven ","Andrew Nesbitt ","Samlior ","Didrik Nordström ","RasmusErik Voel Jensen ","Robert Kiel ","Smite Chow ","Soeren ","Sönke Hahn ","TJKoury ","Tiago Alves ","XiaoZhang ","Yusef Napora ","Zane Starr ","ebinks ","Aditya Bose <13054902+adbose@users.noreply.github.com>","isan_rivkin ","mayerwin ","mcclure ","phillmac ","robertkiel ","shresthagrawal <34920931+shresthagrawal@users.noreply.github.com>","swedneck <40505480+swedneck@users.noreply.github.com>","greenSnot ","Aleksei ","Bernd Strehl ","Chris Bratlien ","Cindy Wu ","Daijiro Wachi ","Diogo Silva ","Dmitriy Ryajov ","Ethan Lam ","Fei Liu ","Felipe Martins ","Florian-Merle ","Francis Gulotta ","Guy Sviry <32539816+guysv@users.noreply.github.com>","Henrique Dias ","Irakli Gozalishvili ","Joel Gustafson ","John Rees ","João Santos ","Julien Bouquillon ","Kevin Kwok ","Kevin Lacker ","Lars Gierth ","Leask Wong ","Marcin Tojek ","Michael Burns <5170+mburns@users.noreply.github.com>","Miguel Mota ","Nuno Nogueira ","Philipp Muens "]}')},{}],eXVcE:[function(e,t,r){"use strict";t.exports={ADVERTISE_BOOT_DELAY:9e5,ADVERTISE_TTL:18e5,CIRCUIT_PROTO_CODE:290,HOP_METADATA_KEY:"hop_relay",HOP_METADATA_VALUE:"true",RELAY_RENDEZVOUS_NS:"/libp2p/relay"}},{}],"5uTJL":[function(e,t,r){"use strict";const i=e("./multiaddr/is-private");function n(e,t){const r=i(e.multiaddr),n=i(t.multiaddr);return r&&!n?1:!r&&n||e.isCertified&&!t.isCertified?-1:!e.isCertified&&t.isCertified?1:0}t.exports.publicAddressesFirst=function(e){return[...e].sort(n)}},{"./multiaddr/is-private":"gME6b"}],gME6b:[function(e,t,r){"use strict";const i=e("private-ip");t.exports=function(e){const{address:t}=e.nodeAddress();return i(t)}},{"private-ip":"kXRph"}],kXRph:[function(e,t,r){"use strict";t.exports=e("./lib").default},{"./lib":"hAqtf"}],hAqtf:[function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});const n=e("netmask"),s=i(e("ip-regex")),o=i(e("is-ip")),a=e("ipaddr.js"),c=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"].map((e=>new n.Netmask(e)));function u(e){return/^::$/.test(e)||/^::1$/.test(e)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(e)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(e)||/^ff([0-9a-fA-F]{2,2}):/i.test(e)}r.default=e=>{if(a.isValid(e)){const t=a.parse(e);if("ipv4"===t.kind())return function(e){for(let t of c)if(t.contains(e))return!0;return!1}(t.toNormalizedString());if("ipv6"===t.kind())return u(e)}else if(o.default(e)&&s.default.v6().test(e))return u(e)}},{netmask:"2iaUq","ip-regex":"foGrp","is-ip":"arQx3","ipaddr.js":"8jiec"}],"2iaUq":[function(e,t,r){(function(){var e,t,i,n,s,o,a,c;c=function(e){return[(-16777216&e)>>>24,(16711680&e)>>>16,(65280&e)>>>8,255&e].join(".")},a=function(e){var r,i,n,s,o,a;for(r=[],n=s=0;s<=3&&0!==e.length;n=++s){if(n>0){if("."!==e[0])throw new Error("Invalid IP");e=e.substring(1)}o=(a=t(e))[0],i=a[1],e=e.substring(i),r.push(o)}if(0!==e.length)throw new Error("Invalid IP");switch(r.length){case 1:if(r[0]>4294967295)throw new Error("Invalid IP");return r[0]>>>0;case 2:if(r[0]>255||r[1]>16777215)throw new Error("Invalid IP");return(r[0]<<24|r[1])>>>0;case 3:if(r[0]>255||r[1]>255||r[2]>65535)throw new Error("Invalid IP");return(r[0]<<24|r[1]<<16|r[2])>>>0;case 4:if(r[0]>255||r[1]>255||r[2]>255||r[3]>255)throw new Error("Invalid IP");return(r[0]<<24|r[1]<<16|r[2]<<8|r[3])>>>0;default:throw new Error("Invalid IP")}},n=(i=function(e){return e.charCodeAt(0)})("0"),o=i("a"),s=i("A"),t=function(e){var t,r,a,c,u;for(c=0,t=10,r="9",a=0,e.length>1&&"0"===e[a]&&("x"===e[a+1]||"X"===e[a+1]?(a+=2,t=16):"0"<=e[a+1]&&e[a+1]<="9"&&(a++,t=8,r="7")),u=a;a>>0;else{if(16!==t)break;if("a"<=e[a]&&e[a]<="f")c=c*t+(10+i(e[a])-o)>>>0;else{if(!("A"<=e[a]&&e[a]<="F"))break;c=c*t+(10+i(e[a])-s)>>>0}}if(c>4294967295)throw new Error("too large");a++}if(a===u)throw new Error("empty octet");return[c,a]},e=function(){function e(e,t){var r,i,n;if("string"!=typeof e)throw new Error("Missing `net' parameter");if(t||(n=e.split("/",2),e=n[0],t=n[1]),t||(t=32),"string"==typeof t&&t.indexOf(".")>-1){try{this.maskLong=a(t)}catch(e){throw e,new Error("Invalid mask: "+t)}for(r=i=32;i>=0;r=--i)if(this.maskLong===4294967295<<32-r>>>0){this.bitmask=r;break}}else{if(!t&&0!==t)throw new Error("Invalid mask: empty");this.bitmask=parseInt(t,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0)}try{this.netLong=(a(e)&this.maskLong)>>>0}catch(t){throw t,new Error("Invalid net address: "+e)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+t);this.size=Math.pow(2,32-this.bitmask),this.base=c(this.netLong),this.mask=c(this.maskLong),this.hostmask=c(~this.maskLong),this.first=this.bitmask<=30?c(this.netLong+1):this.base,this.last=this.bitmask<=30?c(this.netLong+this.size-2):c(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?c(this.netLong+this.size-1):void 0}return e.prototype.contains=function(t){return"string"==typeof t&&(t.indexOf("/")>0||4!==t.split(".").length)&&(t=new e(t)),t instanceof e?this.contains(t.base)&&this.contains(t.broadcast||t.last):(a(t)&this.maskLong)>>>0==(this.netLong&this.maskLong)>>>0},e.prototype.next=function(t){return null==t&&(t=1),new e(c(this.netLong+this.size*t),this.mask)},e.prototype.forEach=function(e){var t,r,i;for(i=a(this.first),r=a(this.last),t=0;i<=r;)e(c(i),i,t),t++,i++},e.prototype.toString=function(){return this.base+"/"+this.bitmask},e}(),r.ip2long=a,r.long2ip=c,r.Netmask=e}).call(this)},{}],"8jiec":[function(e,t,r){!function(e){const r="(0?\\d+|0x[a-f0-9]+)",i={fourOctet:new RegExp(`^${r}\\.${r}\\.${r}\\.${r}$`,"i"),threeOctet:new RegExp(`^${r}\\.${r}\\.${r}$`,"i"),twoOctet:new RegExp(`^${r}\\.${r}$`,"i"),longValue:new RegExp(`^${r}$`,"i")},n=new RegExp("^0[0-7]+$","i"),s=new RegExp("^0x[a-f0-9]+$","i"),o="%[0-9a-z]{1,}",a="(?:[0-9a-f]+::?)+",c={zoneIndex:new RegExp(o,"i"),native:new RegExp(`^(::)?(${a})?([0-9a-f]+)?(::)?(${o})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${r}\\.${r}\\.${r}\\.${r}(${o})?)$`,"i"),transitional:new RegExp(`^((?:${a})|(?:::)(?:${a})?)${r}\\.${r}\\.${r}\\.${r}(${o})?$`,"i")};function u(e,t){if(e.indexOf("::")!==e.lastIndexOf("::"))return null;let r,i,n=0,s=-1,o=(e.match(c.zoneIndex)||[])[0];for(o&&(o=o.substring(1),e=e.replace(/%.+$/,""));(s=e.indexOf(":",s+1))>=0;)n++;if("::"===e.substr(0,2)&&n--,"::"===e.substr(-2,2)&&n--,n>t)return null;for(i=t-n,r=":";i--;)r+="0:";return":"===(e=e.replace("::",r))[0]&&(e=e.slice(1)),":"===e[e.length-1]&&(e=e.slice(0,-1)),{parts:t=function(){const t=e.split(":"),r=[];for(let e=0;e0;){if(n=r-i,n<0&&(n=0),e[s]>>n!=t[s]>>n)return!1;i-=r,s+=1}return!0}function d(e){if(s.test(e))return parseInt(e,16);if("0"===e[0]&&!isNaN(parseInt(e[1],10))){if(n.test(e))return parseInt(e,8);throw new Error(`ipaddr: cannot parse ${e} as octal`)}return parseInt(e,10)}function f(e,t){for(;e.length=0;i-=1){if(n=this.octets[i],!(n in r))return null;if(s=r[n],t&&0!==s)return null;8!==s&&(t=!0),e+=s}return 32-e},e.prototype.range=function(){return h.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){return this.octets.slice(0)},e.prototype.toIPv4MappedAddress=function(){return h.IPv6.parse(`::ffff:${this.toString()}`)},e.prototype.toNormalizedString=function(){return this.toString()},e.prototype.toString=function(){return this.octets.join(".")},e}(),h.IPv4.broadcastAddressFromCIDR=function(e){try{const t=this.parseCIDR(e),r=t[0].toByteArray(),i=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),n=[];let s=0;for(;s<4;)n.push(parseInt(r[s],10)|255^parseInt(i[s],10)),s++;return new this(n)}catch(e){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},h.IPv4.isIPv4=function(e){return null!==this.parser(e)},h.IPv4.isValid=function(e){try{return new this(this.parser(e)),!0}catch(e){return!1}},h.IPv4.isValidFourPartDecimal=function(e){return!(!h.IPv4.isValid(e)||!e.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},h.IPv4.networkAddressFromCIDR=function(e){let t,r,i,n,s;try{for(t=this.parseCIDR(e),i=t[0].toByteArray(),s=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),n=[],r=0;r<4;)n.push(parseInt(i[r],10)&parseInt(s[r],10)),r++;return new this(n)}catch(e){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},h.IPv4.parse=function(e){const t=this.parser(e);if(null===t)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(t)},h.IPv4.parseCIDR=function(e){let t;if(t=e.match(/^(.+)\/(\d+)$/)){const e=parseInt(t[2]);if(e>=0&&e<=32){const r=[this.parse(t[1]),e];return Object.defineProperty(r,"toString",{value:function(){return this.join("/")}}),r}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},h.IPv4.parser=function(e){let t,r,n;if(t=e.match(i.fourOctet))return function(){const e=t.slice(1,6),i=[];for(let t=0;t4294967295||n<0)throw new Error("ipaddr: address outside defined range");return function(){const e=[];let t;for(t=0;t<=24;t+=8)e.push(n>>t&255);return e}().reverse()}return(t=e.match(i.twoOctet))?function(){const e=t.slice(1,4),r=[];if(n=d(e[1]),n>16777215||n<0)throw new Error("ipaddr: address outside defined range");return r.push(d(e[0])),r.push(n>>16&255),r.push(n>>8&255),r.push(255&n),r}():(t=e.match(i.threeOctet))?function(){const e=t.slice(1,5),r=[];if(n=d(e[2]),n>65535||n<0)throw new Error("ipaddr: address outside defined range");return r.push(d(e[0])),r.push(d(e[1])),r.push(n>>8&255),r.push(255&n),r}():null},h.IPv4.subnetMaskFromPrefixLength=function(e){if((e=parseInt(e))<0||e>32)throw new Error("ipaddr: invalid IPv4 prefix length");const t=[0,0,0,0];let r=0;const i=Math.floor(e/8);for(;r=0;s-=1){if(i=this.parts[s],!(i in r))return null;if(n=r[i],t&&0!==n)return null;16!==n&&(t=!0),e+=n}return 128-e},e.prototype.range=function(){return h.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){let e;const t=[],r=this.parts;for(let i=0;i>8),t.push(255&e);return t},e.prototype.toFixedLengthString=function(){const e=function(){const e=[];for(let t=0;t>8,255&t,r>>8,255&r])},e.prototype.toNormalizedString=function(){const e=function(){const e=[];for(let t=0;tn&&(i=r.index,n=r[0].length);return n<0?t:`${t.substring(0,i)}::${t.substring(i+n)}`},e.prototype.toString=function(){return this.toNormalizedString().replace(/((^|:)(0(:|$))+)/,"::")},e}(),h.IPv6.broadcastAddressFromCIDR=function(e){try{const t=this.parseCIDR(e),r=t[0].toByteArray(),i=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),n=[];let s=0;for(;s<16;)n.push(parseInt(r[s],10)|255^parseInt(i[s],10)),s++;return new this(n)}catch(e){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${e})`)}},h.IPv6.isIPv6=function(e){return null!==this.parser(e)},h.IPv6.isValid=function(e){if("string"==typeof e&&-1===e.indexOf(":"))return!1;try{const t=this.parser(e);return new this(t.parts,t.zoneId),!0}catch(e){return!1}},h.IPv6.networkAddressFromCIDR=function(e){let t,r,i,n,s;try{for(t=this.parseCIDR(e),i=t[0].toByteArray(),s=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),n=[],r=0;r<16;)n.push(parseInt(i[r],10)&parseInt(s[r],10)),r++;return new this(n)}catch(e){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${e})`)}},h.IPv6.parse=function(e){const t=this.parser(e);if(null===t.parts)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(t.parts,t.zoneId)},h.IPv6.parseCIDR=function(e){let t,r,i;if((r=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(r[2]),t>=0&&t<=128))return i=[this.parse(r[1]),t],Object.defineProperty(i,"toString",{value:function(){return this.join("/")}}),i;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},h.IPv6.parser=function(e){let t,r,i,n,s,o;if(i=e.match(c.deprecatedTransitional))return this.parser(`::ffff:${i[1]}`);if(c.native.test(e))return u(e,8);if((i=e.match(c.transitional))&&(o=i[6]||"",t=u(i[1].slice(0,-1)+o,6),t.parts)){for(s=[parseInt(i[2]),parseInt(i[3]),parseInt(i[4]),parseInt(i[5])],r=0;r128)throw new Error("ipaddr: invalid IPv6 prefix length");const t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let r=0;const i=Math.floor(e/8);for(;rc(this.libp2p))),t.on("close",(()=>c(this.libp2p))),d.push(t.listen(e))}if(0===d.length){t.push(r);continue}if(!(await s(d)).find((e=>!0===e.isFulfilled))&&this.faultTolerance!==l.NO_FATAL)throw a(new Error(`Transport (${r}) could not listen on any available address`),o.ERR_NO_VALID_ADDRESSES)}if(t.length===this._transports.size){const e=`no valid addresses were provided for transports [${t}]`;if(this.faultTolerance===l.FATAL_ALL)throw a(new Error(e),o.ERR_NO_VALID_ADDRESSES);n(`libp2p in dial mode only: ${e}`)}}async remove(e){if(n("removing %s",e),this._listeners.has(e))for(const t of this._listeners.get(e))t.removeAllListeners("listening"),t.removeAllListeners("close"),await t.close();this._transports.delete(e),this._listeners.delete(e)}async removeAll(){const e=[];for(const t of this._transports.keys())e.push(this.remove(t));await Promise.all(e)}}const l={FATAL_ALL:0,NO_FATAL:1};u.FaultTolerance=l,t.exports=u},{debug:"bO5wM","p-settle":"hczkz","./errors":"3rNo5","err-code":"chZjB","./record/utils":"7dy3Z"}],hczkz:[function(e,t,r){"use strict";const i=e("p-reflect"),n=e("p-limit");t.exports=async(e,t={})=>{const{concurrency:r=1/0}=t,s=n(r);return Promise.all(e.map((e=>e&&"function"==typeof e.then?i(e):i("function"==typeof e?s((()=>e())):Promise.resolve(e)))))}},{"p-reflect":"3v3gm","p-limit":"k9NpZ"}],"3v3gm":[function(e,t,r){"use strict";const i=async e=>{try{return{isFulfilled:!0,isRejected:!1,value:await e}}catch(e){return{isFulfilled:!1,isRejected:!0,reason:e}}};t.exports=i,t.exports.default=i},{}],k9NpZ:[function(e,t,r){"use strict";const i=e("p-try"),n=e=>{if(!Number.isInteger(e)&&e!==1/0||!(e>0))return Promise.reject(new TypeError("Expected `concurrency` to be a number from 1 and up"));const t=[];let r=0;const n=()=>{r--,t.length>0&&t.shift()()},s=(e,t,...s)=>{r++;const o=i(e,...s);t(o),o.then(n,n)},o=(i,...n)=>new Promise((o=>((i,n,...o)=>{rr},pendingCount:{get:()=>t.length},clearQueue:{value:()=>{t.length=0}}}),o};t.exports=n,t.exports.default=n},{"p-try":"RBpbF"}],RBpbF:[function(e,t,r){"use strict";const i=(e,...t)=>new Promise((r=>{r(e(...t))}));t.exports=i,t.exports.default=i},{}],"7dy3Z":[function(e,t,r){"use strict";const i=e("./envelope"),n=e("./peer-record");t.exports.updateSelfPeerRecord=async function(e){const t=new n({peerId:e.peerId,multiaddrs:e.multiaddrs}),r=await i.seal(t,e.peerId);e.peerStore.addressBook.consumePeerRecord(r)}},{"./envelope":"27rHX","./peer-record":"ewlv9"}],ewlv9:[function(e,t,r){"use strict";const{Multiaddr:i}=e("multiaddr"),n=e("peer-id"),s=e("libp2p-utils/src/array-equals"),{PeerRecord:o}=e("./peer-record"),{ENVELOPE_DOMAIN_PEER_RECORD:a,ENVELOPE_PAYLOAD_TYPE_PEER_RECORD:c}=e("./consts");class u{constructor({peerId:e,multiaddrs:t=[],seqNumber:r=Date.now()}){this.domain=a,this.codec=c,this.peerId=e,this.multiaddrs=t,this.seqNumber=r,this._marshal=void 0}marshal(){return this._marshal||(this._marshal=o.encode({peerId:this.peerId.toBytes(),seq:this.seqNumber,addresses:this.multiaddrs.map((e=>({multiaddr:e.bytes})))}).finish()),this._marshal}equals(e){return e instanceof u&&(!!this.peerId.equals(e.peerId)&&(this.seqNumber===e.seqNumber&&!!s(this.multiaddrs,e.multiaddrs)))}}u.createFromProtobuf=e=>{const t=o.decode(e),r=n.createFromBytes(t.peerId),s=(t.addresses||[]).map((e=>new i(e.multiaddr))),a=Number(t.seq);return new u({peerId:r,multiaddrs:s,seqNumber:a})},u.DOMAIN=a,t.exports=u},{multiaddr:"8Mu1u","peer-id":"8Bdb3","libp2p-utils/src/array-equals":"8n4Vn","./peer-record":"48CV1","./consts":"5QB9f"}],"8n4Vn":[function(e,t,r){"use strict";t.exports=function(e,t){return e.length===t.length&&t.sort()&&e.sort().every(((e,r)=>t[r].equals(e)))}},{}],"48CV1":[function(e,t,r){"use strict";var i=e("protobufjs/minimal"),n=i.Reader,s=i.Writer,o=i.util,a=i.roots["libp2p-peer-record"]||(i.roots["libp2p-peer-record"]={});a.PeerRecord=function(){function e(e){if(this.addresses=[],e)for(var t=Object.keys(e),r=0;r>>3){case 1:i.peerId=e.bytes();break;case 2:i.seq=e.uint64();break;case 3:i.addresses&&i.addresses.length||(i.addresses=[]),i.addresses.push(a.PeerRecord.AddressInfo.decode(e,e.uint32()));break;default:e.skipType(7&s)}}return i},e.fromObject=function(e){if(e instanceof a.PeerRecord)return e;var t=new a.PeerRecord;if(null!=e.peerId&&("string"==typeof e.peerId?o.base64.decode(e.peerId,t.peerId=o.newBuffer(o.base64.length(e.peerId)),0):e.peerId.length&&(t.peerId=e.peerId)),null!=e.seq&&(o.Long?(t.seq=o.Long.fromValue(e.seq)).unsigned=!0:"string"==typeof e.seq?t.seq=parseInt(e.seq,10):"number"==typeof e.seq?t.seq=e.seq:"object"==typeof e.seq&&(t.seq=new o.LongBits(e.seq.low>>>0,e.seq.high>>>0).toNumber(!0))),e.addresses){if(!Array.isArray(e.addresses))throw TypeError(".PeerRecord.addresses: array expected");t.addresses=[];for(var r=0;r>>0,e.seq.high>>>0).toNumber(!0):e.seq),e.addresses&&e.addresses.length){r.addresses=[];for(var n=0;n>>3==1)i.multiaddr=e.bytes();else e.skipType(7&s)}return i},e.fromObject=function(e){if(e instanceof a.PeerRecord.AddressInfo)return e;var t=new a.PeerRecord.AddressInfo;return null!=e.multiaddr&&("string"==typeof e.multiaddr?o.base64.decode(e.multiaddr,t.multiaddr=o.newBuffer(o.base64.length(e.multiaddr)),0):e.multiaddr.length&&(t.multiaddr=e.multiaddr)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.multiaddr="":(r.multiaddr=[],t.bytes!==Array&&(r.multiaddr=o.newBuffer(r.multiaddr)))),null!=e.multiaddr&&e.hasOwnProperty("multiaddr")&&(r.multiaddr=t.bytes===String?o.base64.encode(e.multiaddr,0,e.multiaddr.length):t.bytes===Array?Array.prototype.slice.call(e.multiaddr):e.multiaddr),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e}(),e}(),t.exports=a},{"protobufjs/minimal":"grAXL"}],"5QB9f":[function(e,t,r){"use strict";const i=Uint8Array.from([3,1]);t.exports={ENVELOPE_DOMAIN_PEER_RECORD:"libp2p-peer-record",ENVELOPE_PAYLOAD_TYPE_PEER_RECORD:i}},{}],"8bdzg":[function(e,t,r){"use strict";const{EventEmitter:i}=e("events"),{Multiaddr:n}=e("multiaddr"),s=e("peer-id");t.exports=class extends i{constructor(e,{listen:t=[],announce:r=[]}={}){super(),this.peerId=e,this.listen=new Set(t.map((e=>e.toString()))),this.announce=new Set(r.map((e=>e.toString()))),this.observed=new Set}getListenAddrs(){return Array.from(this.listen).map((e=>new n(e)))}getAnnounceAddrs(){return Array.from(this.announce).map((e=>new n(e)))}getObservedAddrs(){return Array.from(this.observed).map((e=>new n(e)))}addObservedAddr(e){let t=new n(e);const r=t.getPeerId();if(r){s.createFromB58String(r).equals(this.peerId)&&(t=t.decapsulate(new n(`/p2p/${this.peerId}`)))}const i=t.toString();this.observed.has(i)||(this.observed.add(i),this.emit("change:addresses"))}}},{events:"g82pp",multiaddr:"8Mu1u","peer-id":"8Bdb3"}],bZLZf:[function(e,t,r){"use strict";const i=e("debug"),n=Object.assign(i("libp2p:connection-manager"),{error:i("libp2p:connection-manager:err")}),s=e("err-code"),o=e("merge-options"),a=e("./latency-monitor"),c=e("retimer"),{EventEmitter:u}=e("events"),l=e("peer-id"),{codes:{ERR_INVALID_PARAMETERS:d}}=e("../errors"),f={maxConnections:1/0,minConnections:0,maxData:1/0,maxSentData:1/0,maxReceivedData:1/0,maxEventLoopDelay:1/0,pollInterval:2e3,autoDialInterval:1e4,movingAverageInterval:6e4,defaultPeerValue:1};t.exports=class extends u{constructor(e,t={}){if(super(),this._libp2p=e,this._peerId=e.peerId.toB58String(),this._options=o.call({ignoreUndefined:!0},f,t),this._options.maxConnectionse+t.length),0)}start(){this._libp2p.metrics&&(this._timer=this._timer||c(this._checkMetrics,this._options.pollInterval)),this._latencyMonitor.start(),this._onLatencyMeasure=this._onLatencyMeasure.bind(this),this._latencyMonitor.on("data",this._onLatencyMeasure),this._started=!0,n("started"),this._options.autoDial&&this._autoDial()}async stop(){this._autoDialTimeout&&this._autoDialTimeout.clear(),this._timer&&this._timer.clear(),this._latencyMonitor.removeListener("data",this._onLatencyMeasure),this._latencyMonitor.stop(),this._started=!1,await this._close(),n("stopped")}async _close(){const e=[];for(const t of this.connections.values())for(const r of t)e.push(r.close());await Promise.all(e),this.connections.clear()}setPeerValue(e,t){if(t<0||t>1)throw new Error("value should be a number between 0 and 1");this._peerValues.set(e.toB58String(),t)}_checkMetrics(){if(this._libp2p.metrics){const e=this._libp2p.metrics.global.movingAverages,t=e.dataReceived[this._options.movingAverageInterval].movingAverage();this._checkMaxLimit("maxReceivedData",t);const r=e.dataSent[this._options.movingAverageInterval].movingAverage();this._checkMaxLimit("maxSentData",r);const i=t+r;this._checkMaxLimit("maxData",i),n("metrics update",i),this._timer=c(this._checkMetrics,this._options.pollInterval)}}onConnect(e){const t=e.remotePeer,r=t.toB58String(),i=this.connections.get(r);this.emit("peer:connect",e),i?i.push(e):this.connections.set(r,[e]),this._libp2p.peerStore.keyBook.set(t,t.pubKey),this._peerValues.has(r)||this._peerValues.set(r,this._options.defaultPeerValue),this._checkMaxLimit("maxConnections",this.size)}onDisconnect(e){const t=e.remotePeer.toB58String();let r=this.connections.get(t);r&&r.length>1?(r=r.filter((t=>t.id!==e.id)),this.connections.set(t,r)):r&&(this.connections.delete(t),this._peerValues.delete(e.remotePeer.toB58String()),this.emit("peer:disconnect",e))}get(e){const t=this.getAll(e);return t.length?t[0]:null}getAll(e){if(!l.isPeerId(e))throw s(new Error("peerId must be an instance of peer-id"),d);const t=e.toB58String(),r=this.connections.get(t);return r?r.filter((e=>"open"===e.stat.status)):[]}_onLatencyMeasure(e){this._checkMaxLimit("maxEventLoopDelay",e.avgMs)}_checkMaxLimit(e,t){const r=this._options[e];n("checking limit of %s. current value: %d of %d",e,t,r),t>r&&(n("%s: limit exceeded: %s, %d",this._peerId,e,t),this._maybeDisconnectOne())}async _autoDial(){const e=this._options.minConnections;if(this.size>=e)return void(this._autoDialTimeout=c(this._autoDial,this._options.autoDialInterval));const t=Array.from(this._libp2p.peerStore.peers.values()).sort(((e,t)=>!t.protocols||!t.protocols.length||e.protocols&&e.protocols.length?t.id.pubKey&&!e.id.pubKey?1:-1:1));for(let r=0;re[1]-t[1]))));n("%s: sorted peer values: %j",this._peerId,e);const t=e[0];if(t){const e=t[0];n("%s: lowest value peer is %s",this._peerId,e),n("%s: closing a connection to %j",this._peerId,e);for(const t of this.connections.values())if(t[0].remotePeer.toB58String()===e){t[0].close();break}}}}}},{debug:"bO5wM","err-code":"chZjB","merge-options":"fupyv","./latency-monitor":"cAPgo",retimer:"8W3r3",events:"g82pp","peer-id":"8Bdb3","../errors":"3rNo5"}],cAPgo:[function(e,t,r){"use strict";const{EventEmitter:i}=e("events"),n=e("./visibility-change-emitter"),s=e("debug")("latency-monitor:LatencyMonitor");t.exports=class extends i{constructor({latencyCheckIntervalMs:e,dataEmitIntervalMs:t,asyncTestFn:r,latencyRandomPercentage:i}={}){super();const n=this;n.latencyCheckIntervalMs=e||500,n.latencyRandomPercentage=i||10,n._latecyCheckMultiply=n.latencyRandomPercentage/100*2*n.latencyCheckIntervalMs,n._latecyCheckSubtract=n._latecyCheckMultiply/2,n.dataEmitIntervalMs=null===t||0===t?void 0:t||5e3,s("latencyCheckIntervalMs: %s dataEmitIntervalMs: %s",n.latencyCheckIntervalMs,n.dataEmitIntervalMs),n.dataEmitIntervalMs?s("Expecting ~%s events per summary",n.latencyCheckIntervalMs/n.dataEmitIntervalMs):s("Not emitting summaries"),n.asyncTestFn=r}start(){globalThis.process&&globalThis.process.hrtime?(s("Using process.hrtime for timing"),this.now=globalThis.process.hrtime,this.getDeltaMS=e=>{const t=this.now(e);return 1e3*t[0]+t[1]/1e6}):"undefined"!=typeof window&&window.performance&&window.performance.now?(s("Using performance.now for timing"),this.now=window.performance.now.bind(window.performance),this.getDeltaMS=e=>Math.round(this.now()-e)):(s("Using Date.now for timing"),this.now=Date.now,this.getDeltaMS=e=>this.now()-e),this._latencyData=this._initLatencyData(),"undefined"!=typeof window&&(this._visibilityChangeEmitter=new n,this._visibilityChangeEmitter.on("visibilityChange",(e=>{e?this._startTimers():(this._emitSummary(),this._stopTimers())}))),this._visibilityChangeEmitter&&!this._visibilityChangeEmitter.isVisible()||this._startTimers()}stop(){this._stopTimers()}_startTimers(){this._checkLatencyID||(this._checkLatency(),this.dataEmitIntervalMs&&(this._emitIntervalID=setInterval((()=>this._emitSummary()),this.dataEmitIntervalMs),"function"==typeof this._emitIntervalID.unref&&this._emitIntervalID.unref()))}_stopTimers(){this._checkLatencyID&&(clearTimeout(this._checkLatencyID),this._checkLatencyID=void 0),this._emitIntervalID&&(clearInterval(this._emitIntervalID),this._emitIntervalID=void 0)}_emitSummary(){const e=this.getSummary();e.events>0&&this.emit("data",e)}getSummary(){const e={events:this._latencyData.events,minMs:this._latencyData.minMs,maxMs:this._latencyData.maxMs,avgMs:this._latencyData.events?this._latencyData.totalMs/this._latencyData.events:Number.POSITIVE_INFINITY,lengthMs:this.getDeltaMS(this._latencyData.startTime)};return this._latencyData=this._initLatencyData(),s("Summary: %O",e),e}_checkLatency(){const e=this,t=Math.random()*e._latecyCheckMultiply-e._latecyCheckSubtract,r={deltaOffset:Math.ceil(e.latencyCheckIntervalMs+t),startTime:e.now()},i=()=>{if(!this._checkLatencyID)return;const t=e.getDeltaMS(r.startTime)-r.deltaOffset;e._checkLatency(),e._latencyData.events++,e._latencyData.minMs=Math.min(e._latencyData.minMs,t),e._latencyData.maxMs=Math.max(e._latencyData.maxMs,t),e._latencyData.totalMs+=t,s("MS: %s Data: %O",t,e._latencyData)};s("localData: %O",r),this._checkLatencyID=setTimeout((()=>{e.asyncTestFn?(r.deltaOffset=0,r.startTime=e.now(),e.asyncTestFn(i)):(r.deltaOffset-=1,i())}),r.deltaOffset),"function"==typeof this._checkLatencyID.unref&&this._checkLatencyID.unref()}_initLatencyData(){return{startTime:this.now(),minMs:Number.POSITIVE_INFINITY,maxMs:Number.NEGATIVE_INFINITY,events:0,totalMs:0}}}},{events:"g82pp","./visibility-change-emitter":"dTe03",debug:"bO5wM"}],dTe03:[function(e,t,r){"use strict";const{EventEmitter:i}=e("events"),n=e("debug")("latency-monitor:VisibilityChangeEmitter");t.exports=class extends i{constructor(){super(),"undefined"!=typeof document?(this._initializeVisibilityVarNames(),this._addVisibilityChangeListener()):n('This is not a browser, no "document" found. Stopping.')}_initializeVisibilityVarNames(){let e,t;void 0!==document.hidden?(e="hidden",t="visibilitychange"):void 0!==document.mozHidden?(e="mozHidden",t="mozvisibilitychange"):void 0!==document.msHidden?(e="msHidden",t="msvisibilitychange"):void 0!==document.webkitHidden&&(e="webkitHidden",t="webkitvisibilitychange"),this._hidden=e,this._visibilityChange=t}_addVisibilityChangeListener(){void 0===document.addEventListener||void 0===document[this._hidden]?n("Checking page visibility requires a browser that supports the Page Visibility API."):document.addEventListener(this._visibilityChange,this._handleVisibilityChange.bind(this),!1)}isVisible(){if(void 0!==this._hidden&&void 0!==document[this._hidden])return!document[this._hidden]}_handleVisibilityChange(){const e=!document[this._hidden];n(e?"Page Visible":"Page Hidden"),this.emit("visibilityChange",e)}}},{events:"g82pp",debug:"bO5wM"}],"8W3r3":[function(e,t,r){"use strict";const i=e("./time");class n{constructor(e,t,r){const n=this;this._started=i(),this._rescheduled=0,this._scheduled=t,this._args=r,this._triggered=!1,this._timerWrapper=()=>{n._rescheduled>0?(n._scheduled=n._rescheduled-(i()-n._started),n._schedule(n._scheduled)):(n._triggered=!0,e.apply(null,n._args))},this._timer=setTimeout(this._timerWrapper,t)}reschedule(e){e||(e=this._scheduled);const t=i();t+e-(this._started+this._scheduled)<0?(clearTimeout(this._timer),this._schedule(e)):this._triggered?this._schedule(e):(this._started=t,this._rescheduled=e)}_schedule(e){this._triggered=!1,this._started=i(),this._rescheduled=0,this._scheduled=e,this._timer=setTimeout(this._timerWrapper,e)}clear(){clearTimeout(this._timer)}}t.exports=function(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("timeout needed");let e;if(arguments.length>0){e=new Array(arguments.length-2);for(var t=0;te.bytes))},dstPeer:{id:g.toBytes(),addrs:[new a(o).bytes]}}}),r=i.encapsulate(`/p2p-circuit/p2p/${this.peerId.toB58String()}`),s=d({stream:t,remoteAddr:e,localAddr:r});return n("new outbound connection %s",s.remoteAddr),this._upgrader.upgradeOutbound(s)}catch(e){throw n.error("Circuit relay dial failed",e),m&&await b.close(),e}}createListener(e,t){return"function"==typeof e&&(t=e,e={}),this.handler=t,h(this._libp2p)}filter(e){return(e=Array.isArray(e)?e:[e]).filter((e=>o.Circuit.matches(e)))}get[Symbol.toStringTag](){return"Circuit"}static isTransport(e){return Boolean(e&&e[v])}}t.exports=w},{debug:"bO5wM","err-code":"chZjB",mafmt:"l1lok",multiaddr:"8Mu1u","peer-id":"8Bdb3","./protocol":"fLprH","../errors":"3rNo5","libp2p-utils/src/stream-to-ma-conn":"9Ldtq","./multicodec":"cvoxe","./listener":"3rDyV","./circuit/hop":"8wHM9","./circuit/stop":"9XOcP","./circuit/stream-handler":"4ZlbH"}],fLprH:[function(e,t,r){"use strict";var i=e("protobufjs/minimal"),n=i.Reader,s=i.Writer,o=i.util,a=i.roots["libp2p-circuit"]||(i.roots["libp2p-circuit"]={});a.CircuitRelay=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:i.type=e.int32();break;case 2:i.srcPeer=a.CircuitRelay.Peer.decode(e,e.uint32());break;case 3:i.dstPeer=a.CircuitRelay.Peer.decode(e,e.uint32());break;case 4:i.code=e.int32();break;default:e.skipType(7&s)}}return i},e.fromObject=function(e){if(e instanceof a.CircuitRelay)return e;var t=new a.CircuitRelay;switch(e.type){case"HOP":case 1:t.type=1;break;case"STOP":case 2:t.type=2;break;case"STATUS":case 3:t.type=3;break;case"CAN_HOP":case 4:t.type=4}if(null!=e.srcPeer){if("object"!=typeof e.srcPeer)throw TypeError(".CircuitRelay.srcPeer: object expected");t.srcPeer=a.CircuitRelay.Peer.fromObject(e.srcPeer)}if(null!=e.dstPeer){if("object"!=typeof e.dstPeer)throw TypeError(".CircuitRelay.dstPeer: object expected");t.dstPeer=a.CircuitRelay.Peer.fromObject(e.dstPeer)}switch(e.code){case"SUCCESS":case 100:t.code=100;break;case"HOP_SRC_ADDR_TOO_LONG":case 220:t.code=220;break;case"HOP_DST_ADDR_TOO_LONG":case 221:t.code=221;break;case"HOP_SRC_MULTIADDR_INVALID":case 250:t.code=250;break;case"HOP_DST_MULTIADDR_INVALID":case 251:t.code=251;break;case"HOP_NO_CONN_TO_DST":case 260:t.code=260;break;case"HOP_CANT_DIAL_DST":case 261:t.code=261;break;case"HOP_CANT_OPEN_DST_STREAM":case 262:t.code=262;break;case"HOP_CANT_SPEAK_RELAY":case 270:t.code=270;break;case"HOP_CANT_RELAY_TO_SELF":case 280:t.code=280;break;case"STOP_SRC_ADDR_TOO_LONG":case 320:t.code=320;break;case"STOP_DST_ADDR_TOO_LONG":case 321:t.code=321;break;case"STOP_SRC_MULTIADDR_INVALID":case 350:t.code=350;break;case"STOP_DST_MULTIADDR_INVALID":case 351:t.code=351;break;case"STOP_RELAY_REFUSED":case 390:t.code=390;break;case"MALFORMED_MESSAGE":case 400:t.code=400}return t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.type=t.enums===String?"HOP":1,r.srcPeer=null,r.dstPeer=null,r.code=t.enums===String?"SUCCESS":100),null!=e.type&&e.hasOwnProperty("type")&&(r.type=t.enums===String?a.CircuitRelay.Type[e.type]:e.type),null!=e.srcPeer&&e.hasOwnProperty("srcPeer")&&(r.srcPeer=a.CircuitRelay.Peer.toObject(e.srcPeer,t)),null!=e.dstPeer&&e.hasOwnProperty("dstPeer")&&(r.dstPeer=a.CircuitRelay.Peer.toObject(e.dstPeer,t)),null!=e.code&&e.hasOwnProperty("code")&&(r.code=t.enums===String?a.CircuitRelay.Status[e.code]:e.code),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.Status=(t={},(r=Object.create(t))[t[100]="SUCCESS"]=100,r[t[220]="HOP_SRC_ADDR_TOO_LONG"]=220,r[t[221]="HOP_DST_ADDR_TOO_LONG"]=221,r[t[250]="HOP_SRC_MULTIADDR_INVALID"]=250,r[t[251]="HOP_DST_MULTIADDR_INVALID"]=251,r[t[260]="HOP_NO_CONN_TO_DST"]=260,r[t[261]="HOP_CANT_DIAL_DST"]=261,r[t[262]="HOP_CANT_OPEN_DST_STREAM"]=262,r[t[270]="HOP_CANT_SPEAK_RELAY"]=270,r[t[280]="HOP_CANT_RELAY_TO_SELF"]=280,r[t[320]="STOP_SRC_ADDR_TOO_LONG"]=320,r[t[321]="STOP_DST_ADDR_TOO_LONG"]=321,r[t[350]="STOP_SRC_MULTIADDR_INVALID"]=350,r[t[351]="STOP_DST_MULTIADDR_INVALID"]=351,r[t[390]="STOP_RELAY_REFUSED"]=390,r[t[400]="MALFORMED_MESSAGE"]=400,r),e.Type=function(){var e={},t=Object.create(e);return t[e[1]="HOP"]=1,t[e[2]="STOP"]=2,t[e[3]="STATUS"]=3,t[e[4]="CAN_HOP"]=4,t}(),e.Peer=function(){function e(e){if(this.addrs=[],e)for(var t=Object.keys(e),r=0;r>>3){case 1:i.id=e.bytes();break;case 2:i.addrs&&i.addrs.length||(i.addrs=[]),i.addrs.push(e.bytes());break;default:e.skipType(7&s)}}if(!i.hasOwnProperty("id"))throw o.ProtocolError("missing required 'id'",{instance:i});return i},e.fromObject=function(e){if(e instanceof a.CircuitRelay.Peer)return e;var t=new a.CircuitRelay.Peer;if(null!=e.id&&("string"==typeof e.id?o.base64.decode(e.id,t.id=o.newBuffer(o.base64.length(e.id)),0):e.id.length&&(t.id=e.id)),e.addrs){if(!Array.isArray(e.addrs))throw TypeError(".CircuitRelay.Peer.addrs: array expected");t.addrs=[];for(var r=0;r(o(new Uint8Array(0)),u())};function u(){return c.timeline.close||(c.timeline.close=Date.now()),Promise.resolve()}return c}},{"abortable-iterator":"awlU8",debug:"bO5wM"}],cvoxe:[function(e,t,r){"use strict";t.exports={relay:"/libp2p/circuit/relay/0.1.0"}},{}],"3rDyV":[function(e,t,r){"use strict";const{EventEmitter:i}=e("events"),{Multiaddr:n}=e("multiaddr");t.exports=e=>{const t=new Map;const r=Object.assign(new i,{close:()=>Promise.resolve(),listen:async function(i){const s=String(i).split("/p2p-circuit").find((e=>""!==e)),o=await e.dial(new n(s)),a=o.remoteAddr.encapsulate("/p2p-circuit");t.set(o.remotePeer.toB58String(),a),r.emit("listening")},getAddrs:function(){const e=[];for(const r of t.values())e.push(r);return e}});return e.connectionManager.on("peer:disconnect",(e=>{t.delete(e.remotePeer.toB58String())&&r.emit("close")})),r}},{events:"g82pp",multiaddr:"8Mu1u"}],"8wHM9":[function(e,t,r){"use strict";const i=e("debug"),n=Object.assign(i("libp2p:circuit:hop"),{error:i("libp2p:circuit:hop:err")}),s=e("err-code"),o=e("peer-id"),{validateAddrs:a}=e("./utils"),c=e("./stream-handler"),{CircuitRelay:u}=e("../protocol"),{pipe:l}=e("it-pipe"),{codes:d}=e("../../errors"),{stop:f}=e("./stop"),h=e("./../multicodec");t.exports={handleHop:async function({connection:e,request:t,streamHandler:r,circuit:i}){if(!i._options.hop.enabled)return n("HOP request received but we are not acting as a relay"),r.end({type:u.Type.STATUS,code:u.Status.HOP_CANT_SPEAK_RELAY});try{a(t,r)}catch(t){return n.error("invalid hop request via peer %s",e.remotePeer.toB58String(),t)}if(!t.dstPeer)return void n("HOP request received but we do not receive a dstPeer");const s=new o(t.dstPeer.id),c=i._connectionManager.get(s);if(!c&&!i._options.hop.active)return n("HOP request received but we are not connected to the destination peer"),r.end({type:u.Type.STATUS,code:u.Status.HOP_NO_CONN_TO_DST});if(!c)return;const d={type:u.Type.STOP,dstPeer:t.dstPeer,srcPeer:t.srcPeer};let h;try{h=await f({connection:c,request:d})}catch(e){return n.error(e)}n("hop request from %s is valid",e.remotePeer.toB58String()),r.write({type:u.Type.STATUS,code:u.Status.SUCCESS});const p=r.rest();return l(p,h,p)},hop:async function({connection:e,request:t}){const{stream:r}=await e.newStream([h.relay]),i=new c({stream:r});i.write(t);const o=await i.read();if(!o)throw s(new Error("HOP request had no response"),d.ERR_HOP_REQUEST_FAILED);if(o.code===u.Status.SUCCESS)return n("hop request was successful"),i.rest();throw n("hop request failed with code %d, closing stream",o.code),i.close(),s(new Error(`HOP request failed with code ${o.code}`),d.ERR_HOP_REQUEST_FAILED)},canHop:async function({connection:e}){const{stream:t}=await e.newStream([h.relay]),r=new c({stream:t});r.write({type:u.Type.CAN_HOP});const i=await r.read();return await r.close(),!(!i||i.code!==u.Status.SUCCESS)},handleCanHop:function({connection:e,streamHandler:t,circuit:r}){const i=r._options.hop.enabled;n("can hop (%s) request from %s",i,e.remotePeer.toB58String()),t.end({type:u.Type.STATUS,code:i?u.Status.SUCCESS:u.Status.HOP_CANT_SPEAK_RELAY})}}},{debug:"bO5wM","err-code":"chZjB","peer-id":"8Bdb3","./utils":"daC1e","./stream-handler":"4ZlbH","../protocol":"fLprH","it-pipe":"giKBQ","../../errors":"3rNo5","./stop":"9XOcP","./../multicodec":"cvoxe"}],daC1e:[function(e,t,r){"use strict";const{Multiaddr:i}=e("multiaddr"),{CircuitRelay:n}=e("../protocol");function s(e,t){e.write({type:n.Type.STATUS,code:t})}t.exports={validateAddrs:function(e,t){try{e.dstPeer&&e.dstPeer.addrs&&e.dstPeer.addrs.forEach((e=>new i(e)))}catch(r){throw s(t,e.type===n.Type.HOP?n.Status.HOP_DST_MULTIADDR_INVALID:n.Status.STOP_DST_MULTIADDR_INVALID),r}try{e.srcPeer&&e.srcPeer.addrs&&e.srcPeer.addrs.forEach((e=>new i(e)))}catch(r){throw s(t,e.type===n.Type.HOP?n.Status.HOP_SRC_MULTIADDR_INVALID:n.Status.STOP_SRC_MULTIADDR_INVALID),r}}}},{multiaddr:"8Mu1u","../protocol":"fLprH"}],"4ZlbH":[function(e,t,r){"use strict";const i=e("debug"),n=Object.assign(i("libp2p:circuit:stream-handler"),{error:i("libp2p:circuit:stream-handler:err")}),s=e("it-length-prefixed"),o=e("it-handshake"),{CircuitRelay:a}=e("../protocol");t.exports=class{constructor({stream:e,maxLength:t=4096}){this.stream=e,this.shake=o(this.stream),this.decoder=s.decode.fromReader(this.shake.reader,{maxDataLength:t})}async read(){const e=await this.decoder.next();if(e.value){const t=a.decode(e.value.slice());return n("read message type",t.type),t}n("read received no value, closing stream"),this.close()}write(e){n("write message type %s",e.type),this.shake.write(s.encode.single(a.encode(e).finish()))}rest(){return this.shake.rest(),this.shake.stream}end(e){this.write(e),this.close()}close(){n("closing the stream"),this.rest().sink([])}}},{debug:"bO5wM","it-length-prefixed":"3yxIE","it-handshake":"5ZBDe","../protocol":"fLprH"}],"9XOcP":[function(e,t,r){"use strict";const i=e("debug"),n=Object.assign(i("libp2p:circuit:stop"),{error:i("libp2p:circuit:stop:err")}),{CircuitRelay:s}=e("../protocol"),o=e("../multicodec"),a=e("./stream-handler"),{validateAddrs:c}=e("./utils");t.exports.handleStop=function({connection:e,request:t,streamHandler:r}){try{c(t,r)}catch(t){return n.error("invalid stop request via peer %s",e.remotePeer.toB58String(),t)}return n("stop request is valid"),r.write({type:s.Type.STATUS,code:s.Status.SUCCESS}),r.rest()},t.exports.stop=async function({connection:e,request:t}){const{stream:r}=await e.newStream([o.relay]);n("starting stop request to %s",e.remotePeer.toB58String());const i=new a({stream:r});i.write(t);const c=await i.read();return c?c.code===s.Status.SUCCESS?(n("stop request to %s was successful",e.remotePeer.toB58String()),i.rest()):(n("stop request failed with code %d",c.code),void i.close()):i.close()}},{debug:"bO5wM","../protocol":"fLprH","../multicodec":"cvoxe","./stream-handler":"4ZlbH","./utils":"daC1e"}],hBCQx:[function(e,t,r){"use strict";const i=e("debug"),n=Object.assign(i("libp2p:relay"),{error:i("libp2p:relay:err")}),{setDelayedInterval:s,clearDelayedInterval:o}=e("set-delayed-interval"),a=e("./auto-relay"),{namespaceToCid:c}=e("./utils"),{RELAY_RENDEZVOUS_NS:u}=e("./constants");t.exports=class{constructor(e){this._libp2p=e,this._options={...e._config.relay},this._autoRelay=this._options.autoRelay.enabled&&new a({libp2p:e,...this._options.autoRelay}),this._advertiseService=this._advertiseService.bind(this)}start(){this._options.hop.enabled&&this._options.advertise.enabled&&(this._timeout=s(this._advertiseService,this._options.advertise.ttl,this._options.advertise.bootDelay))}stop(){o(this._timeout)}async _advertiseService(){try{const e=await c(u);await this._libp2p.contentRouting.provide(e)}catch(e){"NO_ROUTERS_AVAILABLE"===e.code?(n.error("a content router, such as a DHT, must be provided in order to advertise the relay service",e),this.stop()):n.error(e)}}}},{debug:"bO5wM","set-delayed-interval":"4OF34","./auto-relay":"84VTV","./utils":"l4Fw3","./constants":"eXVcE"}],"84VTV":[function(e,t,r){"use strict";const i=e("debug"),n=Object.assign(i("libp2p:auto-relay"),{error:i("libp2p:auto-relay:err")}),{fromString:s}=e("uint8arrays/from-string"),{toString:o}=e("uint8arrays/to-string"),{Multiaddr:a}=e("multiaddr"),c=e("peer-id"),{relay:u}=e("./multicodec"),{canHop:l}=e("./circuit/hop"),{namespaceToCid:d}=e("./utils"),{CIRCUIT_PROTO_CODE:f,HOP_METADATA_KEY:h,HOP_METADATA_VALUE:p,RELAY_RENDEZVOUS_NS:g}=e("./constants");t.exports=class{constructor({libp2p:e,maxListeners:t=1,onError:r}){this._libp2p=e,this._peerId=e.peerId,this._peerStore=e.peerStore,this._connectionManager=e.connectionManager,this._transportManager=e.transportManager,this._addressSorter=e.dialer.addressSorter,this.maxListeners=t,this._listenRelays=new Set,this._onProtocolChange=this._onProtocolChange.bind(this),this._onPeerDisconnected=this._onPeerDisconnected.bind(this),this._peerStore.on("change:protocols",this._onProtocolChange),this._connectionManager.on("peer:disconnect",this._onPeerDisconnected),this._onError=(e,t)=>{n.error(t||e),r&&r(e,t)}}async _onProtocolChange({peerId:e,protocols:t}){const r=e.toB58String(),i=t.find((e=>e===u));if(i||!this._listenRelays.has(r)){if(i&&!this._listenRelays.has(r))try{const t=this._connectionManager.get(e);if(!t)return;if(t.remoteAddr.protoCodes().includes(f))return void n(`relayed connection to ${r} will not be used to hop on`);await l({connection:t})&&(this._peerStore.metadataBook.set(e,h,s(p)),await this._addListenRelay(t,r))}catch(e){this._onError(e)}}else this._removeListenRelay(r)}_onPeerDisconnected(e){const t=e.remotePeer.toB58String();this._listenRelays.has(t)&&this._removeListenRelay(t)}async _addListenRelay(e,t){if(this._listenRelays.size>=this.maxListeners)return;const r=this._peerStore.addressBook.getMultiaddrsForPeer(e.remotePeer,this._addressSorter);if(!r||!r.length)return;const i=`${r[0].toString()}/p2p-circuit`;this._listenRelays.add(t);try{await this._transportManager.listen([new a(i)])}catch(e){this._onError(e),this._listenRelays.delete(t)}}_removeListenRelay(e){this._listenRelays.delete(e)&&this._listenOnAvailableHopRelays([e])}async _listenOnAvailableHopRelays(e=[]){if(this._listenRelays.size>=this.maxListeners)return;const t=[];for(const[r,i]of this._peerStore.metadataBook.data.entries()){if(this._listenRelays.has(r)||e.includes(r))continue;const n=i.get(h);if(!n||o(n)!==p)continue;const s=c.createFromB58String(r),a=this._connectionManager.get(s);if(a){if(await this._addListenRelay(a,r),this._listenRelays.size>=this.maxListeners)return}else t.push(s)}for(const e of t)if(await this._tryToListenOnRelay(e),this._listenRelays.size>=this.maxListeners)return;try{const e=await d(g);for await(const t of this._libp2p.contentRouting.findProviders(e)){if(!t.multiaddrs.length)continue;const e=t.id;if(this._peerStore.addressBook.add(e,t.multiaddrs),await this._tryToListenOnRelay(e),this._listenRelays.size>=this.maxListeners)return}}catch(e){this._onError(e)}}async _tryToListenOnRelay(e){try{const t=await this._libp2p.dial(e);await this._addListenRelay(t,e.toB58String())}catch(t){this._onError(t,`could not connect and listen on known hop relay ${e.toB58String()}`)}}}},{debug:"bO5wM","uint8arrays/from-string":"dF7Y4","uint8arrays/to-string":"hC8JB",multiaddr:"8Mu1u","peer-id":"8Bdb3","./multicodec":"cvoxe","./circuit/hop":"8wHM9","./utils":"l4Fw3","./constants":"eXVcE"}],l4Fw3:[function(e,t,r){"use strict";const{CID:i}=e("multiformats/cid"),{sha256:n}=e("multiformats/hashes/sha2");t.exports.namespaceToCid=async e=>{const t=(new TextEncoder).encode(e),r=await n.digest(t);return i.createV0(r)}},{"multiformats/cid":"9ooAY","multiformats/hashes/sha2":"7i9MT"}],kwWEi:[function(e,t,r){"use strict";const i=e("debug"),n=Object.assign(i("libp2p:dialer"),{error:i("libp2p:dialer:err")}),s=e("err-code"),{Multiaddr:o}=e("multiaddr"),a=e("timeout-abort-controller"),{AbortError:c}=e("abortable-iterator"),{anySignal:u}=e("any-signal"),l=e("./dial-request"),{publicAddressesFirst:d}=e("libp2p-utils/src/address-sort"),f=e("../get-peer"),{codes:h}=e("../errors"),{DIAL_TIMEOUT:p,MAX_PARALLEL_DIALS:g,MAX_PER_PEER_DIALS:y,MAX_ADDRS_TO_DIAL:m}=e("../constants");t.exports=class{constructor({transportManager:e,peerStore:t,addressSorter:r=d,maxParallelDials:i=g,maxAddrsToDial:n=m,dialTimeout:s=p,maxDialsPerPeer:a=y,resolvers:c={}}){this.transportManager=e,this.peerStore=t,this.addressSorter=r,this.maxParallelDials=i,this.maxAddrsToDial=n,this.timeout=s,this.maxDialsPerPeer=a,this.tokens=[...new Array(i)].map(((e,t)=>t)),this._pendingDials=new Map,this._pendingDialTargets=new Map;for(const[e,t]of Object.entries(c))o.resolvers.set(e,t)}destroy(){for(const e of this._pendingDials.values())try{e.controller.abort()}catch(e){n.error(e)}this._pendingDials.clear();for(const e of this._pendingDialTargets.values())e.reject(new c("Dialer was destroyed"));this._pendingDialTargets.clear()}async connectToPeer(e,t={}){const r=await this._createCancellableDialTarget(e);if(!r.addrs.length)throw s(new Error("The dial request has no valid addresses"),h.ERR_NO_VALID_ADDRESSES);const i=this._pendingDials.get(r.id)||this._createPendingDial(r,t);try{const e=await i.promise;return n("dial succeeded to %s",r.id),e}catch(e){throw i.controller.signal.aborted&&(e.code=h.ERR_TIMEOUT),n.error(e),e}finally{i.destroy()}}async _createCancellableDialTarget(e){const t=`${parseInt(String(1e9*Math.random()),10).toString()+Date.now()}`,r=new Promise(((e,r)=>{this._pendingDialTargets.set(t,{resolve:e,reject:r})})),i=await Promise.race([this._createDialTarget(e),r]);return this._pendingDialTargets.delete(t),i}async _createDialTarget(e){const{id:t,multiaddrs:r}=f(e);r&&this.peerStore.addressBook.add(t,r);let i=this.peerStore.addressBook.getMultiaddrsForPeer(t,this.addressSorter)||[];o.isMultiaddr(e)&&(i=i.filter((t=>!e.equals(t))),i.unshift(e));const n=[];for(const e of i){(await this._resolve(e)).forEach((e=>n.push(e)))}const a=n.filter((e=>this.transportManager.transportForMultiaddr(e)));if(a.length>this.maxAddrsToDial)throw this.peerStore.delete(t),s(new Error("dial with more addresses than allowed"),h.ERR_TOO_MANY_ADDRESSES);return{id:t.toB58String(),addrs:a}}_createPendingDial(e,t={}){const r=new l({addrs:e.addrs,dialAction:(e,t)=>{if(t.signal.aborted)throw s(new Error("already aborted"),h.ERR_ALREADY_ABORTED);return this.transportManager.dial(e,t)},dialer:this}),i=new a(this.timeout),n=[i.signal];t.signal&&n.push(t.signal);const o=u(n),c={dialRequest:r,controller:i,promise:r.run({...t,signal:o}),destroy:()=>{i.clear(),this._pendingDials.delete(e.id)}};return this._pendingDials.set(e.id,c),c}getTokens(e){const t=Math.min(e,this.maxDialsPerPeer,this.tokens.length),r=this.tokens.splice(0,t);return n("%d tokens request, returning %d, %d remaining",e,t,this.tokens.length),r}releaseToken(e){this.tokens.indexOf(e)>-1||(n("token %d released",e),this.tokens.push(e))}async _resolve(e){if(!e.protoNames().includes("dnsaddr"))return[e];const t=await this._resolveRecord(e);return(await Promise.all(t.map((e=>this._resolve(e))))).flat().reduce(((e,t)=>(e.find((e=>e.equals(t)))||e.push(t),e)),[])}async _resolveRecord(e){try{e=new o(e.toString());return await e.resolve()}catch(t){return n.error(`multiaddr ${e} could not be resolved`),[]}}}},{debug:"bO5wM","err-code":"chZjB",multiaddr:"8Mu1u","timeout-abort-controller":"hzClg","abortable-iterator":"awlU8","any-signal":"kXgRR","./dial-request":"bCRVF","libp2p-utils/src/address-sort":"5uTJL","../get-peer":"39nOe","../errors":"3rNo5","../constants":"92Vak"}],bCRVF:[function(e,t,r){"use strict";const i=e("err-code"),n=e("abort-controller").default,{anySignal:s}=e("any-signal"),o=e("p-fifo"),a=e("p-any");t.exports=class{constructor({addrs:e,dialAction:t,dialer:r}){this.addrs=e,this.dialer=r,this.dialAction=t}async run(e={}){const t=this.dialer.getTokens(this.addrs.length);if(t.length<1)throw i(new Error("No dial tokens available"),"ERR_NO_DIAL_TOKENS");const r=new o;t.forEach((e=>r.push(e)));const c=this.addrs.map((()=>new n));let u=0;try{return await a(this.addrs.map((async(i,n)=>{const o=await r.shift();let a;try{const l=c[n].signal;a=await this.dialAction(i,{...e,signal:e.signal?s([l,e.signal]):l}),c.splice(n,1)}finally{u++,this.addrs.length-u>=t.length?r.push(o):this.dialer.releaseToken(t.splice(t.indexOf(o),1)[0])}return a})))}finally{c.map((e=>e.abort())),t.forEach((e=>this.dialer.releaseToken(e)))}}}},{"err-code":"chZjB","abort-controller":"lNJ7z","any-signal":"kXgRR","p-fifo":"9S0qu","p-any":"24Yiw"}],"9S0qu":[function(e,t,r){const i=e("fast-fifo"),n=e("p-defer");t.exports=class{constructor(){this._buffer=new i,this._waitingConsumers=new i}push(e){const{promise:t,resolve:r}=n();return this._buffer.push({chunk:e,resolve:r}),this._consume(),t}_consume(){for(;!this._waitingConsumers.isEmpty()&&!this._buffer.isEmpty();){const e=this._waitingConsumers.shift(),t=this._buffer.shift();e.resolve(t.chunk),t.resolve()}}shift(){const{promise:e,resolve:t}=n();return this._waitingConsumers.push({resolve:t}),this._consume(),e}isEmpty(){return this._buffer.isEmpty()}}},{"fast-fifo":"8Ws5O","p-defer":"5rKSv"}],"24Yiw":[function(e,t,r){"use strict";const i=e("p-some"),n=e("p-cancelable");t.exports=(e,t)=>{const r=i(e,{...t,count:1});return n.fn((async e=>{e((()=>{r.cancel()}));const[t]=await r;return t}))()},t.exports.AggregateError=i.AggregateError},{"p-some":"gmdP0","p-cancelable":"fDp4B"}],gmdP0:[function(e,t,r){"use strict";const i=e("aggregate-error"),n=e("p-cancelable");class s extends Error{}t.exports=(e,t)=>new n(((r,n,o)=>{const{count:a,filter:c=(()=>!0)}=t;if(!Number.isFinite(a))return void n(new TypeError("Expected a finite number, got "+typeof t.count));const u=[],l=[];let d=0,f=!1;const h=new Set,p=()=>{for(const t of e)h.has(t)||"function"!=typeof t.cancel||t.cancel()};o(p);for(const t of e)d++,(async()=>{try{const e=await t;if(f)return;if(!c(e))throw new s("Value does not satisfy filter");u.push(e)}catch(e){l.push(e)}finally{h.add(t),!f&&(u.length===a&&(r(u),f=!0),d-l.lengthd&&(n(new RangeError(`Expected input to contain at least ${t.count} items, but contains ${d} items`)),p())})),t.exports.AggregateError=i,t.exports.FilterError=s},{"aggregate-error":"45emq","p-cancelable":"fDp4B"}],fDp4B:[function(e,t,r){"use strict";class i extends Error{constructor(e){super(e||"Promise was canceled"),this.name="CancelError"}get isCanceled(){return!0}}class n{static fn(e){return(...t)=>new n(((r,i,n)=>{t.push(n),e(...t).then(r,i)}))}constructor(e){this._cancelHandlers=[],this._isPending=!0,this._isCanceled=!1,this._rejectOnCancel=!0,this._promise=new Promise(((t,r)=>{this._reject=r;const i=e=>{if(!this._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");this._cancelHandlers.push(e)};return Object.defineProperties(i,{shouldReject:{get:()=>this._rejectOnCancel,set:e=>{this._rejectOnCancel=e}}}),e((e=>{this._isCanceled&&i.shouldReject||(this._isPending=!1,t(e))}),(e=>{this._isPending=!1,r(e)}),i)}))}then(e,t){return this._promise.then(e,t)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}cancel(e){if(this._isPending&&!this._isCanceled){if(this._isCanceled=!0,this._cancelHandlers.length>0)try{for(const e of this._cancelHandlers)e()}catch(e){return void this._reject(e)}this._rejectOnCancel&&this._reject(new i(e))}}get isCanceled(){return this._isCanceled}}Object.setPrototypeOf(n.prototype,Promise.prototype),t.exports=n,t.exports.CancelError=i},{}],f4Pg5:[function(e,t,r){"use strict";const i=e("debug"),n=Object.assign(i("libp2p:keychain"),{error:i("libp2p:keychain:err")}),s=e("sanitize-filename"),o=e("merge-options"),a=e("libp2p-crypto"),{Key:c}=e("interface-datastore/key"),u=e("./cms"),l=e("err-code"),{toString:d}=e("uint8arrays/to-string"),{fromString:f}=e("uint8arrays/from-string");e("node-forge/lib/sha512");const h="/info/",p=new WeakMap,g=14,y=16,m=1e3,b={dek:{keyLength:64,iterationCount:1e4,salt:"you should override this value with a crypto secure random number",hash:"sha2-512"}};function v(e){return!!e&&("string"==typeof e&&e===s(e.trim()))}async function w(e){const t=800*Math.random()+200;throw await new Promise((e=>setTimeout(e,t))),e}function _(e){return new c("/pkcs8/"+e)}function E(e){return new c(h+e)}t.exports=class{constructor(e,t){if(!e)throw new Error("store is required");if(this.store=e,this.opts=o(b,t),this.opts.pass&&this.opts.pass.length<20)throw new Error("pass must be least 20 characters");if(this.opts.dek.keyLengtht.id===e))}catch(e){return w(e)}}async findKeyByName(e){if(!v(e))return w(l(new Error(`Invalid key name '${e}'`),"ERR_INVALID_KEY_NAME"));const t=E(e);try{const e=await this.store.get(t);return JSON.parse(d(e))}catch(t){return w(l(new Error(`Key '${e}' does not exist. ${t.message}`),"ERR_KEY_NOT_FOUND"))}}async removeKey(e){if(!v(e)||"self"===e)return w(l(new Error(`Invalid key name '${e}'`),"ERR_INVALID_KEY_NAME"));const t=_(e),r=await this.findKeyByName(e),i=this.store.batch();return i.delete(t),i.delete(E(e)),await i.commit(),r}async renameKey(e,t){const r=this;if(!v(e)||"self"===e)return w(l(new Error(`Invalid old key name '${e}'`),"ERR_OLD_KEY_NAME_INVALID"));if(!v(t)||"self"===t)return w(l(new Error(`Invalid new key name '${t}'`),"ERR_NEW_KEY_NAME_INVALID"));const i=_(e),n=_(t),s=E(e),o=E(t);if(await r.store.has(n))return w(l(new Error(`Key '${t}' already exists`),"ERR_KEY_ALREADY_EXISTS"));try{const e=await r.store.get(i),a=await r.store.get(s),c=JSON.parse(d(a));c.name=t;const u=r.store.batch();return u.put(n,e),u.put(o,f(JSON.stringify(c))),u.delete(i),u.delete(s),await u.commit(),c}catch(e){return w(e)}}async exportKey(e,t){if(!v(e))return w(l(new Error(`Invalid key name '${e}'`),"ERR_INVALID_KEY_NAME"));if(!t)return w(l(new Error("Password is required"),"ERR_PASSWORD_REQUIRED"));const r=_(e);try{const e=await this.store.get(r),i=d(e),n=p.get(this).dek;return(await a.keys.import(i,n)).export(t)}catch(e){return w(e)}}async importKey(e,t,r){if(!v(e)||"self"===e)return w(l(new Error(`Invalid key name '${e}'`),"ERR_INVALID_KEY_NAME"));if(!t)return w(l(new Error("PEM encoded key is required"),"ERR_PEM_REQUIRED"));const i=_(e);if(await this.store.has(i))return w(l(new Error(`Key '${e}' already exists`),"ERR_KEY_ALREADY_EXISTS"));let n,s;try{n=await a.keys.import(t,r)}catch(e){return w(l(new Error("Cannot read the key, most likely the password is wrong"),"ERR_CANNOT_READ_KEY"))}try{s=await n.id();const e=p.get(this).dek;t=await n.export(e)}catch(e){return w(e)}const o={name:e,id:s},c=this.store.batch();return c.put(i,f(t)),c.put(E(e),f(JSON.stringify(o))),await c.commit(),o}async importPeer(e,t){const r=this;if(!v(e))return w(l(new Error(`Invalid key name '${e}'`),"ERR_INVALID_KEY_NAME"));if(!t||!t.privKey)return w(l(new Error("Peer.privKey is required"),"ERR_MISSING_PRIVATE_KEY"));const i=t.privKey,n=_(e);if(await r.store.has(n))return w(l(new Error(`Key '${e}' already exists`),"ERR_KEY_ALREADY_EXISTS"));try{const t=await i.id(),s=p.get(this).dek,o=await i.export(s),a={name:e,id:t},c=r.store.batch();return c.put(n,f(o)),c.put(E(e),f(JSON.stringify(a))),await c.commit(),a}catch(e){return w(e)}}async _getPrivateKey(e){if(!v(e))return w(l(new Error(`Invalid key name '${e}'`),"ERR_INVALID_KEY_NAME"));try{const t=_(e),r=await this.store.get(t);return d(r)}catch(t){return w(l(new Error(`Key '${e}' does not exist. ${t.message}`),"ERR_KEY_NOT_FOUND"))}}async rotateKeychainPass(e,t){if("string"!=typeof e)return w(l(new Error(`Invalid old pass type '${typeof e}'`),"ERR_INVALID_OLD_PASS_TYPE"));if("string"!=typeof t)return w(l(new Error(`Invalid new pass type '${typeof t}'`),"ERR_INVALID_NEW_PASS_TYPE"));if(t.length<20)return w(l(new Error(`Invalid pass length ${t.length}`),"ERR_INVALID_PASS_LENGTH"));n("recreating keychain");const r=p.get(this).dek;this.opts.pass=t;const i=t?a.pbkdf2(t,this.opts.dek.salt,this.opts.dek.iterationCount,this.opts.dek.keyLength,this.opts.dek.hash):"";p.set(this,{dek:i});const s=await this.listKeys();for(const e of s){const t=await this.store.get(_(e.name)),n=d(t),s=await a.keys.import(n,r),o=i.toString(),c=await s.export(o),u=this.store.batch(),l={name:e.name,id:e.id};u.put(_(e.name),f(c)),u.put(E(e.name),f(JSON.stringify(l))),await u.commit()}n("keychain reconstructed")}}},{debug:"bO5wM","sanitize-filename":"gfrhY","merge-options":"fupyv","libp2p-crypto":"bb1cb","interface-datastore/key":"9hGOz","./cms":"2CEx0","err-code":"chZjB","uint8arrays/to-string":"hC8JB","uint8arrays/from-string":"dF7Y4","node-forge/lib/sha512":"9XKJ9"}],gfrhY:[function(e,t,r){"use strict";var i=e("truncate-utf8-bytes"),n=/[\/\?<>\\:\*\|"]/g,s=/[\x00-\x1f\x80-\x9f]/g,o=/^\.+$/,a=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,c=/[\. ]+$/;function u(e,t){if("string"!=typeof e)throw new Error("Input must be string");var r=e.replace(n,t).replace(s,t).replace(o,t).replace(a,t).replace(c,t);return i(r,255)}t.exports=function(e,t){var r=t&&t.replacement||"",i=u(e,r);return""===r?i:u(i,"")}},{"truncate-utf8-bytes":"jMN74"}],jMN74:[function(e,t,r){"use strict";var i=e("./lib/truncate"),n=e("utf8-byte-length/browser");t.exports=i.bind(null,n)},{"./lib/truncate":"16NPs","utf8-byte-length/browser":"3kc7b"}],"16NPs":[function(e,t,r){"use strict";function i(e){return e>=55296&&e<=56319}function n(e){return e>=56320&&e<=57343}t.exports=function(e,t,r){if("string"!=typeof t)throw new Error("Input must be string");for(var s,o,a=t.length,c=0,u=0;ur)return t.slice(0,u-o.length+1)}return t}},{}],"3kc7b":[function(e,t,r){"use strict";function i(e){return e>=55296&&e<=56319}function n(e){return e>=56320&&e<=57343}t.exports=function(e){if("string"!=typeof e)throw new Error("Input must be string");for(var t=e.length,r=0,s=null,o=null,a=0;a=128&&s<=2047?r+=2:s>=2048&&s<=65535&&(r+=3),o=s;return r}},{}],"2CEx0":[function(e,t,r){"use strict";e("node-forge/lib/pkcs7"),e("node-forge/lib/pbe");const i=e("node-forge/lib/forge"),{certificateForKey:n,findAsync:s}=e("./util"),o=e("err-code"),{fromString:a}=e("uint8arrays/from-string"),{toString:c}=e("uint8arrays/to-string"),u=new WeakMap;t.exports=class{constructor(e,t){if(!e)throw o(new Error("keychain is required"),"ERR_KEYCHAIN_REQUIRED");this.keychain=e,u.set(this,{dek:t})}async encrypt(e,t){if(!(t instanceof Uint8Array))throw o(new Error("Plain data must be a Uint8Array"),"ERR_INVALID_PARAMS");const r=await this.keychain.findKeyByName(e),s=await this.keychain._getPrivateKey(e),c=u.get(this).dek,l=i.pki.decryptRsaPrivateKey(s,c),d=await n(r,l),f=i.pkcs7.createEnvelopedData();f.addRecipient(d),f.content=i.util.createBuffer(t),f.encrypt();const h=i.asn1.toDer(f.toAsn1()).getBytes();return a(h,"ascii")}async decrypt(e){if(!(e instanceof Uint8Array))throw o(new Error("CMS data is required"),"ERR_INVALID_PARAMS");let t;try{const r=i.util.createBuffer(c(e,"ascii")),n=i.asn1.fromDer(r);t=i.pkcs7.messageFromAsn1(n)}catch(e){throw o(new Error("Invalid CMS: "+e.message),"ERR_INVALID_CMS")}const r=t.recipients.filter((e=>e.issuer.find((e=>"O"===e.shortName&&"ipfs"===e.value)))).filter((e=>e.issuer.find((e=>"CN"===e.shortName)))).map((e=>({recipient:e,keyId:e.issuer.find((e=>"CN"===e.shortName)).value}))),n=await s(r,(async e=>{try{if(await this.keychain.findKeyById(e.keyId))return!0}catch(e){return!1}return!1}));if(!n){const e=r.map((e=>e.keyId));throw o(new Error("Decryption needs one of the key(s): "+e.join(", ")),"ERR_MISSING_KEYS",{missingKeys:e})}const l=await this.keychain.findKeyById(n.keyId);if(!l)throw o(new Error("No key available to decrypto"),"ERR_NO_KEY");const d=await this.keychain._getPrivateKey(l.name),f=u.get(this).dek,h=i.pki.decryptRsaPrivateKey(d,f);return t.decrypt(n.recipient,h),a(t.content.getBytes(),"ascii")}}},{"node-forge/lib/pkcs7":"2u5SG","node-forge/lib/pbe":"gUP8s","node-forge/lib/forge":"4OuPD","./util":"hlA8C","err-code":"chZjB","uint8arrays/from-string":"dF7Y4","uint8arrays/to-string":"hC8JB"}],"2u5SG":[function(e,t,r){var i=e("./forge");e("./aes"),e("./asn1"),e("./des"),e("./oids"),e("./pem"),e("./pkcs7asn1"),e("./random"),e("./util"),e("./x509");var n=i.asn1,s=t.exports=i.pkcs7=i.pkcs7||{};function o(e){var t={},r=[];if(!n.validate(e,s.asn1.recipientInfoValidator,t,r)){var o=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw o.errors=r,o}return{version:t.version.charCodeAt(0),issuer:i.pki.RDNAttributesAsArray(t.issuer),serialNumber:i.util.createBuffer(t.serial).toHex(),encryptedContent:{algorithm:n.derToOid(t.encAlgorithm),parameter:t.encParameter.value,content:t.encKey}}}function a(e){for(var t,r=[],s=0;s0){for(var r=n.create(n.Class.CONTEXT_SPECIFIC,1,!0,[]),s=0;s=r&&o0&&o.value[0].value.push(n.create(n.Class.CONTEXT_SPECIFIC,0,!0,t)),s.length>0&&o.value[0].value.push(n.create(n.Class.CONTEXT_SPECIFIC,1,!0,s)),o.value[0].value.push(n.create(n.Class.UNIVERSAL,n.Type.SET,!0,e.signerInfos)),n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OID,!1,n.oidToDer(e.type).getBytes()),o])},addSigner:function(t){var r=t.issuer,n=t.serialNumber;if(t.certificate){var s=t.certificate;"string"==typeof s&&(s=i.pki.certificateFromPem(s)),r=s.issuer.attributes,n=s.serialNumber}var o=t.key;if(!o)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof o&&(o=i.pki.privateKeyFromPem(o));var a=t.digestAlgorithm||i.pki.oids.sha1;switch(a){case i.pki.oids.sha1:case i.pki.oids.sha256:case i.pki.oids.sha384:case i.pki.oids.sha512:case i.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+a)}var c=t.authenticatedAttributes||[];if(c.length>0){for(var u=!1,l=!1,d=0;d128)throw new Error('Invalid "nsComment" content.');e.value=n.create(n.Class.UNIVERSAL,n.Type.IA5STRING,!1,e.comment)}else if("subjectKeyIdentifier"===e.name&&t.cert){var h=t.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=h.toHex(),e.value=n.create(n.Class.UNIVERSAL,n.Type.OCTETSTRING,!1,h.getBytes())}else if("authorityKeyIdentifier"===e.name&&t.cert){e.value=n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[]);l=e.value.value;if(e.keyIdentifier){var p=!0===e.keyIdentifier?t.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;l.push(n.create(n.Class.CONTEXT_SPECIFIC,0,!1,p))}if(e.authorityCertIssuer){var y=[n.create(n.Class.CONTEXT_SPECIFIC,4,!0,[g(!0===e.authorityCertIssuer?t.cert.issuer:e.authorityCertIssuer)])];l.push(n.create(n.Class.CONTEXT_SPECIFIC,1,!0,y))}if(e.serialNumber){var m=i.util.hexToBytes(!0===e.serialNumber?t.cert.serialNumber:e.serialNumber);l.push(n.create(n.Class.CONTEXT_SPECIFIC,2,!1,m))}}else if("cRLDistributionPoints"===e.name){e.value=n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[]);l=e.value.value;var b,v=n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[]),w=n.create(n.Class.CONTEXT_SPECIFIC,0,!0,[]);for(f=0;f2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(d.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(c.validity.notBefore=d[0],c.validity.notAfter=d[1],c.tbsCertificate=r.tbsCertificate,t){var f;if(c.md=null,c.signatureOid in o)switch(o[c.signatureOid]){case"sha1WithRSAEncryption":c.md=i.md.sha1.create();break;case"md5WithRSAEncryption":c.md=i.md.md5.create();break;case"sha256WithRSAEncryption":case"RSASSA-PSS":c.md=i.md.sha256.create();break;case"sha384WithRSAEncryption":c.md=i.md.sha384.create();break;case"sha512WithRSAEncryption":c.md=i.md.sha512.create()}if(null===c.md)throw(f=new Error("Could not compute certificate digest. Unknown signature OID.")).signatureOid=c.signatureOid,f;var g=n.toDer(c.tbsCertificate);c.md.update(g.getBytes())}var m=i.md.sha1.create();c.issuer.getField=function(e){return h(c.issuer,e)},c.issuer.addField=function(e){y([e]),c.issuer.attributes.push(e)},c.issuer.attributes=s.RDNAttributesAsArray(r.certIssuer,m),r.certIssuerUniqueId&&(c.issuer.uniqueId=r.certIssuerUniqueId),c.issuer.hash=m.digest().toHex();var b=i.md.sha1.create();return c.subject.getField=function(e){return h(c.subject,e)},c.subject.addField=function(e){y([e]),c.subject.attributes.push(e)},c.subject.attributes=s.RDNAttributesAsArray(r.certSubject,b),r.certSubjectUniqueId&&(c.subject.uniqueId=r.certSubjectUniqueId),c.subject.hash=b.digest().toHex(),r.certExtensions?c.extensions=s.certificateExtensionsFromAsn1(r.certExtensions):c.extensions=[],c.publicKey=s.publicKeyFromAsn1(r.subjectPublicKeyInfo),c},s.certificateExtensionsFromAsn1=function(e){for(var t=[],r=0;r1&&(r=c.value.charCodeAt(1),s=c.value.length>2?c.value.charCodeAt(2):0),t.digitalSignature=128==(128&r),t.nonRepudiation=64==(64&r),t.keyEncipherment=32==(32&r),t.dataEncipherment=16==(16&r),t.keyAgreement=8==(8&r),t.keyCertSign=4==(4&r),t.cRLSign=2==(2&r),t.encipherOnly=1==(1&r),t.decipherOnly=128==(128&s)}else if("basicConstraints"===t.name){(c=n.fromDer(t.value)).value.length>0&&c.value[0].type===n.Type.BOOLEAN?t.cA=0!==c.value[0].value.charCodeAt(0):t.cA=!1;var a=null;c.value.length>0&&c.value[0].type===n.Type.INTEGER?a=c.value[0].value:c.value.length>1&&(a=c.value[1].value),null!==a&&(t.pathLenConstraint=n.derToInteger(a))}else if("extKeyUsage"===t.name)for(var c=n.fromDer(t.value),u=0;u1&&(r=c.value.charCodeAt(1)),t.client=128==(128&r),t.server=64==(64&r),t.email=32==(32&r),t.objsign=16==(16&r),t.reserved=8==(8&r),t.sslCA=4==(4&r),t.emailCA=2==(2&r),t.objCA=1==(1&r)}else if("subjectAltName"===t.name||"issuerAltName"===t.name){var d;t.altNames=[];c=n.fromDer(t.value);for(var f=0;f=w&&e<_?n.create(n.Class.UNIVERSAL,n.Type.UTCTIME,!1,n.dateToUtcTime(e)):n.create(n.Class.UNIVERSAL,n.Type.GENERALIZEDTIME,!1,n.dateToGeneralizedTime(e))}s.getTBSCertificate=function(e){var t=E(e.validity.notBefore),r=E(e.validity.notAfter),o=n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.CONTEXT_SPECIFIC,0,!0,[n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,n.integerToDer(e.version).getBytes())]),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,i.util.hexToBytes(e.serialNumber)),n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OID,!1,n.oidToDer(e.siginfo.algorithmOid).getBytes()),b(e.siginfo.algorithmOid,e.siginfo.parameters)]),g(e.issuer),n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[t,r]),g(e.subject),s.publicKeyToAsn1(e.publicKey)]);return e.issuer.uniqueId&&o.value.push(n.create(n.Class.CONTEXT_SPECIFIC,1,!0,[n.create(n.Class.UNIVERSAL,n.Type.BITSTRING,!1,String.fromCharCode(0)+e.issuer.uniqueId)])),e.subject.uniqueId&&o.value.push(n.create(n.Class.CONTEXT_SPECIFIC,2,!0,[n.create(n.Class.UNIVERSAL,n.Type.BITSTRING,!1,String.fromCharCode(0)+e.subject.uniqueId)])),e.extensions.length>0&&o.value.push(s.certificateExtensionsToAsn1(e.extensions)),o},s.getCertificationRequestInfo=function(e){return n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,n.integerToDer(e.version).getBytes()),g(e.subject),s.publicKeyToAsn1(e.publicKey),v(e)])},s.distinguishedNameToAsn1=function(e){return g(e)},s.certificateToAsn1=function(e){var t=e.tbsCertificate||s.getTBSCertificate(e);return n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[t,n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OID,!1,n.oidToDer(e.signatureOid).getBytes()),b(e.signatureOid,e.signatureParameters)]),n.create(n.Class.UNIVERSAL,n.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},s.certificateExtensionsToAsn1=function(e){var t=n.create(n.Class.CONTEXT_SPECIFIC,3,!0,[]),r=n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[]);t.value.push(r);for(var i=0;il.validity.notAfter)&&(c={message:"Certificate is not valid yet or has expired.",error:s.certificateError.certificate_expired,notBefore:l.validity.notBefore,notAfter:l.validity.notAfter,now:o}),null===c){if(null===(d=t[0]||e.getIssuer(l))&&l.isIssuer(l)&&(f=!0,d=l),d){var h=d;i.util.isArray(h)||(h=[h]);for(var p=!1;!p&&h.length>0;){d=h.shift();try{p=d.verify(l)}catch(e){}}p||(c={message:"Certificate signature is invalid.",error:s.certificateError.bad_certificate})}null!==c||d&&!f||e.hasCertificate(l)||(c={message:"Certificate is not trusted.",error:s.certificateError.unknown_ca})}if(null===c&&d&&!l.isIssuer(d)&&(c={message:"Certificate issuer is invalid.",error:s.certificateError.bad_certificate}),null===c)for(var g={keyUsage:!0,basicConstraints:!0},y=0;null===c&&yb.pathLenConstraint&&(c={message:"Certificate basicConstraints pathLenConstraint violated.",error:s.certificateError.bad_certificate})}var w=null===c||c.error,_=r.verify?r.verify(w,u,n):w;if(!0!==_)throw!0===w&&(c={message:"The application rejected the certificate.",error:s.certificateError.bad_certificate}),(_||0===_)&&("object"!=typeof _||i.util.isArray(_)?"string"==typeof _&&(c.error=_):(_.message&&(c.message=_.message),_.error&&(c.error=_.error))),c;c=null,a=!1,++u}while(t.length>0);return!0}},{"./forge":"4OuPD","./aes":"1SAd7","./asn1":"bcsXQ","./des":"6e2qD","./md":"fYbz5","./mgf":"igoKv","./oids":"7VPL4","./pem":"9qqi9","./pss":"fYf6X","./rsa":"9ROH2","./util":"df43p"}],igoKv:[function(e,t,r){var i=e("./forge");e("./mgf1"),t.exports=i.mgf=i.mgf||{},i.mgf.mgf1=i.mgf1},{"./forge":"4OuPD","./mgf1":"d3pVa"}],d3pVa:[function(e,t,r){var i=e("./forge");e("./util"),i.mgf=i.mgf||{},(t.exports=i.mgf.mgf1=i.mgf1=i.mgf1||{}).create=function(e){return{generate:function(t,r){for(var n=new i.util.ByteBuffer,s=Math.ceil(r/e.digestLength),o=0;o>8*f-d&255;return(w=String.fromCharCode(w.charCodeAt(0)&~_)+w.substr(1))+g+String.fromCharCode(188)},verify:function(e,o,a){var c,u=a-1,l=Math.ceil(u/8);if(o=o.substr(-l),l>8*l-u&255;if(0!=(f.charCodeAt(0)&p))throw new Error("Bits beyond keysize not zero as expected.");var g=n.generate(h,d),y="";for(c=0;c{const r=i.setRsaPublicKey(t.n,t.e),n=i.createCertificate();n.publicKey=r,n.serialNumber="01",n.validity.notBefore=new Date,n.validity.notAfter=new Date,n.validity.notAfter.setFullYear(n.validity.notBefore.getFullYear()+10);const s=[{name:"organizationName",value:"ipfs"},{shortName:"OU",value:"keystore"},{name:"commonName",value:e.id}];return n.setSubject(s),n.setIssuer(s),n.setExtensions([{name:"basicConstraints",cA:!0},{name:"keyUsage",keyCertSign:!0,digitalSignature:!0,nonRepudiation:!0,keyEncipherment:!0,dataEncipherment:!0},{name:"extKeyUsage",serverAuth:!0,clientAuth:!0,codeSigning:!0,emailProtection:!0,timeStamping:!0},{name:"nsCertType",client:!0,server:!0,email:!0,objsign:!0,sslCA:!0,emailCA:!0,objCA:!0}]),n.sign(t),n},findAsync:async function(e,t){const r=e.map(t);return e[(await Promise.all(r)).findIndex((e=>e))]}}},{"node-forge/lib/x509":"f2ToB","node-forge/lib/forge":"4OuPD"}],jy74B:[function(e,t,r){"use strict";const i=e("merge-options"),{pipe:n}=e("it-pipe"),{tap:s}=e("streaming-iterables"),o=e("./old-peers"),{METRICS:a}=e("../constants"),c=e("./stats"),u=["dataReceived","dataSent"],l={in:"dataReceived",out:"dataSent"};class d{constructor(e){this._options=i(a,e),this._globalStats=new c(u,this._options),this._peerStats=new Map,this._protocolStats=new Map,this._oldPeers=o(this._options.maxOldPeersRetention),this._running=!1,this._onMessage=this._onMessage.bind(this),this._connectionManager=e.connectionManager,this._connectionManager.on("peer:disconnect",(e=>{this.onPeerDisconnected(e.remotePeer)}))}start(){this._running=!0}stop(){this._running=!1,this._globalStats.stop();for(const e of this._peerStats.values())e.stop();for(const e of this._protocolStats.values())e.stop()}get global(){return this._globalStats}get peers(){return Array.from(this._peerStats.keys())}forPeer(e){const t=e.toB58String();return this._peerStats.get(t)||this._oldPeers.get(t)}get protocols(){return Array.from(this._protocolStats.keys())}forProtocol(e){return this._protocolStats.get(e)}onPeerDisconnected(e){const t=e.toB58String(),r=this._peerStats.get(t);r&&(r.stop(),this._peerStats.delete(t),this._oldPeers.set(t,r))}_onMessage({remotePeer:e,protocol:t,direction:r,dataLength:i}){if(!this._running)return;const n=l[r];let s=this.forPeer(e);if(s||(s=new c(u,this._options),this._peerStats.set(e.toB58String(),s)),s.push(n,i),this._globalStats.push(n,i),t){let e=this.forProtocol(t);e||(e=new c(u,this._options),this._protocolStats.set(t,e)),e.push(n,i)}}updatePlaceholder(e,t){if(!this._running)return;const r=this.forPeer(e),i=t.toB58String(),n=this.forPeer(t);let s=r;n&&(s=d.mergeStats(n,s),this._oldPeers.delete(i)),this._peerStats.delete(e.toB58String()),this._peerStats.set(i,s),s.start()}trackStream({stream:e,remotePeer:t,protocol:r}){const i=this,o=e.source;e.source=s((e=>i._onMessage({remotePeer:t,protocol:r,direction:"in",dataLength:e.length})))(o);const a=e.sink;return e.sink=e=>n(e,s((e=>i._onMessage({remotePeer:t,protocol:r,direction:"out",dataLength:e.length}))),a),e}static mergeStats(e,t){return e.stop(),t.stop(),e._queue=[...e._queue,...t._queue],e}}t.exports=d},{"merge-options":"fupyv","it-pipe":"giKBQ","streaming-iterables":"jrrai","./old-peers":"98TJE","../constants":"92Vak","./stats":"e6AW2"}],"98TJE":[function(e,t,r){"use strict";const i=e("hashlru");t.exports=e=>{const t=i(e);return t.delete=t.remove,t}},{hashlru:"kBj5c"}],e6AW2:[function(e,t,r){"use strict";const{EventEmitter:i}=e("events"),{BigNumber:n}=e("bignumber.js"),s=e("@vascosantos/moving-average"),o=e("retimer");t.exports=class extends i{constructor(e,t){super(),this._options=t,this._queue=[],this._stats={dataReceived:n(0),dataSent:n(0)},this._frequencyLastTime=Date.now(),this._frequencyAccumulators={},this._movingAverages={},this._update=this._update.bind(this);const r=this._options.movingAverageIntervals;for(let t=0;t{this._updateFrequencyFor(r,t,e)})),this._frequencyLastTime=e}_updateFrequencyFor(e,t,r){const i=this._frequencyAccumulators[e]||0;this._frequencyAccumulators[e]=0;const n=i/(t||1)*1e3;let o=this._movingAverages[e];o||(o=this._movingAverages[e]={});const a=this._options.movingAverageIntervals;for(let e=0;e0||e===t?t:t-1}function g(e){for(var t,r,i=1,n=e.length,s=e[0]+"";iu^r?1:-1;for(a=(c=n.length)<(u=s.length)?c:u,o=0;os[o]^r?1:-1;return c==u?0:c>u^r?1:-1}function m(e,t,r,i){if(er||e!==s(e))throw Error(o+(i||"Argument")+("number"==typeof e?er?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function b(e){var t=e.c.length-1;return p(e.e/u)==t&&e.c[t]%2!=0}function v(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function w(e,t,r){var i,n;if(t<0){for(n=r+".";++t;n+=r);e=n+e}else if(++t>(i=e.length)){for(n=r,t-=i;--t;n+=r);e+=n}else tL?g.c=g.e=null:e.e=10;d/=10,c++);return void(c>L?g.c=g.e=null:(g.e=c,g.c=[e]))}p=String(e)}else{if(!i.test(p=String(e)))return E(g,p,f);g.s=45==p.charCodeAt(0)?(p=p.slice(1),-1):1}(c=p.indexOf("."))>-1&&(p=p.replace(".","")),(d=p.search(/e/i))>0?(c<0&&(c=d),c+=+p.slice(d+1),p=p.substring(0,d)):c<0&&(c=p.length)}else{if(m(t,2,z.length,"Base"),10==t)return $(g=new V(e),j+g.e+1,D);if(p=String(e),f="number"==typeof e){if(0*e!=0)return E(g,p,f,t);if(g.s=1/e<0?(p=p.slice(1),-1):1,V.DEBUG&&p.replace(/^0\.0*|\./,"").length>15)throw Error(a+e)}else g.s=45===p.charCodeAt(0)?(p=p.slice(1),-1):1;for(r=z.slice(0,t),c=d=0,h=p.length;dc){c=h;continue}}else if(!o&&(p==p.toUpperCase()&&(p=p.toLowerCase())||p==p.toLowerCase()&&(p=p.toUpperCase()))){o=!0,d=-1,c=0;continue}return E(g,String(e),f,t)}f=!1,(c=(p=_(p,t,10,g.s)).indexOf("."))>-1?p=p.replace(".",""):c=p.length}for(d=0;48===p.charCodeAt(d);d++);for(h=p.length;48===p.charCodeAt(--h););if(p=p.slice(d,++h)){if(h-=d,f&&V.DEBUG&&h>15&&(e>l||e!==s(e)))throw Error(a+g.s*e);if((c=c-d-1)>L)g.c=g.e=null;else if(c=x)?v(c,o):w(c,o,"0");else if(s=(e=$(new V(e),t,r)).e,a=(c=g(e.c)).length,1==i||2==i&&(t<=s||s<=M)){for(;aa){if(--t>0)for(c+=".";t--;c+="0");}else if((t+=s-a)>0)for(s+1==a&&(c+=".");t--;c+="0");return e.s<0&&n?"-"+c:c}function G(e,t){for(var r,i=1,n=new V(e[0]);i=10;n/=10,i++);return(r=i+r*u-1)>L?e.c=e.e=null:r=10;f/=10,o++);if((a=t-o)<0)a+=u,l=t,g=(h=y[p=0])/m[o-l-1]%10|0;else if((p=n((a+1)/u))>=y.length){if(!i)break e;for(;y.length<=p;y.push(0));h=g=0,o=1,l=(a%=u)-u+1}else{for(h=f=y[p],o=1;f>=10;f/=10,o++);g=(l=(a%=u)-u+o)<0?0:h/m[o-l-1]%10|0}if(i=i||t<0||null!=y[p+1]||(l<0?h:h%m[o-l-1]),i=r<4?(g||i)&&(0==r||r==(e.s<0?3:2)):g>5||5==g&&(4==r||i||6==r&&(a>0?l>0?h/m[o-l]:0:y[p-1])%10&1||r==(e.s<0?8:7)),t<1||!y[0])return y.length=0,i?(t-=e.e+1,y[0]=m[(u-t%u)%u],e.e=-t||0):y[0]=e.e=0,e;if(0==a?(y.length=p,f=1,p--):(y.length=p+1,f=m[u-a],y[p]=l>0?s(h/m[o-l]%m[l])*f:0),i)for(;;){if(0==p){for(a=1,l=y[0];l>=10;l/=10,a++);for(l=y[0]+=f,f=1;l>=10;l/=10,f++);a!=f&&(e.e++,y[0]==c&&(y[0]=1));break}if(y[p]+=f,y[p]!=c)break;y[p--]=0,f=1}for(a=y.length;0===y[--a];y.pop());}e.e>L?e.c=e.e=null:e.e=x?v(t,r):w(t,r,"0"),e.s<0?"-"+t:t)}return V.clone=e,V.ROUND_UP=0,V.ROUND_DOWN=1,V.ROUND_CEIL=2,V.ROUND_FLOOR=3,V.ROUND_HALF_UP=4,V.ROUND_HALF_DOWN=5,V.ROUND_HALF_EVEN=6,V.ROUND_HALF_CEIL=7,V.ROUND_HALF_FLOOR=8,V.EUCLID=9,V.config=V.set=function(e){var t,r;if(null!=e){if("object"!=typeof e)throw Error(o+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(m(r=e[t],0,h,t),j=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(m(r=e[t],0,8,t),D=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(m(r[0],-h,0,t),m(r[1],0,h,t),M=r[0],x=r[1]):(m(r,-h,h,t),M=-(x=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)m(r[0],-h,-1,t),m(r[1],1,h,t),B=r[0],L=r[1];else{if(m(r,-h,h,t),!r)throw Error(o+t+" cannot be zero: "+r);B=-(L=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(o+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw N=!r,Error(o+"crypto unavailable");N=r}else N=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(m(r=e[t],0,9,t),U=r),e.hasOwnProperty(t="POW_PRECISION")&&(m(r=e[t],0,h,t),F=r),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(r=e[t]))throw Error(o+t+" not an object: "+r);K=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(o+t+" invalid: "+r);z=r}}return{DECIMAL_PLACES:j,ROUNDING_MODE:D,EXPONENTIAL_AT:[M,x],RANGE:[B,L],CRYPTO:N,MODULO_MODE:U,POW_PRECISION:F,FORMAT:K,ALPHABET:z}},V.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!V.DEBUG)return!0;var t,r,i=e.c,n=e.e,a=e.s;e:if("[object Array]"=={}.toString.call(i)){if((1===a||-1===a)&&n>=-h&&n<=h&&n===s(n)){if(0===i[0]){if(0===n&&1===i.length)return!0;break e}if((t=(n+1)%u)<1&&(t+=u),String(i[0]).length==t){for(t=0;t=c||r!==s(r))break e;if(0!==r)return!0}}}else if(null===i&&null===n&&(null===a||1===a||-1===a))return!0;throw Error(o+"Invalid BigNumber: "+e)},V.maximum=V.max=function(){return G(arguments,O.lt)},V.minimum=V.min=function(){return G(arguments,O.gt)},V.random=(S=9007199254740992,T=Math.random()*S&2097151?function(){return s(Math.random()*S)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,i,a,c,l=0,f=[],p=new V(C);if(null==e?e=j:m(e,0,h),a=n(e/u),N)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(a*=2));l>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),t[l]=r[0],t[l+1]=r[1]):(f.push(c%1e14),l+=2);l=a/2}else{if(!crypto.randomBytes)throw N=!1,Error(o+"crypto unavailable");for(t=crypto.randomBytes(a*=7);l=9e15?crypto.randomBytes(7).copy(t,l):(f.push(c%1e14),l+=7);l=a/7}if(!N)for(;l=10;c/=10,l++);lr-1&&(null==o[n+1]&&(o[n+1]=0),o[n+1]+=o[n]/r|0,o[n]%=r)}return o.reverse()}return function(i,n,s,o,a){var c,u,l,d,f,h,p,y,m=i.indexOf("."),b=j,v=D;for(m>=0&&(d=F,F=0,i=i.replace(".",""),h=(y=new V(n)).pow(i.length-m),F=d,y.c=t(w(g(h.c),h.e,"0"),10,s,e),y.e=y.c.length),l=d=(p=t(i,n,s,a?(c=z,e):(c=e,z))).length;0==p[--d];p.pop());if(!p[0])return c.charAt(0);if(m<0?--l:(h.c=p,h.e=l,h.s=o,p=(h=r(h,y,b,v,s)).c,f=h.r,l=h.e),m=p[u=l+b+1],d=s/2,f=f||u<0||null!=p[u+1],f=v<4?(null!=m||f)&&(0==v||v==(h.s<0?3:2)):m>d||m==d&&(4==v||f||6==v&&1&p[u-1]||v==(h.s<0?8:7)),u<1||!p[0])i=f?w(c.charAt(1),-b,c.charAt(0)):c.charAt(0);else{if(p.length=u,f)for(--s;++p[--u]>s;)p[u]=0,u||(++l,p=[1].concat(p));for(d=p.length;!p[--d];);for(m=0,i="";m<=d;i+=c.charAt(p[m++]));i=w(i,l,c.charAt(0))}return i}}(),r=function(){function e(e,t,r){var i,n,s,o,a=0,c=e.length,u=t%f,l=t/f|0;for(e=e.slice();c--;)a=((n=u*(s=e[c]%f)+(i=l*s+(o=e[c]/f|0)*u)%f*f+a)/r|0)+(i/f|0)+l*o,e[c]=n%r;return a&&(e=[a].concat(e)),e}function t(e,t,r,i){var n,s;if(r!=i)s=r>i?1:-1;else for(n=s=0;nt[n]?1:-1;break}return s}function r(e,t,r,i){for(var n=0;r--;)e[r]-=n,n=e[r]1;e.splice(0,1));}return function(i,n,o,a,l){var d,f,h,g,y,m,b,v,w,_,E,S,T,A,k,I,R,P=i.s==n.s?1:-1,O=i.c,C=n.c;if(!(O&&O[0]&&C&&C[0]))return new V(i.s&&n.s&&(O?!C||O[0]!=C[0]:C)?O&&0==O[0]||!C?0*P:P/0:NaN);for(w=(v=new V(P)).c=[],P=o+(f=i.e-n.e)+1,l||(l=c,f=p(i.e/u)-p(n.e/u),P=P/u|0),h=0;C[h]==(O[h]||0);h++);if(C[h]>(O[h]||0)&&f--,P<0)w.push(1),g=!0;else{for(A=O.length,I=C.length,h=0,P+=2,(y=s(l/(C[0]+1)))>1&&(C=e(C,y,l),O=e(O,y,l),I=C.length,A=O.length),T=I,E=(_=O.slice(0,I)).length;E=l/2&&k++;do{if(y=0,(d=t(C,_,I,E))<0){if(S=_[0],I!=E&&(S=S*l+(_[1]||0)),(y=s(S/k))>1)for(y>=l&&(y=l-1),b=(m=e(C,y,l)).length,E=_.length;1==t(m,_,b,E);)y--,r(m,I=10;P/=10,h++);$(v,o+(v.e=h+f*u-1)+1,a,g)}else v.e=f,v.r=+g;return v}}(),A=/^(-?)0([xbo])(?=\w[\w.]*$)/i,k=/^([^.]+)\.$/,I=/^\.([^.]+)$/,R=/^-?(Infinity|NaN)$/,P=/^\s*\+(?=[\w.])|^\s+|\s+$/g,E=function(e,t,r,i){var n,s=r?t:t.replace(P,"");if(R.test(s))e.s=isNaN(s)?null:s<0?-1:1;else{if(!r&&(s=s.replace(A,(function(e,t,r){return n="x"==(r=r.toLowerCase())?16:"b"==r?2:8,i&&i!=n?e:t})),i&&(n=i,s=s.replace(k,"$1").replace(I,"0.$1")),t!=s))return new V(s,n);if(V.DEBUG)throw Error(o+"Not a"+(i?" base "+i:"")+" number: "+t);e.s=null}e.c=e.e=null},O.absoluteValue=O.abs=function(){var e=new V(this);return e.s<0&&(e.s=1),e},O.comparedTo=function(e,t){return y(this,new V(e,t))},O.decimalPlaces=O.dp=function(e,t){var r,i,n,s=this;if(null!=e)return m(e,0,h),null==t?t=D:m(t,0,8),$(new V(s),e+s.e+1,t);if(!(r=s.c))return null;if(i=((n=r.length-1)-p(this.e/u))*u,n=r[n])for(;n%10==0;n/=10,i--);return i<0&&(i=0),i},O.dividedBy=O.div=function(e,t){return r(this,new V(e,t),j,D)},O.dividedToIntegerBy=O.idiv=function(e,t){return r(this,new V(e,t),0,1)},O.exponentiatedBy=O.pow=function(e,t){var r,i,a,c,l,d,f,h,p=this;if((e=new V(e)).c&&!e.isInteger())throw Error(o+"Exponent not an integer: "+W(e));if(null!=t&&(t=new V(t)),l=e.e>14,!p.c||!p.c[0]||1==p.c[0]&&!p.e&&1==p.c.length||!e.c||!e.c[0])return h=new V(Math.pow(+W(p),l?2-b(e):+W(e))),t?h.mod(t):h;if(d=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new V(NaN);(i=!d&&p.isInteger()&&t.isInteger())&&(p=p.mod(t))}else{if(e.e>9&&(p.e>0||p.e<-1||(0==p.e?p.c[0]>1||l&&p.c[1]>=24e7:p.c[0]<8e13||l&&p.c[0]<=9999975e7)))return c=p.s<0&&b(e)?-0:0,p.e>-1&&(c=1/c),new V(d?1/c:c);F&&(c=n(F/u+2))}for(l?(r=new V(.5),d&&(e.s=1),f=b(e)):f=(a=Math.abs(+W(e)))%2,h=new V(C);;){if(f){if(!(h=h.times(p)).c)break;c?h.c.length>c&&(h.c.length=c):i&&(h=h.mod(t))}if(a){if(0===(a=s(a/2)))break;f=a%2}else if($(e=e.times(r),e.e+1,1),e.e>14)f=b(e);else{if(0===(a=+W(e)))break;f=a%2}p=p.times(p),c?p.c&&p.c.length>c&&(p.c.length=c):i&&(p=p.mod(t))}return i?h:(d&&(h=C.div(h)),t?h.mod(t):c?$(h,F,D,undefined):h)},O.integerValue=function(e){var t=new V(this);return null==e?e=D:m(e,0,8),$(t,t.e+1,e)},O.isEqualTo=O.eq=function(e,t){return 0===y(this,new V(e,t))},O.isFinite=function(){return!!this.c},O.isGreaterThan=O.gt=function(e,t){return y(this,new V(e,t))>0},O.isGreaterThanOrEqualTo=O.gte=function(e,t){return 1===(t=y(this,new V(e,t)))||0===t},O.isInteger=function(){return!!this.c&&p(this.e/u)>this.c.length-2},O.isLessThan=O.lt=function(e,t){return y(this,new V(e,t))<0},O.isLessThanOrEqualTo=O.lte=function(e,t){return-1===(t=y(this,new V(e,t)))||0===t},O.isNaN=function(){return!this.s},O.isNegative=function(){return this.s<0},O.isPositive=function(){return this.s>0},O.isZero=function(){return!!this.c&&0==this.c[0]},O.minus=function(e,t){var r,i,n,s,o=this,a=o.s;if(t=(e=new V(e,t)).s,!a||!t)return new V(NaN);if(a!=t)return e.s=-t,o.plus(e);var l=o.e/u,d=e.e/u,f=o.c,h=e.c;if(!l||!d){if(!f||!h)return f?(e.s=-t,e):new V(h?o:NaN);if(!f[0]||!h[0])return h[0]?(e.s=-t,e):new V(f[0]?o:3==D?-0:0)}if(l=p(l),d=p(d),f=f.slice(),a=l-d){for((s=a<0)?(a=-a,n=f):(d=l,n=h),n.reverse(),t=a;t--;n.push(0));n.reverse()}else for(i=(s=(a=f.length)<(t=h.length))?a:t,a=t=0;t0)for(;t--;f[r++]=0);for(t=c-1;i>a;){if(f[--i]=0;){for(r=0,y=S[n]%w,m=S[n]/w|0,s=n+(o=l);s>n;)r=((d=y*(d=E[--o]%w)+(a=m*d+(h=E[o]/w|0)*y)%w*w+b[s]+r)/v|0)+(a/w|0)+m*h,b[s--]=d%v;b[s]=r}return r?++i:b.splice(0,1),H(e,b,i)},O.negated=function(){var e=new V(this);return e.s=-e.s||null,e},O.plus=function(e,t){var r,i=this,n=i.s;if(t=(e=new V(e,t)).s,!n||!t)return new V(NaN);if(n!=t)return e.s=-t,i.minus(e);var s=i.e/u,o=e.e/u,a=i.c,l=e.c;if(!s||!o){if(!a||!l)return new V(n/0);if(!a[0]||!l[0])return l[0]?e:new V(a[0]?i:0*n)}if(s=p(s),o=p(o),a=a.slice(),n=s-o){for(n>0?(o=s,r=l):(n=-n,r=a),r.reverse();n--;r.push(0));r.reverse()}for((n=a.length)-(t=l.length)<0&&(r=l,l=a,a=r,t=n),n=0;t;)n=(a[--t]=a[t]+l[t]+n)/c|0,a[t]=c===a[t]?0:a[t]%c;return n&&(a=[n].concat(a),++o),H(e,a,o)},O.precision=O.sd=function(e,t){var r,i,n,s=this;if(null!=e&&e!==!!e)return m(e,1,h),null==t?t=D:m(t,0,8),$(new V(s),e,t);if(!(r=s.c))return null;if(i=(n=r.length-1)*u+1,n=r[n]){for(;n%10==0;n/=10,i--);for(n=r[0];n>=10;n/=10,i++);}return e&&s.e+1>i&&(i=s.e+1),i},O.shiftedBy=function(e){return m(e,-9007199254740991,l),this.times("1e"+e)},O.squareRoot=O.sqrt=function(){var e,t,i,n,s,o=this,a=o.c,c=o.s,u=o.e,l=j+4,d=new V("0.5");if(1!==c||!a||!a[0])return new V(!c||c<0&&(!a||a[0])?NaN:a?o:1/0);if(0==(c=Math.sqrt(+W(o)))||c==1/0?(((t=g(a)).length+u)%2==0&&(t+="0"),c=Math.sqrt(+t),u=p((u+1)/2)-(u<0||u%2),i=new V(t=c==1/0?"5e"+u:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+u)):i=new V(c+""),i.c[0])for((c=(u=i.e)+l)<3&&(c=0);;)if(s=i,i=d.times(s.plus(r(o,s,l,1))),g(s.c).slice(0,c)===(t=g(i.c)).slice(0,c)){if(i.e0&&g>0){for(s=g%c||c,d=p.substr(0,s);s0&&(d+=l+p.slice(s)),h&&(d="-"+d)}i=f?d+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?f.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):f):d}return(r.prefix||"")+i+(r.suffix||"")},O.toFraction=function(e){var t,i,n,s,a,c,l,f,h,p,y,m,b=this,v=b.c;if(null!=e&&(!(l=new V(e)).isInteger()&&(l.c||1!==l.s)||l.lt(C)))throw Error(o+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+W(l));if(!v)return new V(b);for(t=new V(C),h=i=new V(C),n=f=new V(C),m=g(v),a=t.e=m.length-b.e-1,t.c[0]=d[(c=a%u)<0?u+c:c],e=!e||l.comparedTo(t)>0?a>0?t:h:l,c=L,L=1/0,l=new V(m),f.c[0]=0;p=r(l,t,0,1),1!=(s=i.plus(p.times(n))).comparedTo(e);)i=n,n=s,h=f.plus(p.times(s=h)),f=s,t=l.minus(p.times(s=t)),l=s;return s=r(e.minus(i),n,0,1),f=f.plus(s.times(h)),i=i.plus(s.times(n)),f.s=h.s=b.s,y=r(h,n,a*=2,D).minus(b).abs().comparedTo(r(f,i,a,D).minus(b).abs())<1?[h,n]:[f,i],L=c,y},O.toNumber=function(){return+W(this)},O.toPrecision=function(e,t){return null!=e&&m(e,1,h),q(this,e,t,2)},O.toString=function(e){var t,r=this,i=r.s,n=r.e;return null===n?i?(t="Infinity",i<0&&(t="-"+t)):t="NaN":(null==e?t=n<=M||n>=x?v(g(r.c),n):w(g(r.c),n,"0"):10===e?t=w(g((r=$(new V(r),j+n+1,D)).c),r.e,"0"):(m(e,2,z.length,"Base"),t=_(w(g(r.c),n,"0"),10,e,i,!0)),i<0&&r.c[0]&&(t="-"+t)),t},O.valueOf=O.toJSON=function(){return W(this)},O._isBigNumber=!0,null!=t&&V.set(t),V}(),r.default=r.BigNumber=r,"function"==typeof define&&define.amd?define((function(){return r})):void 0!==t&&t.exports?t.exports=r:(e||(e="undefined"!=typeof self&&self?self:window),e.BigNumber=r)}(this)},{}],"2F3Pq":[function(e,t,r){"use strict";const i=Math.exp;t.exports=function(e){if("number"!=typeof e)throw new Error("must provide a timespan to the moving average constructor");if(e<=0)throw new Error("must provide a timespan > 0 to the moving average constructor");let t,r,n=0,s=0,o=0,a={};return a.push=function(a,c){if(r){const u=1-i(-(a-r)/e),l=c-t;t=u*c+(1-u)*t,n=(1-u)*(n+l*(u*l)),s=Math.sqrt(n),o=t+u*l}else t=c;r=a},a.movingAverage=function(){return t},a.variance=function(){return n},a.deviation=function(){return s},a.forecast=function(){return o},a}},{}],fdRaE:[function(e,t,r){"use strict";const i=e("debug"),n=Object.assign(i("libp2p:upgrader"),{error:i("libp2p:upgrader:err")}),s=e("err-code"),o=e("multistream-select"),{Connection:a}=e("libp2p-interfaces/src/connection"),c=e("peer-id"),{pipe:u}=e("it-pipe"),l=e("mutable-proxy"),{codes:d}=e("./errors");t.exports=class{constructor({localPeer:e,metrics:t,cryptos:r=new Map,muxers:i=new Map,onConnectionEnd:n=(()=>{}),onConnection:s=(()=>{})}){this.localPeer=e,this.metrics=t,this.cryptos=r,this.muxers=i,this.protector=null,this.protocols=new Map,this.onConnection=s,this.onConnectionEnd=n}async upgradeInbound(e){let t,r,i,s,o,a,c;if(this.metrics){({setTarget:a,proxy:c}=l());const t=(1e9*Math.random()).toString(36)+Date.now();a({toB58String:()=>t}),e=this.metrics.trackStream({stream:e,remotePeer:c})}n("Starting the inbound connection upgrade");let u=e;this.protector&&(u=await this.protector.protect(e));try{({conn:t,remotePeer:r,protocol:o}=await this._encryptInbound(this.localPeer,u,this.cryptos)),this.muxers.size?({stream:i,Muxer:s}=await this._multiplexInbound(t,this.muxers)):i=t}catch(t){throw n.error("Failed to upgrade inbound connection",t),await e.close(t),t}return this.metrics&&(this.metrics.updatePlaceholder(c,r),a(r)),n("Successfully upgraded inbound connection"),this._createConnection({cryptoProtocol:o,direction:"inbound",maConn:e,upgradedConn:i,Muxer:s,remotePeer:r})}async upgradeOutbound(e){const t=e.remoteAddr.getPeerId();if(!t)throw s(new Error("outbound connection must have a peer id"),d.ERR_INVALID_MULTIADDR);const r=c.createFromB58String(t);let i,o,a,u,f,h,p;if(this.metrics){({setTarget:h,proxy:p}=l());const t=(1e9*Math.random()).toString(36)+Date.now();h({toB58String:()=>t}),e=this.metrics.trackStream({stream:e,remotePeer:p})}n("Starting the outbound connection upgrade");let g=e;this.protector&&(g=await this.protector.protect(e));try{({conn:i,remotePeer:o,protocol:u}=await this._encryptOutbound(this.localPeer,g,r,this.cryptos)),this.muxers.size?({stream:a,Muxer:f}=await this._multiplexOutbound(i,this.muxers)):a=i}catch(t){throw n.error("Failed to upgrade outbound connection",t),await e.close(t),t}return this.metrics&&(this.metrics.updatePlaceholder(p,o),h(o)),n("Successfully upgraded outbound connection"),this._createConnection({cryptoProtocol:u,direction:"outbound",maConn:e,upgradedConn:a,Muxer:f,remotePeer:o})}_createConnection({cryptoProtocol:e,direction:t,maConn:r,upgradedConn:i,Muxer:c,remotePeer:l}){let f,h,p;c&&(f=new c({onStream:async e=>{if(!p)return;const r=new o.Listener(e);try{const{stream:i,protocol:s}=await r.handle(Array.from(this.protocols.keys()));n("%s: incoming stream opened on %s",t,s),this.metrics&&this.metrics.trackStream({stream:i,remotePeer:l,protocol:s}),p.addStream(e,{protocol:s}),this._onStream({connection:p,stream:{...e,...i},protocol:s})}catch(e){n.error(e)}},onStreamEnd:e=>{p.removeStream(e.id)}}),h=async e=>{n("%s: starting new stream on %s",t,e);const r=f.newStream(),i=new o.Dialer(r);try{const{stream:t,protocol:n}=await i.select(e);return this.metrics&&this.metrics.trackStream({stream:t,remotePeer:l,protocol:n}),{stream:{...r,...t},protocol:n}}catch(e){throw n.error("could not create new stream",e),s(e,d.ERR_UNSUPPORTED_PROTOCOL)}},u(i,f,i).catch(n.error));const g=r.timeline;r.timeline=new Proxy(g,{set:(...e)=>(p&&"close"===e[1]&&e[2]&&!g.close&&(async()=>{try{"open"===p.stat.status&&await p.close()}catch(e){n.error(e)}finally{this.onConnectionEnd(p)}})(),Reflect.set(...e))}),r.timeline.upgraded=Date.now();const y=()=>{throw s(new Error("connection is not multiplexed"),"ERR_CONNECTION_NOT_MULTIPLEXED")};return p=new a({localAddr:r.localAddr,remoteAddr:r.remoteAddr,localPeer:this.localPeer,remotePeer:l,stat:{direction:t,timeline:r.timeline,multiplexer:c&&c.multicodec,encryption:e},newStream:h||y,getStreams:()=>f?f.streams:y(),close:async()=>{await r.close(),f&&f.streams.map((e=>e.abort()))}}),this.onConnection(p),p}_onStream({connection:e,stream:t,protocol:r}){this.protocols.get(r)({connection:e,stream:t,protocol:r})}async _encryptInbound(e,t,r){const i=new o.Listener(t),a=Array.from(r.keys());n("handling inbound crypto protocol selection",a);try{const{stream:t,protocol:s}=await i.handle(a),o=r.get(s);if(n("encrypting inbound connection..."),!o)throw new Error(`no crypto module found for ${s}`);return{...await o.secureInbound(e,t),protocol:s}}catch(e){throw s(e,d.ERR_ENCRYPTION_FAILED)}}async _encryptOutbound(e,t,r,i){const a=new o.Dialer(t),c=Array.from(i.keys());n("selecting outbound crypto protocol",c);try{const{stream:t,protocol:s}=await a.select(c),o=i.get(s);if(n("encrypting outbound connection to %j",r),!o)throw new Error(`no crypto module found for ${s}`);return{...await o.secureOutbound(e,t,r),protocol:s}}catch(e){throw s(e,d.ERR_ENCRYPTION_FAILED)}}async _multiplexOutbound(e,t){const r=new o.Dialer(e),i=Array.from(t.keys());n("outbound selecting muxer %s",i);try{const{stream:e,protocol:s}=await r.select(i);n("%s selected as muxer protocol",s);return{stream:e,Muxer:t.get(s)}}catch(e){throw s(e,d.ERR_MUXER_UNAVAILABLE)}}async _multiplexInbound(e,t){const r=new o.Listener(e),i=Array.from(t.keys());n("inbound handling muxers %s",i);try{const{stream:e,protocol:n}=await r.handle(i);return{stream:e,Muxer:t.get(n)}}catch(e){throw s(e,d.ERR_MUXER_UNAVAILABLE)}}}},{debug:"bO5wM","err-code":"chZjB","multistream-select":"jMWmZ","libp2p-interfaces/src/connection":"GaTue","peer-id":"8Bdb3","it-pipe":"giKBQ","mutable-proxy":"iviy0","./errors":"3rNo5"}],jMWmZ:[function(e,t,r){"use strict";const i=e("./select"),n=e("./handle"),s=e("./ls"),{PROTOCOL_ID:o}=e("./constants");r.PROTOCOL_ID=o;class a{constructor(e){this._stream=e,this._shaken=!1}async _handshake(){if(this._shaken)return;const{stream:e}=await i(this._stream,o);this._stream=e,this._shaken=!0}}r.Dialer=class extends a{select(e){return i(this._stream,e,this._shaken?null:o)}async ls(){await this._handshake();const{stream:e,protocols:t}=await s(this._stream);return this._stream=e,t}};r.Listener=class extends a{handle(e){return n(this._stream,e)}}},{"./select":"69bj3","./handle":"dCEW4","./ls":"kJyHp","./constants":"78iMV"}],"69bj3":[function(e,t,r){"use strict";const i=e("debug")("mss:select"),n=e("err-code"),s=e("./multistream"),o=e("it-handshake");t.exports=async(e,t,r)=>{t=Array.isArray(t)?[...t]:[t];const{reader:a,writer:c,rest:u,stream:l}=o(e),d=t.shift();r?(i('select: write ["%s", "%s"]',r,d),s.writeAll(c,[r,d])):(i('select: write "%s"',d),s.write(c,d));let f=(await s.read(a)).toString();if(i('select: read "%s"',f),f===r&&(f=(await s.read(a)).toString(),i('select: read "%s"',f)),f===d)return u(),{stream:l,protocol:d};for(const e of t){i('select: write "%s"',e),s.write(c,e);const t=(await s.read(a)).toString();if(i('select: read "%s" for "%s"',t,e),t===e)return u(),{stream:l,protocol:e}}throw u(),n(new Error("protocol selection failed"),"ERR_UNSUPPORTED_PROTOCOL")}},{debug:"bO5wM","err-code":"chZjB","./multistream":"l6zhU","it-handshake":"5ZBDe"}],l6zhU:[function(e,t,r){"use strict";const i=e("bl/BufferList"),n=e("it-length-prefixed"),s=e("it-pipe"),o=e("err-code"),{fromString:a}=e("uint8arrays/from-string"),c=e("it-first"),u=a("\n");r.encode=e=>n.encode.single(new i([e,u])),r.write=(e,t)=>e.push(r.encode(t)),r.writeAll=(e,t)=>{e.push(t.reduce(((e,t)=>e.append(r.encode(t))),new i))},r.read=async e=>{let t=1;const r={[Symbol.asyncIterator](){return this},next:()=>e.next(t)},i=await s(r,n.decode({onLength:e=>{t=e}}),c);if(i.get(i.length-1)!==u[0])throw o(new Error("missing newline"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return i.shallowSlice(0,-1)}},{"bl/BufferList":"im7j6","it-length-prefixed":"3yxIE","it-pipe":"giKBQ","err-code":"chZjB","uint8arrays/from-string":"dF7Y4","it-first":"hBrkP"}],dCEW4:[function(e,t,r){"use strict";const i=e("debug")("mss:handle"),n=e("bl/BufferList"),s=e("./multistream"),o=e("it-handshake"),{PROTOCOL_ID:a}=e("./constants");t.exports=async(e,t)=>{t=Array.isArray(t)?t:[t];const{writer:r,reader:c,rest:u,stream:l}=o(e);for(;;){const e=(await s.read(c)).toString();if(i('read "%s"',e),e!==a){if(t.includes(e))return s.write(r,e),i('respond with "%s" for "%s"',e,e),u(),{stream:l,protocol:e};"ls"!==e?(s.write(r,"na"),i('respond with "na" for "%s"',e)):(s.write(r,new n(t.map((e=>s.encode(e))))),i('respond with "%s" for %s',t,e))}else i('respond with "%s" for "%s"',a,e),s.write(r,a)}}},{debug:"bO5wM","bl/BufferList":"im7j6","./multistream":"l6zhU","it-handshake":"5ZBDe","./constants":"78iMV"}],"78iMV":[function(e,t,r){"use strict";r.PROTOCOL_ID="/multistream/1.0.0"},{}],kJyHp:[function(e,t,r){"use strict";const i=e("it-reader"),n=e("debug")("it-multistream-select:ls"),s=e("./multistream"),o=e("it-handshake"),a=e("it-length-prefixed"),c=e("it-pipe");t.exports=async e=>{const{reader:t,writer:r,rest:u,stream:l}=o(e);n('write "ls"'),s.write(r,"ls"),u();const d=await s.read(t),f=i([d]),h=[];return await c(f,a.decode(),(async e=>{for await(const t of e)h.push(t.shallowSlice(0,-1).toString())})),{stream:l,protocols:h}}},{"it-reader":"btxDo",debug:"bO5wM","./multistream":"l6zhU","it-handshake":"5ZBDe","it-length-prefixed":"3yxIE","it-pipe":"giKBQ"}],GaTue:[function(e,t,r){"use strict";r.Connection=e("./connection")},{"./connection":"kwiyC"}],kwiyC:[function(e,t,r){"use strict";const i=e("peer-id"),{Multiaddr:n}=e("multiaddr"),s=e("err-code"),{OPEN:o,CLOSING:a,CLOSED:c}=e("./status"),u=Symbol.for("@libp2p/interface-connection/connection");class l{constructor({localAddr:e,remoteAddr:t,localPeer:r,remotePeer:a,newStream:c,close:u,getStreams:l,stat:d}){!function(e,t,r,o,a,c,u){if(e&&!n.isMultiaddr(e))throw s(new Error("localAddr must be an instance of multiaddr"),"ERR_INVALID_PARAMETERS");if(!i.isPeerId(t))throw s(new Error("localPeer must be an instance of peer-id"),"ERR_INVALID_PARAMETERS");if(!i.isPeerId(r))throw s(new Error("remotePeer must be an instance of peer-id"),"ERR_INVALID_PARAMETERS");if("function"!=typeof o)throw s(new Error("new stream must be a function"),"ERR_INVALID_PARAMETERS");if("function"!=typeof a)throw s(new Error("close must be a function"),"ERR_INVALID_PARAMETERS");if("function"!=typeof c)throw s(new Error("getStreams must be a function"),"ERR_INVALID_PARAMETERS");if(!u)throw s(new Error("connection metadata object must be provided"),"ERR_INVALID_PARAMETERS");if("inbound"!==u.direction&&"outbound"!==u.direction)throw s(new Error('direction must be "inbound" or "outbound"'),"ERR_INVALID_PARAMETERS");if(!u.timeline)throw s(new Error("connection timeline object must be provided in the stat object"),"ERR_INVALID_PARAMETERS");if(!u.timeline.open)throw s(new Error("connection open timestamp must be provided"),"ERR_INVALID_PARAMETERS");if(!u.timeline.upgraded)throw s(new Error("connection upgraded timestamp must be provided"),"ERR_INVALID_PARAMETERS")}(e,r,a,c,u,l,d),this.id=parseInt(String(1e9*Math.random())).toString(36)+Date.now(),this.localAddr=e,this.remoteAddr=t,this.localPeer=r,this.remotePeer=a,this._stat={...d,status:o},this._newStream=c,this._close=u,this._getStreams=l,this.registry=new Map,this.tags=[]}get[Symbol.toStringTag](){return"Connection"}get[u](){return!0}static isConnection(e){return Boolean(e&&e[u])}get stat(){return this._stat}get streams(){return this._getStreams()}async newStream(e){if(this.stat.status===a)throw s(new Error("the connection is being closed"),"ERR_CONNECTION_BEING_CLOSED");if(this.stat.status===c)throw s(new Error("the connection is closed"),"ERR_CONNECTION_CLOSED");Array.isArray(e)||(e=[e]);const{stream:t,protocol:r}=await this._newStream(e);return this.addStream(t,{protocol:r}),{stream:t,protocol:r}}addStream(e,{protocol:t,metadata:r={}}){this.registry.set(e.id,{protocol:t,...r})}removeStream(e){this.registry.delete(e)}async close(){if(this.stat.status!==c){if(this._closing)return this._closing;this.stat.status=a,this._closing=await this._close(),this._stat.timeline.close=Date.now(),this.stat.status=c}}}t.exports=l},{"peer-id":"8Bdb3",multiaddr:"8Mu1u","err-code":"chZjB","./status":"hXsny"}],hXsny:[function(e,t,r){"use strict";t.exports={OPEN:"open",CLOSING:"closing",CLOSED:"closed"}},{}],iviy0:[function(e,t,r){"use strict";function i(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t{t.set(e,this.get(s.createFromB58String(e)))})),t}delete(e){const t=this.addressBook.delete(e),r=this.keyBook.delete(e),i=this.protoBook.delete(e),n=this.metadataBook.delete(e);return t||r||i||n}get(e){if(!s.isPeerId(e))throw i(new Error("peerId must be an instance of peer-id"),l);const t=this.keyBook.data.get(e.toB58String()),r=this.addressBook.get(e),n=this.metadataBook.get(e),o=this.protoBook.get(e);if(t||r||n||o)return{id:t||e,addresses:r||[],protocols:o||[],metadata:n}}}},{"err-code":"chZjB",events:"g82pp","peer-id":"8Bdb3","./address-book":"lgtGk","./key-book":"5ggTp","./metadata-book":"emm3H","./proto-book":"98zRc","../errors":"3rNo5"}],lgtGk:[function(e,t,r){"use strict";const i=e("debug"),n=Object.assign(i("libp2p:peer-store:address-book"),{error:i("libp2p:peer-store:address-book:err")}),s=e("err-code"),{Multiaddr:o}=e("multiaddr"),a=e("peer-id"),c=e("./book"),u=e("../record/peer-record"),{codes:{ERR_INVALID_PARAMETERS:l}}=e("../errors"),d=e("../record/envelope");t.exports=class extends c{constructor(e){super({peerStore:e,eventName:"change:multiaddrs",eventProperty:"multiaddrs",eventTransformer:e=>e.addresses?e.addresses.map((e=>e.multiaddr)):[]}),this.data=new Map}consumePeerRecord(e){let t;try{t=u.createFromProtobuf(e.payload)}catch(e){return n.error("invalid peer record received"),!1}if(!t.peerId.equals(e.peerId))return n("signing key does not match PeerId in the PeerRecord"),!1;if(!t.multiaddrs||!t.multiaddrs.length)return!1;const r=t.peerId,i=r.toB58String(),s=(this.data.get(i)||{record:void 0}).record;if(s&&s.seqNumber>=t.seqNumber)return!1;const o=this._toAddresses(t.multiaddrs,!0);return this._setData(r,{addresses:o,record:{raw:e.marshal(),seqNumber:t.seqNumber}}),n(`stored provided peer record for ${i}`),!0}getRawEnvelope(e){const t=this.data.get(e.toB58String());if(t&&t.record&&t.record.raw)return t.record.raw}getPeerRecord(e){const t=this.getRawEnvelope(e);if(t)return d.createFromProtobuf(t)}set(e,t){if(!a.isPeerId(e))throw n.error("peerId must be an instance of peer-id to store data"),s(new Error("peerId must be an instance of peer-id"),l);const r=this._toAddresses(t);if(!r.length)return this;const i=e.toB58String(),o=this.data.get(i);if(o&&o.addresses&&o.addresses.length===r.length){if(o.addresses.filter((e=>r.some((t=>e.multiaddr.equals(t.multiaddr))))).length===o.addresses.length)return n(`the addresses provided to store are equal to the already stored for ${i}`),this}return this._setData(e,{addresses:r,record:o&&o.record}),n(`stored provided multiaddrs for ${i}`),o||this._ps.emit("peer",e),this}add(e,t){if(!a.isPeerId(e))throw n.error("peerId must be an instance of peer-id to store data"),s(new Error("peerId must be an instance of peer-id"),l);const r=this._toAddresses(t),i=e.toB58String();if(!r.length)return this;const o=this.data.get(i);return o&&o.addresses&&(o.addresses.forEach((e=>{r.find((t=>t.multiaddr.equals(e.multiaddr)))||r.push(e)})),o.addresses.length===r.length)?(n(`the addresses provided to store are already stored for ${i}`),this):(this._setData(e,{addresses:r,record:o&&o.record}),n(`added provided multiaddrs for ${i}`),o&&o.addresses||this._ps.emit("peer",e),this)}get(e){if(!a.isPeerId(e))throw s(new Error("peerId must be an instance of peer-id"),l);const t=this.data.get(e.toB58String());return t&&t.addresses?[...t.addresses]:void 0}_toAddresses(e,t=!1){if(!e)throw n.error("multiaddrs must be provided to store data"),s(new Error("multiaddrs must be provided"),l);const r=[];return e.forEach((e=>{if(!o.isMultiaddr(e))throw n.error(`multiaddr ${e} must be an instance of multiaddr`),s(new Error(`multiaddr ${e} must be an instance of multiaddr`),l);r.find((t=>t.multiaddr.equals(e)))||r.push({multiaddr:e,isCertified:t})})),r}getMultiaddrsForPeer(e,t=(e=>e)){if(!a.isPeerId(e))throw s(new Error("peerId must be an instance of peer-id"),l);const r=this.data.get(e.toB58String());if(r&&r.addresses)return t(r.addresses||[]).map((t=>{const r=t.multiaddr,i=r.getPeerId();return i&&i===e.toB58String()?r:r.encapsulate(`/p2p/${e.toB58String()}`)}))}}},{debug:"bO5wM","err-code":"chZjB",multiaddr:"8Mu1u","peer-id":"8Bdb3","./book":"aXIpl","../record/peer-record":"ewlv9","../errors":"3rNo5","../record/envelope":"27rHX"}],aXIpl:[function(e,t,r){"use strict";const i=e("err-code"),n=e("peer-id"),{codes:{ERR_INVALID_PARAMETERS:s}}=e("../errors"),o=e=>e;t.exports=class{constructor({peerStore:e,eventName:t,eventProperty:r,eventTransformer:i=o}){this._ps=e,this.eventName=t,this.eventProperty=r,this.eventTransformer=i,this.data=new Map}set(e,t){throw i(new Error("set must be implemented by the subclass"),"ERR_NOT_IMPLEMENTED")}_setData(e,t,{emit:r=!0}={}){const i=e.toB58String();this.data.set(i,t),r&&this._emit(e,t)}_emit(e,t){this._ps.emit(this.eventName,{peerId:e,[this.eventProperty]:this.eventTransformer(t)})}get(e){if(!n.isPeerId(e))throw i(new Error("peerId must be an instance of peer-id"),s);const t=this.data.get(e.toB58String());return t?[...t]:void 0}delete(e){if(!n.isPeerId(e))throw i(new Error("peerId must be an instance of peer-id"),s);return!!this.data.delete(e.toB58String())&&(this._emit(e,[]),!0)}}},{"err-code":"chZjB","peer-id":"8Bdb3","../errors":"3rNo5"}],"5ggTp":[function(e,t,r){"use strict";const i=e("debug"),n=Object.assign(i("libp2p:peer-store:key-book"),{error:i("libp2p:peer-store:key-book:err")}),s=e("err-code"),o=e("peer-id"),a=e("./book"),{codes:{ERR_INVALID_PARAMETERS:c}}=e("../errors");t.exports=class extends a{constructor(e){super({peerStore:e,eventName:"change:pubkey",eventProperty:"pubkey",eventTransformer:e=>e.pubKey}),this.data=new Map}set(e,t){if(!o.isPeerId(e))throw n.error("peerId must be an instance of peer-id to store data"),s(new Error("peerId must be an instance of peer-id"),c);const r=e.toB58String();return!this.data.get(r)&&t&&(e.pubKey=t,this._setData(e,e),n(`stored provided public key for ${r}`)),this}get(e){if(!o.isPeerId(e))throw s(new Error("peerId must be an instance of peer-id"),c);const t=this.data.get(e.toB58String());return t?t.pubKey:void 0}}},{debug:"bO5wM","err-code":"chZjB","peer-id":"8Bdb3","./book":"aXIpl","../errors":"3rNo5"}],emm3H:[function(e,t,r){"use strict";const i=e("debug"),n=Object.assign(i("libp2p:peer-store:proto-book"),{error:i("libp2p:peer-store:proto-book:err")}),s=e("err-code"),{equals:o}=e("uint8arrays/equals"),a=e("peer-id"),c=e("./book"),{codes:{ERR_INVALID_PARAMETERS:u}}=e("../errors");t.exports=class extends c{constructor(e){super({peerStore:e,eventName:"change:metadata",eventProperty:"metadata"}),this.data=new Map}set(e,t,r){if(!a.isPeerId(e))throw n.error("peerId must be an instance of peer-id to store data"),s(new Error("peerId must be an instance of peer-id"),u);if("string"!=typeof t||!(r instanceof Uint8Array))throw n.error("valid key and value must be provided to store data"),s(new Error("valid key and value must be provided"),u);return this._setValue(e,t,r),this}_setValue(e,t,r,{emit:i=!0}={}){const s=e.toB58String(),a=this.data.get(s)||new Map,c=a.get(t);c&&o(r,c)?n(`the metadata provided to store is equal to the already stored for ${s} on ${t}`):(a.set(t,r),this.data.set(s,a),i&&this._emit(e,t))}get(e){if(!a.isPeerId(e))throw s(new Error("peerId must be an instance of peer-id"),u);return this.data.get(e.toB58String())}getValue(e,t){if(!a.isPeerId(e))throw s(new Error("peerId must be an instance of peer-id"),u);const r=this.data.get(e.toB58String());return r&&r.get(t)}delete(e){if(!a.isPeerId(e))throw s(new Error("peerId must be an instance of peer-id"),u);return!!this.data.delete(e.toB58String())&&(this._emit(e),!0)}deleteValue(e,t){if(!a.isPeerId(e))throw s(new Error("peerId must be an instance of peer-id"),u);const r=this.data.get(e.toB58String());return!(!r||!r.delete(t))&&(this._emit(e,t),!0)}}},{debug:"bO5wM","err-code":"chZjB","uint8arrays/equals":"eY3cX","peer-id":"8Bdb3","./book":"aXIpl","../errors":"3rNo5"}],"98zRc":[function(e,t,r){"use strict";const i=e("debug"),n=Object.assign(i("libp2p:peer-store:proto-book"),{error:i("libp2p:peer-store:proto-book:err")}),s=e("err-code"),o=e("peer-id"),a=e("./book"),{codes:{ERR_INVALID_PARAMETERS:c}}=e("../errors");t.exports=class extends a{constructor(e){super({peerStore:e,eventName:"change:protocols",eventProperty:"protocols",eventTransformer:e=>Array.from(e)}),this.data=new Map}set(e,t){if(!o.isPeerId(e))throw n.error("peerId must be an instance of peer-id to store data"),s(new Error("peerId must be an instance of peer-id"),c);if(!t)throw n.error("protocols must be provided to store data"),s(new Error("protocols must be provided"),c);const r=e.toB58String(),i=this.data.get(r),a=new Set(t);return i&&(l=a,(u=i).size===l.size&&[...u].every((e=>l.has(e))))?(n(`the protocols provided to store are equal to the already stored for ${r}`),this):(this._setData(e,a),n(`stored provided protocols for ${r}`),this);var u,l}add(e,t){if(!o.isPeerId(e))throw n.error("peerId must be an instance of peer-id to store data"),s(new Error("peerId must be an instance of peer-id"),c);if(!t)throw n.error("protocols must be provided to store data"),s(new Error("protocols must be provided"),c);const r=e.toB58String(),i=this.data.get(r)||new Set,a=new Set([...i,...t]);return i.size===a.size?(n(`the protocols provided to store are already stored for ${r}`),this):(this._setData(e,a),n(`added provided protocols for ${r}`),this)}remove(e,t){if(!o.isPeerId(e))throw n.error("peerId must be an instance of peer-id to store data"),s(new Error("peerId must be an instance of peer-id"),c);if(!t)throw n.error("protocols must be provided to store data"),s(new Error("protocols must be provided"),c);const r=e.toB58String(),i=this.data.get(r);if(i){const s=new Set([...i].filter((e=>!t.includes(e))));if(i.size===s.size)return this;this._setData(e,s),n(`removed provided protocols for ${r}`)}return this}}},{debug:"bO5wM","err-code":"chZjB","peer-id":"8Bdb3","./book":"aXIpl","../errors":"3rNo5"}],"4AHRd":[function(e,t,r){"use strict";t.exports=function(e,t,r){const i=new e(t,r);return i._subscribeAdapter=i.subscribe,i._unsubscribeAdapter=i.unsubscribe,i.subscribe=function(e,t){t&&i.on(e,t),i._subscribeAdapter(e)},i.unsubscribe=function(e,t){t?i.removeListener(e,t):i.removeAllListeners(e),0===i.listenerCount(e)&&i._unsubscribeAdapter(e)},i}},{}],kcKey:[function(e,t,r){"use strict";const i=e("debug"),n=Object.assign(i("libp2p:persistent-peer-store"),{error:i("libp2p:persistent-peer-store:err")}),{Key:s}=e("interface-datastore/key"),{Multiaddr:o}=e("multiaddr"),a=e("peer-id"),{base32:c}=e("multiformats/bases/base32"),u=e(".."),{NAMESPACE_ADDRESS:l,NAMESPACE_COMMON:d,NAMESPACE_KEYS:f,NAMESPACE_METADATA:h,NAMESPACE_PROTOCOL:p}=e("./consts"),{Addresses:g}=e("./pb/address-book"),{Protocols:y}=e("./pb/proto-book");t.exports=class extends u{constructor({peerId:e,datastore:t,threshold:r=5}){super({peerId:e}),this._datastore=t,this._dirtyPeers=new Set,this._dirtyMetadata=new Map,this.threshold=r,this._addDirtyPeer=this._addDirtyPeer.bind(this)}async start(){n("PeerStore is starting"),this.on("change:protocols",this._addDirtyPeer),this.on("change:multiaddrs",this._addDirtyPeer),this.on("change:pubkey",this._addDirtyPeerKey),this.on("change:metadata",this._addDirtyPeerMetadata);for await(const e of this._datastore.query({prefix:d}))await this._processDatastoreEntry(e);n("PeerStore started")}async stop(){n("PeerStore is stopping"),this.removeAllListeners(),await this._commitData(),n("PeerStore stopped")}_addDirtyPeer({peerId:e}){const t=e.toB58String();n("add dirty peer",t),this._dirtyPeers.add(t),this._dirtyPeers.size>=this.threshold&&this._commitData().catch((e=>{n.error("error committing data",e)}))}_addDirtyPeerKey({peerId:e}){if(e.hasInlinePublicKey())return;const t=e.toB58String();n("add dirty peer key",t),this._dirtyPeers.add(t),this._dirtyPeers.size>=this.threshold&&this._commitData().catch((e=>{n.error("error committing data",e)}))}_addDirtyPeerMetadata({peerId:e,metadata:t}){const r=e.toB58String();n("add dirty metadata peer",r),this._dirtyPeers.add(r);const i=this._dirtyMetadata.get(r)||new Set;i.add(t),this._dirtyMetadata.set(r,i),this._dirtyPeers.size>=this.threshold&&this._commitData().catch((e=>{n.error("error committing data",e)}))}async _commitData(){const e=Array.from(this._dirtyPeers);if(!e.length)return;this._dirtyPeers.clear(),n("create batch commit");const t=this._datastore.batch();for(const r of e){const e=this.keyBook.data.get(r)||a.createFromB58String(r);this._batchAddressBook(e,t),!e.hasInlinePublicKey()&&this._batchKeyBook(e,t),this._batchMetadataBook(e,t),this._batchProtoBook(e,t)}await t.commit(),n("batch committed")}_batchAddressBook(e,t){const r=e.toString(),i=new s(`${l}${r}`),o=this.addressBook.data.get(e.toB58String());try{if(!o)return void t.delete(i);const e=g.encode({addrs:o.addresses.map((e=>({multiaddr:e.multiaddr.bytes,isCertified:e.isCertified}))),certifiedRecord:o.record?{seq:o.record.seqNumber,raw:o.record.raw}:void 0}).finish();t.put(i,e)}catch(e){n.error(e)}}_batchKeyBook(e,t){const r=e.toString(),i=new s(`${f}${r}`);try{if(!e.pubKey)return void t.delete(i);const r=e.marshalPubKey();t.put(i,r)}catch(e){n.error(e)}}_batchMetadataBook(e,t){const r=e.toString(),i=this._dirtyMetadata.get(e.toB58String())||[];try{i.forEach((i=>{const n=new s(`${h}${r}/${i}`),o=this.metadataBook.getValue(e,i);o?t.put(n,o):t.delete(n)}))}catch(e){n.error(e)}}_batchProtoBook(e,t){const r=e.toString(),i=new s(`${p}${r}`),o=this.protoBook.get(e);try{if(!o)return void t.delete(i);const e=y.encode({protocols:o}).finish();t.put(i,e)}catch(e){n.error(e)}}async _processDatastoreEntry({key:e,value:t}){try{const r=e.toString().split("/"),i=a.createFromBytes(c.decode(r[3]));let s;switch(r[2]){case"addrs":s=g.decode(t),this.addressBook._setData(i,{addresses:s.addrs.map((e=>({multiaddr:new o(e.multiaddr),isCertified:Boolean(e.isCertified)}))),record:s.certifiedRecord?{raw:s.certifiedRecord.raw,seqNumber:s.certifiedRecord.seq}:void 0},{emit:!1});break;case"keys":s=await a.createFromPubKey(t),this.keyBook._setData(s,s,{emit:!1});break;case"metadata":this.metadataBook._setValue(i,r[4],t,{emit:!1});break;case"protos":s=y.decode(t),this.protoBook._setData(i,new Set(s.protocols),{emit:!1});break;default:n("invalid data persisted for: ",e.toString())}}catch(e){n.error(e)}}}},{debug:"bO5wM","interface-datastore/key":"9hGOz",multiaddr:"8Mu1u","peer-id":"8Bdb3","multiformats/bases/base32":"5k9Tu","..":"hDFM8","./consts":"2EBy4","./pb/address-book":"jj9hF","./pb/proto-book":"j2d2m"}],"2EBy4":[function(e,t,r){"use strict";t.exports.NAMESPACE_COMMON="/peers/",t.exports.NAMESPACE_ADDRESS="/peers/addrs/",t.exports.NAMESPACE_KEYS="/peers/keys/",t.exports.NAMESPACE_METADATA="/peers/metadata/",t.exports.NAMESPACE_PROTOCOL="/peers/protos/"},{}],jj9hF:[function(e,t,r){"use strict";var i=e("protobufjs/minimal"),n=i.Reader,s=i.Writer,o=i.util,a=i.roots["libp2p-address-book"]||(i.roots["libp2p-address-book"]={});a.Addresses=function(){function e(e){if(this.addrs=[],e)for(var t=Object.keys(e),r=0;r>>3){case 1:i.addrs&&i.addrs.length||(i.addrs=[]),i.addrs.push(a.Addresses.Address.decode(e,e.uint32()));break;case 2:i.certifiedRecord=a.Addresses.CertifiedRecord.decode(e,e.uint32());break;default:e.skipType(7&s)}}return i},e.fromObject=function(e){if(e instanceof a.Addresses)return e;var t=new a.Addresses;if(e.addrs){if(!Array.isArray(e.addrs))throw TypeError(".Addresses.addrs: array expected");t.addrs=[];for(var r=0;r>>3){case 1:i.multiaddr=e.bytes();break;case 2:i.isCertified=e.bool();break;default:e.skipType(7&s)}}return i},e.fromObject=function(e){if(e instanceof a.Addresses.Address)return e;var t=new a.Addresses.Address;return null!=e.multiaddr&&("string"==typeof e.multiaddr?o.base64.decode(e.multiaddr,t.multiaddr=o.newBuffer(o.base64.length(e.multiaddr)),0):e.multiaddr.length&&(t.multiaddr=e.multiaddr)),null!=e.isCertified&&(t.isCertified=Boolean(e.isCertified)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.multiaddr="":(r.multiaddr=[],t.bytes!==Array&&(r.multiaddr=o.newBuffer(r.multiaddr))),r.isCertified=!1),null!=e.multiaddr&&e.hasOwnProperty("multiaddr")&&(r.multiaddr=t.bytes===String?o.base64.encode(e.multiaddr,0,e.multiaddr.length):t.bytes===Array?Array.prototype.slice.call(e.multiaddr):e.multiaddr),null!=e.isCertified&&e.hasOwnProperty("isCertified")&&(r.isCertified=e.isCertified),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e}(),e.CertifiedRecord=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:i.seq=e.uint64();break;case 2:i.raw=e.bytes();break;default:e.skipType(7&s)}}return i},e.fromObject=function(e){if(e instanceof a.Addresses.CertifiedRecord)return e;var t=new a.Addresses.CertifiedRecord;return null!=e.seq&&(o.Long?(t.seq=o.Long.fromValue(e.seq)).unsigned=!0:"string"==typeof e.seq?t.seq=parseInt(e.seq,10):"number"==typeof e.seq?t.seq=e.seq:"object"==typeof e.seq&&(t.seq=new o.LongBits(e.seq.low>>>0,e.seq.high>>>0).toNumber(!0))),null!=e.raw&&("string"==typeof e.raw?o.base64.decode(e.raw,t.raw=o.newBuffer(o.base64.length(e.raw)),0):e.raw.length&&(t.raw=e.raw)),t},e.toObject=function(e,t){t||(t={});var r={};if(t.defaults){if(o.Long){var i=new o.Long(0,0,!0);r.seq=t.longs===String?i.toString():t.longs===Number?i.toNumber():i}else r.seq=t.longs===String?"0":0;t.bytes===String?r.raw="":(r.raw=[],t.bytes!==Array&&(r.raw=o.newBuffer(r.raw)))}return null!=e.seq&&e.hasOwnProperty("seq")&&("number"==typeof e.seq?r.seq=t.longs===String?String(e.seq):e.seq:r.seq=t.longs===String?o.Long.prototype.toString.call(e.seq):t.longs===Number?new o.LongBits(e.seq.low>>>0,e.seq.high>>>0).toNumber(!0):e.seq),null!=e.raw&&e.hasOwnProperty("raw")&&(r.raw=t.bytes===String?o.base64.encode(e.raw,0,e.raw.length):t.bytes===Array?Array.prototype.slice.call(e.raw):e.raw),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e}(),e}(),t.exports=a},{"protobufjs/minimal":"grAXL"}],j2d2m:[function(e,t,r){"use strict";var i=e("protobufjs/minimal"),n=i.Reader,s=i.Writer,o=i.util,a=i.roots["libp2p-proto-book"]||(i.roots["libp2p-proto-book"]={});a.Protocols=function(){function e(e){if(this.protocols=[],e)for(var t=Object.keys(e),r=0;r>>3==1)i.protocols&&i.protocols.length||(i.protocols=[]),i.protocols.push(e.string());else e.skipType(7&s)}return i},e.fromObject=function(e){if(e instanceof a.Protocols)return e;var t=new a.Protocols;if(e.protocols){if(!Array.isArray(e.protocols))throw TypeError(".Protocols.protocols: array expected");t.protocols=[];for(var r=0;rl(1,e)),c,u),v=Date.now();if(!d(m,b))throw s(new Error("Received wrong ping ack"),"ERR_WRONG_PING_ACK");return v-y}).mount=function(e){e.handle(`/${e._config.protocolPrefix}/${f}/${p}`,(({stream:e})=>a(e,e)))},r.unmount=function(e){e.unhandle(`/${e._config.protocolPrefix}/${f}/${p}`)}},{debug:"bO5wM","err-code":"chZjB","libp2p-crypto":"bb1cb","it-pipe":"giKBQ","it-buffer":"jQv22","streaming-iterables":"jrrai","uint8arrays/equals":"eY3cX","./constants":"g9JxC"}],g9JxC:[function(e,t,r){"use strict";t.exports={PROTOCOL:"/ipfs/ping/1.0.0",PING_LENGTH:32,PROTOCOL_VERSION:"1.0.0",PROTOCOL_NAME:"ping"}},{}],jPbT6:[function(e,t,r){"use strict";const i=e("debug"),n=Object.assign(i("libp2p:identify"),{error:i("libp2p:identify:err")}),s=e("err-code"),o=e("it-length-prefixed"),{pipe:a}=e("it-pipe"),{collect:c,take:u,consume:l}=e("streaming-iterables"),{fromString:d}=e("uint8arrays/from-string"),f=e("peer-id"),{Multiaddr:h}=e("multiaddr"),{toBuffer:p}=e("it-buffer"),g=e("./message"),y=e("../record/envelope"),m=e("../record/peer-record"),{MULTICODEC_IDENTIFY:b,MULTICODEC_IDENTIFY_PUSH:v,IDENTIFY_PROTOCOL_VERSION:w,MULTICODEC_IDENTIFY_PROTOCOL_NAME:_,MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME:E,MULTICODEC_IDENTIFY_PROTOCOL_VERSION:S,MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION:T}=e("./consts"),{codes:A}=e("../errors");class k{static getProtocolStr(e){return{identifyProtocolStr:`/${e._config.protocolPrefix}/${_}/${S}`,identifyPushProtocolStr:`/${e._config.protocolPrefix}/${E}/${T}`}}constructor({libp2p:e}){this._libp2p=e,this.peerStore=e.peerStore,this.addressManager=e.addressManager,this.connectionManager=e.connectionManager,this.peerId=e.peerId,this.handleMessage=this.handleMessage.bind(this);const t=k.getProtocolStr(e);this.identifyProtocolStr=t.identifyProtocolStr,this.identifyPushProtocolStr=t.identifyPushProtocolStr,this._host={protocolVersion:`${e._config.protocolPrefix}/${w}`,...e._options.host},this.peerStore.metadataBook.set(this.peerId,"AgentVersion",d(this._host.agentVersion)),this.peerStore.metadataBook.set(this.peerId,"ProtocolVersion",d(this._host.protocolVersion)),this.connectionManager.on("peer:connect",(e=>{this.identify(e).catch(n.error)})),this.peerStore.on("change:multiaddrs",(({peerId:e})=>{e.toString()===this.peerId.toString()&&this.pushToPeerStore()})),this.peerStore.on("change:protocols",(({peerId:e})=>{e.toString()===this.peerId.toString()&&this.pushToPeerStore()}))}async push(e){const t=await this.peerStore.addressBook.getRawEnvelope(this.peerId),r=this._libp2p.multiaddrs.map((e=>e.bytes)),i=this.peerStore.protoBook.get(this.peerId)||[],s=e.map((async e=>{try{const{stream:n}=await e.newStream(this.identifyPushProtocolStr);await a([g.Identify.encode({listenAddrs:r,signedPeerRecord:t,protocols:i}).finish()],o.encode(),n,l)}catch(e){n.error("could not push identify update to peer",e)}}));return Promise.all(s)}pushToPeerStore(){if(!this._libp2p.isStarted())return;const e=[];let t;for(const r of this.peerStore.peers.values())r.protocols.includes(this.identifyPushProtocolStr)&&(t=this.connectionManager.get(r.id))&&e.push(t);this.push(e)}async identify(e){const{stream:t}=await e.newStream(this.identifyProtocolStr),[r]=await a([],t,o.decode(),u(1),p,c);if(!r)throw s(new Error("No data could be retrieved"),A.ERR_CONNECTION_ENDED);let i;try{i=g.Identify.decode(r)}catch(e){throw s(e,A.ERR_INVALID_MESSAGE)}const{publicKey:l,listenAddrs:b,protocols:v,observedAddr:w,signedPeerRecord:_}=i,E=await f.createFromPubKey(l);if(e.remotePeer.toB58String()!==E.toB58String())throw s(new Error("identified peer does not match the expected peer"),A.ERR_INVALID_PEER);const S=k.getCleanMultiaddr(w);try{const e=await y.openAndCertify(_,m.DOMAIN);if(this.peerStore.addressBook.consumePeerRecord(e))return this.peerStore.protoBook.set(E,v),this.peerStore.metadataBook.set(E,"AgentVersion",d(i.agentVersion)),void this.peerStore.metadataBook.set(E,"ProtocolVersion",d(i.protocolVersion))}catch(e){n("received invalid envelope, discard it and fallback to listenAddrs is available",e)}try{this.peerStore.addressBook.set(E,b.map((e=>new h(e))))}catch(e){n.error("received invalid addrs",e)}this.peerStore.protoBook.set(E,v),this.peerStore.metadataBook.set(E,"AgentVersion",d(i.agentVersion)),this.peerStore.metadataBook.set(E,"ProtocolVersion",d(i.protocolVersion)),n("received observed address of %s",S)}handleMessage({connection:e,stream:t,protocol:r}){switch(r){case this.identifyProtocolStr:return this._handleIdentify({connection:e,stream:t});case this.identifyPushProtocolStr:return this._handlePush({connection:e,stream:t});default:n.error("cannot handle unknown protocol %s",r)}}async _handleIdentify({connection:e,stream:t}){let r=new Uint8Array(0);this.peerId.pubKey&&(r=this.peerId.pubKey.bytes);const i=await this.peerStore.addressBook.getRawEnvelope(this.peerId),s=this.peerStore.protoBook.get(this.peerId)||[],c=g.Identify.encode({protocolVersion:this._host.protocolVersion,agentVersion:this._host.agentVersion,publicKey:r,listenAddrs:this._libp2p.multiaddrs.map((e=>e.bytes)),signedPeerRecord:i,observedAddr:e.remoteAddr.bytes,protocols:s}).finish();try{await a([c],o.encode(),t,l)}catch(e){n.error("could not respond to identify request",e)}}async _handlePush({connection:e,stream:t}){let r;try{const[e]=await a([],t,o.decode(),u(1),p,c);r=g.Identify.decode(e)}catch(e){return n.error("received invalid message",e)}const i=e.remotePeer;try{const e=await y.openAndCertify(r.signedPeerRecord,m.DOMAIN);if(this.peerStore.addressBook.consumePeerRecord(e))return void this.peerStore.protoBook.set(i,r.protocols)}catch(e){n("received invalid envelope, discard it and fallback to listenAddrs is available",e)}try{this.peerStore.addressBook.set(i,r.listenAddrs.map((e=>new h(e))))}catch(e){n.error("received invalid addrs",e)}this.peerStore.protoBook.set(i,r.protocols)}static getCleanMultiaddr(e){if(e&&e.length>0)try{return new h(e)}catch(e){return null}return null}}const I={IDENTIFY:b,IDENTIFY_PUSH:v};k.multicodecs=I,k.Messsage=g,t.exports=k},{debug:"bO5wM","err-code":"chZjB","it-length-prefixed":"3yxIE","it-pipe":"giKBQ","streaming-iterables":"jrrai","uint8arrays/from-string":"dF7Y4","peer-id":"8Bdb3",multiaddr:"8Mu1u","it-buffer":"jQv22","./message":"cIqCO","../record/envelope":"27rHX","../record/peer-record":"ewlv9","./consts":"62PhM","../errors":"3rNo5"}],cIqCO:[function(e,t,r){"use strict";var i=e("protobufjs/minimal"),n=i.Reader,s=i.Writer,o=i.util,a=i.roots["libp2p-identify"]||(i.roots["libp2p-identify"]={});a.Identify=function(){function e(e){if(this.listenAddrs=[],this.protocols=[],e)for(var t=Object.keys(e),r=0;r>>3){case 5:i.protocolVersion=e.string();break;case 6:i.agentVersion=e.string();break;case 1:i.publicKey=e.bytes();break;case 2:i.listenAddrs&&i.listenAddrs.length||(i.listenAddrs=[]),i.listenAddrs.push(e.bytes());break;case 4:i.observedAddr=e.bytes();break;case 3:i.protocols&&i.protocols.length||(i.protocols=[]),i.protocols.push(e.string());break;case 8:i.signedPeerRecord=e.bytes();break;default:e.skipType(7&s)}}return i},e.fromObject=function(e){if(e instanceof a.Identify)return e;var t=new a.Identify;if(null!=e.protocolVersion&&(t.protocolVersion=String(e.protocolVersion)),null!=e.agentVersion&&(t.agentVersion=String(e.agentVersion)),null!=e.publicKey&&("string"==typeof e.publicKey?o.base64.decode(e.publicKey,t.publicKey=o.newBuffer(o.base64.length(e.publicKey)),0):e.publicKey.length&&(t.publicKey=e.publicKey)),e.listenAddrs){if(!Array.isArray(e.listenAddrs))throw TypeError(".Identify.listenAddrs: array expected");t.listenAddrs=[];for(var r=0;r{a.error(e)}))}async _start(){const e=this._transportManager.getAddrs();for(const t of e){const{family:e,host:r,port:i,transport:n}=t.toOptions();if(!t.isThinWaistAddress()||"tcp"!==n)continue;if(p(t))continue;if(4!==e)continue;const s=this._getClient(),c=this._externalIp||await s.externalIp();if(l(c))throw new Error(`${c} is private - please set config.nat.externalIp to an externally routable IP or ensure you are not behind a double NAT`);const u=y();a(`opening uPnP connection from ${c}:${u} to ${r}:${i}`),await s.map({publicPort:u,privatePort:i,protocol:n.toUpperCase()}),this._addressManager.addObservedAddr(o.fromNodeAddress({family:4,address:c,port:u},n))}}_getClient(){if(this._client)return this._client;const e=new i(this._options),t=s(e.map.bind(e)),r=s(e.destroy.bind(e)),n=s(e.externalIp.bind(e));return this._client={map:(...e)=>u((()=>t(...e)),{onFailedAttempt:a.error,unref:!0}),destroy:(...e)=>u((()=>r(...e)),{onFailedAttempt:a.error,unref:!0}),externalIp:(...e)=>u((()=>n(...e)),{onFailedAttempt:a.error,unref:!0})},this._client}async stop(){if(!c&&this._client)try{await this._client.destroy(),this._client=null}catch(e){a.error(e)}}}},{"@motrix/nat-api":"lHksA",debug:"bO5wM","es6-promisify":"4jb5N",multiaddr:"8Mu1u",wherearewe:"lr9au","p-retry":"3fyh8","private-ip":"kXRph","../package.json":"cq0b4","err-code":"chZjB","./errors":"3rNo5","libp2p-utils/src/multiaddr/is-loopback":"55HY1"}],"4jb5N":[function(e,t,r){var i=e("@parcel/transformer-js/src/esmodule-helpers.js");i.defineInteropFlag(r),i.export(r,"promisify",(()=>n));function n(e){if("function"!=typeof e)throw new TypeError("Argument to promisify must be a function");var t=e["__ES6-PROMISIFY--CUSTOM-ARGUMENTS__"],r=n.Promise||Promise;if("function"!=typeof r)throw new Error("No Promise implementation found; do you need a polyfill?");return function(){for(var i=arguments.length,n=Array(i),s=0;s{n.push((function(e){if(e)return i(e);for(var n=arguments.length,s=Array(1{var i=t[r];i&&(a[i]=e)})),r(a)})),e.apply(this,n)}))}}n.argumentNames="__ES6-PROMISIFY--CUSTOM-ARGUMENTS__",n.Promise=void 0},{"@parcel/transformer-js/src/esmodule-helpers.js":"h08wk"}],lr9au:[function(e,t,r){var i=e("process");const n=e("is-electron"),s="object"==typeof window&&"object"==typeof document&&9===document.nodeType,o=n(),a=s&&!o,c=o&&!s,u=o&&s,l="function"==typeof e&&void 0!==i&&void 0!==i.release&&"node"===i.release.name&&!o,d="function"==typeof importScripts&&"undefined"!=typeof self&&"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,f=void 0!==i&&void 0!==i.env&&!1;t.exports={isTest:f,isElectron:o,isElectronMain:c,isElectronRenderer:u,isNode:l,isBrowser:a,isWebWorker:d,isEnvWithDom:s}},{process:"bjUAi","is-electron":"e6ybt"}],"3fyh8":[function(e,t,r){"use strict";const i=e("retry"),n=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"];class s extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,({message:e}=e)):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}}const o=(e,t)=>new Promise(((r,o)=>{t={onFailedAttempt:()=>{},retries:10,...t};const a=i.operation(t);a.attempt((async i=>{try{r(await e(i))}catch(e){if(!(e instanceof Error))return void o(new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`));if(e instanceof s)a.stop(),o(e.originalError);else if(e instanceof TypeError&&(c=e.message,!n.includes(c)))a.stop(),o(e);else{((e,t,r)=>{const i=r.retries-(t-1);e.attemptNumber=t,e.retriesLeft=i})(e,i,t);try{await t.onFailedAttempt(e)}catch(e){return void o(e)}a.retry(e)||o(a.mainError())}}var c}))}));t.exports=o,t.exports.default=o,t.exports.AbortError=s},{retry:"l316T"}],l316T:[function(e,t,r){t.exports=e("./lib/retry")},{"./lib/retry":"e5bUs"}],e5bUs:[function(e,t,r){var i=e("./retry_operation");r.operation=function(e){var t=r.timeouts(e);return new i(t,{forever:e&&(e.forever||e.retries===1/0),unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})},r.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var r in e)t[r]=e[r];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var i=[],n=0;n=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(void 0===r){if(!this._cachedTimeouts)return!1;this._errors.splice(0,this._errors.length-1),r=this._cachedTimeouts.slice(-1)}var i=this;return this._timer=setTimeout((function(){i._attempts++,i._operationTimeoutCb&&(i._timeout=setTimeout((function(){i._operationTimeoutCb(i._attempts)}),i._operationTimeout),i._options.unref&&i._timeout.unref()),i._fn(i._attempts)}),r),this._options.unref&&this._timer.unref(),!0},i.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout((function(){r._operationTimeoutCb()}),r._operationTimeout)),this._operationStart=(new Date).getTime(),this._fn(this._attempts)},i.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},i.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},i.prototype.start=i.prototype.try,i.prototype.errors=function(){return this._errors},i.prototype.attempts=function(){return this._attempts},i.prototype.mainError=function(){if(0===this._errors.length)return null;for(var e={},t=null,r=0,i=0;i=r&&(t=n,r=o)}return t}},{}],"55HY1":[function(e,t,r){"use strict";const i=e("is-loopback-addr");t.exports=function(e){const{address:t}=e.nodeAddress();return i(t)}},{"is-loopback-addr":"8SMxm"}],"8SMxm":[function(e,t,r){"use strict";t.exports=function(e){return/^127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(e)||/^::1$/.test(e)}},{}],"1MCQb":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-bitswap"),n=e("./libp2p.js"),s=e("multiaddr"),o=e("err-code"),a=e("../block-storage.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(o);class l{constructor(e,t,r,i,n){this.peerId=e,this.libp2p=t,this.bitswap=r,this.repo=i,this.blockstore=n}static async start({peerId:e,repo:t,print:r,options:s}){t.closed&&await t.open();const o=await t.config.getAll(),c=await n.createLibp2p({options:s,repo:t,peerId:e,multiaddrs:d(e,o),config:o,keychainConfig:void 0});c.keychain&&await c.loadKeychain(),await c.start();for(const t of c.multiaddrs)r(`Swarm listening on ${t}/p2p/${e.toB58String()}`);const u=i.createBitswap(c,t.blocks,{statsEnabled:!0});await u.start();const f=new a.BlockStorage(t.blocks,u);return t.blocks=f,t.pins.blockstore=f,new l(e,c,u,t,f)}static async stop(e){e.repo.blocks=e.blockstore.unwrap(),e.repo.pins.blockstore=e.blockstore.unwrap(),await Promise.all([e.bitswap.stop(),e.libp2p.stop()])}}const d=(e,t)=>{const r=e.toB58String(),i=[],n=t.Addresses&&t.Addresses.Swarm||[];for(const e of n){let t=new s.Multiaddr(e);if(t.protoCodes().includes(f))throw u.default(new Error("websocket-star swarm addresses are not supported. See https://github.com/ipfs/js-ipfs/issues/2779"),"ERR_WEBSOCKET_STAR_SWARM_ADDR_NOT_SUPPORTED");const n=t.getPeerId();n&&n!==r&&(t=t.encapsulate(`/p2p/${r}`)),i.push(t)}return i},f=479;r.Network=l},{"ipfs-bitswap":"flwND","./libp2p.js":"jcB2q",multiaddr:"8Mu1u","err-code":"chZjB","../block-storage.js":"55a3I"}],flwND:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./bitswap.js");r.createBitswap=(e,t,r={})=>new i.Bitswap(e,t,r)},{"./bitswap.js":"dAIea"}],dAIea:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./want-manager/index.js"),n=e("./network.js"),s=e("./decision-engine/index.js"),o=e("./notifications.js"),a=e("./utils/index.js"),c=e("./stats/index.js"),u=e("native-abort-controller"),l=e("any-signal"),d=e("blockstore-core/base"),f=e("multiformats/cid");const h={statsEnabled:!1,statsComputeThrottleTimeout:1e3,statsComputeThrottleMaxQueueSize:1e3},p=["blocksReceived","dataReceived","dupBlksReceived","dupDataReceived","blocksSent","dataSent","providesBufferLength","wantListLength","peerCount"];class g extends d.BaseBlockstore{constructor(e,t,r={}){super(),this._libp2p=e,this._log=a.logger(this.peerId),this._options=Object.assign({},h,r),this._stats=new c.Stats(p,{enabled:this._options.statsEnabled,computeThrottleTimeout:this._options.statsComputeThrottleTimeout,computeThrottleMaxQueueSize:this._options.statsComputeThrottleMaxQueueSize}),this.network=new n.Network(e,this,this._stats,{hashLoader:r.hashLoader}),this.blockstore=t,this.engine=new s.DecisionEngine(this.peerId,t,this.network,this._stats),this.wm=new i.WantManager(this.peerId,this.network,this._stats),this.notifications=new o.Notifications(this.peerId),this.started=!1}isStarted(){return this.started}get peerId(){return this._libp2p.peerId}async _receiveMessage(e,t){try{await this.engine.messageReceived(e,t)}catch(e){this._log("failed to receive message",t)}if(0===t.blocks.size)return;const r=[];for(const[e,i]of t.blocks.entries()){const t=f.CID.parse(e);r.push({wasWanted:this.wm.wantlist.contains(t),cid:t,data:i})}this.wm.cancelWants(r.filter((({wasWanted:e})=>e)).map((({cid:e})=>e))),await Promise.all(r.map((({cid:t,wasWanted:r,data:i})=>this._handleReceivedBlock(e,t,i,r))))}async _handleReceivedBlock(e,t,r,i){this._log("received block");const n=await this.blockstore.has(t);this._updateReceiveCounters(e.toB58String(),t,r,n),i&&await this.put(t,r)}_updateReceiveCounters(e,t,r,i){this._stats.push(e,"blocksReceived",1),this._stats.push(e,"dataReceived",r.length),i&&(this._stats.push(e,"dupBlksReceived",1),this._stats.push(e,"dupDataReceived",r.length))}_receiveError(e){this._log.error("ReceiveError: %s",e.message)}_onPeerConnected(e){this.wm.connected(e)}_onPeerDisconnected(e){this.wm.disconnected(e),this.engine.peerDisconnected(e),this._stats.disconnected(e)}enableStats(){this._stats.enable()}disableStats(){this._stats.disable()}wantlistForPeer(e,t){return this.engine.wantlistForPeer(e)}ledgerForPeer(e){return this.engine.ledgerForPeer(e)}async get(e,t={}){const r=(e,t)=>(this.wm.wantBlocks([e],t),this.notifications.wantBlock(e,t));let i=!1;const n=new u.AbortController,s=t.signal?l.anySignal([t.signal,n.signal]):n.signal,o=await Promise.race([this.notifications.wantBlock(e,{signal:s}),(async(e,t)=>{try{return await this.blockstore.get(e,t)}catch(n){if("ERR_NOT_FOUND"!==n.code)throw n;return i||(i=!0,this.network.findAndConnect(e).catch((e=>this._log.error(e)))),r(e,t)}})(e,{signal:s})]);return n.abort(),o}async*getMany(e,t={}){for await(const r of e)yield this.get(r,t)}unwant(e){const t=Array.isArray(e)?e:[e];this.wm.unwantBlocks(t),t.forEach((e=>this.notifications.unwantBlock(e)))}cancelWants(e){this.wm.cancelWants(Array.isArray(e)?e:[e])}async put(e,t,r){await this.blockstore.put(e,t),this._sendHaveBlockNotifications(e,t)}async*putMany(e,t){for await(const{key:r,value:i}of this.blockstore.putMany(e,t))this._sendHaveBlockNotifications(r,i),yield{key:r,value:i}}_sendHaveBlockNotifications(e,t){this.notifications.hasBlock(e,t),this.engine.receivedBlocks([{cid:e,data:t}]),this.network.provide(e).catch((e=>{this._log.error("Failed to provide: %s",e.message)}))}getWantlist(){return this.wm.wantlist.entries()}peers(){return this.engine.peers()}stat(){return this._stats}start(){this.wm.start(),this.network.start(),this.engine.start(),this.started=!0}stop(){this._stats.stop(),this.wm.stop(),this.network.stop(),this.engine.stop(),this.started=!1}unwrap(){return this.blockstore}}r.Bitswap=g},{"./want-manager/index.js":"i19lk","./network.js":"5d3og","./decision-engine/index.js":"drDE5","./notifications.js":"jCbDy","./utils/index.js":"9omCc","./stats/index.js":"da28N","native-abort-controller":"6zwoZ","any-signal":"kXgRR","blockstore-core/base":"l2CNM","multiformats/cid":"9ooAY"}],i19lk:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../message/index.js"),n=e("../wantlist/index.js"),s=e("../constants.js"),o=e("./msg-queue.js"),a=e("../utils/index.js"),c=e("multiformats/bases/base58");r.WantManager=class{constructor(e,t,r){this.peers=new Map,this.wantlist=new n.Wantlist(r),this.network=t,this._stats=r,this._peerId=e,this._log=a.logger(e,"want")}_addEntries(e,t,r){const n=e.map(((e,r)=>new i.BitswapMessage.Entry(e,s.kMaxPriority-r,i.BitswapMessage.WantType.Block,t)));n.forEach((e=>{e.cancel?r?this.wantlist.removeForce(e.cid.toString(c.base58btc)):this.wantlist.remove(e.cid):(this._log("adding to wl"),this.wantlist.add(e.cid,e.priority))}));for(const e of this.peers.values())e.addEntries(n)}_startPeerHandler(e){let t=this.peers.get(e.toB58String());if(t)return void t.refcnt++;t=new o.MsgQueue(this._peerId,e,this.network);const r=new i.BitswapMessage(!0);for(const e of this.wantlist.entries())r.addEntry(e[1].cid,e[1].priority);return t.addMessage(r),this.peers.set(e.toB58String(),t),t}_stopPeerHandler(e){const t=this.peers.get(e.toB58String());t&&(t.refcnt--,t.refcnt>0||this.peers.delete(e.toB58String()))}wantBlocks(e,t={}){this._addEntries(e,!1),t&&t.signal&&t.signal.addEventListener("abort",(()=>{this.cancelWants(e)}))}unwantBlocks(e){this._log("unwant blocks: %s",e.length),this._addEntries(e,!0,!0)}cancelWants(e){this._log("cancel wants: %s",e.length),this._addEntries(e,!0)}connectedPeers(){return Array.from(this.peers.keys())}connected(e){this._startPeerHandler(e)}disconnected(e){this._stopPeerHandler(e)}start(){}stop(){this.peers.forEach((e=>this.disconnected(e.peerId)))}}},{"../message/index.js":"3KDsa","../wantlist/index.js":"hFdtZ","../constants.js":"jvLuC","./msg-queue.js":"bgetp","../utils/index.js":"9omCc","multiformats/bases/base58":"4n7mA"}],"3KDsa":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("multiformats/hashes/sha2"),s=e("multiformats/bases/base58"),o=e("varint-decoder"),a=e("../utils/varint-encoder.js"),c=e("../utils/index.js"),u=e("./message.js"),l=e("./entry.js"),d=e("err-code");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=f(o),p=f(d);class g{constructor(e){this.full=e,this.wantlist=new Map,this.blocks=new Map,this.blockPresences=new Map,this.pendingBytes=0}get empty(){return 0===this.blocks.size&&0===this.wantlist.size&&0===this.blockPresences.size}addEntry(e,t,r,i,n){null==r&&(r=g.WantType.Block);const o=e.toString(s.base58btc),a=this.wantlist.get(o);a?(a.wantType===r&&(a.priority=t),i&&(a.cancel=Boolean(i)),n&&(a.sendDontHave=Boolean(n)),r===g.WantType.Block&&a.wantType===g.WantType.Have&&(a.wantType=r)):this.wantlist.set(o,new l.BitswapMessageEntry(e,t,r,i,n))}addBlock(e,t){const r=e.toString(s.base58btc);this.blocks.set(r,t)}addHave(e){const t=e.toString(s.base58btc);this.blockPresences.has(t)||this.blockPresences.set(t,g.BlockPresenceType.Have)}addDontHave(e){const t=e.toString(s.base58btc);this.blockPresences.has(t)||this.blockPresences.set(t,g.BlockPresenceType.DontHave)}cancel(e){const t=e.toString(s.base58btc);this.wantlist.delete(t),this.addEntry(e,0,g.WantType.Block,!0,!1)}setPendingBytes(e){this.pendingBytes=e}serializeToBitswap100(){const e={wantlist:{entries:Array.from(this.wantlist.values()).map((e=>({block:e.cid.bytes,priority:Number(e.priority),cancel:Boolean(e.cancel)}))),full:!!this.full||void 0},blocks:Array.from(this.blocks.values())};return u.Message.encode(e).finish()}serializeToBitswap110(){const e={wantlist:{entries:Array.from(this.wantlist.values()).map((e=>({block:e.cid.bytes,priority:Number(e.priority),wantType:e.wantType,cancel:Boolean(e.cancel),sendDontHave:Boolean(e.sendDontHave)}))),full:!!this.full||void 0},blockPresences:[],payload:[],pendingBytes:this.pendingBytes};for(const[t,r]of this.blocks.entries()){const n=i.CID.parse(t),s=n.version,o=n.code,c=n.multihash.code,l=n.multihash.digest.length,d=a([s,o,c,l]);e.payload.push(new u.Message.Block({prefix:d,data:r}))}for(const[t,r]of this.blockPresences)e.blockPresences.push(new u.Message.BlockPresence({cid:i.CID.parse(t).bytes,type:r}));return this.pendingBytes>0&&(e.pendingBytes=this.pendingBytes),u.Message.encode(e).finish()}equals(e){return!!(this.full===e.full&&this.pendingBytes===e.pendingBytes&&c.isMapEqual(this.wantlist,e.wantlist)&&c.isMapEqual(this.blocks,e.blocks)&&c.isMapEqual(this.blockPresences,e.blockPresences))}get[Symbol.toStringTag](){const e=Array.from(this.wantlist.keys()),t=Array.from(this.blocks.keys());return`BitswapMessage `}}g.deserialize=async(e,t)=>{const r=u.Message.decode(e),s=r.wantlist&&r.wantlist.full||!1,o=new g(s);return r.wantlist&&r.wantlist.entries&&r.wantlist.entries.forEach((e=>{if(!e.block)return;const t=i.CID.decode(e.block);o.addEntry(t,e.priority||0,e.wantType,Boolean(e.cancel),Boolean(e.sendDontHave))})),r.blockPresences&&r.blockPresences.forEach((e=>{if(!e.cid)return;const t=i.CID.decode(e.cid);e.type===g.BlockPresenceType.Have?o.addHave(t):o.addDontHave(t)})),r.blocks.length>0?(await Promise.all(r.blocks.map((async e=>{const t=await n.sha256.digest(e),r=i.CID.createV0(t);o.addBlock(r,e)}))),o):r.payload.length>0?(await Promise.all(r.payload.map((async e=>{if(!e.prefix||!e.data)return;const r=h.default(e.prefix),s=r[0],a=r[1],c=r[2],u=c===n.sha256.code?n.sha256:t&&await t.getHasher(c);if(!u)throw p.default(new Error("Unknown hash algorithm"),"ERR_UNKNOWN_HASH_ALG");const l=await u.digest(e.data),d=i.CID.create(s,a,l);o.addBlock(d,e.data)}))),o.setPendingBytes(r.pendingBytes),o):o},g.blockPresenceSize=e=>e.bytes.length+1,g.Entry=l.BitswapMessageEntry,g.WantType={Block:u.Message.Wantlist.WantType.Block,Have:u.Message.Wantlist.WantType.Have},g.BlockPresenceType={Have:u.Message.BlockPresenceType.Have,DontHave:u.Message.BlockPresenceType.DontHave},r.BitswapMessage=g},{"multiformats/cid":"9ooAY","multiformats/hashes/sha2":"7i9MT","multiformats/bases/base58":"4n7mA","varint-decoder":"4XERa","../utils/varint-encoder.js":"4kcuH","../utils/index.js":"9omCc","./message.js":"2JgzA","./entry.js":"7Jb33","err-code":"chZjB"}],"4XERa":[function(e,t,r){"use strict";const i=e("varint");t.exports=e=>{if(!(e instanceof Uint8Array))throw new Error("arg needs to be a Uint8Array");const t=[];for(;e.length>0;){const r=i.decode(e);t.push(r),e=e.slice(i.decode.bytes)}return t}},{varint:"lqmon"}],lqmon:[function(e,t,r){t.exports={encode:e("./encode.js"),decode:e("./decode.js"),encodingLength:e("./length.js")}},{"./encode.js":"2HIPs","./decode.js":"5Jcva","./length.js":"cD3BZ"}],"2HIPs":[function(e,t,r){t.exports=function e(t,r,n){r=r||[];var s=n=n||0;for(;t>=i;)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-s+1,r};var i=Math.pow(2,31)},{}],"5Jcva":[function(e,t,r){t.exports=function e(t,r){var i,n=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");i=t[o++],n+=s<28?(127&i)<=128);return e.bytes=o-r,n}},{}],cD3BZ:[function(e,t,r){var i=Math.pow(2,7),n=Math.pow(2,14),s=Math.pow(2,21),o=Math.pow(2,28),a=Math.pow(2,35),c=Math.pow(2,42),u=Math.pow(2,49),l=Math.pow(2,56),d=Math.pow(2,63);t.exports=function(e){return ee+n.default.encodingLength(t)),0)),r=0;for(const i of e)t=n.encode(i,t,r),r+=n.default.encodingLength(i);return t}},{varint:"aN1CO"}],"9omCc":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("debug"),n=e("uint8arrays/equals"),s=e("../message/entry.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(i);const c=(e,t,r)=>{let i=0;const n=r.length;for(;it.reduce(((t,r)=>{const i=e(r);return t[i]?t[i].push(r):t[i]=[r],t}),{}),r.includesWith=c,r.isMapEqual=(e,t)=>{if(e.size!==t.size)return!1;for(const[r,i]of e){const e=t.get(r);if(void 0===e)return!1;if(i instanceof Uint8Array&&e instanceof Uint8Array&&!n.equals(i,e))return!1;if(i instanceof s.BitswapMessageEntry&&e instanceof s.BitswapMessageEntry&&!i.equals(e))return!1}return!0},r.logger=(e,t)=>{const r=["bitswap"];return t&&r.push(t),e&&r.push(`${e.toB58String().slice(0,8)}`),Object.assign(a.default(r.join(":")),{error:a.default(r.concat(["error"]).join(":"))})},r.pullAllWith=(e,t,r)=>t.filter((t=>!c(e,t,r))),r.sortBy=(e,t)=>Array.prototype.slice.call(t,0).sort(((t,r)=>{const i=e(t),n=e(r);return in?1:0})),r.uniqWith=(e,t)=>{let r=0;const i=t.length,n=[];let s;for(;r`}equals(e){return this.cancel===e.cancel&&this.sendDontHave===e.sendDontHave&&this.wantType===e.wantType&&this.entry.equals(e.entry)}}r.BitswapMessageEntry=o},{"../wantlist/index.js":"hFdtZ","multiformats/bases/base58":"4n7mA"}],hFdtZ:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./entry.js"),n=e("multiformats/bases/base58"),s=e("../message/message.js");const o=s.Message.Wantlist.WantType.Block,a=s.Message.Wantlist.WantType.Have;class c{constructor(e){this.set=new Map,this._stats=e}get length(){return this.set.size}add(e,t,r){const s=e.toString(n.base58btc),c=this.set.get(s);c?(c.inc(),c.priority=t,c.wantType===a&&r===o&&(c.wantType=r)):(this.set.set(s,new i.WantListEntry(e,t,r)),this._stats&&this._stats.push(null,"wantListSize",1))}remove(e){const t=e.toString(n.base58btc),r=this.set.get(t);r&&(r.dec(),r.hasRefs()||(this.set.delete(t),this._stats&&this._stats.push(null,"wantListSize",-1)))}removeForce(e){this.set.has(e)&&this.set.delete(e)}forEach(e){return this.set.forEach(e)}entries(){return this.set.entries()}sortedEntries(){return new Map((e=e=>e[1].key,t=Array.from(this.set.entries()),Array.prototype.slice.call(t,0).sort(((t,r)=>{const i=e(t),n=e(r);return in?1:0}))));var e,t}contains(e){const t=e.toString(n.base58btc);return this.set.has(t)}get(e){const t=e.toString(n.base58btc);return this.set.get(t)}}c.Entry=i.WantListEntry,r.Wantlist=c},{"./entry.js":"9pqLF","multiformats/bases/base58":"4n7mA","../message/message.js":"2JgzA"}],"9pqLF":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/bases/base58");class n{constructor(e,t,r){this._refCounter=1,this.cid=e,this.priority=t||1,this.wantType=r}inc(){this._refCounter+=1}dec(){this._refCounter=Math.max(0,this._refCounter-1)}hasRefs(){return this._refCounter>0}get[Symbol.toStringTag](){return`WantlistEntry `}equals(e){return this._refCounter===e._refCounter&&this.cid.equals(e.cid)&&this.priority===e.priority&&this.wantType===e.wantType}}r.WantListEntry=n},{"multiformats/bases/base58":"4n7mA"}],"2JgzA":[function(e,t,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(r,"__esModule",{value:!0});var n=i(e("protobufjs/minimal.js"));const s=n.default.Reader,o=n.default.Writer,a=n.default.util,c=n.default.roots["ipfs-bitswap"]||(n.default.roots["ipfs-bitswap"]={}),u=c.Message=(()=>{function e(e){if(this.blocks=[],this.payload=[],this.blockPresences=[],e)for(var t=Object.keys(e),r=0;r>>3){case 1:i.wantlist=c.Message.Wantlist.decode(e,e.uint32());break;case 2:i.blocks&&i.blocks.length||(i.blocks=[]),i.blocks.push(e.bytes());break;case 3:i.payload&&i.payload.length||(i.payload=[]),i.payload.push(c.Message.Block.decode(e,e.uint32()));break;case 4:i.blockPresences&&i.blockPresences.length||(i.blockPresences=[]),i.blockPresences.push(c.Message.BlockPresence.decode(e,e.uint32()));break;case 5:i.pendingBytes=e.int32();break;default:e.skipType(7&n)}}return i},e.fromObject=function(e){if(e instanceof c.Message)return e;var t=new c.Message;if(null!=e.wantlist){if("object"!=typeof e.wantlist)throw TypeError(".Message.wantlist: object expected");t.wantlist=c.Message.Wantlist.fromObject(e.wantlist)}if(e.blocks){if(!Array.isArray(e.blocks))throw TypeError(".Message.blocks: array expected");t.blocks=[];for(var r=0;r>>3){case 1:i.entries&&i.entries.length||(i.entries=[]),i.entries.push(c.Message.Wantlist.Entry.decode(e,e.uint32()));break;case 2:i.full=e.bool();break;default:e.skipType(7&n)}}return i},e.fromObject=function(e){if(e instanceof c.Message.Wantlist)return e;var t=new c.Message.Wantlist;if(e.entries){if(!Array.isArray(e.entries))throw TypeError(".Message.Wantlist.entries: array expected");t.entries=[];for(var r=0;r>>3){case 1:i.block=e.bytes();break;case 2:i.priority=e.int32();break;case 3:i.cancel=e.bool();break;case 4:i.wantType=e.int32();break;case 5:i.sendDontHave=e.bool();break;default:e.skipType(7&n)}}return i},e.fromObject=function(e){if(e instanceof c.Message.Wantlist.Entry)return e;var t=new c.Message.Wantlist.Entry;switch(null!=e.block&&("string"==typeof e.block?a.base64.decode(e.block,t.block=a.newBuffer(a.base64.length(e.block)),0):e.block.length&&(t.block=e.block)),null!=e.priority&&(t.priority=0|e.priority),null!=e.cancel&&(t.cancel=Boolean(e.cancel)),e.wantType){case"Block":case 0:t.wantType=0;break;case"Have":case 1:t.wantType=1}return null!=e.sendDontHave&&(t.sendDontHave=Boolean(e.sendDontHave)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.block="":(r.block=[],t.bytes!==Array&&(r.block=a.newBuffer(r.block))),r.priority=0,r.cancel=!1,r.wantType=t.enums===String?"Block":0,r.sendDontHave=!1),null!=e.block&&e.hasOwnProperty("block")&&(r.block=t.bytes===String?a.base64.encode(e.block,0,e.block.length):t.bytes===Array?Array.prototype.slice.call(e.block):e.block),null!=e.priority&&e.hasOwnProperty("priority")&&(r.priority=e.priority),null!=e.cancel&&e.hasOwnProperty("cancel")&&(r.cancel=e.cancel),null!=e.wantType&&e.hasOwnProperty("wantType")&&(r.wantType=t.enums===String?c.Message.Wantlist.WantType[e.wantType]:e.wantType),null!=e.sendDontHave&&e.hasOwnProperty("sendDontHave")&&(r.sendDontHave=e.sendDontHave),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,n.default.util.toJSONOptions)},e}(),e}(),e.Block=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:i.prefix=e.bytes();break;case 2:i.data=e.bytes();break;default:e.skipType(7&n)}}return i},e.fromObject=function(e){if(e instanceof c.Message.Block)return e;var t=new c.Message.Block;return null!=e.prefix&&("string"==typeof e.prefix?a.base64.decode(e.prefix,t.prefix=a.newBuffer(a.base64.length(e.prefix)),0):e.prefix.length&&(t.prefix=e.prefix)),null!=e.data&&("string"==typeof e.data?a.base64.decode(e.data,t.data=a.newBuffer(a.base64.length(e.data)),0):e.data.length&&(t.data=e.data)),t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.prefix="":(r.prefix=[],t.bytes!==Array&&(r.prefix=a.newBuffer(r.prefix))),t.bytes===String?r.data="":(r.data=[],t.bytes!==Array&&(r.data=a.newBuffer(r.data)))),null!=e.prefix&&e.hasOwnProperty("prefix")&&(r.prefix=t.bytes===String?a.base64.encode(e.prefix,0,e.prefix.length):t.bytes===Array?Array.prototype.slice.call(e.prefix):e.prefix),null!=e.data&&e.hasOwnProperty("data")&&(r.data=t.bytes===String?a.base64.encode(e.data,0,e.data.length):t.bytes===Array?Array.prototype.slice.call(e.data):e.data),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,n.default.util.toJSONOptions)},e}(),e.BlockPresenceType=function(){const e={},t=Object.create(e);return t[e[0]="Have"]=0,t[e[1]="DontHave"]=1,t}(),e.BlockPresence=function(){function e(e){if(e)for(var t=Object.keys(e),r=0;r>>3){case 1:i.cid=e.bytes();break;case 2:i.type=e.int32();break;default:e.skipType(7&n)}}return i},e.fromObject=function(e){if(e instanceof c.Message.BlockPresence)return e;var t=new c.Message.BlockPresence;switch(null!=e.cid&&("string"==typeof e.cid?a.base64.decode(e.cid,t.cid=a.newBuffer(a.base64.length(e.cid)),0):e.cid.length&&(t.cid=e.cid)),e.type){case"Have":case 0:t.type=0;break;case"DontHave":case 1:t.type=1}return t},e.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(t.bytes===String?r.cid="":(r.cid=[],t.bytes!==Array&&(r.cid=a.newBuffer(r.cid))),r.type=t.enums===String?"Have":0),null!=e.cid&&e.hasOwnProperty("cid")&&(r.cid=t.bytes===String?a.base64.encode(e.cid,0,e.cid.length):t.bytes===Array?Array.prototype.slice.call(e.cid):e.cid),null!=e.type&&e.hasOwnProperty("type")&&(r.type=t.enums===String?c.Message.BlockPresenceType[e.type]:e.type),r},e.prototype.toJSON=function(){return this.constructor.toObject(this,n.default.util.toJSONOptions)},e}(),e})();r.Message=u,r.default=c},{"protobufjs/minimal.js":"grAXL"}],jvLuC:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});const i=Math.pow(2,31)-1;r.hasBlockTimeout=15e3,r.kMaxPriority=i,r.maxListeners=1e3,r.maxProvidersPerRequest=3,r.provideTimeout=15e3,r.providerRequestTimeout=1e4,r.wantlistSendDebounceMs=1},{}],bgetp:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("just-debounce-it"),n=e("../message/index.js"),s=e("../utils/index.js"),o=e("../constants.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=a(i);r.MsgQueue=class{constructor(e,t,r){this.peerId=t,this.network=r,this.refcnt=1,this._entries=[],this._log=s.logger(e,"msgqueue"),this.sendEntries=c.default(this._sendEntries.bind(this),o.wantlistSendDebounceMs)}addMessage(e){e.empty||this.send(e)}addEntries(e){this._entries=this._entries.concat(e),this.sendEntries()}_sendEntries(){if(!this._entries.length)return;const e=new n.BitswapMessage(!1);this._entries.forEach((t=>{t.cancel?e.cancel(t.cid):e.addEntry(t.cid,t.priority)})),this._entries=[],this.addMessage(e)}async send(e){try{await this.network.connectTo(this.peerId)}catch(e){return void this._log.error("cant connect to peer %s: %s",this.peerId.toB58String(),e.message)}this._log("sending message to peer %s",this.peerId.toB58String()),this.network.sendMessage(this.peerId,e).catch((e=>{this._log.error("send error: %s",e.message)}))}}},{"just-debounce-it":"ci2L4","../message/index.js":"3KDsa","../utils/index.js":"9omCc","../constants.js":"jvLuC"}],ci2L4:[function(e,t,r){t.exports=function(e,t,r){var i=null,n=null,s=function(){i&&(clearTimeout(i),n=null,i=null)},o=function(){if(!t)return e.apply(this,arguments);var o=this,a=arguments,c=r&&!i;return s(),n=function(){e.apply(o,a)},i=setTimeout((function(){if(i=null,!c){var e=n;return n=null,e()}}),t),c?n():void 0};return o.cancel=s,o.flush=function(){var e=n;s(),e&&e()},o}},{}],"5d3og":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("it-length-prefixed"),n=e("it-pipe"),s=e("libp2p-interfaces/src/topology/multicodec-topology.js"),o=e("./message/index.js"),a=e("./constants.js"),c=e("./utils/index.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=u(i),d=u(s);const f="/ipfs/bitswap/1.0.0",h="/ipfs/bitswap/1.1.0",p="/ipfs/bitswap/1.2.0";r.Network=class{constructor(e,t,r,i={}){this._log=c.logger(e.peerId,"network"),this._libp2p=e,this._bitswap=t,this._protocols=[f],i.b100Only||(this._protocols.unshift(h),this._protocols.unshift(p)),this._stats=r,this._running=!1,this._onPeerConnect=this._onPeerConnect.bind(this),this._onPeerDisconnect=this._onPeerDisconnect.bind(this),this._onConnection=this._onConnection.bind(this),this._hashLoader=i.hashLoader}start(){this._running=!0,this._libp2p.handle(this._protocols,this._onConnection);const e=new d.default({multicodecs:this._protocols,handlers:{onConnect:this._onPeerConnect,onDisconnect:this._onPeerDisconnect}});this._registrarId=this._libp2p.registrar.register(e);for(const e of this._libp2p.peerStore.peers.values()){const t=this._libp2p.connectionManager.get(e.id);t&&this._onPeerConnect(t.remotePeer)}}stop(){this._running=!1,this._libp2p.unhandle(this._protocols),null!=this._registrarId&&this._libp2p.registrar.unregister(this._registrarId)}async _onConnection({protocol:e,stream:t,connection:r}){if(this._running){this._log("incoming new bitswap %s connection from %s",e,r.remotePeer.toB58String());try{await n.pipe(t,l.default.decode(),(async e=>{for await(const t of e)try{const e=await o.BitswapMessage.deserialize(t.slice(),this._hashLoader);await this._bitswap._receiveMessage(r.remotePeer,e)}catch(e){this._bitswap._receiveError(e);break}}))}catch(e){this._log(e)}}}_onPeerConnect(e){this._bitswap._onPeerConnected(e)}_onPeerDisconnect(e){this._bitswap._onPeerDisconnected(e)}findProviders(e,t,r={}){return this._libp2p.contentRouting.findProviders(e,{timeout:a.providerRequestTimeout,maxNumProviders:t})}async findAndConnect(e,t){const r=[];for await(const i of this.findProviders(e,a.maxProvidersPerRequest,t))this._log(`connecting to provider ${i.id}`),r.push(this.connectTo(i.id,t).catch((e=>{this._log.error(e)})));await Promise.all(r)}async provide(e,t){await this._libp2p.contentRouting.provide(e,t)}async sendMessage(e,t){if(!this._running)throw new Error("network isn't running");const r=e.toB58String();this._log("sendMessage to %s",r,t);const i=await this._libp2p.dial(e),{stream:s,protocol:o}=await i.newStream([p,h,f]);let a;switch(o){case f:a=t.serializeToBitswap100();break;case h:case p:a=t.serializeToBitswap110();break;default:throw new Error("Unknown protocol: "+o)}!async function(e,t,r){try{await n.pipe([t],l.default.encode(),e)}catch(e){r(e)}}(s,a,this._log),this._updateSentStats(e,t.blocks)}async connectTo(e,t){if(!this._running)throw new Error("network isn't running");return this._libp2p.dial(e,t)}_updateSentStats(e,t){const r=e.toB58String();if(this._stats){for(const e of t.values())this._stats.push(r,"dataSent",e.length);this._stats.push(r,"blocksSent",t.size)}}}},{"it-length-prefixed":"3yxIE","it-pipe":"giKBQ","libp2p-interfaces/src/topology/multicodec-topology.js":"52SML","./message/index.js":"3KDsa","./constants.js":"jvLuC","./utils/index.js":"9omCc"}],drDE5:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("multiformats/cid"),n=e("multiformats/bases/base58"),s=e("../message/index.js"),o=e("../wantlist/index.js"),a=e("./ledger.js"),c=e("./req-queue.js"),u=e("./task-merger.js"),l=e("../utils/index.js");const d=s.BitswapMessage.WantType;r.DecisionEngine=class{constructor(e,t,r,i,n={}){this._log=l.logger(e,"engine"),this.blockstore=t,this.network=r,this._stats=i,this._opts=this._processOpts(n),this.ledgerMap=new Map,this._running=!1,this._requestQueue=new c.RequestQueue(u.TaskMerger)}_processOpts(e){return{maxSizeReplaceHasWithBlock:1024,targetMessageSize:16384,...e}}_scheduleProcessTasks(){setTimeout((()=>{this._processTasks()}))}async _processTasks(){if(!this._running)return;const{peerId:e,tasks:t,pendingSize:r}=this._requestQueue.popTasks(this._opts.targetMessageSize);if(0===t.length)return;const n=new s.BitswapMessage(!1);n.setPendingBytes(r);const o=[],a=new Map;for(const e of t){const t=i.CID.parse(e.topic);e.data.haveBlock?e.data.isWantBlock?(o.push(t),a.set(e.topic,e.data)):n.addHave(t):n.addDontHave(t)}const c=await this._getBlocks(o);for(const[e,t]of a){const r=i.CID.parse(e),s=c.get(e);s?n.addBlock(r,s):t.sendDontHave&&n.addDontHave(r)}if(n.empty)return e&&this._requestQueue.tasksDone(e,t),void this._scheduleProcessTasks();try{e&&await this.network.sendMessage(e,n);for(const[t,r]of c.entries())e&&this.messageSent(e,i.CID.parse(t),r)}catch(e){this._log.error(e)}e&&this._requestQueue.tasksDone(e,t),this._scheduleProcessTasks()}wantlistForPeer(e){const t=e.toB58String(),r=this.ledgerMap.get(t);return r?r.wantlist.sortedEntries():new Map}ledgerForPeer(e){const t=e.toB58String(),r=this.ledgerMap.get(t);return r?{peer:r.partner,value:r.debtRatio(),sent:r.accounting.bytesSent,recv:r.accounting.bytesRecv,exchanged:r.exchangeCount}:null}peers(){return Array.from(this.ledgerMap.values()).map((e=>e.partner))}receivedBlocks(e){if(e.length){for(const t of this.ledgerMap.values())for(const r of e){const e=t.wantlistContains(r.cid);if(!e)continue;const i=r.data.length,o=this._sendAsBlock(e.wantType,i);let a=i;o||(a=s.BitswapMessage.blockPresenceSize(e.cid)),this._requestQueue.pushTasks(t.partner,[{topic:e.cid.toString(n.base58btc),priority:e.priority,size:a,data:{blockSize:i,isWantBlock:o,haveBlock:!0,sendDontHave:!1}}])}this._scheduleProcessTasks()}}async messageReceived(e,t){const r=this._findOrCreate(e);if(t.empty)return;if(t.full&&(r.wantlist=new o.Wantlist),this._updateBlockAccounting(t.blocks,r),0===t.wantlist.size)return void this._scheduleProcessTasks();const i=[],n=[];t.wantlist.forEach((e=>{e.cancel?(r.cancelWant(e.cid),i.push(e.cid)):(r.wants(e.cid,e.priority,e.wantType),n.push(e))})),this._cancelWants(e,i),await this._addWants(e,n),this._scheduleProcessTasks()}_cancelWants(e,t){for(const r of t)this._requestQueue.remove(r.toString(n.base58btc),e)}async _addWants(e,t){const r=await this._getBlockSizes(t.map((e=>e.cid))),i=[];for(const o of t){const t=o.cid.toString(n.base58btc),a=r.get(t);if(null==a)o.sendDontHave&&i.push({topic:t,priority:o.priority,size:s.BitswapMessage.blockPresenceSize(o.cid),data:{isWantBlock:o.wantType===d.Block,blockSize:0,haveBlock:!1,sendDontHave:o.sendDontHave}});else{const e=this._sendAsBlock(o.wantType,a);let r=a;e||(r=s.BitswapMessage.blockPresenceSize(o.cid)),i.push({topic:t,priority:o.priority,size:r,data:{isWantBlock:e,blockSize:a,haveBlock:!0,sendDontHave:o.sendDontHave}})}this._requestQueue.pushTasks(e,i)}}_sendAsBlock(e,t){return e===d.Block||t<=this._opts.maxSizeReplaceHasWithBlock}async _getBlockSizes(e){const t=await this._getBlocks(e);return new Map([...t].map((([e,t])=>[e,t.length])))}async _getBlocks(e){const t=new Map;return await Promise.all(e.map((async e=>{try{const r=await this.blockstore.get(e);t.set(e.toString(n.base58btc),r)}catch(t){"ERR_NOT_FOUND"!==t.code&&this._log.error("failed to query blockstore for %s: %s",e,t)}}))),t}_updateBlockAccounting(e,t){for(const r of e.values())this._log("got block (%s bytes)",r.length),t.receivedBytes(r.length)}messageSent(e,t,r){const i=this._findOrCreate(e);i.sentBytes(r.length),i.wantlist.remove(t)}numBytesSentTo(e){return this._findOrCreate(e).accounting.bytesSent}numBytesReceivedFrom(e){return this._findOrCreate(e).accounting.bytesRecv}peerDisconnected(e){}_findOrCreate(e){const t=e.toB58String(),r=this.ledgerMap.get(t);if(r)return r;const i=new a.Ledger(e);return this.ledgerMap.set(t,i),this._stats&&this._stats.push(t,"peerCount",1),i}start(){this._running=!0}stop(){this._running=!1}}},{"multiformats/cid":"9ooAY","multiformats/bases/base58":"4n7mA","../message/index.js":"3KDsa","../wantlist/index.js":"hFdtZ","./ledger.js":"9MSJX","./req-queue.js":"2w6WU","./task-merger.js":"hlwar","../utils/index.js":"9omCc"}],"9MSJX":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../wantlist/index.js");r.Ledger=class{constructor(e){this.partner=e,this.wantlist=new i.Wantlist,this.exchangeCount=0,this.sentToPeer=new Map,this.accounting={bytesSent:0,bytesRecv:0}}sentBytes(e){this.exchangeCount++,this.lastExchange=(new Date).getTime(),this.accounting.bytesSent+=e}receivedBytes(e){this.exchangeCount++,this.lastExchange=(new Date).getTime(),this.accounting.bytesRecv+=e}wants(e,t,r){this.wantlist.add(e,t,r)}cancelWant(e){this.wantlist.remove(e)}wantlistContains(e){return this.wantlist.get(e)}debtRatio(){return this.accounting.bytesSent/(this.accounting.bytesRecv+1)}}},{"../wantlist/index.js":"hFdtZ"}],"2w6WU":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("../utils/sorted-map.js");const n={hasNewInfo:()=>!1,merge(){}};class s{constructor(e,t){this.peerId=e,this._taskMerger=t,this._activeTotalSize=0,this._pending=new o,this._active=new Set}pushTasks(e){for(const t of e)this._pushTask(t)}_pushTask(e){if(!this._taskHasMoreInfoThanActiveTasks(e))return;const t=this._pending.get(e.topic);if(t)return e.priority>t.priority&&this._pending.updatePriority(e.topic,e.priority),void this._taskMerger.merge(e,t);this._pending.add(e)}_taskHasMoreInfoThanActiveTasks(e){const t=[];for(const r of this._active)r.topic===e.topic&&t.push(r);return 0===t.length||this._taskMerger.hasNewInfo(e,t)}popTasks(e){let t=0;const r=[],i=this._pending.tasks();for(let n=0;ne+t.task.size),0)}get(e){return(this._tasks.get(e)||{}).task}add(e){this._tasks.set(e.topic,{created:Date.now(),task:e})}delete(e){this._tasks.delete(e)}tasks(){return[...this._tasks.values()].map((e=>e.task))}updatePriority(e,t){const r=this._tasks.get(e);if(!r)return;const i=this._tasks.indexOf(e);r.task.priority=t,this._tasks.update(i)}_compare(e,t){return e[1].task.priority===t[1].task.priority?e[1].created-t[1].created:t[1].task.priority-e[1].task.priority}}r.RequestQueue=class{constructor(e=n){this._taskMerger=e,this._byPeer=new i.SortedMap([],s.compare)}pushTasks(e,t){let r=this._byPeer.get(e.toB58String());r||(r=new s(e,this._taskMerger)),r.pushTasks(t),this._byPeer.set(e.toB58String(),r)}popTasks(e){const t=this._head();if(void 0===t)return{tasks:[],pendingSize:0};const{tasks:r,pendingSize:i}=t.popTasks(e);if(0===r.length)return{tasks:r,pendingSize:i};const n=t.peerId;return t.isIdle()?this._byPeer.delete(n.toB58String()):this._byPeer.update(0),{peerId:n,tasks:r,pendingSize:i}}_head(){if(0!==this._byPeer.size)for(const[,e]of this._byPeer)return e}remove(e,t){const r=this._byPeer.get(t.toB58String());r&&r.remove(e)}tasksDone(e,t){const r=this._byPeer.get(e.toB58String());if(!r)return;const i=this._byPeer.indexOf(e.toB58String());for(const e of t)r.taskDone(e);this._byPeer.update(i)}}},{"../utils/sorted-map.js":"h0gYa"}],h0gYa:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});class i extends Map{constructor(e,t){super(),this._cmp=t||this._defaultSort,this._keys=[];for(const[t,r]of e||[])this.set(t,r)}update(e){if(e<0||e>=this._keys.length)return;const t=this._keys[e];this._keys.splice(e,1);const r=this._find(t);this._keys.splice(r,0,t)}set(e,t){if(this.has(e)){const t=this.indexOf(e);this._keys.splice(t,1)}super.set(e,t);const r=this._find(e);return this._keys.splice(r,0,e),this}clear(){super.clear(),this._keys=[]}delete(e){if(!this.has(e))return!1;const t=this.indexOf(e);return this._keys.splice(t,1),super.delete(e)}indexOf(e){if(!this.has(e))return-1;const t=this._find(e);if(this._keys[t]===e)return t;for(let r=1;r>>1,n=this._kCmp(this._keys[i],e);if(n<0)t=i+1;else{if(!(n>0))return i;r=i}}return t}*keys(){for(const e of this._keys)yield e}*values(){for(const e of this._keys)yield this.get(e)}*entries(){for(const e of this._keys)yield[e,this.get(e)]}*[Symbol.iterator](){yield*this.entries()}forEach(e,t){if(e)for(const r of this._keys)e.apply(t,[[r,this.get(r)]])}_defaultSort(e,t){return e[0]`unwant:${n.toString(e.multihash.bytes,"base64")}`,c=e=>`block:${n.toString(e.multihash.bytes,"base64")}`;class u extends i.EventEmitter{constructor(e){super(),this.setMaxListeners(s.maxListeners),this._log=o.logger(e,"notif")}hasBlock(e,t){const r=c(e);this._log(r),this.emit(r,t)}wantBlock(e,t={}){if(!e)throw new Error("Not a valid cid");const r=c(e),i=a(e);return this._log(`wantBlock:${e}`),new Promise(((n,s)=>{const o=()=>{this.removeListener(r,a),s(new Error(`Block for ${e} unwanted`))},a=e=>{this.removeListener(i,o),n(e)};this.once(i,o),this.once(r,a),t&&t.signal&&t.signal.addEventListener("abort",(()=>{this.removeListener(r,a),this.removeListener(i,o),s(new Error(`Want for ${e} aborted`))}))}))}unwantBlock(e){const t=a(e);this._log(t),this.emit(t)}}r.Notifications=u},{events:"g82pp","uint8arrays/to-string":"hC8JB","./constants.js":"jvLuC","./utils/index.js":"9omCc"}],da28N:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("events"),n=e("./stat.js");const s={enabled:!1,computeThrottleTimeout:1e3,computeThrottleMaxQueueSize:1e3,movingAverageIntervals:[6e4,3e5,9e5]};class o extends i.EventEmitter{constructor(e=[],t=s){super();const r=Object.assign({},s,t);if("number"!=typeof r.computeThrottleTimeout)throw new Error("need computeThrottleTimeout");if("number"!=typeof r.computeThrottleMaxQueueSize)throw new Error("need computeThrottleMaxQueueSize");this._initialCounters=e,this._options=r,this._enabled=this._options.enabled,this._global=new n.Stat(e,r),this._global.on("update",(e=>this.emit("update",e))),this._peers=new Map}enable(){this._enabled=!0,this._options.enabled=!0,this._global.enable()}disable(){this._enabled=!1,this._options.enabled=!1,this._global.disable()}stop(){this._enabled=!1,this._global.stop();for(const e of this._peers)e[1].stop()}get snapshot(){return this._global.snapshot}get movingAverages(){return this._global.movingAverages}forPeer(e){const t="string"!=typeof e&&e.toB58String?e.toB58String():`${e}`;return this._peers.get(t)}push(e,t,r){if(this._enabled&&(this._global.push(t,r),e)){let i=this._peers.get(e);i||(i=new n.Stat(this._initialCounters,this._options),this._peers.set(e,i)),i.push(t,r)}}disconnected(e){const t=e.toB58String(),r=this._peers.get(t);r&&(r.stop(),this._peers.delete(t))}}r.Stats=o},{events:"g82pp","./stat.js":"bywlH"}],bywlH:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("events");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=n(e("@vascosantos/moving-average"));class o extends i.EventEmitter{constructor(e,t){super(),this._options=t,this._queue=[],this._stats={},this._frequencyLastTime=Date.now(),this._frequencyAccumulators={},this._movingAverages={},this._update=this._update.bind(this),e.forEach((e=>{this._stats[e]=BigInt(0),this._movingAverages[e]={},this._options.movingAverageIntervals.forEach((t=>{(this._movingAverages[e][t]=s.default(t)).push(this._frequencyLastTime,0)}))})),this._enabled=this._options.enabled}enable(){this._enabled=!0}disable(){this._disabled=!0}stop(){this._timeout&&clearTimeout(this._timeout)}get snapshot(){return Object.assign({},this._stats)}get movingAverages(){return Object.assign({},this._movingAverages)}push(e,t){this._enabled&&(this._queue.push([e,t,Date.now()]),this._resetComputeTimeout())}_resetComputeTimeout(){this._timeout&&clearTimeout(this._timeout),this._timeout=setTimeout(this._update,this._nextTimeout())}_nextTimeout(){const e=this._queue.length/this._options.computeThrottleMaxQueueSize;return Math.max(this._options.computeThrottleTimeout*(1-e),0)}_update(){if(this._timeout=null,this._queue.length){let e;for(;this._queue.length;){const t=e=this._queue.shift();t&&this._applyOp(t)}e&&this._updateFrequency(e[2]),this.emit("update",this._stats)}}_updateFrequency(e){const t=e-this._frequencyLastTime;t&&Object.keys(this._stats).forEach((r=>{this._updateFrequencyFor(r,t,e)})),this._frequencyLastTime=e}_updateFrequencyFor(e,t,r){const i=this._frequencyAccumulators[e]||0;this._frequencyAccumulators[e]=0;const n=i/t*1e3;let o=this._movingAverages[e];o||(o=this._movingAverages[e]={}),this._options.movingAverageIntervals.forEach((e=>{let t=o[e];t||(t=o[e]=s.default(e)),t.push(r,n)}))}_applyOp(e){const t=e[0],r=e[1];if("number"!=typeof r)throw new Error(`invalid increment number: ${r}`);Object.prototype.hasOwnProperty.call(this._stats,t)||(this._stats[t]=BigInt(0)),this._stats[t]=BigInt(this._stats[t])+BigInt(r),this._frequencyAccumulators[t]||(this._frequencyAccumulators[t]=0),this._frequencyAccumulators[t]+=r}}r.Stat=o},{events:"g82pp","@vascosantos/moving-average":"2F3Pq"}],"55a3I":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("blockstore-core"),n=e("it-merge"),s=e("it-pushable"),o=e("it-filter");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=a(n),u=a(s),l=a(o);class d extends i.BaseBlockstore{constructor(e,t){super(),this.child=e,this.bitswap=t}open(){return this.child.open()}close(){return this.child.close()}unwrap(){return this.child}async put(e,t,r={}){await this.has(e)||(this.bitswap.isStarted()?await this.bitswap.put(e,t,r):await this.child.put(e,t,r))}async*putMany(e,t={}){const r=l.default(e,(async({key:e})=>!await this.has(e)));this.bitswap.isStarted()?yield*this.bitswap.putMany(r,t):yield*this.child.putMany(r,t)}async get(e,t={}){return!await this.has(e)&&this.bitswap.isStarted()?this.bitswap.get(e,t):this.child.get(e,t)}async*getMany(e,t={}){const r=u.default(),i=u.default();Promise.resolve().then((async()=>{for await(const t of e)!await this.has(t)&&this.bitswap.isStarted()?r.push(t):i.push(t);r.end(),i.end()})),yield*c.default(this.bitswap.getMany(r,t),this.child.getMany(i,t))}async delete(e,t){await this.child.delete(e,t)}async*deleteMany(e,t){yield*this.child.deleteMany(e,t)}async has(e,t={}){return this.child.has(e,t)}async*query(e,t={}){yield*this.child.query(e,t)}async*queryKeys(e,t={}){yield*this.child.queryKeys(e,t)}}r.BlockStorage=d},{"blockstore-core":"alw2u","it-merge":"cPFu3","it-pushable":"bnpei","it-filter":"5LCTL"}],alw2u:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./errors.js"),n=e("./base.js"),s=e("./memory.js");const o={...i};r.BaseBlockstore=n.BaseBlockstore,r.MemoryBlockstore=s.MemoryBlockstore,r.Errors=o},{"./errors.js":"eBPsS","./base.js":"l2CNM","./memory.js":"ahARU"}],eBPsS:[function(e,t,r){"use strict";function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(r,"__esModule",{value:!0});var n=i(e("err-code"));r.abortedError=function(e){return e=e||new Error("Aborted"),n.default(e,"ERR_ABORTED")},r.notFoundError=function(e){return e=e||new Error("Not Found"),n.default(e,"ERR_NOT_FOUND")}},{"err-code":"chZjB"}],ahARU:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./base.js"),n=e("multiformats/bases/base32"),s=e("multiformats/codecs/raw"),o=e("multiformats/cid"),a=e("multiformats/hashes/digest"),c=e("./errors.js");function u(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var l=u(s),d=u(a);class f extends i.BaseBlockstore{constructor(){super(),this.data={}}open(){return Promise.resolve()}close(){return Promise.resolve()}async put(e,t){this.data[n.base32.encode(e.multihash.bytes)]=t}async get(e){if(!await this.has(e))throw c.notFoundError();return this.data[n.base32.encode(e.multihash.bytes)]}async has(e){return void 0!==this.data[n.base32.encode(e.multihash.bytes)]}async delete(e){delete this.data[n.base32.encode(e.multihash.bytes)]}async*_all(){yield*Object.entries(this.data).map((([e,t])=>({key:o.CID.createV1(l.code,d.decode(n.base32.decode(e))),value:t})))}async*_allKeys(){yield*Object.entries(this.data).map((([e])=>o.CID.createV1(l.code,d.decode(n.base32.decode(e)))))}}r.MemoryBlockstore=f},{"./base.js":"l2CNM","multiformats/bases/base32":"5k9Tu","multiformats/codecs/raw":"fdfgp","multiformats/cid":"9ooAY","multiformats/hashes/digest":"kpRBg","./errors.js":"eBPsS"}],cGDFf:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("./addrs.js"),n=e("./connect.js"),s=e("./disconnect.js"),o=e("./local-addrs.js"),a=e("./peers.js");r.SwarmAPI=class{constructor({network:e}){this.addrs=i.createAddrs({network:e}),this.connect=n.createConnect({network:e}),this.disconnect=s.createDisconnect({network:e}),this.localAddrs=o.createLocalAddrs({network:e}),this.peers=a.createPeers({network:e})}}},{"./addrs.js":"4nmdM","./connect.js":"1cg0c","./disconnect.js":"kER7G","./local-addrs.js":"vjKoo","./peers.js":"gf7YS"}],"4nmdM":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option");r.createAddrs=function({network:e}){return i.withTimeoutOption((async function(t={}){const r=[],{libp2p:i}=await e.use(t);for(const[e,t]of i.peerStore.peers.entries())r.push({id:e,addrs:t.addresses.map((e=>e.multiaddr))});return r}))}},{"ipfs-core-utils/with-timeout-option":"j29MK"}],"1cg0c":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option");r.createConnect=function({network:e}){return i.withTimeoutOption((async function(t,r={}){const{libp2p:i}=await e.use(r);await i.dial(t,r)}))}},{"ipfs-core-utils/with-timeout-option":"j29MK"}],kER7G:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option");r.createDisconnect=function({network:e}){return i.withTimeoutOption((async function(t,r={}){const{libp2p:i}=await e.use(r);await i.hangUp(t)}))}},{"ipfs-core-utils/with-timeout-option":"j29MK"}],vjKoo:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option");r.createLocalAddrs=function({network:e}){return i.withTimeoutOption((async function(t={}){const{libp2p:r}=await e.use(t);return r.multiaddrs}))}},{"ipfs-core-utils/with-timeout-option":"j29MK"}],gf7YS:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option");r.createPeers=function({network:e}){return i.withTimeoutOption((async function(t={}){const{libp2p:r}=await e.use(t),i=[];for(const[e,n]of r.connections)for(const r of n){const n={addr:r.remoteAddr,peer:e};(t.verbose||t.direction)&&(n.direction=r.stat.direction),t.verbose&&(n.muxer=r.stat.multiplexer,n.latency="n/a",n.streams=[]),i.push(n)}return i}))}},{"ipfs-core-utils/with-timeout-option":"j29MK"}],dHQEh:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("peer-id"),n=e("ipfs-core-utils/with-timeout-option");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=s(i);const a={success:!0,time:0,text:""};r.createPing=function({network:e}){return n.withTimeoutOption((async function*(t,r={}){const{libp2p:i}=await e.use();r.count=r.count||10;const n=o.default.createFromB58String(t),s=i.peerStore.get(n);let c=s&&s.id;if(!c){yield{...a,text:`Looking up peer ${t}`};const e=await i.peerRouting.findPeer(n);c=e&&e.id}if(!c)throw new Error("Peer was not found");yield{...a,text:`PING ${c.toB58String()}`};let u=0,l=0;for(let e=0;e{const r=await e.use(t);if(d.default(r.libp2p,"_config.dht.enabled",!1))return r;throw new s.NotEnabledError("dht not enabled")};r.createDht=function({network:e,repo:t}){const{get:r,put:i,findProvs:n,findPeer:s,provide:o,query:c}={async get(t,r={}){const{libp2p:i}=await f(e,r);return i._dht.get(t,r)},async*put(t,r,i){const{libp2p:n}=await f(e,i);yield*n._dht.put(t,r)},async*findProvs(t,r={numProviders:20}){const{libp2p:i}=await f(e,r);for await(const e of i._dht.findProviders(t,{maxNumProviders:r.numProviders,signal:r.signal}))yield{id:e.id.toB58String(),addrs:e.addrs}},async findPeer(t,r){const{libp2p:i}=await f(e,r),n=await i._dht.findPeer(u.default.parse(t));return{id:n.id.toB58String(),addrs:n.multiaddrs}},async*provide(r,i={recursive:!1}){const{libp2p:n}=await f(e,i),s=Array.isArray(r)?r:[r];if(!(await Promise.all(s.map((e=>t.blocks.has(e))))).every((e=>e)))throw l.default(new Error("block(s) not found locally, cannot provide"),"ERR_BLOCK_NOT_FOUND");if(i.recursive)throw l.default(new Error("not implemented yet"),"ERR_NOT_IMPLEMENTED_YET");for(const e of s)yield n._dht.provide(e)},async*query(t,r){const{libp2p:i}=await f(e,r);for await(const e of i._dht.getClosestPeers(u.default.parse(t).toBytes()))yield{id:e.toB58String(),addrs:[]}}};return{get:a.withTimeoutOption(r),put:a.withTimeoutOption(i),findProvs:a.withTimeoutOption(n),findPeer:a.withTimeoutOption(s),provide:a.withTimeoutOption(o),query:a.withTimeoutOption(c)}}},{"peer-id":"8Bdb3","err-code":"chZjB","../errors.js":"j69o8",dlv:"hp0pQ","ipfs-core-utils/with-timeout-option":"j29MK"}],"7IJgU":[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=e("ipfs-core-utils/with-timeout-option"),n=e("err-code"),s=e("../errors.js"),o=e("dlv");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=a(n),u=a(o);const l=async()=>{throw new s.NotEnabledError("pubsub not enabled")};r.createPubsub=function({network:e,config:t}){const r=u.default(t||{},"Pubsub.Enabled",!0);return{subscribe:r?i.withTimeoutOption((async function(t,r,i={}){const{libp2p:n}=await e.use(i);return n.pubsub.subscribe(t,r,i)})):l,unsubscribe:r?i.withTimeoutOption((async function(t,r,i={}){const{libp2p:n}=await e.use(i);n.pubsub.unsubscribe(t,r,i)})):l,publish:r?i.withTimeoutOption((async function(t,r,i={}){const{libp2p:n}=await e.use(i);if(!r)throw c.default(new Error('argument "data" is required'),"ERR_ARG_REQUIRED");await n.pubsub.publish(t,r)})):l,ls:r?i.withTimeoutOption((async function(t={}){const{libp2p:r}=await e.use(t);return r.pubsub.getTopics()})):l,peers:r?i.withTimeoutOption((async function(t,r={}){const{libp2p:i}=await e.use(r);return i.pubsub.getSubscribers(t)})):l}}},{"ipfs-core-utils/with-timeout-option":"j29MK","err-code":"chZjB","../errors.js":"j69o8",dlv:"hp0pQ"}],juo1D:[function(e,t,r){var i,n;"undefined"!=typeof window&&(i=this,n=function(){return function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(i,n,function(t){return e[t]}.bind(null,n));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(e,t,r){"use strict";var i=Object.prototype.hasOwnProperty,n="~";function s(){}function o(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,r,i,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new o(r,i||e,s),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function c(e,t){0==--e._eventsCount?e._events=new s:delete e._events[t]}function u(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(n=!1)),u.prototype.eventNames=function(){var e,t,r=[];if(0===this._eventsCount)return r;for(t in e=this._events)i.call(e,t)&&r.push(n?t.slice(1):t);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(e)):r},u.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,s=r.length,o=new Array(s);i0}),!1)}e.exports=function(e,t){t=t||{};var n={main:r.m},s=t.all?{main:Object.keys(n.main)}:function(e,t){for(var r={main:[t]},i={main:[]},n={main:{}};c(r);)for(var s=Object.keys(r),o=0;o>>8^255&y^99,e[h]=y,t[y]=h;var m=f[h],b=f[m],v=f[b],w=257*f[y]^16843008*y;i[h]=w<<24|w>>>8,n[h]=w<<16|w>>>16,s[h]=w<<8|w>>>24,o[h]=w,w=16843009*v^65537*b^257*m^16843008*h,c[y]=w<<24|w>>>8,u[y]=w<<16|w>>>16,l[y]=w<<8|w>>>24,d[y]=w,h?(h=m^f[f[f[v^m]]],p^=f[f[p]]):h=p=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i>>5}function f(e,t){return!!(t+1=e.length)return!1;var i=d(e,t);if(i<=r)return!1;var n=t+i;if(n===e.length||n+1>>6),!((c=(60&t[r+2])>>>2)>p.length-1))return l=(1&t[r+2])<<2,l|=(192&t[r+3])>>>6,a.logger.log("manifest codec:"+s+",ADTS data:type:"+o+",sampleingIndex:"+c+"["+p[c]+"Hz],channelConfig:"+l),/firefox/i.test(f)?c>=6?(o=5,d=new Array(4),u=c-3):(o=2,d=new Array(2),u=c):-1!==f.indexOf("android")?(o=2,d=new Array(2),u=c):(o=5,d=new Array(4),s&&(-1!==s.indexOf("mp4a.40.29")||-1!==s.indexOf("mp4a.40.5"))||!s&&c>=6?u=c-3:((s&&-1!==s.indexOf("mp4a.40.2")&&(c>=6&&1===l||/vivaldi/i.test(f))||!s&&1===l)&&(o=2,d=new Array(2)),u=c)),d[0]=o<<3,d[0]|=(14&c)>>1,d[1]|=(1&c)<<7,d[1]|=l<<3,5===o&&(d[1]|=(14&u)>>1,d[2]=(1&u)<<7,d[2]|=8,d[3]=0),{config:d,samplerate:p[c],channelCount:l,codec:"mp4a.40."+o,manifestCodec:h};e.trigger(i.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+c})}(t,r,s,o);e.config=c.config,e.samplerate=c.samplerate,e.channelCount=c.channelCount,e.codec=c.codec,e.manifestCodec=c.manifestCodec,a.logger.log("parsed codec:"+e.codec+",rate:"+c.samplerate+",nb channel:"+c.channelCount)}}function g(e){return 9216e4/e}function y(e,t,r,i,n){var s=function(e,t,r,i,n){var s,o,a=e.length;if(s=l(e,t),o=d(e,t),(o-=s)>0&&t+s+o<=a)return{headerLength:s,frameLength:o,stamp:r+i*n}}(t,r,i,n,g(e.samplerate));if(s){var o=s.stamp,a=s.headerLength,c=s.frameLength,u={unit:t.subarray(r+a,r+a+c),pts:o,dts:o};return e.samples.push(u),{sample:u,length:c+a}}}var m=r("./src/demux/id3.js"),b=function(){function e(e,t,r){this.observer=e,this.config=r,this.remuxer=t}var t=e.prototype;return t.resetInitSegment=function(e,t,r,i){this._audioTrack={container:"audio/adts",type:"audio",id:0,sequenceNumber:0,isAAC:!0,samples:[],len:0,manifestCodec:t,duration:i,inputTimeScale:9e4}},t.resetTimeStamp=function(){},e.probe=function(e){if(!e)return!1;for(var t=(m.default.getID3Data(e,0)||[]).length,r=e.length;tt.length)){var s=this.parseHeader(t,r);if(s&&r+s.frameLength<=t.length){var o=i+n*(9e4*s.samplesPerFrame/s.sampleRate),a={unit:t.subarray(r,r+s.frameLength),pts:o,dts:o};return e.config=[],e.channelCount=s.channelCount,e.samplerate=s.sampleRate,e.samples.push(a),{sample:a,length:s.frameLength}}}},parseHeader:function(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,n=e[t+2]>>4&15,s=e[t+2]>>2&3,o=e[t+2]>>1&1;if(1!==r&&0!==n&&15!==n&&3!==s){var a=3===r?3-i:3===i?3:4,c=1e3*w.BitratesMap[14*a+n-1],u=3===r?0:2===r?1:2,l=w.SamplingRateMap[3*u+s],d=e[t+3]>>6==3?1:2,f=w.SamplesCoefficients[r][i],h=w.BytesInSlot[i],p=8*f*h;return{sampleRate:l,channelCount:d,frameLength:parseInt(f*c/l+o,10)*h,samplesPerFrame:p}}},isHeaderPattern:function(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])},isHeader:function(e,t){return!!(t+1e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)>>3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;return e>32&&a.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0?this.word<<=t:this.bytesAvailable>0&&this.loadWord(),(t=e-t)>0&&this.bitsAvailable?r<>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},t.skipScalingList=function(e){var t,r=8,i=8;for(t=0;t=e.length)return void r();if(!(e[t].unit.length<32)){var i=this.decrypter.isSync();if(this.decryptAacSample(e,t,r,i),!i)return}}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,n=32;n<=e.length-16;n+=160,i+=16)r.set(e.subarray(n,n+16),i);return r},t.getAvcDecryptedUnit=function(e,t){t=new Uint8Array(t);for(var r=0,i=32;i<=e.length-16;i+=160,r+=16)e.set(t.subarray(r,r+16),i);return e},t.decryptAvcSample=function(e,t,r,i,n,s){var o=this.discardEPB(n.data),a=this.getAvcEncryptedData(o),c=this;this.decryptBuffer(a.buffer,(function(a){n.data=c.getAvcDecryptedUnit(o,a),s||c.decryptAvcSamples(e,t,r+1,i)}))},t.decryptAvcSamples=function(e,t,r,i){for(;;t++,r=0){if(t>=e.length)return void i();for(var n=e[t].units;!(r>=n.length);r++){var s=n[r];if(!(s.data.length<=48||1!==s.type&&5!==s.type)){var o=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,i,s,o),!o)return}}}},e}(),T={video:1,audio:2,id3:3,text:4},A=function(){function e(e,t,r,i){this.observer=e,this.config=r,this.typeSupported=i,this.remuxer=t,this.sampleAes=null,this.pmtUnknownTypes={}}var t=e.prototype;return t.setDecryptData=function(e){null!=e&&null!=e.key&&"SAMPLE-AES"===e.method?this.sampleAes=new S(this.observer,this.config,e,this.discardEPB):this.sampleAes=null},e.probe=function(t){var r=e._syncOffset(t);return!(r<0||(r&&a.logger.warn("MPEG2-TS detected but first sync word found @ offset "+r+", junk ahead ?"),0))},e._syncOffset=function(e){for(var t=Math.min(1e3,e.length-564),r=0;r>4>1){if((d=c+5+t[c+4])===c+188)continue}else d=c+4;switch(l){case v:u&&(S&&(f=R(S))&&P(f,!1),S={data:[],size:0}),S&&(S.data.push(t.subarray(d,c+188)),S.size+=c+188-d);break;case w:u&&(T&&(f=R(T))&&(m.isAAC?O(f):C(f)),T={data:[],size:0}),T&&(T.data.push(t.subarray(d,c+188)),T.size+=c+188-d);break;case _:u&&(A&&(f=R(A))&&j(f),A={data:[],size:0}),A&&(A.data.push(t.subarray(d,c+188)),A.size+=c+188-d);break;case 0:u&&(d+=t[d]+1),E=this._pmtId=k(t,d);break;case E:u&&(d+=t[d]+1);var M=I(t,d,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,null!=this.sampleAes);(v=M.avc)>0&&(y.pid=v),(w=M.audio)>0&&(m.pid=w,m.isAAC=M.isAAC),(_=M.id3)>0&&(b.pid=_),p&&!g&&(a.logger.log("reparse from beginning"),p=!1,c=D-188),g=this.pmtParsed=!0;break;case 17:case 8191:break;default:p=!0}}else this.observer.trigger(i.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});S&&(f=R(S))?(P(f,!0),y.pesData=null):y.pesData=S,T&&(f=R(T))?(m.isAAC?O(f):C(f),m.pesData=null):(T&&T.size&&a.logger.log("last AAC PES packet truncated,might overlap between fragments"),m.pesData=T),A&&(f=R(A))?(j(f),b.pesData=null):b.pesData=A,null==this.sampleAes?this.remuxer.remux(m,y,b,this._txtTrack,r,s,o):this.decryptAndRemux(m,y,b,this._txtTrack,r,s,o)},t.decryptAndRemux=function(e,t,r,i,n,s,o){if(e.samples&&e.isAAC){var a=this;this.sampleAes.decryptAacSamples(e.samples,0,(function(){a.decryptAndRemuxAvc(e,t,r,i,n,s,o)}))}else this.decryptAndRemuxAvc(e,t,r,i,n,s,o)},t.decryptAndRemuxAvc=function(e,t,r,i,n,s,o){if(t.samples){var a=this;this.sampleAes.decryptAvcSamples(t.samples,0,0,(function(){a.remuxer.remux(e,t,r,i,n,s,o)}))}else this.remuxer.remux(e,t,r,i,n,s,o)},t.destroy=function(){this._initPTS=this._initDTS=void 0,this._duration=0},t._parsePAT=function(e,t){return(31&e[t+10])<<8|e[t+11]},t._trackUnknownPmt=function(e,t,r){var i=this.pmtUnknownTypes[e]||0;return 0===i&&(this.pmtUnknownTypes[e]=0,t.call(a.logger,r)),this.pmtUnknownTypes[e]++,i},t._parsePMT=function(e,t,r,i){var n,s,o={audio:-1,avc:-1,id3:-1,isAAC:!0};for(n=t+3+((15&e[t+1])<<8|e[t+2])-4,t+=12+((15&e[t+10])<<8|e[t+11]);t1;){var f=new Uint8Array(d[0].length+d[1].length);f.set(d[0]),f.set(d[1],d[0].length),d[0]=f,d.splice(1,1)}if(1===((t=d[0])[0]<<16)+(t[1]<<8)+t[2]){if((i=(t[4]<<8)+t[5])&&i>e.size-6)return null;if(192&(r=t[7])&&(o=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&r?o-(c=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2)>54e5&&(a.logger.warn(Math.round((o-c)/9e4)+"s delta between PTS and DTS, align them"),o=c):c=o),u=(n=t[8])+9,e.size<=u)return null;e.size-=u,s=new Uint8Array(e.size);for(var h=0,p=d.length;hg){u-=g;continue}t=t.subarray(u),g-=u,u=0}s.set(t,l),l+=g}return i&&(i-=n+3),{data:s,pts:o,dts:c,len:i}}return null},t.pushAccesUnit=function(e,t){if(e.units.length&&e.frame){var r=t.samples,i=r.length;if(isNaN(e.pts)){if(!i)return void t.dropped++;var n=r[i-1];e.pts=n.pts,e.dts=n.dts}!this.config.forceKeyFrameOnDiscontinuity||!0===e.key||t.sps&&(i||this.contiguous)?(e.id=i,r.push(e)):t.dropped++}e.debug.length&&a.logger.log(e.pts+"/"+e.dts+":"+e.debug)},t._parseAVCPES=function(e,t){var r,i,n,s=this,o=this._avcTrack,a=this._parseAVCNALu(e.data),c=this.avcSample,u=!1,l=this.pushAccesUnit.bind(this),d=function(e,t,r,i){return{key:e,pts:t,dts:r,units:[],debug:i}};e.data=null,c&&a.length&&!o.audFound&&(l(c,o),c=this.avcSample=d(!1,e.pts,e.dts,"")),a.forEach((function(t){switch(t.type){case 1:i=!0,c||(c=s.avcSample=d(!0,e.pts,e.dts,"")),c.frame=!0;var a=t.data;if(u&&a.length>4){var f=new E(a).readSliceType();2!==f&&4!==f&&7!==f&&9!==f||(c.key=!0)}break;case 5:i=!0,c||(c=s.avcSample=d(!0,e.pts,e.dts,"")),c.key=!0,c.frame=!0;break;case 6:i=!0,(r=new E(s.discardEPB(t.data))).readUByte();for(var h=0,p=0,g=!1,y=0;!g&&r.bytesAvailable>1;){h=0;do{h+=y=r.readUByte()}while(255===y);p=0;do{p+=y=r.readUByte()}while(255===y);if(4===h&&0!==r.bytesAvailable){if(g=!0,181===r.readUByte()&&49===r.readUShort()&&1195456820===r.readUInt()&&3===r.readUByte()){var b=r.readUByte(),v=31&b,w=[b,r.readUByte()];for(n=0;n16){var _=[];for(n=0;n<16;n++)_.push(r.readUByte().toString(16)),3!==n&&5!==n&&7!==n&&9!==n||_.push("-");var S=p-16,T=new Uint8Array(S);for(n=0;n0){if(t.pts>=e[r-1].pts)e.push(t);else for(var i=r-1;i>=0;i--)if(t.pts=0)i={data:e.subarray(d,s-c-1),type:n},l.push(i);else{var f=this._getLastNalUnit();if(f&&(u&&s<=4-u&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-u)),(r=s-c-1)>0)){var h=new Uint8Array(f.data.byteLength+r);h.set(f.data,0),h.set(e.subarray(0,r),f.data.byteLength),f.data=h}}s=0&&c>=0&&(i={data:e.subarray(d,o),type:n,state:c},l.push(i)),0===l.length){var p=this._getLastNalUnit();if(p){var g=new Uint8Array(p.data.byteLength+e.byteLength);g.set(p.data,0),g.set(e,p.data.byteLength),p.data=g}}return a.naluState=c,l},t.discardEPB=function(e){for(var t,r,i=e.byteLength,n=[],s=1;s1&&(a.logger.log("AAC: align PTS for overlapping frames by "+Math.round((_-m)/90)),m=_)}for(;s>24&255,t[1]=i>>16&255,t[2]=i>>8&255,t[3]=255&i,t.set(e,4),n=0,i=8;n>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))},e.mfhd=function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))},e.minf=function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))},e.moof=function(t,r,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,r))},e.moov=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(e.mvex(t)))},e.mvex=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(i))},e.mvhd=function(t,r){r*=t;var i=Math.floor(r/(R+1)),n=Math.floor(r%(R+1)),s=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(e.types.mvhd,s)},e.sdtp=function(t){var r,i,n=t.samples||[],s=new Uint8Array(4+n.length);for(i=0;i>>8&255),s.push(255&n),s=s.concat(Array.prototype.slice.call(i));for(r=0;r>>8&255),o.push(255&n),o=o.concat(Array.prototype.slice.call(i));var a=e.box(e.types.avcC,new Uint8Array([1,s[3],s[4],s[5],255,224|t.sps.length].concat(s).concat([t.pps.length]).concat(o))),c=t.width,u=t.height,l=t.pixelRatio[0],d=t.pixelRatio[1];return e.box(e.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,c>>8&255,255&c,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),a,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([l>>24,l>>16&255,l>>8&255,255&l,d>>24,d>>16&255,d>>8&255,255&d])))},e.esds=function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))},e.mp4a=function(t){var r=t.samplerate;return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),e.box(e.types.esds,e.esds(t)))},e.mp3=function(t){var r=t.samplerate;return e.box(e.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]))},e.stsd=function(t){return"audio"===t.type?t.isAAC||"mp3"!==t.codec?e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.mp3(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))},e.tkhd=function(t){var r=t.id,i=t.duration*t.timescale,n=t.width,s=t.height,o=Math.floor(i/(R+1)),a=Math.floor(i%(R+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,a>>24,a>>16&255,a>>8&255,255&a,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,n>>8&255,255&n,0,0,s>>8&255,255&s,0,0]))},e.traf=function(t,r){var i=e.sdtp(t),n=t.id,s=Math.floor(r/(R+1)),o=Math.floor(r%(R+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o])),e.trun(t,i.length+16+20+8+16+8+8),i)},e.trak=function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.trex=function(t){var r=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},e.trun=function(t,r){var i,n,s,o,a,c,u=t.samples||[],l=u.length,d=12+16*l,f=new Uint8Array(d);for(r+=8+d,f.set([0,0,15,1,l>>>24&255,l>>>16&255,l>>>8&255,255&l,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i>>24&255,s>>>16&255,s>>>8&255,255&s,o>>>24&255,o>>>16&255,o>>>8&255,255&o,a.isLeading<<2|a.dependsOn,a.isDependedOn<<6|a.hasRedundancy<<4|a.paddingValue<<1|a.isNonSync,61440&a.degradPrio,15&a.degradPrio,c>>>24&255,c>>>16&255,c>>>8&255,255&c],12+16*i);return e.box(e.types.trun,f)},e.initSegment=function(t){e.types||e.init();var r,i=e.moov(t);return(r=new Uint8Array(e.FTYP.byteLength+i.byteLength)).set(e.FTYP),r.set(i,e.FTYP.byteLength),r},e}(),O=P;function C(e,t,r,i){void 0===r&&(r=1),void 0===i&&(i=!1);var n=e*t*r;return i?Math.round(n):n}function j(e,t){return void 0===t&&(t=!1),C(e,1e3,1/9e4,t)}function D(e,t){return void 0===t&&(t=1),C(e,9e4,1/t)}var M=D(10),x=D(.2),B=null;function L(e,t){var r;if(void 0===t)return e;for(r=t4294967296;)e+=r;return e}var N,U=function(){function e(e,t,r,i){if(this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===B){var n=navigator.userAgent.match(/Chrome\/(\d+)/i);B=n?parseInt(n[1]):0}}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){this._initPTS=this._initDTS=e},t.resetInitSegment=function(){this.ISGenerated=!1},t.getVideoStartPts=function(e){var t=!1,r=e.reduce((function(e,r){var i=r.pts-e;return i<-4294967296?(t=!0,L(e,r.pts)):i>0?e:r.pts}),e[0].pts);return t&&a.logger.debug("PTS rollover detected"),r},t.remux=function(e,t,r,n,s,o,c){if(this.ISGenerated||this.generateIS(e,t,s),this.ISGenerated){var u=e.samples.length,l=t.samples.length,d=s,f=s;if(u&&l){var h=this.getVideoStartPts(t.samples),p=(L(e.samples[0].pts,h)-h)/t.inputTimeScale;d+=Math.max(0,p),f+=Math.max(0,-p)}if(u){e.timescale||(a.logger.warn("regenerate InitSegment as audio detected"),this.generateIS(e,t,s));var g,y=this.remuxAudio(e,d,o,c);l&&(y&&(g=y.endPTS-y.startPTS),t.timescale||(a.logger.warn("regenerate InitSegment as video detected"),this.generateIS(e,t,s)),this.remuxVideo(t,f,o,g))}else if(l){var m=this.remuxVideo(t,f,o,0,c);m&&e.codec&&this.remuxEmptyAudio(e,d,o,m)}}r.samples.length&&this.remuxID3(r,s),n.samples.length&&this.remuxText(n,s),this.observer.trigger(i.default.FRAG_PARSED)},t.generateIS=function(e,t,r){var s,o,c=this.observer,u=e.samples,l=t.samples,d=this.typeSupported,f="audio/mp4",h={},p={tracks:h},g=void 0===this._initPTS;if(g&&(s=o=1/0),e.config&&u.length&&(e.timescale=e.samplerate,a.logger.log("audio sampling rate : "+e.samplerate),e.isAAC||(d.mpeg?(f="audio/mpeg",e.codec=""):d.mp3&&(e.codec="mp3")),h.audio={container:f,codec:e.codec,initSegment:!e.isAAC&&d.mpeg?new Uint8Array:O.initSegment([e]),metadata:{channelCount:e.channelCount}},g&&(s=o=u[0].pts-Math.round(e.inputTimeScale*r))),t.sps&&t.pps&&l.length){var y=t.inputTimeScale;if(t.timescale=y,h.video={container:"video/mp4",codec:t.codec,initSegment:O.initSegment([t]),metadata:{width:t.width,height:t.height}},g){var m=this.getVideoStartPts(l),b=Math.round(y*r);o=Math.min(o,L(l[0].dts,m)-b),s=Math.min(s,m-b),this.observer.trigger(i.default.INIT_PTS_FOUND,{initPTS:s})}}else g&&h.audio&&this.observer.trigger(i.default.INIT_PTS_FOUND,{initPTS:s});Object.keys(h).length?(c.trigger(i.default.FRAG_PARSING_INIT_SEGMENT,p),this.ISGenerated=!0,g&&(this._initPTS=s,this._initDTS=o)):c.trigger(i.default.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})},t.remuxVideo=function(e,t,r,s){var o,c,u,l,d,f=e.timescale,h=e.samples,p=[],g=h.length,y=this._initPTS,m=8,b=Number.POSITIVE_INFINITY,v=Number.NEGATIVE_INFINITY,w=0,_=!1,E=this.nextAvcDts;if(0!==g){r||(E=t*f-(h[0].pts-L(h[0].dts,h[0].pts)));for(var S=0;ST.pts&&(w=Math.max(Math.min(w,T.pts-T.dts),-1*x)),T.dts0?S-1:S].dts&&(_=!0)}_&&h.sort((function(e,t){var r=e.dts-t.dts,i=e.pts-t.pts;return r||i||e.id-t.id})),l=h[0].dts,d=h[g-1].dts;var A=Math.round((d-l)/(g-1));if(w<0){if(w<-2*A){a.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+j(-A,!0)+" ms");for(var k=w,I=0;IA;if(C||P<-1){C?a.logger.warn("AVC: "+j(P,!0)+" ms ("+P+"dts) hole between fragments detected, filling it"):a.logger.warn("AVC: "+j(-P,!0)+" ms ("+P+"dts) overlapping between fragments detected"),l=E;var D=h[0].pts-P;h[0].dts=l,h[0].pts=D,a.logger.log("Video: First PTS/DTS adjusted: "+j(D,!0)+"/"+j(l,!0)+", delta: "+j(P,!0)+" ms")}}B&&B<75&&(l=Math.max(0,l));for(var M=0,N=0,U=0;U0?$-1:$].dts;if(ie.stretchShortVideoTrack){var se=ie.maxBufferHole,oe=Math.floor(se*f),ae=(s?b+s*f:this.nextAudioPts)-Y.pts;ae>oe?((o=ae-ne)<0&&(o=ne),a.logger.log("It is approximately "+j(ae,!1)+" ms to the next segment; using duration "+j(o,!1)+" ms for the last video frame.")):o=ne}else o=ne}W=Math.round(Y.pts-Y.dts),p.push({size:Z,duration:o,cts:W,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:Y.key?2:1,isNonSync:Y.key?0:1}})}this.nextAvcDts=d+o;var ce=e.dropped;if(e.nbNalu=0,e.dropped=0,p.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var ue=p[0].flags;ue.dependsOn=2,ue.isNonSync=0}e.samples=p,u=O.moof(e.sequenceNumber++,l,e),e.samples=[];var le={data1:u,data2:c,startPTS:b/f,endPTS:(v+o)/f,startDTS:l/f,endDTS:this.nextAvcDts/f,type:"video",hasAudio:!1,hasVideo:!0,nb:p.length,dropped:ce};return this.observer.trigger(i.default.FRAG_PARSING_DATA,le),le}},t.remuxAudio=function(e,t,r,s){var o,c,u,l,d,f,h=e.inputTimeScale,p=e.timescale,g=h/p,y=(e.isAAC?1024:1152)*g,m=this._initPTS,b=!e.isAAC&&this.typeSupported.mpeg,v=b?0:8,w=e.samples,_=[],E=this.nextAudioPts;if(r|=w.length&&E&&(s&&Math.abs(t-E/h)<.1||Math.abs(w[0].pts-E-m)<20*y),w.forEach((function(e){e.pts=e.dts=L(e.pts-m,t*h)})),0!==(w=w.filter((function(e){return e.pts>=0}))).length){if(r||(E=s?Math.max(0,t*h):w[0].pts),e.isAAC)for(var S=this.config.maxAudioFramesDrift,T=0,A=E;T0?(a.logger.warn("Dropping 1 audio frame @ "+j(A,!0)/1e3+"s due to "+j(P,!0)+" ms overlap."),w.splice(T,1)):(a.logger.warn("Audio frame @ "+j(R,!0)/1e3+"s overlaps nextAudioPts by "+j(P,!0)+" ms."),A=R+y,T++);else if(P>=S*y&&P0&&q0&&((c=I.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(c=z.subarray()),N+=G*c.length);else if(q<-12){a.logger.log("drop overlapping AAC sample, expected/parsed/delta: "+j(E,!0)+" ms / "+j(V,!0)+" ms / "+j(-q,!0)+" ms"),N-=z.byteLength;continue}V=E}if(d=V,!(N>0))return;N+=v;try{u=new Uint8Array(N)}catch(e){return void this.observer.trigger(i.default.ERROR,{type:n.ErrorTypes.MUX_ERROR,details:n.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:N,reason:"fail allocating audio mdat "+N})}b||(new DataView(u.buffer).setUint32(0,N),u.set(O.types.mdat,4));for(var H=0;H=2&&(W=_[B-2].duration,o.duration=W),B){this.nextAudioPts=E=f+g*W,e.samples=_,l=b?new Uint8Array:O.moof(e.sequenceNumber++,d/g,e),e.samples=[];var Y=d/h,X=E/h,Z={data1:l,data2:u,startPTS:Y,endPTS:X,startDTS:Y,endDTS:X,type:"audio",hasAudio:!0,hasVideo:!1,nb:B};return this.observer.trigger(i.default.FRAG_PARSING_DATA,Z),Z}return null}},t.remuxEmptyAudio=function(e,t,r,i){var n=e.inputTimeScale,s=n/(e.samplerate?e.samplerate:n),o=this.nextAudioPts,c=(void 0!==o?o:i.startDTS*n)+this._initDTS,u=i.endDTS*n+this._initDTS,l=1024*s,d=Math.ceil((u-c)/l),f=I.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(a.logger.warn("remux empty Audio"),f){for(var h=[],p=0;p0&&null!=t&&null!=t.key&&"AES-128"===t.method){var g=this.decrypter;null==g&&(g=this.decrypter=new s.default(this.observer,this.config));var y=N();g.decrypt(e,t.key.buffer,t.iv.buffer,(function(e){var s=N();p.observer.trigger(i.default.FRAG_DECRYPTED,{stats:{tstart:y,tdecrypt:s}}),p.pushDecrypted(new Uint8Array(e),t,new Uint8Array(r),n,o,a,c,u,l,d,f,h)}))}else this.pushDecrypted(new Uint8Array(e),t,new Uint8Array(r),n,o,a,c,u,l,d,f,h)},t.pushDecrypted=function(e,t,r,s,o,a,c,u,l,d,f,h){var p=this.demuxer,g=this.remuxer;if(!p||c||u){for(var y,m=this.observer,w=this.typeSupported,_=this.config,E=[{demux:A,remux:U},{demux:v.default,remux:F},{demux:b,remux:U},{demux:k,remux:U}],S=0,T=E.length;S1?r-1:0),n=1;n1?r-1:0),n=1;n0)return t.subarray(i,i+n)},e._readSize=function(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3]},e.getTimeStamp=function(t){for(var r=e.getID3Frames(t),i=0;i>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(a);break;case 12:case 13:c=e[f++],d+=String.fromCharCode((31&a)<<6|63&c);break;case 14:c=e[f++],u=e[f++],d+=String.fromCharCode((15&a)<<12|(63&c)<<6|(63&u)<<0)}}return d},e}(),o=s._utf8ArrayToStr;t.default=s},"./src/demux/mp4demuxer.js":function(e,t,r){"use strict";r.r(t);var i=r(/*! ../utils/logger */"./src/utils/logger.js"),n=r(/*! ../events */"./src/events.js"),s=Math.pow(2,32)-1,o=function(){function e(e,t){this.observer=e,this.remuxer=t}var t=e.prototype;return t.resetTimeStamp=function(e){this.initPTS=e},t.resetInitSegment=function(t,r,i,s){if(t&&t.byteLength){var o=this.initData=e.parseInitSegment(t);null==r&&(r="mp4a.40.5"),null==i&&(i="avc1.42e01e");var a={};o.audio&&o.video?a.audiovideo={container:"video/mp4",codec:r+","+i,initSegment:s?t:null}:(o.audio&&(a.audio={container:"audio/mp4",codec:r,initSegment:s?t:null}),o.video&&(a.video={container:"video/mp4",codec:i,initSegment:s?t:null})),this.observer.trigger(n.default.FRAG_PARSING_INIT_SEGMENT,{tracks:a})}else r&&(this.audioCodec=r),i&&(this.videoCodec=i)},e.probe=function(t){return e.findBox({data:t,start:0,end:Math.min(t.length,16384)},["moof"]).length>0},e.bin2str=function(e){return String.fromCharCode.apply(null,e)},e.readUint16=function(e,t){e.data&&(t+=e.start,e=e.data);var r=e[t]<<8|e[t+1];return r<0?65536+r:r},e.readUint32=function(e,t){e.data&&(t+=e.start,e=e.data);var r=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return r<0?4294967296+r:r},e.writeUint32=function(e,t,r){e.data&&(t+=e.start,e=e.data),e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r},e.findBox=function(t,r){var i,n,s,o,a,c,u=[];if(t.data?(a=t.start,s=t.end,t=t.data):(a=0,s=t.byteLength),!r.length)return null;for(i=a;i1?i+n:s,e.bin2str(t.subarray(i+4,i+8))===r[0]&&(1===r.length?u.push({data:t,start:i+8,end:c}):(o=e.findBox({data:t,start:i+8,end:c},r.slice(1))).length&&(u=u.concat(o))),i=c;return u},e.parseSegmentIndex=function(t){var r,i=e.findBox(t,["moov"])[0],n=i?i.end:null,s=0,o=e.findBox(t,["sidx"]);if(!o||!o[0])return null;r=[];var a=(o=o[0]).data[0];s=0===a?8:16;var c=e.readUint32(o,s);s+=4,s+=0===a?8:16,s+=2;var u=o.end+0,l=e.readUint16(o,s);s+=2;for(var d=0;d>>31)return void console.warn("SIDX has hierarchical references (not supported)");var g=e.readUint32(o,f);f+=4,r.push({referenceSize:p,subsegmentDuration:g,info:{duration:g/c,start:u,end:u+p-1}}),u+=p,s=f+=4}return{earliestPresentationTime:0,timescale:c,version:a,referencesCount:l,references:r,moovEndOffset:n}},e.parseInitSegment=function(t){var r=[];return e.findBox(t,["moov","trak"]).forEach((function(t){var n=e.findBox(t,["tkhd"])[0];if(n){var s=n.data[n.start],o=0===s?12:20,a=e.readUint32(n,o),c=e.findBox(t,["mdia","mdhd"])[0];if(c){o=0===(s=c.data[c.start])?12:20;var u=e.readUint32(c,o),l=e.findBox(t,["mdia","hdlr"])[0];if(l){var d={soun:"audio",vide:"video"}[e.bin2str(l.data.subarray(l.start+8,l.start+12))];if(d){var f=e.findBox(t,["mdia","minf","stbl","stsd"]);if(f.length){f=f[0];var h=e.bin2str(f.data.subarray(f.start+12,f.start+16));i.logger.log("MP4Demuxer:"+d+":"+h+" found")}r[a]={timescale:u,type:d},r[d]={timescale:u,id:a}}}}}})),r},e.getStartDTS=function(t,r){var i,n,s;return i=e.findBox(r,["moof","traf"]),n=[].concat.apply([],i.map((function(r){return e.findBox(r,["tfhd"]).map((function(i){var n,s;return n=e.readUint32(i,4),s=t[n].timescale||9e4,e.findBox(r,["tfdt"]).map((function(t){var r,i;return r=t.data[t.start],i=e.readUint32(t,4),1===r&&(i*=Math.pow(2,32),i+=e.readUint32(t,8)),i}))[0]/s}))}))),s=Math.min.apply(null,n),isFinite(s)?s:0},e.offsetStartDTS=function(t,r,i){e.findBox(r,["moof","traf"]).map((function(r){return e.findBox(r,["tfhd"]).map((function(n){var o=e.readUint32(n,4),a=t[o].timescale||9e4;e.findBox(r,["tfdt"]).map((function(t){var r=t.data[t.start],n=e.readUint32(t,4);if(0===r)e.writeUint32(t,4,n-i*a);else{n*=Math.pow(2,32),n+=e.readUint32(t,8),n-=i*a,n=Math.max(n,0);var o=Math.floor(n/(s+1)),c=Math.floor(n%(s+1));e.writeUint32(t,4,o),e.writeUint32(t,8,c)}}))}))}))},t.append=function(t,r,i,s){var o=this.initData;o||(this.resetInitSegment(t,this.audioCodec,this.videoCodec,!1),o=this.initData);var a,c=this.initPTS;if(void 0===c){var u=e.getStartDTS(o,t);this.initPTS=c=u-r,this.observer.trigger(n.default.INIT_PTS_FOUND,{initPTS:c})}e.offsetStartDTS(o,t,c),a=e.getStartDTS(o,t),this.remuxer.remux(o.audio,o.video,null,null,a,i,s,t)},t.destroy=function(){},e}();t.default=o},"./src/errors.ts":function(e,t,r){"use strict";var i,n,s,o;r.r(t),r.d(t,"ErrorTypes",(function(){return i})),r.d(t,"ErrorDetails",(function(){return s})),(n=i||(i={})).NETWORK_ERROR="networkError",n.MEDIA_ERROR="mediaError",n.KEY_SYSTEM_ERROR="keySystemError",n.MUX_ERROR="muxError",n.OTHER_ERROR="otherError",(o=s||(s={})).KEY_SYSTEM_NO_KEYS="keySystemNoKeys",o.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",o.KEY_SYSTEM_NO_SESSION="keySystemNoSession",o.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",o.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",o.MANIFEST_LOAD_ERROR="manifestLoadError",o.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",o.MANIFEST_PARSING_ERROR="manifestParsingError",o.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",o.LEVEL_EMPTY_ERROR="levelEmptyError",o.LEVEL_LOAD_ERROR="levelLoadError",o.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",o.LEVEL_SWITCH_ERROR="levelSwitchError",o.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",o.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",o.FRAG_LOAD_ERROR="fragLoadError",o.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",o.FRAG_DECRYPT_ERROR="fragDecryptError",o.FRAG_PARSING_ERROR="fragParsingError",o.REMUX_ALLOC_ERROR="remuxAllocError",o.KEY_LOAD_ERROR="keyLoadError",o.KEY_LOAD_TIMEOUT="keyLoadTimeOut",o.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",o.BUFFER_APPEND_ERROR="bufferAppendError",o.BUFFER_APPENDING_ERROR="bufferAppendingError",o.BUFFER_STALLED_ERROR="bufferStalledError",o.BUFFER_FULL_ERROR="bufferFullError",o.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",o.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",o.INTERNAL_EXCEPTION="internalException"},"./src/events.js":function(e,t,r){"use strict";r.r(t),t.default={MEDIA_ATTACHING:"hlsMediaAttaching",MEDIA_ATTACHED:"hlsMediaAttached",MEDIA_DETACHING:"hlsMediaDetaching",MEDIA_DETACHED:"hlsMediaDetached",BUFFER_RESET:"hlsBufferReset",BUFFER_CODECS:"hlsBufferCodecs",BUFFER_CREATED:"hlsBufferCreated",BUFFER_APPENDING:"hlsBufferAppending",BUFFER_APPENDED:"hlsBufferAppended",BUFFER_EOS:"hlsBufferEos",BUFFER_FLUSHING:"hlsBufferFlushing",BUFFER_FLUSHED:"hlsBufferFlushed",MANIFEST_LOADING:"hlsManifestLoading",MANIFEST_LOADED:"hlsManifestLoaded",MANIFEST_PARSED:"hlsManifestParsed",LEVEL_SWITCHING:"hlsLevelSwitching",LEVEL_SWITCHED:"hlsLevelSwitched",LEVEL_LOADING:"hlsLevelLoading",LEVEL_LOADED:"hlsLevelLoaded",LEVEL_UPDATED:"hlsLevelUpdated",LEVEL_PTS_UPDATED:"hlsLevelPtsUpdated",LEVELS_UPDATED:"hlsLevelsUpdated",AUDIO_TRACKS_UPDATED:"hlsAudioTracksUpdated",AUDIO_TRACK_SWITCHING:"hlsAudioTrackSwitching",AUDIO_TRACK_SWITCHED:"hlsAudioTrackSwitched",AUDIO_TRACK_LOADING:"hlsAudioTrackLoading",AUDIO_TRACK_LOADED:"hlsAudioTrackLoaded",SUBTITLE_TRACKS_UPDATED:"hlsSubtitleTracksUpdated",SUBTITLE_TRACK_SWITCH:"hlsSubtitleTrackSwitch",SUBTITLE_TRACK_LOADING:"hlsSubtitleTrackLoading",SUBTITLE_TRACK_LOADED:"hlsSubtitleTrackLoaded",SUBTITLE_FRAG_PROCESSED:"hlsSubtitleFragProcessed",CUES_PARSED:"hlsCuesParsed",NON_NATIVE_TEXT_TRACKS_FOUND:"hlsNonNativeTextTracksFound",INIT_PTS_FOUND:"hlsInitPtsFound",FRAG_LOADING:"hlsFragLoading",FRAG_LOAD_PROGRESS:"hlsFragLoadProgress",FRAG_LOAD_EMERGENCY_ABORTED:"hlsFragLoadEmergencyAborted",FRAG_LOADED:"hlsFragLoaded",FRAG_DECRYPTED:"hlsFragDecrypted",FRAG_PARSING_INIT_SEGMENT:"hlsFragParsingInitSegment",FRAG_PARSING_USERDATA:"hlsFragParsingUserdata",FRAG_PARSING_METADATA:"hlsFragParsingMetadata",FRAG_PARSING_DATA:"hlsFragParsingData",FRAG_PARSED:"hlsFragParsed",FRAG_BUFFERED:"hlsFragBuffered",FRAG_CHANGED:"hlsFragChanged",FPS_DROP:"hlsFpsDrop",FPS_DROP_LEVEL_CAPPING:"hlsFpsDropLevelCapping",ERROR:"hlsError",DESTROYING:"hlsDestroying",KEY_LOADING:"hlsKeyLoading",KEY_LOADED:"hlsKeyLoaded",STREAM_STATE_TRANSITION:"hlsStreamStateTransition",LIVE_BACK_BUFFER_REACHED:"hlsLiveBackBufferReached"}},"./src/hls.ts":function(e,t,r){"use strict";r.r(t),r.d(t,"default",(function(){return hr}));var i={};r.r(i),r.d(i,"newCue",(function(){return mt}));var n,s,o,a,c=r("./node_modules/url-toolkit/src/url-toolkit.js"),u=r("./src/errors.ts"),l=r("./src/polyfills/number.js"),d=r("./src/events.js"),f=r("./src/utils/logger.js"),h={hlsEventGeneric:!0,hlsHandlerDestroying:!0,hlsHandlerDestroyed:!0},p=function(){function e(e){this.hls=void 0,this.handledEvents=void 0,this.useGenericHandler=void 0,this.hls=e,this.onEvent=this.onEvent.bind(this);for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i>8*(15-r)&255;return t},n.setDecryptDataFromLevelKey=function(e,t){var r=e;return(null==e?void 0:e.method)&&e.uri&&!e.iv&&((r=new w(e.baseuri,e.reluri)).method=e.method,r.iv=this.createInitializationVector(t)),r},t=e,(r=[{key:"url",get:function(){return!this._url&&this.relurl&&(this._url=Object(c.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(e){this._url=e}},{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var e=this.sn;"number"!=typeof e&&(this.levelkey&&"AES-128"===this.levelkey.method&&!this.levelkey.iv&&f.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),e=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,e)}return this._decryptdata}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!Object(l.isFiniteNumber)(this.programDateTime))return null;var e=Object(l.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){return!(!this.decryptdata||null===this.decryptdata.uri||null!==this.decryptdata.key)}}])&&_(t.prototype,r),i&&_(t,i),e}();function S(e,t){for(var r=0;rNumber.MAX_SAFE_INTEGER?1/0:t},t.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),i=0;iNumber.MAX_SAFE_INTEGER?1/0:t},t.decimalFloatingPoint=function(e){return parseFloat(this[e])},t.enumeratedString=function(e){return this[e]},t.decimalResolution=function(e){var t=A.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e){var t,r={};for(k.lastIndex=0;null!==(t=k.exec(e));){var i=t[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[t[1]]=i}return r},e}(),R={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0}};function P(e,t){return MediaSource.isTypeSupported((t||"video")+'/mp4;codecs="'+e+'"')}var O=/(?:#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)|#EXT-X-SESSION-DATA:([^\n\r]*)[\r\n]+)/g,C=/#EXT-X-MEDIA:(.*)/g,j=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/|(?!#)([\S+ ?]+)/.source,/|#EXT-X-BYTERANGE:*(.+)/.source,/|#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/|#.*/.source].join(""),"g"),D=/(?:(?:#(EXTM3U))|(?:#EXT-X-(PLAYLIST-TYPE):(.+))|(?:#EXT-X-(MEDIA-SEQUENCE): *(\d+))|(?:#EXT-X-(TARGETDURATION): *(\d+))|(?:#EXT-X-(KEY):(.+))|(?:#EXT-X-(START):(.+))|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DISCONTINUITY-SEQ)UENCE:(\d+))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-(VERSION):(\d+))|(?:#EXT-X-(MAP):(.+))|(?:(#)([^:]*):(.*))|(?:(#)(.*))(?:.*)\r?\n?/,M=/\.(mp4|m4s|m4v|m4a)$/i,x=function(){function e(){}return e.findGroup=function(e,t){for(var r=0;r2?(t=r.shift()+".",t+=parseInt(r.shift()).toString(16),t+=("000"+parseInt(r.shift()).toString(16)).substr(-4)):t=e,t},e.resolve=function(e,t){return c.buildAbsoluteURL(t,e,{alwaysNormalize:!0})},e.parseMasterPlaylist=function(t,r){var i,n=[],s={},o=!1;function a(e,t){["video","audio"].forEach((function(r){var i=e.filter((function(e){return function(e,t){var r=R[t];return!!r&&!0===r[e.slice(0,4)]}(e,r)}));if(i.length){var n=i.filter((function(e){return 0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)}));t[r+"Codec"]=n.length>0?n[0]:i[0],e=e.filter((function(e){return-1===i.indexOf(e)}))}})),t.unknownCodecs=e}for(O.lastIndex=0;null!=(i=O.exec(t));)if(i[1]){var c={},u=c.attrs=new I(i[1]);c.url=e.resolve(i[2],r);var l=u.decimalResolution("RESOLUTION");l&&(c.width=l.width,c.height=l.height),c.bitrate=u.decimalInteger("AVERAGE-BANDWIDTH")||u.decimalInteger("BANDWIDTH"),c.name=u.NAME,a([].concat((u.CODECS||"").split(/[ ,]+/)),c),c.videoCodec&&-1!==c.videoCodec.indexOf("avc1")&&(c.videoCodec=e.convertAVC1ToAVCOTI(c.videoCodec)),n.push(c)}else if(i[3]){var d=new I(i[3]);d["DATA-ID"]&&(o=!0,s[d["DATA-ID"]]=d)}return{levels:n,sessionData:o?s:null}},e.parseMasterPlaylistMedia=function(t,r,i,n){var s;void 0===n&&(n=[]);var o=[],a=0;for(C.lastIndex=0;null!==(s=C.exec(t));){var c=new I(s[1]);if(c.TYPE===i){var u={attrs:c,id:a++,groupId:c["GROUP-ID"],instreamId:c["INSTREAM-ID"],name:c.NAME||c.LANGUAGE,type:i,default:"YES"===c.DEFAULT,autoselect:"YES"===c.AUTOSELECT,forced:"YES"===c.FORCED,lang:c.LANGUAGE};if(c.URI&&(u.url=e.resolve(c.URI,r)),n.length){var l=e.findGroup(n,u.groupId);u.audioCodec=l?l.codec:n[0].codec}o.push(u)}}return o},e.parseLevelPlaylist=function(e,t,r,i,n){var s,o,a,c=0,u=0,d=new T(t),h=0,p=null,g=new E,y=null;for(j.lastIndex=0;null!==(s=j.exec(e));){var m=s[1];if(m){g.duration=parseFloat(m);var b=(" "+s[2]).slice(1);g.title=b||null,g.tagList.push(b?["INF",m,b]:["INF",m])}else if(s[3]){if(Object(l.isFiniteNumber)(g.duration)){var v=c++;g.type=i,g.start=u,a&&(g.levelkey=a),g.sn=v,g.level=r,g.cc=h,g.urlId=n,g.baseurl=t,g.relurl=(" "+s[3]).slice(1),B(g,p),d.fragments.push(g),p=g,u+=g.duration,g=new E}}else if(s[4]){var _=(" "+s[4]).slice(1);p?g.setByteRange(_,p):g.setByteRange(_)}else if(s[5])g.rawProgramDateTime=(" "+s[5]).slice(1),g.tagList.push(["PROGRAM-DATE-TIME",g.rawProgramDateTime]),null===y&&(y=d.fragments.length);else{if(!(s=s[0].match(D))){f.logger.warn("No matches on slow regex match for level playlist!");continue}for(o=1;o=0&&(a.method=R,a.key=null,a.iv=O));break;case"START":var C=new I(S).decimalFloatingPoint("TIME-OFFSET");Object(l.isFiniteNumber)(C)&&(d.startTimeOffset=C);break;case"MAP":var x=new I(S);g.relurl=x.URI,x.BYTERANGE&&g.setByteRange(x.BYTERANGE),g.baseurl=t,g.level=r,g.type=i,g.sn="initSegment",d.initSegment=g,(g=new E).rawProgramDateTime=d.initSegment.rawProgramDateTime;break;default:f.logger.warn("line parsed but not handled: "+s)}}}return(g=p)&&!g.relurl&&(d.fragments.pop(),u-=g.duration),d.totalduration=u,d.averagetargetduration=u/d.fragments.length,d.endSN=c-1,d.startCC=d.fragments[0]?d.fragments[0].cc:0,d.endCC=h,!d.initSegment&&d.fragments.length&&d.fragments.every((function(e){return M.test(e.relurl)}))&&(f.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(g=new E).relurl=d.fragments[0].relurl,g.baseurl=t,g.level=r,g.type=i,g.sn="initSegment",d.initSegment=g,d.needSidxRanges=!0),y&&function(e,t){for(var r=e[t],i=t-1;i>=0;i--){var n=e[i];n.programDateTime=r.programDateTime-1e3*n.duration,r=n}}(d.fragments,y),d},e}();function B(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):(null==t?void 0:t.programDateTime)&&(e.programDateTime=t.endProgramDateTime),Object(l.isFiniteNumber)(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}var L=window.performance,N=function(e){var t,r;function i(t){var r;return(r=e.call(this,t,d.default.MANIFEST_LOADING,d.default.LEVEL_LOADING,d.default.AUDIO_TRACK_LOADING,d.default.SUBTITLE_TRACK_LOADING)||this).loaders={},r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r,i.canHaveQualityLevels=function(e){return e!==n.AUDIO_TRACK&&e!==n.SUBTITLE_TRACK},i.mapContextToLevelType=function(e){switch(e.type){case n.AUDIO_TRACK:return o.AUDIO;case n.SUBTITLE_TRACK:return o.SUBTITLE;default:return o.MAIN}},i.getResponseUrl=function(e,t){var r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r};var s=i.prototype;return s.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,n=new(r||i)(t);return e.loader=n,this.loaders[e.type]=n,n},s.getInternalLoader=function(e){return this.loaders[e.type]},s.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},s.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},s.destroy=function(){this.destroyInternalLoaders(),e.prototype.destroy.call(this)},s.onManifestLoading=function(e){this.load({url:e.url,type:n.MANIFEST,level:0,id:null,responseType:"text"})},s.onLevelLoading=function(e){this.load({url:e.url,type:n.LEVEL,level:e.level,id:e.id,responseType:"text"})},s.onAudioTrackLoading=function(e){this.load({url:e.url,type:n.AUDIO_TRACK,level:null,id:e.id,responseType:"text"})},s.onSubtitleTrackLoading=function(e){this.load({url:e.url,type:n.SUBTITLE_TRACK,level:null,id:e.id,responseType:"text"})},s.load=function(e){var t=this.hls.config;f.logger.debug("Loading playlist of type "+e.type+", level: "+e.level+", id: "+e.id);var r,i,s,o,a=this.getInternalLoader(e);if(a){var c=a.context;if(c&&c.url===e.url)return f.logger.trace("playlist request ongoing"),!1;f.logger.warn("aborting previous loader for type: "+e.type),a.abort()}switch(e.type){case n.MANIFEST:r=t.manifestLoadingMaxRetry,i=t.manifestLoadingTimeOut,s=t.manifestLoadingRetryDelay,o=t.manifestLoadingMaxRetryTimeout;break;case n.LEVEL:r=0,o=0,s=0,i=t.levelLoadingTimeOut;break;default:r=t.levelLoadingMaxRetry,i=t.levelLoadingTimeOut,s=t.levelLoadingRetryDelay,o=t.levelLoadingMaxRetryTimeout}a=this.createInternalLoader(e);var u={timeout:i,maxRetry:r,retryDelay:s,maxRetryDelay:o},l={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};return f.logger.debug("Calling internal loader delegate for URL: "+e.url),a.load(e,u,l),!0},s.loadsuccess=function(e,t,r,i){if(void 0===i&&(i=null),r.isSidxRequest)return this._handleSidxRequest(e,r),void this._handlePlaylistLoaded(e,t,r,i);if(this.resetInternalLoader(r.type),"string"!=typeof e.data)throw new Error('expected responseType of "text" for PlaylistLoader');var n=e.data;t.tload=L.now(),0===n.indexOf("#EXTM3U")?n.indexOf("#EXTINF:")>0||n.indexOf("#EXT-X-TARGETDURATION:")>0?this._handleTrackOrLevelPlaylist(e,t,r,i):this._handleMasterPlaylist(e,t,r,i):this._handleManifestParsingError(e,r,"no EXTM3U delimiter",i)},s.loaderror=function(e,t,r){void 0===r&&(r=null),this._handleNetworkError(t,r,!1,e)},s.loadtimeout=function(e,t,r){void 0===r&&(r=null),this._handleNetworkError(t,r,!0)},s._handleMasterPlaylist=function(e,t,r,n){var s=this.hls,o=e.data,a=i.getResponseUrl(e,r),c=x.parseMasterPlaylist(o,a),u=c.levels,l=c.sessionData;if(u.length){var h=u.map((function(e){return{id:e.attrs.AUDIO,codec:e.audioCodec}})),p=x.parseMasterPlaylistMedia(o,a,"AUDIO",h),g=x.parseMasterPlaylistMedia(o,a,"SUBTITLES"),y=x.parseMasterPlaylistMedia(o,a,"CLOSED-CAPTIONS");if(p.length){var m=!1;p.forEach((function(e){e.url||(m=!0)})),!1===m&&u[0].audioCodec&&!u[0].attrs.AUDIO&&(f.logger.log("audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:{},url:""}))}s.trigger(d.default.MANIFEST_LOADED,{levels:u,audioTracks:p,subtitles:g,captions:y,url:a,stats:t,networkDetails:n,sessionData:l})}else this._handleManifestParsingError(e,r,"no level found in manifest",n)},s._handleTrackOrLevelPlaylist=function(e,t,r,s){var o=this.hls,a=r.id,c=r.level,f=r.type,h=i.getResponseUrl(e,r),p=Object(l.isFiniteNumber)(a)?a:0,g=Object(l.isFiniteNumber)(c)?c:p,y=i.mapContextToLevelType(r),m=x.parseLevelPlaylist(e.data,h,g,y,p);if(m.tload=t.tload,m.fragments.length){if(f===n.MANIFEST){var b={url:h,details:m};o.trigger(d.default.MANIFEST_LOADED,{levels:[b],audioTracks:[],url:h,stats:t,networkDetails:s,sessionData:null})}if(t.tparsed=L.now(),m.needSidxRanges){var v=m.initSegment.url;this.load({url:v,isSidxRequest:!0,type:f,level:c,levelDetails:m,id:a,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer"})}else r.levelDetails=m,this._handlePlaylistLoaded(e,t,r,s)}else o.trigger(d.default.ERROR,{type:u.ErrorTypes.NETWORK_ERROR,details:u.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:h,reason:"no fragments found in level",level:"number"==typeof r.level?r.level:void 0})},s._handleSidxRequest=function(e,t){if("string"==typeof e.data)throw new Error("sidx request must be made with responseType of array buffer");var r=y.default.parseSegmentIndex(new Uint8Array(e.data));if(r){var i=r.references,n=t.levelDetails;i.forEach((function(e,t){var r=e.info;if(n){var i=n.fragments[t];0===i.byteRange.length&&i.setByteRange(String(1+r.end-r.start)+"@"+String(r.start))}})),n&&n.initSegment.setByteRange(String(r.moovEndOffset)+"@0")}},s._handleManifestParsingError=function(e,t,r,i){this.hls.trigger(d.default.ERROR,{type:u.ErrorTypes.NETWORK_ERROR,details:u.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:e.url,reason:r,networkDetails:i})},s._handleNetworkError=function(e,t,r,i){var s,o;void 0===r&&(r=!1),void 0===i&&(i=null),f.logger.info("A network error occured while loading a "+e.type+"-type playlist");var a=this.getInternalLoader(e);switch(e.type){case n.MANIFEST:s=r?u.ErrorDetails.MANIFEST_LOAD_TIMEOUT:u.ErrorDetails.MANIFEST_LOAD_ERROR,o=!0;break;case n.LEVEL:s=r?u.ErrorDetails.LEVEL_LOAD_TIMEOUT:u.ErrorDetails.LEVEL_LOAD_ERROR,o=!1;break;case n.AUDIO_TRACK:s=r?u.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,o=!1;break;default:o=!1}a&&(a.abort(),this.resetInternalLoader(e.type));var c={type:u.ErrorTypes.NETWORK_ERROR,details:s,fatal:o,url:e.url,loader:a,context:e,networkDetails:t};i&&(c.response=i),this.hls.trigger(d.default.ERROR,c)},s._handlePlaylistLoaded=function(e,t,r,s){var o=r.type,a=r.level,c=r.id,u=r.levelDetails;if(u&&u.targetduration)if(i.canHaveQualityLevels(r.type))this.hls.trigger(d.default.LEVEL_LOADED,{details:u,level:a||0,id:c||0,stats:t,networkDetails:s});else switch(o){case n.AUDIO_TRACK:this.hls.trigger(d.default.AUDIO_TRACK_LOADED,{details:u,id:c,stats:t,networkDetails:s});break;case n.SUBTITLE_TRACK:this.hls.trigger(d.default.SUBTITLE_TRACK_LOADED,{details:u,id:c,stats:t,networkDetails:s})}else this._handleManifestParsingError(e,r,"invalid target duration",s)},i}(g),U=function(e){var t,r;function i(t){var r;return(r=e.call(this,t,d.default.FRAG_LOADING)||this).loaders={},r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n=i.prototype;return n.destroy=function(){var t=this.loaders;for(var r in t){var i=t[r];i&&i.destroy()}this.loaders={},e.prototype.destroy.call(this)},n.onFragLoading=function(e){var t=e.frag,r=t.type,i=this.loaders,n=this.hls.config,s=n.fLoader,o=n.loader;t.loaded=0;var a,c,u,d=i[r];d&&(f.logger.warn("abort previous fragment loader for type: "+r),d.abort()),d=i[r]=t.loader=n.fLoader?new s(n):new o(n),a={url:t.url,frag:t,responseType:"arraybuffer",progressData:!1};var h=t.byteRangeStartOffset,p=t.byteRangeEndOffset;Object(l.isFiniteNumber)(h)&&Object(l.isFiniteNumber)(p)&&(a.rangeStart=h,a.rangeEnd=p),c={timeout:n.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:n.fragLoadingMaxRetryTimeout},u={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this),onProgress:this.loadprogress.bind(this)},d.load(a,c,u)},n.loadsuccess=function(e,t,r,i){void 0===i&&(i=null);var n=e.data,s=r.frag;s.loader=void 0,this.loaders[s.type]=void 0,this.hls.trigger(d.default.FRAG_LOADED,{payload:n,frag:s,stats:t,networkDetails:i})},n.loaderror=function(e,t,r){void 0===r&&(r=null);var i=t.frag,n=i.loader;n&&n.abort(),this.loaders[i.type]=void 0,this.hls.trigger(d.default.ERROR,{type:u.ErrorTypes.NETWORK_ERROR,details:u.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t.frag,response:e,networkDetails:r})},n.loadtimeout=function(e,t,r){void 0===r&&(r=null);var i=t.frag,n=i.loader;n&&n.abort(),this.loaders[i.type]=void 0,this.hls.trigger(d.default.ERROR,{type:u.ErrorTypes.NETWORK_ERROR,details:u.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t.frag,networkDetails:r})},n.loadprogress=function(e,t,r,i){void 0===i&&(i=null);var n=t.frag;n.loaded=e.loaded,this.hls.trigger(d.default.FRAG_LOAD_PROGRESS,{frag:n,stats:e,networkDetails:i})},i}(g),F=function(e){var t,r;function i(t){var r;return(r=e.call(this,t,d.default.KEY_LOADING)||this).loaders={},r.decryptkey=null,r.decrypturl=null,r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n=i.prototype;return n.destroy=function(){for(var t in this.loaders){var r=this.loaders[t];r&&r.destroy()}this.loaders={},e.prototype.destroy.call(this)},n.onKeyLoading=function(e){var t=e.frag,r=t.type,i=this.loaders[r];if(t.decryptdata){var n=t.decryptdata.uri;if(n!==this.decrypturl||null===this.decryptkey){var s=this.hls.config;if(i&&(f.logger.warn("abort previous key loader for type:"+r),i.abort()),!n)return void f.logger.warn("key uri is falsy");t.loader=this.loaders[r]=new s.loader(s),this.decrypturl=n,this.decryptkey=null;var o={url:n,frag:t,responseType:"arraybuffer"},a={timeout:s.fragLoadingTimeOut,maxRetry:0,retryDelay:s.fragLoadingRetryDelay,maxRetryDelay:s.fragLoadingMaxRetryTimeout},c={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};t.loader.load(o,a,c)}else this.decryptkey&&(t.decryptdata.key=this.decryptkey,this.hls.trigger(d.default.KEY_LOADED,{frag:t}))}else f.logger.warn("Missing decryption data on fragment in onKeyLoading")},n.loadsuccess=function(e,t,r){var i=r.frag;i.decryptdata?(this.decryptkey=i.decryptdata.key=new Uint8Array(e.data),i.loader=void 0,delete this.loaders[i.type],this.hls.trigger(d.default.KEY_LOADED,{frag:i})):f.logger.error("after key load, decryptdata unset")},n.loaderror=function(e,t){var r=t.frag,i=r.loader;i&&i.abort(),delete this.loaders[r.type],this.hls.trigger(d.default.ERROR,{type:u.ErrorTypes.NETWORK_ERROR,details:u.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:r,response:e})},n.loadtimeout=function(e,t){var r=t.frag,i=r.loader;i&&i.abort(),delete this.loaders[r.type],this.hls.trigger(d.default.ERROR,{type:u.ErrorTypes.NETWORK_ERROR,details:u.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:r})},i}(g),K="NOT_LOADED",z="APPENDING",V="PARTIAL",q="OK",G=function(e){var t,r;function i(t){var r;return(r=e.call(this,t,d.default.BUFFER_APPENDED,d.default.FRAG_BUFFERED,d.default.FRAG_LOADED)||this).bufferPadding=.2,r.fragments=Object.create(null),r.timeRanges=Object.create(null),r.config=t.config,r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n=i.prototype;return n.destroy=function(){this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.config=null,g.prototype.destroy.call(this),e.prototype.destroy.call(this)},n.getBufferedFrag=function(e,t){var r=this.fragments,i=Object.keys(r).filter((function(i){var n=r[i];if(n.body.type!==t)return!1;if(!n.buffered)return!1;var s=n.body;return s.startPTS<=e&&e<=s.endPTS}));if(0===i.length)return null;var n=i.pop();return r[n].body},n.detectEvictedFragments=function(e,t){var r=this;Object.keys(this.fragments).forEach((function(i){var n=r.fragments[i];if(n&&n.buffered){var s=n.range[e];if(s)for(var o=s.time,a=0;a=i&&t<=n){s.push({startPTS:Math.max(e,r.start(a)),endPTS:Math.min(t,r.end(a))});break}if(ei)s.push({startPTS:Math.max(e,r.start(a)),endPTS:Math.min(t,r.end(a))}),o=!0;else if(t<=i)break}return{time:s,partial:o}},n.getFragmentKey=function(e){return e.type+"_"+e.level+"_"+e.urlId+"_"+e.sn},n.getPartialFragment=function(e){var t,r,i,n=this,s=null,o=0;return Object.keys(this.fragments).forEach((function(a){var c=n.fragments[a];n.isPartial(c)&&(r=c.body.startPTS-n.bufferPadding,i=c.body.endPTS+n.bufferPadding,e>=r&&e<=i&&(t=Math.min(e-r,i-e),o<=t&&(s=c.body,o=t)))})),s},n.getState=function(e){var t=this.getFragmentKey(e),r=this.fragments[t],i=K;return void 0!==r&&(i=r.buffered?!0===this.isPartial(r)?V:q:z),i},n.isPartial=function(e){return!0===e.buffered&&(void 0!==e.range.video&&!0===e.range.video.partial||void 0!==e.range.audio&&!0===e.range.audio.partial)},n.isTimeBuffered=function(e,t,r){for(var i,n,s=0;s=i&&t<=n)return!0;if(t<=i)return!1}return!1},n.onFragLoaded=function(e){var t=e.frag;Object(l.isFiniteNumber)(t.sn)&&!t.bitrateTest&&(this.fragments[this.getFragmentKey(t)]={body:t,range:Object.create(null),buffered:!1})},n.onBufferAppended=function(e){var t=this;this.timeRanges=e.timeRanges,Object.keys(this.timeRanges).forEach((function(e){var r=t.timeRanges[e];t.detectEvictedFragments(e,r)}))},n.onFragBuffered=function(e){this.detectPartialFragments(e.frag)},n.hasFragment=function(e){var t=this.getFragmentKey(e);return void 0!==this.fragments[t]},n.removeFragment=function(e){var t=this.getFragmentKey(e);delete this.fragments[t]},n.removeAllFragments=function(){this.fragments=Object.create(null)},i}(g),H={search:function(e,t){for(var r=0,i=e.length-1,n=null,s=null;r<=i;){var o=t(s=e[n=(r+i)/2|0]);if(o>0)r=n+1;else{if(!(o<0))return s;i=n-1}}return null}},$=function(){function e(){}return e.isBuffered=function(e,t){try{if(e)for(var r=e.buffered,i=0;i=r.start(i)&&t<=r.end(i))return!0}catch(e){}return!1},e.bufferInfo=function(e,t,r){try{if(e){var i,n=e.buffered,s=[];for(i=0;io&&(i[s-1].end=e[n].end):i.push(e[n])}else i.push(e[n])}else i=e;for(var a,c=0,u=t,l=t,d=0;d=f&&t1?t-1:0),i=1;it?(i.duration=s-i.start,i.duration<0&&f.logger.warn("negative duration computed for frag "+i.sn+",level "+i.level+", there should be some duration drift between playlist and fragment!")):(n.duration=i.start-s,n.duration<0&&f.logger.warn("negative duration computed for frag "+n.sn+",level "+n.level+", there should be some duration drift between playlist and fragment!"));else if(r>t){var o=i.cc===n.cc;n.start=i.start+(o&&i.minEndPTS?i.minEndPTS-i.start:i.duration)}else n.start=Math.max(i.start-n.duration,0)}function se(e,t,r,i,n,s){var o=r,a=i;if(Object(l.isFiniteNumber)(t.startPTS)){var c=Math.abs(t.startPTS-r);Object(l.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(c,t.deltaPTS):t.deltaPTS=c,o=Math.max(r,t.startPTS),r=Math.min(r,t.startPTS),a=Math.min(i,t.endPTS),i=Math.max(i,t.endPTS),n=Math.min(n,t.startDTS),s=Math.max(s,t.endDTS)}var u=r-t.start;t.start=t.startPTS=r,t.maxStartPTS=o,t.endPTS=i,t.minEndPTS=a,t.startDTS=n,t.endDTS=s,t.duration=i-r;var d,f,h,p=t.sn;if(!e||pe.endSN)return 0;for(d=p-e.startSN,(f=e.fragments)[d]=t,h=d;h>0;h--)ne(f,h,h-1);for(h=d;hi.length))for(var s=0;sr.startCC||e&&e.cc=(e[e.length-1].endProgramDateTime||0))return null;r=r||0;for(var i=0;ie&&r.start?-1:0}function ge(e,t,r){var i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}var ye=function(){function e(e,t,r,i){this.config=e,this.media=t,this.fragmentTracker=r,this.hls=i,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1}var t=e.prototype;return t.poll=function(e){var t=this.config,r=this.media,i=this.stalled,n=r.currentTime,s=r.seeking,o=this.seeking&&!s,a=!this.seeking&&s;if(this.seeking=s,n===e){if((a||o)&&(this.stalled=null),!r.paused&&!r.ended&&0!==r.playbackRate&&r.buffered.length){var c=$.bufferInfo(r,n,0),u=c.len>0,l=c.nextStart||0;if(u||l){if(s){var d=c.len>2,h=!l||l-n>2&&!this.fragmentTracker.getPartialFragment(n);if(d||h)return;this.moved=!1}if(!this.moved&&this.stalled){var p=Math.max(l,c.start||0)-n;if(p>0&&p<=2)return void this._trySkipBufferHole(null)}var g=self.performance.now();if(null!==i){var y=g-i;!s&&y>=250&&this._reportStall(c.len);var m=$.bufferInfo(r,n,t.maxBufferHole);this._tryFixBufferStall(m,y)}else this.stalled=g}}}else if(this.moved=!0,null!==i){if(this.stallReported){var b=self.performance.now()-i;f.logger.warn("playback not stuck anymore @"+n+", after "+Math.round(b)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}},t._tryFixBufferStall=function(e,t){var r=this.config,i=this.fragmentTracker,n=this.media.currentTime,s=i.getPartialFragment(n);s&&this._trySkipBufferHole(s)||e.len>r.maxBufferHole&&t>1e3*r.highBufferWatchdogPeriod&&(f.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},t._reportStall=function(e){var t=this.hls,r=this.media;this.stallReported||(this.stallReported=!0,f.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer (buffer="+e+")"),t.trigger(d.default.ERROR,{type:u.ErrorTypes.MEDIA_ERROR,details:u.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e}))},t._trySkipBufferHole=function(e){for(var t=this.config,r=this.hls,i=this.media,n=i.currentTime,s=0,o=0;o=s&&n1?i-1:0),s=1;s1&&(this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)),this._tickCallCount=0)},n.doTick=function(){},i}(g),ve="STOPPED",we="STARTING",_e="IDLE",Ee="PAUSED",Se="KEY_LOADING",Te="FRAG_LOADING",Ae="FRAG_LOADING_WAITING_RETRY",ke="WAITING_TRACK",Ie="PARSING",Re="PARSED",Pe="BUFFER_FLUSHING",Oe="ENDED",Ce="ERROR",je="WAITING_INIT_PTS",De="WAITING_LEVEL",Me=function(e){var t,r;function i(){return e.apply(this,arguments)||this}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n=i.prototype;return n.doTick=function(){},n.startLoad=function(){},n.stopLoad=function(){var e=this.fragCurrent;e&&(e.loader&&e.loader.abort(),this.fragmentTracker.removeFragment(e)),this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=ve},n._streamEnded=function(e,t){var r=this.fragCurrent,i=this.fragmentTracker;if(!t.live&&r&&!r.backtracked&&r.sn===t.endSN&&!e.nextStart){var n=i.getState(r);return n===V||n===q}return!1},n.onMediaSeeking=function(){var e=this.config,t=this.media,r=this.mediaBuffer,i=this.state,n=t?t.currentTime:null,s=$.bufferInfo(r||t,n,this.config.maxBufferHole);if(f.logger.log("media seeking to "+(Object(l.isFiniteNumber)(n)?n.toFixed(3):n)),i===Te){var o=this.fragCurrent;if(0===s.len&&o){var a=e.maxFragLookUpTolerance,c=o.start-a,u=o.start+o.duration+a;nu?(o.loader&&(f.logger.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),o.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.state=_e):f.logger.log("seeking outside of buffer but within currently loaded fragment range")}}else i===Oe&&(0===s.len&&(this.fragPrevious=null,this.fragCurrent=null),this.state=_e);t&&(this.lastCurrentTime=n),this.loadedmetadata||(this.nextLoadPosition=this.startPosition=n),this.tick()},n.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},n.onHandlerDestroying=function(){this.stopLoad(),e.prototype.onHandlerDestroying.call(this)},n.onHandlerDestroyed=function(){this.state=ve,this.fragmentTracker=null},n.computeLivePosition=function(e,t){var r=void 0!==this.config.liveSyncDuration?this.config.liveSyncDuration:this.config.liveSyncDurationCount*t.targetduration;return e+Math.max(0,t.totalduration-r)},i}(be);function xe(e,t){for(var r=0;r0&&-1===e&&(f.logger.log("override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=_e,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this.forceStartLoad=!0,this.state=ve},c.stopLoad=function(){this.forceStartLoad=!1,e.prototype.stopLoad.call(this)},c.doTick=function(){switch(this.state){case Pe:this.fragLoadError=0;break;case _e:this._doTickIdle();break;case De:var e=this.levels[this.level];e&&e.details&&(this.state=_e);break;case Ae:var t=window.performance.now(),r=this.retryDate;(!r||t>=r||this.media&&this.media.seeking)&&(f.logger.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=_e)}this._checkBuffer(),this._checkFragmentChanged()},c._doTickIdle=function(){var e=this.hls,t=e.config,r=this.media;if(void 0!==this.levelLastLoaded&&(r||!this.startFragRequested&&t.startFragPrefetch))if(this.altAudio&&this.audioOnly)this.demuxer.frag=null;else{var i;i=this.loadedmetadata?r.currentTime:this.nextLoadPosition;var n=e.nextLoadLevel,s=this.levels[n];if(s){var o,a=s.bitrate;o=a?Math.max(8*t.maxBufferSize/a,t.maxBufferLength):t.maxBufferLength,o=Math.min(o,t.maxMaxBufferLength);var c=i=o)){f.logger.trace("buffer length of "+l.toFixed(3)+" is below max of "+o.toFixed(3)+". checking for more payload ..."),this.level=e.nextLoadLevel=n;var h=s.details;if(!h||h.live&&this.levelLastLoaded!==n)this.state=De;else{if(this._streamEnded(u,h)){var p={};return this.altAudio&&(p.type="video"),this.hls.trigger(d.default.BUFFER_EOS,p),void(this.state=Oe)}this._fetchPayloadOrEos(i,u,h)}}}}},c._fetchPayloadOrEos=function(e,t,r){var i=this.fragPrevious,n=(this.level,r.fragments),s=n.length;if(0!==s){var o,a=n[0].start,c=n[s-1].start+n[s-1].duration,u=t.end;if(r.initSegment&&!r.initSegment.data)o=r.initSegment;else if(r.live){var l=this.config.initialLiveManifestSize;if(sd&&d>c.currentTime&&(f.logger.log("buffer end: "+t.toFixed(3)+" is located too far from the end of live sliding playlist, reset currentTime to : "+d.toFixed(3)),c.currentTime=d),this.nextLoadPosition=d}if(e.PTSKnown&&t>i&&c&&c.readyState)return null;if(this.startFragRequested&&!e.PTSKnown&&n)if(e.hasProgramDateTime)f.logger.log("live playlist, switching playlist, load frag with same PDT: "+n.programDateTime),o=fe(s,n.endProgramDateTime,a.maxFragLookUpTolerance);else{var h=n.sn+1;if(h>=e.startSN&&h<=e.endSN){var p=s[h-e.startSN];n.cc===p.cc&&(o=p,f.logger.log("live playlist, switching playlist, load frag with next SN: "+o.sn))}o||(o=H.search(s,(function(e){return n.cc-e.cc})))&&f.logger.log("live playlist, switching playlist, load frag with same CC: "+o.sn)}return o},c._findFragment=function(e,t,r,i,n,s,o){var a,c=this.hls.config;if(a=ns-c.maxFragLookUpTolerance?0:c.maxFragLookUpTolerance):i[r-1]){var u=a.sn-o.startSN,l=t&&a.level===t.level,d=i[u-1],h=i[u+1];if(t&&a.sn===t.sn)if(l&&!a.backtracked)if(a.snc.maxBufferHole&&t.dropped&&u?(a=d,f.logger.warn("Previous fragment was dropped with large PTS gap between audio and video. Maybe fragment is not starting with a keyframe? Loading previous one to try to overcome this")):(a=h,this.fragmentTracker.getState(a)!==q&&f.logger.log("Re-loading fragment with SN: "+a.sn))}else a=null;else a.backtracked&&(h&&h.backtracked?(f.logger.warn("Already backtracked from fragment "+h.sn+", will not backtrack to fragment "+a.sn+". Loading fragment "+h.sn),a=h):(f.logger.warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),a.dropped=0,d?(a=d).backtracked=!0:u&&(a=null)))}return a},c._loadKey=function(e,t){f.logger.log("Loading key for "+e.sn+" of ["+t.startSN+"-"+t.endSN+"], level "+this.level),this.state=Se,this.hls.trigger(d.default.KEY_LOADING,{frag:e})},c._loadFragment=function(e,t,r,i){var n=this.fragmentTracker.getState(e);this.fragCurrent=e,"initSegment"!==e.sn&&(this.startFragRequested=!0),Object(l.isFiniteNumber)(e.sn)&&!e.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),e.backtracked||n===K||n===V?(e.autoLevel=this.hls.autoLevelEnabled,e.bitrateTest=this.bitrateTest,f.logger.log("Loading "+e.sn+" of ["+t.startSN+"-"+t.endSN+"], level "+this.level+", "+(this.loadedmetadata?"currentTime":"nextLoadPosition")+": "+parseFloat(r.toFixed(3))+", bufferEnd: "+parseFloat(i.toFixed(3))),this.hls.trigger(d.default.FRAG_LOADING,{frag:e}),this.demuxer||(this.demuxer=new re(this.hls,"main")),this.state=Te):n===z&&this._reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e)},c.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,o.MAIN)},c.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.endPTS+.5):null},c._checkFragmentChanged=function(){var e,t,r=this.media;if(r&&r.readyState&&!1===r.seeking&&((t=r.currentTime)>this.lastCurrentTime&&(this.lastCurrentTime=t),$.isBuffered(r,t)?e=this.getBufferedFrag(t):$.isBuffered(r,t+.1)&&(e=this.getBufferedFrag(t+.1)),e)){var i=e;if(i!==this.fragPlaying){this.hls.trigger(d.default.FRAG_CHANGED,{frag:i});var n=i.level;this.fragPlaying&&this.fragPlaying.level===n||this.hls.trigger(d.default.LEVEL_SWITCHED,{level:n}),this.fragPlaying=i}}},c.immediateLevelSwitch=function(){if(f.logger.log("immediateLevelSwitch"),!this.immediateSwitch){this.immediateSwitch=!0;var e,t=this.media;t?(e=t.paused)||t.pause():e=!0,this.previouslyPaused=e}var r=this.fragCurrent;r&&r.loader&&r.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},c.immediateLevelSwitchEnd=function(){var e=this.media;e&&e.buffered.length&&(this.immediateSwitch=!1,e.currentTime>0&&$.isBuffered(e,e.currentTime)&&(e.currentTime-=1e-4),this.previouslyPaused||e.play())},c.nextLevelSwitch=function(){var e=this.media;if(e&&e.readyState){var t,r=this.getBufferedFrag(e.currentTime);if(r&&r.startPTS>1&&this.flushMainBuffer(0,r.startPTS-1),e.paused)t=0;else{var i=this.hls.nextLoadLevel,n=this.levels[i],s=this.fragLastKbps;t=s&&this.fragCurrent?this.fragCurrent.duration*n.bitrate/(1e3*s)+1:0}var o=this.getBufferedFrag(e.currentTime+t);if(o){var a=this.followingBufferedFrag(o);if(a){var c=this.fragCurrent;c&&c.loader&&c.loader.abort(),this.fragCurrent=null;var u=Math.max(o.endPTS,a.maxStartPTS+Math.min(this.config.maxFragLookUpTolerance,a.duration));this.flushMainBuffer(u,Number.POSITIVE_INFINITY)}}}},c.flushMainBuffer=function(e,t){this.state=Pe;var r={startOffset:e,endOffset:t};this.altAudio&&(r.type="video"),this.hls.trigger(d.default.BUFFER_FLUSHING,r)},c.onMediaAttached=function(e){var t=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("seeked",this.onvseeked),t.addEventListener("ended",this.onvended);var r=this.config;this.levels&&r.autoStartLoad&&this.hls.startLoad(r.startPosition),this.gapController=new ye(r,t,this.fragmentTracker,this.hls)},c.onMediaDetaching=function(){var e=this.media;e&&e.ended&&(f.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var t=this.levels;t&&t.forEach((function(e){e.details&&e.details.fragments.forEach((function(e){e.backtracked=void 0}))})),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("seeked",this.onvseeked),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.fragmentTracker.removeAllFragments(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.stopLoad()},c.onMediaSeeked=function(){var e=this.media,t=e?e.currentTime:void 0;Object(l.isFiniteNumber)(t)&&f.logger.log("media seeked to "+t.toFixed(3)),this.tick()},c.onManifestLoading=function(){f.logger.log("trigger BUFFER_RESET"),this.hls.trigger(d.default.BUFFER_RESET),this.fragmentTracker.removeAllFragments(),this.stalled=!1,this.startPosition=this.lastCurrentTime=0},c.onManifestParsed=function(e){var t,r=!1,i=!1;e.levels.forEach((function(e){(t=e.audioCodec)&&(-1!==t.indexOf("mp4a.40.2")&&(r=!0),-1!==t.indexOf("mp4a.40.5")&&(i=!0))})),this.audioCodecSwitch=r&&i,this.audioCodecSwitch&&f.logger.log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.altAudio=e.altAudio,this.levels=e.levels,this.startFragRequested=!1;var n=this.config;(n.autoStartLoad||this.forceStartLoad)&&this.hls.startLoad(n.startPosition)},c.onLevelLoaded=function(e){var t=e.details,r=e.level,i=this.levels[this.levelLastLoaded],n=this.levels[r],s=t.totalduration,o=0;if(f.logger.log("level "+r+" loaded ["+t.startSN+","+t.endSN+"],duration:"+s),t.live||n.details&&n.details.live){var a=n.details;a&&t.fragments.length>0?(oe(a,t),o=t.fragments[0].start,this.liveSyncPosition=this.computeLivePosition(o,a),t.PTSKnown&&Object(l.isFiniteNumber)(o)?f.logger.log("live playlist sliding:"+o.toFixed(3)):(f.logger.log("live playlist - outdated PTS, unknown sliding"),de(this.fragPrevious,i,t))):(f.logger.log("live playlist - first load, unknown sliding"),t.PTSKnown=!1,de(this.fragPrevious,i,t))}else t.PTSKnown=!1;if(n.details=t,this.levelLastLoaded=r,this.hls.trigger(d.default.LEVEL_UPDATED,{details:t,level:r}),!1===this.startFragRequested){if(-1===this.startPosition||-1===this.lastCurrentTime){var c=t.startTimeOffset;Object(l.isFiniteNumber)(c)?(c<0&&(f.logger.log("negative start time offset "+c+", count from end of last fragment"),c=o+s+c),f.logger.log("start time offset found in playlist, adjust startPosition to "+c),this.startPosition=c):t.live?(this.startPosition=this.computeLivePosition(o,t),f.logger.log("configure startPosition to "+this.startPosition)):this.startPosition=0,this.lastCurrentTime=this.startPosition}this.nextLoadPosition=this.startPosition}this.state===De&&(this.state=_e),this.tick()},c.onKeyLoaded=function(){this.state===Se&&(this.state=_e,this.tick())},c.onFragLoaded=function(e){var t=this.fragCurrent,r=this.hls,i=this.levels,n=this.media,s=e.frag;if(this.state===Te&&t&&"main"===s.type&&s.level===t.level&&s.sn===t.sn){var o=e.stats,a=i[t.level],c=a.details;if(this.bitrateTest=!1,this.stats=o,f.logger.log("Loaded "+t.sn+" of ["+c.startSN+" ,"+c.endSN+"],level "+t.level),s.bitrateTest&&r.nextLoadLevel)this.state=_e,this.startFragRequested=!1,o.tparsed=o.tbuffered=window.performance.now(),r.trigger(d.default.FRAG_BUFFERED,{stats:o,frag:t,id:"main"}),this.tick();else if("initSegment"===s.sn)this.state=_e,o.tparsed=o.tbuffered=window.performance.now(),c.initSegment.data=e.payload,r.trigger(d.default.FRAG_BUFFERED,{stats:o,frag:t,id:"main"}),this.tick();else{f.logger.log("Parsing "+t.sn+" of ["+c.startSN+" ,"+c.endSN+"],level "+t.level+", cc "+t.cc),this.state=Ie,this.pendingBuffering=!0,this.appended=!1,s.bitrateTest&&(s.bitrateTest=!1,this.fragmentTracker.onFragLoaded({frag:s}));var u=!(n&&n.seeking)&&(c.PTSKnown||!c.live),l=c.initSegment?c.initSegment.data:[],h=this._getAudioCodec(a);(this.demuxer=this.demuxer||new re(this.hls,"main")).push(e.payload,l,h,a.videoCodec,t,c.totalduration,u)}}this.fragLoadError=0},c.onFragParsingInitSegment=function(e){var t=this.fragCurrent,r=e.frag;if(t&&"main"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===Ie){var i,n,s=e.tracks;if(this.audioOnly=s.audio&&!s.video,this.altAudio&&!this.audioOnly&&delete s.audio,n=s.audio){var o=this.levels[this.level].audioCodec,a=navigator.userAgent.toLowerCase();o&&this.audioCodecSwap&&(f.logger.log("swapping playlist audio codec"),o=-1!==o.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),this.audioCodecSwitch&&1!==n.metadata.channelCount&&-1===a.indexOf("firefox")&&(o="mp4a.40.5"),-1!==a.indexOf("android")&&"audio/mpeg"!==n.container&&(o="mp4a.40.2",f.logger.log("Android: force audio codec to "+o)),n.levelCodec=o,n.id=e.id}for(i in(n=s.video)&&(n.levelCodec=this.levels[this.level].videoCodec,n.id=e.id),this.hls.trigger(d.default.BUFFER_CODECS,s),s){n=s[i],f.logger.log("main track:"+i+",container:"+n.container+",codecs[level/parsed]=["+n.levelCodec+"/"+n.codec+"]");var c=n.initSegment;c&&(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(d.default.BUFFER_APPENDING,{type:i,data:c,parent:"main",content:"initSegment"}))}this.tick()}},c.onFragParsingData=function(e){var t=this,r=this.fragCurrent,i=e.frag;if(r&&"main"===e.id&&i.sn===r.sn&&i.level===r.level&&("audio"!==e.type||!this.altAudio)&&this.state===Ie){var n=this.levels[this.level],s=r;if(Object(l.isFiniteNumber)(e.endPTS)||(e.endPTS=e.startPTS+r.duration,e.endDTS=e.startDTS+r.duration),!0===e.hasAudio&&s.addElementaryStream(b.AUDIO),!0===e.hasVideo&&s.addElementaryStream(b.VIDEO),f.logger.log("Parsed "+e.type+",PTS:["+e.startPTS.toFixed(3)+","+e.endPTS.toFixed(3)+"],DTS:["+e.startDTS.toFixed(3)+"/"+e.endDTS.toFixed(3)+"],nb:"+e.nb+",dropped:"+(e.dropped||0)),"video"===e.type)if(s.dropped=e.dropped,s.dropped)if(s.backtracked)f.logger.warn("Already backtracked on this fragment, appending with the gap",s.sn);else{var o=n.details;if(!o||s.sn!==o.startSN)return f.logger.warn("missing video frame(s), backtracking fragment",s.sn),this.fragmentTracker.removeFragment(s),s.backtracked=!0,this.nextLoadPosition=e.startPTS,this.state=_e,this.fragPrevious=s,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),void this.tick();f.logger.warn("missing video frame(s) on first frag, appending with gap",s.sn)}else s.backtracked=!1;var a=se(n.details,s,e.startPTS,e.endPTS,e.startDTS,e.endDTS),c=this.hls;c.trigger(d.default.LEVEL_PTS_UPDATED,{details:n.details,level:this.level,drift:a,type:e.type,start:e.startPTS,end:e.endPTS}),[e.data1,e.data2].forEach((function(r){r&&r.length&&t.state===Ie&&(t.appended=!0,t.pendingBuffering=!0,c.trigger(d.default.BUFFER_APPENDING,{type:e.type,data:r,parent:"main",content:"data"}))})),this.tick()}},c.onFragParsed=function(e){var t=this.fragCurrent,r=e.frag;t&&"main"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===Ie&&(this.stats.tparsed=window.performance.now(),this.state=Re,this._checkAppendedParsed())},c.onAudioTrackSwitching=function(e){var t=this.altAudio,r=!!e.url,i=e.id;if(!r){if(this.mediaBuffer!==this.media){f.logger.log("switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var n=this.fragCurrent;n.loader&&(f.logger.log("switching to main audio track, cancel main fragment load"),n.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=_e}var s=this.hls;t&&s.trigger(d.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),s.trigger(d.default.AUDIO_TRACK_SWITCHED,{id:i})}},c.onAudioTrackSwitched=function(e){var t=e.id,r=!!this.hls.audioTracks[t].url;if(r){var i=this.videoBuffer;i&&this.mediaBuffer!==i&&(f.logger.log("switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=r,this.tick()},c.onBufferCreated=function(e){var t,r,i=e.tracks,n=!1;for(var s in i){var o=i[s];"main"===o.id?(r=s,t=o,"video"===s&&(this.videoBuffer=i[s].buffer)):n=!0}n&&t?(f.logger.log("alternate track found, use "+r+".buffered to schedule main fragment loading"),this.mediaBuffer=t.buffer):this.mediaBuffer=this.media},c.onBufferAppended=function(e){if("main"===e.parent){var t=this.state;t!==Ie&&t!==Re||(this.pendingBuffering=e.pending>0,this._checkAppendedParsed())}},c._checkAppendedParsed=function(){if(!(this.state!==Re||this.appended&&this.pendingBuffering)){var e=this.fragCurrent;if(e){var t=this.mediaBuffer?this.mediaBuffer:this.media;f.logger.log("main buffered : "+ue.toString(t.buffered)),this.fragPrevious=e;var r=this.stats;r.tbuffered=window.performance.now(),this.fragLastKbps=Math.round(8*r.total/(r.tbuffered-r.tfirst)),this.hls.trigger(d.default.FRAG_BUFFERED,{stats:r,frag:e,id:"main"}),this.state=_e}(this.loadedmetadata||this.startPosition<=0)&&this.tick()}},c.onError=function(e){var t=e.frag||this.fragCurrent;if(!t||"main"===t.type){var r=!!this.media&&$.isBuffered(this.media,this.media.currentTime)&&$.isBuffered(this.media,this.media.currentTime+.5);switch(e.details){case u.ErrorDetails.FRAG_LOAD_ERROR:case u.ErrorDetails.FRAG_LOAD_TIMEOUT:case u.ErrorDetails.KEY_LOAD_ERROR:case u.ErrorDetails.KEY_LOAD_TIMEOUT:if(!e.fatal)if(this.fragLoadError+1<=this.config.fragLoadingMaxRetry){var i=Math.min(Math.pow(2,this.fragLoadError)*this.config.fragLoadingRetryDelay,this.config.fragLoadingMaxRetryTimeout);f.logger.warn("mediaController: frag loading failed, retry in "+i+" ms"),this.retryDate=window.performance.now()+i,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.fragLoadError++,this.state=Ae}else f.logger.error("mediaController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=Ce;break;case u.ErrorDetails.LEVEL_LOAD_ERROR:case u.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==Ce&&(e.fatal?(this.state=Ce,f.logger.warn("streamController: "+e.details+",switch to "+this.state+" state ...")):e.levelRetry||this.state!==De||(this.state=_e));break;case u.ErrorDetails.BUFFER_FULL_ERROR:"main"!==e.parent||this.state!==Ie&&this.state!==Re||(r?(this._reduceMaxBufferLength(this.config.maxBufferLength),this.state=_e):(f.logger.warn("buffer full error also media.currentTime is not buffered, flush everything"),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)))}}},c._reduceMaxBufferLength=function(e){var t=this.config;return t.maxMaxBufferLength>=e&&(t.maxMaxBufferLength/=2,f.logger.warn("main:reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},c._checkBuffer=function(){var e=this.media;if(e&&0!==e.readyState){var t=(this.mediaBuffer?this.mediaBuffer:e).buffered;!this.loadedmetadata&&t.length?(this.loadedmetadata=!0,this._seekToStartPos()):this.immediateSwitch?this.immediateLevelSwitchEnd():this.gapController.poll(this.lastCurrentTime,t)}},c.onFragLoadEmergencyAborted=function(){this.state=_e,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tick()},c.onBufferFlushed=function(){var e=this.mediaBuffer?this.mediaBuffer:this.media;if(e){var t=this.audioOnly?b.AUDIO:b.VIDEO;this.fragmentTracker.detectEvictedFragments(t,e.buffered)}this.state=_e,this.fragPrevious=null},c.onLevelsUpdated=function(e){this.levels=e.levels},c.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},c._seekToStartPos=function(){var e=this.media,t=e.currentTime,r=this.startPosition;if(t!==r&&r>=0){if(e.seeking)return void f.logger.log("could not seek to "+r+", already seeking at "+t);var i=(e.buffered.length?e.buffered.start(0):0)-r;i>0&&i"+e),this.hls.trigger(d.default.STREAM_STATE_TRANSITION,{previousState:t,nextState:e})}},get:function(){return this._state}},{key:"currentLevel",get:function(){var e=this.media;if(e){var t=this.getBufferedFrag(e.currentTime);if(t)return t.level}return-1}},{key:"nextBufferedFrag",get:function(){var e=this.media;return e?this.followingBufferedFrag(this.getBufferedFrag(e.currentTime)):null}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"liveSyncPosition",get:function(){return this._liveSyncPosition},set:function(e){this._liveSyncPosition=e}}])&&xe(n.prototype,s),a&&xe(n,a),i}(Me);function Ne(e,t){for(var r=0;r0){t=r[0].bitrate,r.sort((function(e,t){return e.bitrate-t.bitrate})),this._levels=r;for(var c=0;c=0&&e1&&l.loadError0){var t=this.currentLevelIndex,r=e.urlId,i=e.url[r];f.logger.log("Attempt loading level index "+t+" with URL-id "+r),this.hls.trigger(d.default.LEVEL_LOADING,{url:i,level:t,id:r})}}},a.removeLevel=function(e,t){var r=this.levels.filter((function(r,i){return i!==e||r.url.length>1&&void 0!==t&&(r.url=r.url.filter((function(e,r){return r!==t})),r.urlId=0,!0)})).map((function(e,t){var r=e.details;return r&&r.fragments&&r.fragments.forEach((function(e){e.level=t})),e}));this._levels=r,this.hls.trigger(d.default.LEVELS_UPDATED,{levels:r})},n=i,(s=[{key:"levels",get:function(){return this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;t&&(e=Math.min(e,t.length-1),this.currentLevelIndex===e&&t[e].details||this.setLevelInternal(e))}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this._firstLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}])&&Ne(n.prototype,s),o&&Ne(n,o),i}(g),Fe=r("./src/demux/id3.js");function Ke(e,t){var r;try{r=new Event("addtrack")}catch(e){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function ze(e){if(null==e?void 0:e.cues)for(;e.cues.length>0;)e.removeCue(e.cues[0])}var Ve=function(e){var t,r;function i(t){var r;return(r=e.call(this,t,d.default.MEDIA_ATTACHED,d.default.MEDIA_DETACHING,d.default.FRAG_PARSING_METADATA,d.default.LIVE_BACK_BUFFER_REACHED)||this).id3Track=void 0,r.media=void 0,r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n=i.prototype;return n.destroy=function(){g.prototype.destroy.call(this)},n.onMediaAttached=function(e){this.media=e.media,this.media},n.onMediaDetaching=function(){ze(this.id3Track),this.id3Track=void 0,this.media=void 0},n.getID3Track=function(e){for(var t=0;te[e.length-1].endTime)return e[e.length-1];for(var r=0,i=e.length-1;r<=i;){var n=Math.floor((i+r)/2);if(te[n].endTime))return e[n];r=n+1}}return e[r].endTime-t=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.destroy=function(){},e}();function He(e,t){for(var r=0;r500*r.duration/o){var a=e.levels,c=Math.max(1,n.bw?n.bw/8:1e3*n.loaded/s),u=a[r.level];if(!u)return;var l=u.realBitrate?Math.max(u.realBitrate,u.bitrate):u.bitrate,h=n.total?n.total:Math.max(n.loaded,Math.round(r.duration*l/8)),p=t.currentTime,g=(h-n.loaded)/c,y=($.bufferInfo(t,p,e.config.maxBufferHole).end-p)/o;if(y<2*r.duration/o&&g>y){var m,b,v=e.minAutoLevel;for(b=r.level-1;b>v;b--){var w=a[b].realBitrate?Math.max(a[b].realBitrate,a[b].bitrate):a[b].bitrate;if(r.duration*w/(6.4*c)=i;u--){var l=c[u];if(l){var d=l.details,h=d?d.totalduration/d.fragments.length:t,p=!!d&&d.live,g=void 0;g=u<=e?o*r:a*r;var y=c[u].realBitrate?Math.max(c[u].realBitrate,c[u].bitrate):c[u].bitrate,m=y*h/g;if(f.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+u+"/"+Math.round(g)+"/"+y+"/"+h+"/"+s+"/"+m),g>y&&(!m||p&&!this.bitrateTestDelay||m=0)return h;f.logger.trace("rebuffering expected to happen, lets try to find a quality level minimizing the rebuffering");var p=a?Math.min(a,i.maxStarvationDelay):i.maxStarvationDelay,g=i.abrBandWidthFactor,y=i.abrBandWidthUpFactor;if(0===d){var m=this.bitrateTestDelay;m&&(p=(a?Math.min(a,i.maxLoadingDelay):i.maxLoadingDelay)-m,f.logger.trace("bitrate test took "+Math.round(1e3*m)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*p)+" ms"),g=y=1)}return h=this._findBestLevel(o,a,l,n,t,d+p,g,y,r),Math.max(h,0)}}])&&He(n.prototype,s),o&&He(n,o),i}(g),Ye=Z(),Xe=function(e){var t,r;function i(t){var r;return(r=e.call(this,t,d.default.MEDIA_ATTACHING,d.default.MEDIA_DETACHING,d.default.MANIFEST_PARSED,d.default.BUFFER_RESET,d.default.BUFFER_APPENDING,d.default.BUFFER_CODECS,d.default.BUFFER_EOS,d.default.BUFFER_FLUSHING,d.default.LEVEL_PTS_UPDATED,d.default.LEVEL_UPDATED)||this)._msDuration=null,r._levelDuration=null,r._levelTargetDuration=10,r._live=null,r._objectUrl=null,r._needsFlush=!1,r._needsEos=!1,r.config=void 0,r.audioTimestampOffset=void 0,r.bufferCodecEventsExpected=0,r._bufferCodecEventsTotal=0,r.media=null,r.mediaSource=null,r.segments=[],r.parent=void 0,r.appending=!1,r.appended=0,r.appendError=0,r.flushBufferCounter=0,r.tracks={},r.pendingTracks={},r.sourceBuffer={},r.flushRange=[],r._onMediaSourceOpen=function(){f.logger.log("media source opened"),r.hls.trigger(d.default.MEDIA_ATTACHED,{media:r.media});var e=r.mediaSource;e&&e.removeEventListener("sourceopen",r._onMediaSourceOpen),r.checkPendingTracks()},r._onMediaSourceClose=function(){f.logger.log("media source closed")},r._onMediaSourceEnded=function(){f.logger.log("media source ended")},r._onSBUpdateEnd=function(){if(r.audioTimestampOffset&&r.sourceBuffer.audio){var e=r.sourceBuffer.audio;f.logger.warn("change mpeg audio timestamp offset from "+e.timestampOffset+" to "+r.audioTimestampOffset),e.timestampOffset=r.audioTimestampOffset,delete r.audioTimestampOffset}r._needsFlush&&r.doFlush(),r._needsEos&&r.checkEos(),r.appending=!1;var t=r.parent,i=r.segments.reduce((function(e,r){return r.parent===t?e+1:e}),0),n={},s=r.sourceBuffer;for(var o in s){var a=s[o];if(!a)throw Error("handling source buffer update end error: source buffer for "+o+" uninitilized and unable to update buffered TimeRanges.");n[o]=a.buffered}r.hls.trigger(d.default.BUFFER_APPENDED,{parent:t,pending:i,timeRanges:n}),r._needsFlush||r.doAppending(),r.updateMediaElementDuration(),0===i&&r.flushLiveBackBuffer()},r._onSBUpdateError=function(e){f.logger.error("sourceBuffer error:",e),r.hls.trigger(d.default.ERROR,{type:u.ErrorTypes.MEDIA_ERROR,details:u.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})},r.config=t.config,r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n=i.prototype;return n.destroy=function(){g.prototype.destroy.call(this)},n.onLevelPtsUpdated=function(e){var t=e.type,r=this.tracks.audio;if("audio"===t&&r&&"audio/mpeg"===r.container){var i=this.sourceBuffer.audio;if(!i)throw Error("Level PTS Updated and source buffer for audio uninitalized");if(Math.abs(i.timestampOffset-e.start)>.1){var n=i.updating;try{i.abort()}catch(e){f.logger.warn("can not abort audio buffer: "+e)}n?this.audioTimestampOffset=e.start:(f.logger.warn("change mpeg audio timestamp offset from "+i.timestampOffset+" to "+e.start),i.timestampOffset=e.start)}}},n.onManifestParsed=function(e){var t=2;(e.audio&&!e.video||!e.altAudio)&&(t=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=t,f.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},n.onMediaAttaching=function(e){var t=this.media=e.media;if(t&&Ye){var r=this.mediaSource=new Ye;r.addEventListener("sourceopen",this._onMediaSourceOpen),r.addEventListener("sourceended",this._onMediaSourceEnded),r.addEventListener("sourceclose",this._onMediaSourceClose),t.src=window.URL.createObjectURL(r),this._objectUrl=t.src}},n.onMediaDetaching=function(){f.logger.log("media source detaching");var e=this.mediaSource;if(e){if("open"===e.readyState)try{e.endOfStream()}catch(e){f.logger.warn("onMediaDetaching:"+e.message+" while calling endOfStream")}e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),this.media&&(this._objectUrl&&window.URL.revokeObjectURL(this._objectUrl),this.media.src===this._objectUrl?(this.media.removeAttribute("src"),this.media.load()):f.logger.warn("media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={},this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0}this.hls.trigger(d.default.MEDIA_DETACHED)},n.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.pendingTracks,r=Object.keys(t).length;(r&&!e||2===r)&&(this.createSourceBuffers(t),this.pendingTracks={},this.doAppending())},n.onBufferReset=function(){var e=this.sourceBuffer;for(var t in e){var r=e[t];try{r&&(this.mediaSource&&this.mediaSource.removeSourceBuffer(r),r.removeEventListener("updateend",this._onSBUpdateEnd),r.removeEventListener("error",this._onSBUpdateError))}catch(e){}}this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0},n.onBufferCodecs=function(e){var t=this;Object.keys(this.sourceBuffer).length||(Object.keys(e).forEach((function(r){t.pendingTracks[r]=e[r]})),this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},n.createSourceBuffers=function(e){var t=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(var i in e)if(!t[i]){var n=e[i];if(!n)throw Error("source buffer exists for track "+i+", however track does not");var s=n.levelCodec||n.codec,o=n.container+";codecs="+s;f.logger.log("creating sourceBuffer("+o+")");try{var a=t[i]=r.addSourceBuffer(o);a.addEventListener("updateend",this._onSBUpdateEnd),a.addEventListener("error",this._onSBUpdateError),this.tracks[i]={buffer:a,codec:s,id:n.id,container:n.container,levelCodec:n.levelCodec}}catch(e){f.logger.error("error while trying to add sourceBuffer:"+e.message),this.hls.trigger(d.default.ERROR,{type:u.ErrorTypes.MEDIA_ERROR,details:u.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,err:e,mimeType:o})}}this.hls.trigger(d.default.BUFFER_CREATED,{tracks:this.tracks})},n.onBufferAppending=function(e){this._needsFlush||(this.segments?this.segments.push(e):this.segments=[e],this.doAppending())},n.onBufferEos=function(e){for(var t in this.sourceBuffer)if(!e.type||e.type===t){var r=this.sourceBuffer[t];r&&!r.ended&&(r.ended=!0,f.logger.log(t+" sourceBuffer now EOS"))}this.checkEos()},n.checkEos=function(){var e=this.sourceBuffer,t=this.mediaSource;if(t&&"open"===t.readyState){for(var r in e){var i=e[r];if(i){if(!i.ended)return;if(i.updating)return void(this._needsEos=!0)}}f.logger.log("all media data are available, signal endOfStream() to MediaSource and stop loading fragment");try{t.endOfStream()}catch(e){f.logger.warn("exception while calling mediaSource.endOfStream()")}this._needsEos=!1}else this._needsEos=!1},n.onBufferFlushing=function(e){e.type?this.flushRange.push({start:e.startOffset,end:e.endOffset,type:e.type}):(this.flushRange.push({start:e.startOffset,end:e.endOffset,type:"video"}),this.flushRange.push({start:e.startOffset,end:e.endOffset,type:"audio"})),this.flushBufferCounter=0,this.doFlush()},n.flushLiveBackBuffer=function(){if(this._live){var e=this.config.liveBackBufferLength;if(isFinite(e)&&!(e<0))if(this.media)for(var t=this.media.currentTime,r=this.sourceBuffer,i=Object.keys(r),n=t-Math.max(e,this._levelTargetDuration),s=i.length-1;s>=0;s--){var o=i[s],a=r[o];if(a){var c=a.buffered;c.length>0&&n>c.start(0)&&this.removeBufferRange(o,a,0,n)&&this.hls.trigger(d.default.LIVE_BACK_BUFFER_REACHED,{bufferEnd:n})}}else f.logger.error("flushLiveBackBuffer called without attaching media")}},n.onLevelUpdated=function(e){var t=e.details;t.fragments.length>0&&(this._levelDuration=t.totalduration+t.fragments[0].start,this._levelTargetDuration=t.averagetargetduration||t.targetduration||10,this._live=t.live,this.updateMediaElementDuration())},n.updateMediaElementDuration=function(){var e,t=this.config;if(null!==this._levelDuration&&this.media&&this.mediaSource&&this.sourceBuffer&&0!==this.media.readyState&&"open"===this.mediaSource.readyState){for(var r in this.sourceBuffer){var i=this.sourceBuffer[r];if(i&&!0===i.updating)return}e=this.media.duration,null===this._msDuration&&(this._msDuration=this.mediaSource.duration),!0===this._live&&!0===t.liveDurationInfinity?(f.logger.log("Media Source duration is set to Infinity"),this._msDuration=this.mediaSource.duration=1/0):(this._levelDuration>this._msDuration&&this._levelDuration>e||!Object(l.isFiniteNumber)(e))&&(f.logger.log("Updating Media Source duration to "+this._levelDuration.toFixed(3)),this._msDuration=this.mediaSource.duration=this._levelDuration)}},n.doFlush=function(){for(;this.flushRange.length;){var e=this.flushRange[0];if(!this.flushBuffer(e.start,e.end,e.type))return void(this._needsFlush=!0);this.flushRange.shift(),this.flushBufferCounter=0}if(0===this.flushRange.length){this._needsFlush=!1;var t=0,r=this.sourceBuffer;try{for(var i in r){var n=r[i];n&&(t+=n.buffered.length)}}catch(e){f.logger.error("error while accessing sourceBuffer.buffered")}this.appended=t,this.hls.trigger(d.default.BUFFER_FLUSHED)}},n.doAppending=function(){var e=this.config,t=this.hls,r=this.segments,i=this.sourceBuffer;if(Object.keys(i).length){if(!this.media||this.media.error)return this.segments=[],void f.logger.error("trying to append although a media error occured, flush segment and abort");if(!this.appending){var n=r.shift();if(n)try{var s=i[n.type];if(!s)return void this._onSBUpdateEnd();if(s.updating)return void r.unshift(n);s.ended=!1,this.parent=n.parent,s.appendBuffer(n.data),this.appendError=0,this.appended++,this.appending=!0}catch(i){f.logger.error("error while trying to append buffer:"+i.message),r.unshift(n);var o={type:u.ErrorTypes.MEDIA_ERROR,parent:n.parent,details:"",fatal:!1};22===i.code?(this.segments=[],o.details=u.ErrorDetails.BUFFER_FULL_ERROR):(this.appendError++,o.details=u.ErrorDetails.BUFFER_APPEND_ERROR,this.appendError>e.appendErrorMaxRetry&&(f.logger.log("fail "+e.appendErrorMaxRetry+" times to append segment in sourceBuffer"),this.segments=[],o.fatal=!0)),t.trigger(d.default.ERROR,o)}}}},n.flushBuffer=function(e,t,r){var i=this.sourceBuffer;if(!Object.keys(i).length)return!0;var n="null";if(this.media&&(n=this.media.currentTime.toFixed(3)),f.logger.log("flushBuffer,pos/start/end: "+n+"/"+e+"/"+t),this.flushBufferCounter>=this.appended)return f.logger.warn("abort flushing too many retries"),!0;var s=i[r];if(s){if(s.ended=!1,s.updating)return f.logger.warn("cannot flush, sb updating in progress"),!1;if(this.removeBufferRange(r,s,e,t))return this.flushBufferCounter++,!1}return f.logger.log("buffer flushed"),!0},n.removeBufferRange=function(e,t,r,i){try{for(var n=0;n.5){var u="null";return this.media&&(u=this.media.currentTime.toString()),f.logger.log("sb remove "+e+" ["+a+","+c+"], of ["+s+","+o+"], pos:"+u),t.remove(a,c),!0}}}catch(e){f.logger.warn("removeBufferRange failed",e)}return!1},i}(g);function Ze(e,t){for(var r=0;rthis.autoLevelCapping&&t.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},a.getMaxLevel=function(e){var t=this;if(!this.levels)return-1;var r=this.levels.filter((function(r,n){return i.isLevelAllowed(n,t.restrictedLevels)&&n<=e}));return this.clientRect=null,i.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)},a.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),clearInterval(this.timer),this.timer=setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},a.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=null,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(this.timer=clearInterval(this.timer),this.timer=null)},a.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},i.isLevelAllowed=function(e,t){return void 0===t&&(t=[]),-1===t.indexOf(e)},i.getMaxLevelByMediaSize=function(e,t,r){if(!e||e&&!e.length)return-1;for(var i,n,s=e.length-1,o=0;o=t||a.height>=r)&&(i=a,!(n=e[o+1])||i.width!==n.width||i.height!==n.height)){s=o;break}}return s},n=i,o=[{key:"contentScaleFactor",get:function(){var e=1;try{e=window.devicePixelRatio}catch(e){}return e}}],(s=[{key:"mediaWidth",get:function(){return this.getDimensions().width*i.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*i.contentScaleFactor}}])&&Ze(n.prototype,s),o&&Ze(n,o),i}(g),Je=window.performance,et=function(e){var t,r;function i(t){return e.call(this,t,d.default.MEDIA_ATTACHING)||this}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n=i.prototype;return n.destroy=function(){this.timer&&clearInterval(this.timer),this.isVideoPlaybackQualityAvailable=!1},n.onMediaAttaching=function(e){var t=this.hls.config;t.capLevelOnFPSDrop&&("function"==typeof(this.video=e.media instanceof window.HTMLVideoElement?e.media:null).getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),clearInterval(this.timer),this.timer=setInterval(this.checkFPSInterval.bind(this),t.fpsDroppedMonitoringPeriod))},n.checkFPS=function(e,t,r){var i=Je.now();if(t){if(this.lastTime){var n=i-this.lastTime,s=r-this.lastDroppedFrames,o=t-this.lastDecodedFrames,a=1e3*s/n,c=this.hls;if(c.trigger(d.default.FPS_DROP,{currentDropped:s,currentDecoded:o,totalDroppedFrames:r}),a>0&&s>c.config.fpsDroppedMonitoringThreshold*o){var u=c.currentLevel;f.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(-1===c.autoLevelCapping||c.autoLevelCapping>=u)&&(u-=1,c.trigger(d.default.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:c.currentLevel}),c.autoLevelCapping=u,c.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},n.checkFPSInterval=function(){var e=this.video;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},i}(g),tt=function(){function e(e){e&&e.xhrSetup&&(this.xhrSetup=e.xhrSetup)}var t=e.prototype;return t.destroy=function(){this.abort(),this.loader=null},t.abort=function(){var e=this.loader;e&&4!==e.readyState&&(this.stats.aborted=!0,e.abort()),window.clearTimeout(this.requestTimeout),this.requestTimeout=null,window.clearTimeout(this.retryTimeout),this.retryTimeout=null},t.load=function(e,t,r){this.context=e,this.config=t,this.callbacks=r,this.stats={trequest:window.performance.now(),retry:0},this.retryDelay=t.retryDelay,this.loadInternal()},t.loadInternal=function(){var e,t=this.context;e=this.loader=new window.XMLHttpRequest;var r=this.stats;r.tfirst=0,r.loaded=0;var i=this.xhrSetup;try{if(i)try{i(e,t.url)}catch(r){e.open("GET",t.url,!0),i(e,t.url)}e.readyState||e.open("GET",t.url,!0)}catch(r){return void this.callbacks.onError({code:e.status,text:r.message},t,e)}t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),this.config.timeout),e.send()},t.readystatechange=function(e){var t=e.currentTarget,r=t.readyState,i=this.stats,n=this.context,s=this.config;if(!i.aborted&&r>=2)if(window.clearTimeout(this.requestTimeout),0===i.tfirst&&(i.tfirst=Math.max(window.performance.now(),i.trequest)),4===r){var o=t.status;if(o>=200&&o<300){var a,c;i.tload=Math.max(i.tfirst,window.performance.now()),c="arraybuffer"===n.responseType?(a=t.response).byteLength:(a=t.responseText).length,i.loaded=i.total=c;var u={url:t.responseURL,data:a};this.callbacks.onSuccess(u,i,n,t)}else i.retry>=s.maxRetry||o>=400&&o<499?(f.logger.error(o+" while loading "+n.url),this.callbacks.onError({code:o,text:t.statusText},n,t)):(f.logger.warn(o+" while loading "+n.url+", retrying in "+this.retryDelay+"..."),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,s.maxRetryDelay),i.retry++)}else this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),s.timeout)},t.loadtimeout=function(){f.logger.warn("timeout while loading "+this.context.url),this.callbacks.onTimeout(this.stats,this.context,null)},t.loadprogress=function(e){var t=e.currentTarget,r=this.stats;r.loaded=e.loaded,e.lengthComputable&&(r.total=e.total);var i=this.callbacks.onProgress;i&&i(r,this.context,null,t)},e}();function rt(e,t){for(var r=0;r=this.tracks.length)f.logger.warn("Invalid audio track id:",e.id);else{if(f.logger.log("audioTrack "+e.id+" loaded"),this.tracks[e.id].details=e.details,e.details.live&&!this.hasInterval()){var t=1e3*e.details.targetduration;this.setInterval(t)}!e.details.live&&this.hasInterval()&&this.clearInterval()}},a.onAudioTrackSwitched=function(e){var t=this.tracks[e.id].groupId;t&&this.audioGroupId!==t&&(this.audioGroupId=t)},a.onLevelLoaded=function(e){this._selectAudioGroup(e.level)},a.onError=function(e){e.type===u.ErrorTypes.NETWORK_ERROR&&(e.fatal&&this.clearInterval(),e.details===u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&(f.logger.warn("Network failure on audio-track id:",e.context.id),this._handleLoadError()))},a._setAudioTrack=function(e){if(this._trackId===e&&this.tracks[this._trackId].details)f.logger.debug("Same id as current audio-track passed, and track details available -> no-op");else if(e<0||e>=this.tracks.length)f.logger.warn("Invalid id passed to audio-track controller");else{var t=this.tracks[e];f.logger.log("Now switching to audio-track index "+e),this.clearInterval(),this._trackId=e;var r=t.url,i=t.type,n=t.id;this.hls.trigger(d.default.AUDIO_TRACK_SWITCHING,{id:n,type:i,url:r}),this._loadTrackDetailsIfNeeded(t)}},a.doTick=function(){this._updateTrack(this._trackId)},a._selectAudioGroup=function(e){var t=this.hls.levels[e];if(t&&t.audioGroupIds){var r=t.audioGroupIds[t.urlId];this.audioGroupId!==r&&(this.audioGroupId=r,this._selectInitialAudioTrack())}},a._selectInitialAudioTrack=function(){var e=this,t=this.tracks;if(t.length){var r=this.tracks[this._trackId],i=null;if(r&&(i=r.name),this._selectDefaultTrack){var n=t.filter((function(e){return e.default}));n.length?t=n:f.logger.warn("No default audio tracks defined")}var s=!1,o=function(){t.forEach((function(t){s||e.audioGroupId&&t.groupId!==e.audioGroupId||i&&i!==t.name||(e._setAudioTrack(t.id),s=!0)}))};o(),s||(i=null,o()),s||(f.logger.error("No track found for running audio group-ID: "+this.audioGroupId),this.hls.trigger(d.default.ERROR,{type:u.ErrorTypes.MEDIA_ERROR,details:u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))}},a._needsTrackLoading=function(e){var t=e.details,r=e.url;return!(t&&!t.live||!r)},a._loadTrackDetailsIfNeeded=function(e){if(this._needsTrackLoading(e)){var t=e.url,r=e.id;f.logger.log("loading audio-track playlist for id: "+r),this.hls.trigger(d.default.AUDIO_TRACK_LOADING,{url:t,id:r})}},a._updateTrack=function(e){if(!(e<0||e>=this.tracks.length)){this.clearInterval(),this._trackId=e,f.logger.log("trying to update audio-track "+e);var t=this.tracks[e];this._loadTrackDetailsIfNeeded(t)}},a._handleLoadError=function(){this.trackIdBlacklist[this._trackId]=!0;var e=this._trackId,t=this.tracks[e],r=t.name,i=t.language,n=t.groupId;f.logger.warn("Loading failed on audio track id: "+e+", group-id: "+n+', name/language: "'+r+'" / "'+i+'"');for(var s=e,o=0;o0&&-1===e?(f.logger.log("audio:override startPosition with lastCurrentTime @"+t.toFixed(3)),this.state=_e):(this.lastCurrentTime=this.startPosition?this.startPosition:e,this.state=we),this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()}else this.startPosition=e,this.state=ve},a.doTick=function(){var e,t,r,i=this.hls,n=i.config;switch(this.state){case Ce:case Ee:case Pe:break;case we:this.state=ke,this.loadedmetadata=!1;break;case _e:var s=this.tracks;if(!s)break;if(!this.media&&(this.startFragRequested||!n.startFragPrefetch))break;if(this.loadedmetadata)e=this.media.currentTime;else if(void 0===(e=this.nextLoadPosition))break;var o=this.mediaBuffer?this.mediaBuffer:this.media,a=this.videoBuffer?this.videoBuffer:this.media,c=eT||u.nextStart))return;f.logger.log("alt audio track ahead of main track, seek to start of alt audio track"),this.media.currentTime=T+.05}if(r.initSegment&&!r.initSegment.data)_=r.initSegment;else if(g<=T){if(_=E[0],null!==this.videoTrackCC&&_.cc!==this.videoTrackCC&&(_=function(e,t){return H.search(e,(function(e){return e.cct?-1:0}))}(E,this.videoTrackCC)),r.live&&_.loadIdx&&_.loadIdx===this.fragLoadIdx){var k=u.nextStart?u.nextStart:T;return f.logger.log("no alt audio available @currentTime:"+this.media.currentTime+", seeking @"+(k+.05)),void(this.media.currentTime=k+.05)}}else{var I,R=n.maxFragLookUpTolerance,P=y?E[y.sn-E[0].sn+1]:void 0;gA-R&&(R=0),I=P&&!pe(g,R,P)?P:H.search(E,(function(e){return pe(g,R,e)}))):I=E[S-1],I&&(_=I,T=I.start,y&&_.level===y.level&&_.sn===y.sn&&(_.sn=C||j)&&(f.logger.log("audioStreamController: retryDate reached, switch back to IDLE state"),this.state=_e);break;case je:var D=this.waitingFragment;if(D){var M=D.frag.cc;if(void 0!==this.initPTS[M])this.waitingFragment=null,this.state=Te,this.onFragLoaded(D);else if(this.videoTrackCC!==this.waitingVideoCC)f.logger.log("Waiting fragment cc ("+M+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var x=$.bufferInfo(this.mediaBuffer,this.media.currentTime,n.maxBufferHole);pe(x.end,n.maxFragLookUpTolerance,D.frag)<0&&(f.logger.log("Waiting fragment cc ("+M+") @ "+D.frag.start+" cancelled because another fragment at "+x.end+" is needed"),this.clearWaitingFragment())}}else this.state=_e}},a.clearWaitingFragment=function(){var e=this.waitingFragment;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingFragment=null,this.waitingVideoCC=null,this.state=_e)},a.onMediaAttached=function(e){var t=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("ended",this.onvended);var r=this.config;this.tracks&&r.autoStartLoad&&this.startLoad(r.startPosition)},a.onMediaDetaching=function(){var e=this.media;e&&e.ended&&(f.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},a.onAudioTracksUpdated=function(e){f.logger.log("audio tracks updated"),this.tracks=e.audioTracks},a.onAudioTrackSwitching=function(e){var t=!!e.url;this.trackId=e.id,this.fragCurrent=null,this.clearWaitingFragment(),this.state=Ee,t?this.setInterval(100):this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),t&&(this.audioSwitch=!0,this.state=_e),this.tick()},a.onAudioTrackLoaded=function(e){var t=e.details,r=e.id,i=this.tracks[r],n=i.details,s=t.totalduration,o=0;if(f.logger.log("track "+r+" loaded ["+t.startSN+","+t.endSN+"],duration:"+s),t.live||n&&n.live?n&&t.fragments.length>0?(oe(n,t),o=t.fragments[0].start,t.PTSKnown?f.logger.log("live audio playlist sliding:"+o.toFixed(3)):f.logger.log("live audio playlist - outdated PTS, unknown sliding")):(t.PTSKnown=!1,f.logger.log("live audio playlist - first load, unknown sliding")):t.PTSKnown=!1,i.details=t,!this.startFragRequested){if(-1===this.startPosition){var a=t.startTimeOffset;Object(l.isFiniteNumber)(a)?(f.logger.log("start time offset found in playlist, adjust startPosition to "+a),this.startPosition=a):t.live?(this.startPosition=this.computeLivePosition(o,t),f.logger.log("compute startPosition for audio-track to "+this.startPosition)):this.startPosition=0}this.nextLoadPosition=this.startPosition}this.state===ke&&(this.state=_e),this.tick()},a.onKeyLoaded=function(){this.state===Se&&(this.state=_e,this.tick())},a.onFragLoaded=function(e){var t=this.fragCurrent,r=e.frag;if(this.state===Te&&t&&"audio"===r.type&&r.level===t.level&&r.sn===t.sn){var i=this.tracks[this.trackId],n=i.details,s=n.totalduration,o=t.level,a=t.sn,c=t.cc,u=this.config.defaultAudioCodec||i.audioCodec||"mp4a.40.2",l=this.stats=e.stats;if("initSegment"===a)this.state=_e,l.tparsed=l.tbuffered=st.now(),n.initSegment.data=e.payload,this.hls.trigger(d.default.FRAG_BUFFERED,{stats:l,frag:t,id:"audio"}),this.tick();else{this.state=Ie,this.appended=!1,this.demuxer||(this.demuxer=new re(this.hls,"audio"));var h=this.initPTS[c],p=n.initSegment?n.initSegment.data:[];void 0!==h?(this.pendingBuffering=!0,f.logger.log("Demuxing "+a+" of ["+n.startSN+" ,"+n.endSN+"],track "+o),this.demuxer.push(e.payload,p,u,null,t,s,!1,h)):(f.logger.log("Unknown video PTS for cc "+c+", waiting for video PTS before demuxing audio frag "+a+" of ["+n.startSN+" ,"+n.endSN+"],track "+o),this.waitingFragment=e,this.waitingVideoCC=this.videoTrackCC,this.state=je)}}this.fragLoadError=0},a.onFragParsingInitSegment=function(e){var t=this.fragCurrent,r=e.frag;if(t&&"audio"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===Ie){var i,n=e.tracks;if(n.video&&delete n.video,i=n.audio){i.levelCodec=i.codec,i.id=e.id,this.hls.trigger(d.default.BUFFER_CODECS,n),f.logger.log("audio track:audio,container:"+i.container+",codecs[level/parsed]=["+i.levelCodec+"/"+i.codec+"]");var s=i.initSegment;if(s){var o={type:"audio",data:s,parent:"audio",content:"initSegment"};this.audioSwitch?this.pendingData=[o]:(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(d.default.BUFFER_APPENDING,o))}this.tick()}}},a.onFragParsingData=function(e){var t=this,r=this.fragCurrent,i=e.frag;if(r&&"audio"===e.id&&"audio"===e.type&&i.sn===r.sn&&i.level===r.level&&this.state===Ie){var n=this.trackId,s=this.tracks[n],o=this.hls;Object(l.isFiniteNumber)(e.endPTS)||(e.endPTS=e.startPTS+r.duration,e.endDTS=e.startDTS+r.duration),r.addElementaryStream(b.AUDIO),f.logger.log("parsed "+e.type+",PTS:["+e.startPTS.toFixed(3)+","+e.endPTS.toFixed(3)+"],DTS:["+e.startDTS.toFixed(3)+"/"+e.endDTS.toFixed(3)+"],nb:"+e.nb),se(s.details,r,e.startPTS,e.endPTS);var a=this.media,c=!1;if(this.audioSwitch)if(a&&a.readyState){var h=a.currentTime;f.logger.log("switching audio track : currentTime:"+h),h>=e.startPTS&&(f.logger.log("switching audio track : flushing all audio"),this.state=Pe,o.trigger(d.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),c=!0,this.audioSwitch=!1,o.trigger(d.default.AUDIO_TRACK_SWITCHED,{id:n}))}else this.audioSwitch=!1,o.trigger(d.default.AUDIO_TRACK_SWITCHED,{id:n});var p=this.pendingData;if(!p)return f.logger.warn("Apparently attempt to enqueue media payload without codec initialization data upfront"),void o.trigger(d.default.ERROR,{type:u.ErrorTypes.MEDIA_ERROR,details:null,fatal:!0});this.audioSwitch||([e.data1,e.data2].forEach((function(t){t&&t.length&&p.push({type:e.type,data:t,parent:"audio",content:"data"})})),!c&&p.length&&(p.forEach((function(e){t.state===Ie&&(t.pendingBuffering=!0,t.hls.trigger(d.default.BUFFER_APPENDING,e))})),this.pendingData=[],this.appended=!0)),this.tick()}},a.onFragParsed=function(e){var t=this.fragCurrent,r=e.frag;t&&"audio"===e.id&&r.sn===t.sn&&r.level===t.level&&this.state===Ie&&(this.stats.tparsed=st.now(),this.state=Re,this._checkAppendedParsed())},a.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},a.onBufferCreated=function(e){var t=e.tracks.audio;t&&(this.mediaBuffer=t.buffer,this.loadedmetadata=!0),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer)},a.onBufferAppended=function(e){if("audio"===e.parent){var t=this.state;t!==Ie&&t!==Re||(this.pendingBuffering=e.pending>0,this._checkAppendedParsed())}},a._checkAppendedParsed=function(){if(!(this.state!==Re||this.appended&&this.pendingBuffering)){var e=this.fragCurrent,t=this.stats,r=this.hls;if(e){this.fragPrevious=e,t.tbuffered=st.now(),r.trigger(d.default.FRAG_BUFFERED,{stats:t,frag:e,id:"audio"});var i=this.mediaBuffer?this.mediaBuffer:this.media;i&&f.logger.log("audio buffered : "+ue.toString(i.buffered)),this.audioSwitch&&this.appended&&(this.audioSwitch=!1,r.trigger(d.default.AUDIO_TRACK_SWITCHED,{id:this.trackId})),this.state=_e}this.tick()}},a.onError=function(e){var t=e.frag;if(!t||"audio"===t.type)switch(e.details){case u.ErrorDetails.FRAG_LOAD_ERROR:case u.ErrorDetails.FRAG_LOAD_TIMEOUT:var r=e.frag;if(r&&"audio"!==r.type)break;if(!e.fatal){var i=this.fragLoadError;i?i++:i=1;var n=this.config;if(i<=n.fragLoadingMaxRetry){this.fragLoadError=i;var s=Math.min(Math.pow(2,i-1)*n.fragLoadingRetryDelay,n.fragLoadingMaxRetryTimeout);f.logger.warn("AudioStreamController: frag loading failed, retry in "+s+" ms"),this.retryDate=st.now()+s,this.state=Ae}else f.logger.error("AudioStreamController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=Ce}break;case u.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case u.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:case u.ErrorDetails.KEY_LOAD_ERROR:case u.ErrorDetails.KEY_LOAD_TIMEOUT:this.state!==Ce&&(this.state=e.fatal?Ce:_e,f.logger.warn("AudioStreamController: "+e.details+" while loading frag, now switching to "+this.state+" state ..."));break;case u.ErrorDetails.BUFFER_FULL_ERROR:if("audio"===e.parent&&(this.state===Ie||this.state===Re)){var o=this.mediaBuffer,a=this.media.currentTime;if(o&&$.isBuffered(o,a)&&$.isBuffered(o,a+.5)){var c=this.config;c.maxMaxBufferLength>=c.maxBufferLength&&(c.maxMaxBufferLength/=2,f.logger.warn("AudioStreamController: reduce max buffer length to "+c.maxMaxBufferLength+"s")),this.state=_e}else f.logger.warn("AudioStreamController: buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,this.state=Pe,this.hls.trigger(d.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"})}}},a.onBufferFlushed=function(){var e=this,t=this.pendingData;t&&t.length?(f.logger.log("AudioStreamController: appending pending audio data after buffer flushed"),t.forEach((function(t){e.hls.trigger(d.default.BUFFER_APPENDING,t)})),this.appended=!0,this.pendingData=[],this.state=Re):(this.state=_e,this.fragPrevious=null,this.tick())},n=i,(s=[{key:"state",set:function(e){if(this.state!==e){var t=this.state;this._state=e,f.logger.log("audio stream:"+t+"->"+e)}},get:function(){return this._state}}])&&nt(n.prototype,s),o&&nt(n,o),i}(Me),at=function(){if("undefined"!=typeof window&&window.VTTCue)return window.VTTCue;var e={"":!0,lr:!0,rl:!0},t={start:!0,middle:!0,end:!0,left:!0,right:!0};function r(e){return"string"==typeof e&&!!t[e.toLowerCase()]&&e.toLowerCase()}function i(e){for(var t=1;t100)throw new Error("Position must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",i({},a,{get:function(){return v},set:function(e){var t=r(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");v=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",i({},a,{get:function(){return w},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");w=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",i({},a,{get:function(){return _},set:function(e){var t=r(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");_=t,this.hasBeenReset=!0}})),o.displayState=void 0}return n.prototype.getCueAsHTML=function(){return window.WebVTT.convertCueToDOMTree(window,this.text)},n}(),ct=function(){return{decode:function(e){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}};function ut(){this.window=window,this.state="INITIAL",this.buffer="",this.decoder=new ct,this.regionList=[]}function lt(){this.values=Object.create(null)}function dt(e,t,r,i){var n=i?e.split(i):[e];for(var s in n)if("string"==typeof n[s]){var o=n[s].split(r);2===o.length&&t(o[0],o[1])}}lt.prototype={set:function(e,t){this.get(e)||""===t||(this.values[e]=t)},get:function(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t},has:function(e){return e in this.values},alt:function(e,t,r){for(var i=0;i=0&&t<=100)&&(this.set(e,t),!0)}};var ft=new at(0,0,0),ht="middle"===ft.align?"middle":"center";function pt(e,t,r){var i=e;function n(){var t=function(e){function t(e,t,r,i){return 3600*(0|e)+60*(0|t)+(0|r)+(0|i)/1e3}var r=e.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);return r?r[3]?t(r[1],r[2],r[3].replace(":",""),r[4]):r[1]>59?t(r[1],r[2],0,r[4]):t(0,r[1],r[2],r[4]):null}(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function s(){e=e.replace(/^\s+/,"")}if(s(),t.startTime=n(),s(),"--\x3e"!==e.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=e.substr(3),s(),t.endTime=n(),s(),function(e,t){var i=new lt;dt(e,(function(e,t){switch(e){case"region":for(var n=r.length-1;n>=0;n--)if(r[n].id===t){i.set(e,r[n].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":var s=t.split(","),o=s[0];i.integer(e,o),i.percent(e,o)&&i.set("snapToLines",!1),i.alt(e,o,["auto"]),2===s.length&&i.alt("lineAlign",s[1],["start",ht,"end"]);break;case"position":s=t.split(","),i.percent(e,s[0]),2===s.length&&i.alt("positionAlign",s[1],["start",ht,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",ht,"end","left","right"])}}),/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");var n=i.get("line","auto");"auto"===n&&-1===ft.line&&(n=-1),t.line=n,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",ht);var s=i.get("position","auto");"auto"===s&&50===ft.position&&(s="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=s}(e,t)}function gt(e){return e.replace(//gi,"\n")}ut.prototype={parse:function(e){var t=this;function r(){var e=t.buffer,r=0;for(e=gt(e);r=16?a--:a++,navigator.userAgent.match(/Firefox\//)?s.line=d+1:s.line=d>7?d-2:d+1,s.align="left",s.position=Math.max(0,Math.min(100,a/32*100)),u.push(s),e&&e.addCue(s)}return u}var bt,vt,wt={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},_t=function(e){var t=e;return wt.hasOwnProperty(e)&&(t=wt[e]),String.fromCharCode(t)},Et=15,St=100,Tt={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},At={17:2,18:4,21:6,22:8,23:10,19:13,20:15},kt={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},It={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Rt=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];(vt=bt||(bt={}))[vt.ERROR=0]="ERROR",vt[vt.TEXT=1]="TEXT",vt[vt.WARNING=2]="WARNING",vt[vt.INFO=2]="INFO",vt[vt.DEBUG=3]="DEBUG",vt[vt.DATA=3]="DATA";var Pt=function(){function e(){this.time=null,this.verboseLevel=bt.ERROR}return e.prototype.log=function(e,t){this.verboseLevel>=e&&f.logger.log(this.time+" ["+e+"] "+t)},e}(),Ot=function(e){for(var t=[],r=0;rSt&&(this.logger.log(bt.DEBUG,"Too large cursor position "+this.pos),this.pos=St)},t.moveCursor=function(e){var t=this.pos+e;if(e>1)for(var r=this.pos+1;r=144&&this.backSpace();var t=_t(e);this.pos>=St?this.logger.log(bt.ERROR,"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))},t.clearFromPos=function(e){var t;for(t=e;t0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r},t.getTextAndFormat=function(){return this.rows},e}(),xt=function(){function e(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new Mt(r),this.nonDisplayedMemory=new Mt(r),this.lastOutputScreen=new Mt(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}var t=e.prototype;return t.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},t.getHandler=function(){return this.outputFilter},t.setHandler=function(e){this.outputFilter=e},t.setPAC=function(e){this.writeScreen.setPAC(e)},t.setBkgData=function(e){this.writeScreen.setBkgData(e)},t.setMode=function(e){e!==this.mode&&(this.mode=e,this.logger.log(bt.INFO,"MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)},t.insertChars=function(e){for(var t=0;t=46,t.italics)t.foreground="white";else{var r=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}this.logger.log(bt.INFO,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},t.outputDataUpdate=function(e){void 0===e&&(e=!1);var t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))},t.cueSplitAtTime=function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))},e}();function Bt(e,t,r){r.a=e,r.b=t}function Lt(e,t,r){return r.a===e&&r.b===t}var Nt=function(){function e(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var i=new Pt;this.channels=[null,new xt(e,t,i),new xt(e+1,r,i)],this.cmdHistory={a:null,b:null},this.logger=i}var t=e.prototype;return t.getHandler=function(e){return this.channels[e].getHandler()},t.setHandler=function(e,t){this.channels[e].setHandler(t)},t.addData=function(e,t){var r,i,n,s=!1;this.logger.time=e;for(var o=0;o ("+Ot([i,n])+")"),(r=this.parseCmd(i,n))||(r=this.parseMidrow(i,n)),r||(r=this.parsePAC(i,n)),r||(r=this.parseBackgroundAttributes(i,n)),!r&&(s=this.parseChars(i,n))){var a=this.currentChannel;a&&a>0?this.channels[a].insertChars(s):this.logger.log(bt.WARNING,"No channel found yet. TEXT-MODE?")}r||s||this.logger.log(bt.WARNING,"Couldn't parse cleaned data "+Ot([i,n])+" orig: "+Ot([t[o],t[o+1]]))}},t.parseCmd=function(e,t){var r=this.cmdHistory;if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=33&&t<=35))return!1;if(Lt(e,t,r))return Bt(null,null,r),this.logger.log(bt.DEBUG,"Repeated command ("+Ot([e,t])+") is dropped"),!0;var i=20===e||21===e||23===e?1:2,n=this.channels[i];return 20===e||21===e||28===e||29===e?32===t?n.ccRCL():33===t?n.ccBS():34===t?n.ccAOF():35===t?n.ccAON():36===t?n.ccDER():37===t?n.ccRU(2):38===t?n.ccRU(3):39===t?n.ccRU(4):40===t?n.ccFON():41===t?n.ccRDC():42===t?n.ccTR():43===t?n.ccRTD():44===t?n.ccEDM():45===t?n.ccCR():46===t?n.ccENM():47===t&&n.ccEOC():n.ccTO(t-32),Bt(e,t,r),this.currentChannel=i,!0},t.parseMidrow=function(e,t){var r=0;if((17===e||25===e)&&t>=32&&t<=47){if((r=17===e?1:2)!==this.currentChannel)return this.logger.log(bt.ERROR,"Mismatch channel in midrow parsing"),!1;var i=this.channels[r];return!!i&&(i.ccMIDROW(t),this.logger.log(bt.DEBUG,"MIDROW ("+Ot([e,t])+")"),!0)}return!1},t.parsePAC=function(e,t){var r,i=this.cmdHistory;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127||(16===e||24===e)&&t>=64&&t<=95))return!1;if(Lt(e,t,i))return Bt(null,null,i),!0;var n=e<=23?1:2;r=t>=64&&t<=95?1===n?Tt[e]:kt[e]:1===n?At[e]:It[e];var s=this.channels[n];return!!s&&(s.setPAC(this.interpretPAC(r,t)),Bt(e,t,i),this.currentChannel=n,!0)},t.interpretPAC=function(e,t){var r=t,i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=1==(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i},t.parseChars=function(e,t){var r,i=null,n=null;if(e>=25?(r=2,n=e-8):(r=1,n=e),n>=17&&n<=19){var s=t;s=17===n?t+80:18===n?t+112:t+144,this.logger.log(bt.INFO,"Special char '"+_t(s)+"' in channel "+r),i=[s]}else e>=32&&e<=127&&(i=0===t?[e]:[e,t]);if(i){var o=Ot(i);this.logger.log(bt.DEBUG,"Char codes = "+o.join(",")),Bt(e,t,this.cmdHistory)}return i},t.parseBackgroundAttributes=function(e,t){var r;if(!((16===e||24===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=45&&t<=47))return!1;var i={};16===e||24===e?(r=Math.floor((t-32)/2),i.background=Rt[r],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0));var n=e<=23?1:2;return this.channels[n].setBkgData(i),Bt(e,t,this.cmdHistory),!0},t.reset=function(){for(var e=0;ee)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},t.reset=function(){this.cueRanges=[]},e}(),Ft=function(e,t,r){return e.substr(r||0,t.length)===t},Kt=function(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()},zt={parse:function(e,t,r,i,n,s){var o,a=Object(Fe.utf8ArrayToStr)(new Uint8Array(e)).trim().replace(/\r\n|\n\r|\n|\r/g,"\n").split("\n"),c="00:00.000",u=0,d=0,f=0,h=[],p=!0,g=!1,y=new yt;y.oncue=function(e){var t=r[i],n=r.ccOffset;t&&t.new&&(void 0!==d?n=r.ccOffset=t.start:function(e,t,r){var i=e[t],n=e[i.prevCC];if(!n||!n.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);for(;n&&n.new;)e.ccOffset+=i.start-n.start,i.new=!1,n=e[(i=n).prevCC];e.presentationOffset=r}(r,i,f)),f&&(n=f-r.presentationOffset),g&&(e.startTime+=n-d,e.endTime+=n-d),e.id=Kt(e.startTime.toString())+Kt(e.endTime.toString())+Kt(e.text),e.text=decodeURIComponent(encodeURIComponent(e.text)),e.endTime>0&&h.push(e)},y.onparsingerror=function(e){o=e},y.onflush=function(){o&&s?s(o):n(h)},a.forEach((function(e){if(p){if(Ft(e,"X-TIMESTAMP-MAP=")){p=!1,g=!0,e.substr(16).split(",").forEach((function(e){Ft(e,"LOCAL:")?c=e.substr(6):Ft(e,"MPEGTS:")&&(u=parseInt(e.substr(7)))}));try{t+(9e4*r[i].start||0)<0&&(t+=8589934592),u-=t,d=function(e){var t=parseInt(e.substr(-3)),r=parseInt(e.substr(-6,2)),i=parseInt(e.substr(-9,2)),n=e.length>9?parseInt(e.substr(0,e.indexOf(":"))):0;if(!(Object(l.isFiniteNumber)(t)&&Object(l.isFiniteNumber)(r)&&Object(l.isFiniteNumber)(i)&&Object(l.isFiniteNumber)(n)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+e);return t+=1e3*r,(t+=6e4*i)+36e5*n}(c)/1e3,f=u/9e4}catch(e){g=!1,o=e}return}""===e&&(p=!1)}y.parse(e+"\n")})),y.flush()}};function Vt(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function qt(e,t){return e&&e.label===t.name&&!(e.textTrack1||e.textTrack2)}var Gt=function(e){var t,r;function i(t){var r;if((r=e.call(this,t,d.default.MEDIA_ATTACHING,d.default.MEDIA_DETACHING,d.default.FRAG_PARSING_USERDATA,d.default.FRAG_DECRYPTED,d.default.MANIFEST_LOADING,d.default.MANIFEST_LOADED,d.default.FRAG_LOADED,d.default.INIT_PTS_FOUND)||this).media=null,r.config=void 0,r.enabled=!0,r.Cues=void 0,r.textTracks=[],r.tracks=[],r.initPTS=[],r.unparsedVttFrags=[],r.captionsTracks={},r.nonNativeCaptionsTracks={},r.captionsProperties=void 0,r.cea608Parser1=void 0,r.cea608Parser2=void 0,r.lastSn=-1,r.prevCC=-1,r.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},r.hls=t,r.config=t.config,r.Cues=t.config.cueHandler,r.captionsProperties={textTrack1:{label:r.config.captionsTextTrack1Label,languageCode:r.config.captionsTextTrack1LanguageCode},textTrack2:{label:r.config.captionsTextTrack2Label,languageCode:r.config.captionsTextTrack2LanguageCode},textTrack3:{label:r.config.captionsTextTrack3Label,languageCode:r.config.captionsTextTrack3LanguageCode},textTrack4:{label:r.config.captionsTextTrack4Label,languageCode:r.config.captionsTextTrack4LanguageCode}},r.config.enableCEA708Captions){var i=new Ut(Vt(r),"textTrack1"),n=new Ut(Vt(r),"textTrack2"),s=new Ut(Vt(r),"textTrack3"),o=new Ut(Vt(r),"textTrack4");r.cea608Parser1=new Nt(1,i,n),r.cea608Parser2=new Nt(3,s,o)}return r}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,t.__proto__=r;var n=i.prototype;return n.addCues=function(e,t,r,i,n){for(var s,o,a,c,u=!1,l=n.length;l--;){var f=n[l],h=(s=f[0],o=f[1],a=t,c=r,Math.min(o,c)-Math.max(s,a));if(h>=0&&(f[0]=Math.min(f[0],t),f[1]=Math.max(f[1],r),u=!0,h/(r-t)>.5))return}if(u||n.push([t,r]),this.config.renderTextTracksNatively)this.Cues.newCue(this.captionsTracks[e],t,r,i);else{var p=this.Cues.newCue(null,t,r,i);this.hls.trigger(d.default.CUES_PARSED,{type:"captions",cues:p,track:e})}},n.onInitPtsFound=function(e){var t=this,r=e.frag,i=e.id,n=e.initPTS,s=this.unparsedVttFrags;"main"===i&&(this.initPTS[r.cc]=n),s.length&&(this.unparsedVttFrags=[],s.forEach((function(e){t.onFragLoaded(e)})))},n.getExistingTrack=function(e){var t=this.media;if(t)for(var r=0;r=s.length||r!==n||!o||this.stopped)this._clearReloadTimer();else if(f.logger.log("subtitle track "+r+" loaded"),i.live){var a=ce(o.details,i,e.stats.trequest);f.logger.log("Reloading live subtitle playlist in "+a+"ms"),this.timer=setTimeout((function(){t._loadCurrentTrack()}),a)}else this._clearReloadTimer()},a.startLoad=function(){this.stopped=!1,this._loadCurrentTrack()},a.stopLoad=function(){this.stopped=!0,this._clearReloadTimer()},a._clearReloadTimer=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},a._loadCurrentTrack=function(){var e=this.trackId,t=this.tracks,r=this.hls,i=t[e];e<0||!i||i.details&&!i.details.live||(f.logger.log("Loading subtitle track "+e),r.trigger(d.default.SUBTITLE_TRACK_LOADING,{url:i.url,id:e}))},a._toggleTrackModes=function(e){var t=this.media,r=this.subtitleDisplay,i=this.trackId;if(t){var n=$t(t.textTracks);if(-1===e)[].slice.call(n).forEach((function(e){e.mode="disabled"}));else{var s=n[i];s&&(s.mode="disabled")}var o=n[e];o&&(o.mode=r?"showing":"hidden")}},a._setSubtitleTrackInternal=function(e){var t=this.hls,r=this.tracks;!Object(l.isFiniteNumber)(e)||e<-1||e>=r.length||(this.trackId=e,f.logger.log("Switching to subtitle track "+e),t.trigger(d.default.SUBTITLE_TRACK_SWITCH,{id:e}),this._loadCurrentTrack())},a._onTextTracksChanged=function(){if(this.media&&this.hls.config.renderTextTracksNatively){for(var e=-1,t=$t(this.media.textTracks),r=0;r=i[o].start&&s<=i[o].end){n=i[o];break}var a=t.start+t.duration;n?n.end=a:(n={start:s,end:a},i.push(n))}}},n.onMediaAttached=function(e){var t=e.media;this.media=t,t.addEventListener("seeking",this._onMediaSeeking),this.state=_e},n.onMediaDetaching=function(){var e=this;this.media&&(this.media.removeEventListener("seeking",this._onMediaSeeking),this.fragmentTracker.removeAllFragments(),this.currentTrackId=-1,this.tracks.forEach((function(t){e.tracksBuffered[t.id]=[]})),this.media=null,this.state=ve)},n.onError=function(e){var t=e.frag;t&&"subtitle"===t.type&&(this.fragCurrent&&this.fragCurrent.loader&&this.fragCurrent.loader.abort(),this.state=_e)},n.onSubtitleTracksUpdated=function(e){var t=this;f.logger.log("subtitle tracks updated"),this.tracksBuffered=[],this.tracks=e.subtitleTracks,this.tracks.forEach((function(e){t.tracksBuffered[e.id]=[]}))},n.onSubtitleTrackSwitch=function(e){if(this.currentTrackId=e.id,this.tracks&&this.tracks.length&&-1!==this.currentTrackId){var t=this.tracks[this.currentTrackId];t&&t.details&&this.setInterval(500)}else this.clearInterval()},n.onSubtitleTrackLoaded=function(e){var t=e.id,r=e.details,i=this.currentTrackId,n=this.tracks,s=n[i];t>=n.length||t!==i||!s||(r.live&&function(e,t,r){void 0===r&&(r=0);var i=-1;ae(e,t,(function(e,t,r){t.start=e.start,i=r}));var n=t.fragments;if(i<0)n.forEach((function(e){e.start+=r}));else for(var s=i+1;s0&&r&&r.key&&"AES-128"===r.method){var s=Qt.now();this.decrypter.decrypt(e.payload,r.key.buffer,r.iv.buffer,(function(e){var t=Qt.now();n.trigger(d.default.FRAG_DECRYPTED,{frag:i,payload:e,stats:{tstart:s,tdecrypt:t}})}))}},n.onLevelUpdated=function(e){var t=e.details.fragments;this.lastAVStart=t.length?t[0].start:0},n.doTick=function(){if(this.media)switch(this.state){case _e:var e=this.config,t=this.currentTrackId,r=this.fragmentTracker,i=this.media,n=this.tracks;if(!n||!n[t]||!n[t].details)break;var s,o=e.maxBufferHole,a=e.maxFragLookUpTolerance,c=Math.min(e.maxBufferLength,e.maxMaxBufferLength),u=$.bufferedInfo(this._getBuffered(),i.currentTime,o),l=u.end,h=u.len,p=n[t].details,g=p.fragments,y=g.length,m=g[y-1].start+g[y-1].duration;if(h>c)return;var b=this.fragPrevious;li)&&(this.fragCurrent.loader&&this.fragCurrent.loader.abort(),this.fragmentTracker.removeFragment(this.fragCurrent),this.fragCurrent=null,this.fragPrevious=null,this.state=_e,this.tick())}},i}(Me);(Yt=Wt||(Wt={})).WIDEVINE="com.widevine.alpha",Yt.PLAYREADY="com.microsoft.playready";var er="undefined"!=typeof window&&window.navigator&&window.navigator.requestMediaKeySystemAccess?window.navigator.requestMediaKeySystemAccess.bind(window.navigator):null;function tr(e,t){for(var r=0;r3)return void this.hls.trigger(d.default.ERROR,{type:u.ErrorTypes.KEY_SYSTEM_ERROR,details:u.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});var n=3-this._requestLicenseFailureCount+1;f.logger.warn("Retrying license request, "+n+" attempts left"),this._requestLicense(r,i)}},a._generateLicenseRequestChallenge=function(e,t){if(e.mediaKeySystemDomain===Wt.WIDEVINE)return t;throw new Error("unsupported key-system: "+e.mediaKeySystemDomain)},a._requestLicense=function(e,t){f.logger.log("Requesting content license for key-system");var r=this._mediaKeysList[0];if(!r)return f.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),void this.hls.trigger(d.default.ERROR,{type:u.ErrorTypes.KEY_SYSTEM_ERROR,details:u.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});try{var i=this.getLicenseServerUrl(r.mediaKeySystemDomain),n=this._createLicenseXhr(i,e,t);f.logger.log("Sending license request to URL: "+i);var s=this._generateLicenseRequestChallenge(r,e);n.send(s)}catch(e){f.logger.error("Failure requesting DRM license: "+e),this.hls.trigger(d.default.ERROR,{type:u.ErrorTypes.KEY_SYSTEM_ERROR,details:u.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},a.onMediaAttached=function(e){if(this._emeEnabled){var t=e.media;this._media=t,t.addEventListener("encrypted",this._onMediaEncrypted)}},a.onMediaDetached=function(){var e=this._media,t=this._mediaKeysList;e&&(e.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(t.map((function(e){if(e.mediaKeysSession)return e.mediaKeysSession.close().catch((function(){}))}))).then((function(){return e.setMediaKeys(null)})).catch((function(){})))},a.onManifestParsed=function(e){if(this._emeEnabled){var t=e.levels.map((function(e){return e.audioCodec})),r=e.levels.map((function(e){return e.videoCodec}));this._attemptKeySystemAccess(Wt.WIDEVINE,t,r)}},n=i,(s=[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}])&&tr(n.prototype,s),o&&tr(n,o),i}(g);function ir(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function nr(e){for(var t=1;tt)return i;return 0}},{key:"maxAutoLevel",get:function(){var e=this.levels,t=this.autoLevelCapping;return-1===t&&e&&e.length?e.length-1:t}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"liveSyncPosition",get:function(){return this.streamController.liveSyncPosition}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}}]),i}(J);hr.defaultConfig=void 0},"./src/polyfills/number.js":function(e,t,r){"use strict";r.r(t),r.d(t,"isFiniteNumber",(function(){return i})),r.d(t,"MAX_SAFE_INTEGER",(function(){return n}));var i=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},n=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/utils/get-self-scope.js":function(e,t,r){"use strict";function i(){return"undefined"==typeof window?self:window}r.r(t),r.d(t,"getSelfScope",(function(){return i}))},"./src/utils/logger.js":function(e,t,r){"use strict";r.r(t),r.d(t,"enableLogs",(function(){return l})),r.d(t,"logger",(function(){return d}));var i=r(/*! ./get-self-scope */"./src/utils/get-self-scope.js");function n(){}var s={trace:n,debug:n,log:n,warn:n,info:n,error:n},o=s;function a(e,t){return t="["+e+"] > "+t}var c=Object(i.getSelfScope)();function u(e){var t=c.console[e];return t?function(){for(var r=arguments.length,i=new Array(r),n=0;n1?t-1:0),i=1;i{const s="arraybuffer"===t.responseType?i:n(i);e.loaded=e.total=s.length,e.tload=Math.max(e.tfirst,performance.now());const o={url:t.url,data:s};r.onSuccess(o,e,t)}),console.error);else{var c=this.tsListProvider()[o];c&&this.cat(c).then((s=>{let o;o=i.isBuffer(s)?n(s):s,e.loaded=e.total=o.length,e.tload=Math.max(e.tfirst,performance.now());const a={url:t.url,data:o};r.onSuccess(a,e,t)}))}else{const s=this.m3u8provider();let o;o=i.isBuffer(s)?n(s):s;const a={url:t.url,data:o};r.onSuccess(a,e,t)}}}},{buffer:"etowf"}]},["fsddd"],"fsddd"); //# sourceMappingURL=index.f7af227f.js.map