diff --git a/rln-js/404.html b/rln-js/404.html new file mode 100644 index 0000000..d55b13c --- /dev/null +++ b/rln-js/404.html @@ -0,0 +1 @@ +404: This page could not be found.RLN Example

404

This page could not be found.

\ No newline at end of file diff --git a/rln-js/README.md b/rln-js/README.md deleted file mode 100644 index a7127dd..0000000 --- a/rln-js/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# Using [RLN](https://rfc.vac.dev/spec/32/) in JavaScript - -> Rate limiting nullifier (RLN) is a construct based on zero-knowledge proofs -> that provides an anonymous rate-limited signaling/messaging framework -> suitable for decentralized (and centralized) environments - -**Demonstrates**: - -- RLN: - - Generate credentials - - Insert membership to smart contract (Goerli testnet) - - Retrieve smart contract state - - Generate and send proofs - - Verify incoming proofs -- Pure Javascript/HTML. -- Use minified bundle of js from unpkg.com, no import, no package manager. - -To test the example: - -```shell -git clone https://github.com/waku-org/js-waku-examples -cd js-waku-examples/examples/rln-js -npm install -npm run start -# open http://127.0.0.1:8080 In your browser -``` - -**There are a known issue using this webapp with Firefox + MetaMask. Try Chrome or Brave if you encounter any issue**. - -The `master` branch's HEAD is deployed at https://examples.waku.org/rln-js/. diff --git a/rln-js/_next/static/chunks/240-cd5c5e1cf9cc143f.js b/rln-js/_next/static/chunks/240-cd5c5e1cf9cc143f.js new file mode 100644 index 0000000..e47e0fc --- /dev/null +++ b/rln-js/_next/static/chunks/240-cd5c5e1cf9cc143f.js @@ -0,0 +1 @@ +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[240],{7420:function(){},5856:function(){},6601:function(){},2678:function(){},5819:function(){},4112:function(){},1265:function(){},5539:function(){},4280:function(e,t,r){Promise.resolve().then(r.bind(r,3663))},3663:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return Home}});var n,s,i,a,o,l,c,d,u,h=r(7437);(o||(o={})).FlexHorizontal="flex-horizontal";let Block=e=>{let t="flex-horizontal"===e.type?"items-center justify-between lg:flex":"",r=e.className||"";return(0,h.jsx)("div",{className:"".concat(t," ").concat(r),children:e.children})},Title=e=>(0,h.jsx)("h1",{className:"text-4xl ".concat(e.className||""),children:e.children}),Status=e=>(0,h.jsxs)("p",{className:"text-s",children:[e.text,":"," ",(0,h.jsx)("span",{className:"underline underline-offset-3 decoration-4 decoration-blue-400 dark:decoration-blue-600",children:e.mark})]});var m=r(4660);let g="none",y=(0,m.Ue)(e=>({appStatus:g,setAppStatus:t=>e(e=>({...e,appStatus:t})),ethAccount:"",setEthAccount:t=>e(e=>({...e,ethAccount:t})),chainID:void 0,setChainID:t=>e(e=>({...e,chainID:t})),lastMembershipID:void 0,setLastMembershipID:t=>e(e=>({...e,lastMembershipID:t})),credentials:void 0,setCredentials:t=>e(e=>({...e,credentials:t})),wakuStatus:g,setWakuStatus:t=>e(e=>({...e,wakuStatus:t})),activeCredential:g,setActiveCredential:t=>e(e=>({...e,activeCredential:t})),keystoreCredentials:[],setKeystoreCredentials:t=>e(e=>({...e,keystoreCredentials:t})),activeMembershipID:void 0,setActiveMembershipID:t=>e(e=>({...e,activeMembershipID:t}))}));var x=r(2265),k=r(379),f=r(3981);let isBrowserProviderValid=e=>!!e&&"function"==typeof e.request,isEthereumEvenEmitterValid=e=>!!e&&"function"==typeof e.on&&"function"==typeof e.removeListener;var p=r(3215),v=r.n(p);let b=new(v()).Type("ChatMessage").add(new(v()).Field("timestamp",1,"uint64")).add(new(v()).Field("nick",2,"string")).add(new(v()).Field("text",3,"string"));(n=l||(l={})).WASM_LOADING="WASM Blob download in progress...",n.WASM_FAILED="Failed to download WASM, check console",n.CONTRACT_LOADING="Connecting to RLN contract",n.CONTRACT_FAILED="Failed to connect to RLN contract",n.RLN_INITIALIZED="RLN dependencies initialized",n.KEYSTORE_LOCAL="Keystore initialized from localStore",n.KEYSTORE_NEW="New Keystore was initialized",n.CREDENTIALS_REGISTERING="Registering credentials...",n.CREDENTIALS_REGISTERED="Registered credentials",n.CREDENTIALS_FAILURE="Failed to register credentials, check console",(s=c||(c={})).Status="status",s.Keystore="keystore-changed";let N=new class{async init(){if(this.initialized||this.initializing)return;this.initializing=!0;let e=await this.initRLNWasm();await this.initRLNContract(e),this.emitStatusEvent(l.RLN_INITIALIZED),this.emitKeystoreKeys(),this.initialized=!0,this.initializing=!1}async initRLNWasm(){this.emitStatusEvent(l.WASM_LOADING);try{return this.rlnInstance=await (0,f.Ue)(),this.rlnInstance}catch(e){throw console.error("Failed at fetching WASM and creating RLN instance: ",e),this.emitStatusEvent(l.WASM_FAILED),e}}async initRLNContract(e){this.emitStatusEvent(l.CONTRACT_LOADING);try{this.rlnContract=await f.X.init(e,{registryAddress:f.d$.address,provider:this.ethProvider.getSigner()})}catch(e){throw console.error("Failed to connect to RLN contract: ",e),this.emitStatusEvent(l.CONTRACT_FAILED),e}}initKeystore(){let e=localStorage.getItem("keystore"),t=f.YK.fromString(e||"");return t||f.YK.create()}addEventListener(e,t){return this.emitter.addEventListener(e,t)}removeEventListener(e,t){return this.emitter.removeEventListener(e,t)}emitStatusEvent(e){this.emitter.dispatchEvent(new CustomEvent("status",{detail:e}))}emitKeystoreKeys(){let e=Object.keys(this.keystore.toObject().credentials||{});this.emitter.dispatchEvent(new CustomEvent("keystore-changed",{detail:e}))}async saveKeystore(){localStorage.setItem("keystore",this.keystore.toString()),this.emitKeystoreKeys()}importKeystore(e){this.keystore=f.YK.fromString(e)||f.YK.create(),this.saveKeystore()}constructor(){this.emitter=new EventTarget,this.initialized=!1,this.initializing=!1;let e=window.ethereum;if(!isBrowserProviderValid(e))throw Error("Invalid Ethereum provider present on the page. Check if MetaMask is connected.");this.ethProvider=new k.Q(e,"any"),this.keystore=this.initKeystore()}},useRLN=()=>{let{setAppStatus:e,setKeystoreCredentials:t}=y(),r=x.useRef(void 0);return x.useEffect(()=>{if(r.current||!N)return;let n=!1,statusListener=t=>{e(null==t?void 0:t.detail)};N.addEventListener(c.Status,statusListener);let keystoreListener=e=>{t((null==e?void 0:e.detail)||[])};N.addEventListener(c.Keystore,keystoreListener);let run=async()=>{n||(await (null==N?void 0:N.init()),r.current=N)};return run(),()=>{n=!0,null==N||N.removeEventListener(c.Status,statusListener),null==N||N.removeEventListener(c.Keystore,keystoreListener)}},[r,e]),{rln:r.current}},useWallet=()=>{let{rln:e}=useRLN(),{setEthAccount:t,setChainID:r,setCredentials:n}=y();x.useEffect(()=>{let e=window.ethereum;if(!isEthereumEvenEmitterValid(e)){console.log("Cannot subscribe to ethereum events.");return}let onAccountsChanged=e=>{t(e[0]||"")};e.on("accountsChanged",onAccountsChanged);let onChainChanged=e=>{let t=parseInt(e,16);r(t)};return e.on("chainChanged",onChainChanged),()=>{e.removeListener("chainChanged",onChainChanged),e.removeListener("accountsChanged",onAccountsChanged)}},[t,r]);let s=x.useCallback(async()=>{var t;if(!(null==e?void 0:e.ethProvider)){console.log("Cannot generate credentials, no provider found.");return}let r=e.ethProvider.getSigner(),s=await r.signMessage("".concat("The signature of this message will be used to generate your RLN credentials. Anyone accessing it may send messages on your behalf, please only share with the RLN dApp",". Nonce: ").concat(Math.ceil(1e3*Math.random()))),i=await (null===(t=e.rlnInstance)||void 0===t?void 0:t.generateSeededIdentityCredential(s));n(i)},[e,n]);return{onGenerateCredentials:s}},useContract=()=>{let{rln:e}=useRLN(),{setEthAccount:t,setChainID:r,setLastMembershipID:n}=y(),s=x.useCallback(async()=>{let s=new Promise(async n=>{if(!e){console.log("Cannot fetch wallet, not provider found."),n();return}try{let n=await e.ethProvider.send("eth_requestAccounts",[]);t(n[0]||"");let s=await e.ethProvider.getNetwork();r(s.chainId)}catch(e){console.error("Failed to connect to account: ",e)}n()}),i=new Promise(async t=>{if(!(null==e?void 0:e.rlnContract)||!(null==e?void 0:e.rlnInstance)){console.log("Cannot fetch contract info, no contract found."),t();return}try{await e.rlnContract.fetchMembers(e.rlnInstance),e.rlnContract.subscribeToMembers(e.rlnInstance);let t=e.rlnContract.members.at(-1);t&&n(t.index.toNumber())}catch(e){console.error("Failed to fetch contract state: ",e)}t()});await Promise.any([s,i])},[e,t,r,n]);return{onFetchContract:s}};var C=r(2355);(i=d||(d={})).Status="status",i.Message="message",(a=u||(u={})).INITIALIZING="Initializing",a.WAITING_FOR_PEERS="Waiting for peers",a.STARTING="Starting the node",a.READY="Ready";let E=new class{async init(e){this.initialized||this.initializing||!e.rln.rlnInstance||(this.initializing=!0,this.initEncoder(e),this.decoder=new f.pU(e.rln.rlnInstance,(0,C.UF)(this.contentTopic)),!this.node&&(this.emitStatusEvent("Initializing"),this.node=await (0,C.pq)({defaultBootstrap:!0}),this.emitStatusEvent("Starting the node"),await this.node.start(),this.emitStatusEvent("Waiting for peers"),await (0,C.gT)(this.node),this.emitStatusEvent("Ready"),e.rln.rlnContract&&await this.subscribeToMessages({node:this.node,decoder:this.decoder,rlnContract:e.rln.rlnContract})),this.initialized=!0,this.initializing=!1)}initEncoder(e){let{rln:t,membershipID:r,credentials:n}=e;t.rlnInstance&&(this.encoder=new f.vg((0,C.Mf)({ephemeral:!1,contentTopic:this.contentTopic}),t.rlnInstance,r,n))}async sendMessage(e,t){if(!this.node||!this.encoder)return;let r=new Date,n=b.create({text:t,nick:e,timestamp:Math.floor(r.valueOf()/1e3)}),s=b.encode(n).finish();console.log("Sending message with proof..."),await this.node.lightPush.send(this.encoder,{payload:s,timestamp:r}),console.log("Message sent!")}async subscribeToMessages(e){await e.node.filter.subscribe(e.decoder,t=>{try{let{timestamp:r,nick:n,text:s}=b.decode(t.payload),i="no proof";if(t.rateLimitProof){console.log("Proof received: ",t.rateLimitProof);try{console.time("Proof verification took:");let r=t.verify(e.rlnContract.roots());console.timeEnd("Proof verification took:"),i=r?"verified":"not verified"}catch(e){i="invalid",console.error("Failed to verify proof: ",e)}}this.emitMessageEvent({nick:n,text:s,proofStatus:i,time:new Date(r).toDateString()})}catch(e){console.error("Failed in subscription listener: ",e)}})}addEventListener(e,t){return this.emitter.addEventListener(e,t)}removeEventListener(e,t){return this.emitter.removeEventListener(e,t)}emitStatusEvent(e){this.emitter.dispatchEvent(new CustomEvent("status",{detail:e}))}emitMessageEvent(e){this.emitter.dispatchEvent(new CustomEvent("message",{detail:e}))}constructor(){this.contentTopic="/toy-chat/2/luzhou/proto",this.emitter=new EventTarget,this.initialized=!1,this.initializing=!1}},useWaku=()=>{let e=x.useRef(),[t,r]=x.useState([]),{rln:n}=useRLN(),{activeMembershipID:s,credentials:i,setWakuStatus:a}=y();x.useEffect(()=>{if(!i||!s||!n)return;let statusListener=e=>{a(e.detail||"")};E.addEventListener(d.Status,statusListener);let messagesListener=e=>{r(t=>[...t,e.detail])};E.addEventListener(d.Message,messagesListener);let t=!1,run=async()=>{if(t)return;let r={rln:n,credentials:i,membershipID:s};e.current?e.current.initEncoder(r):(await E.init(r),e.current=E)};return run(),()=>{t=!0,E.removeEventListener(d.Status,statusListener),E.removeEventListener(d.Message,messagesListener)}},[s,i,n,a]);let o=x.useCallback(async(t,r)=>{e.current&&await e.current.sendMessage(t,r)},[e]);return{onSend:o,messages:t}},Header=()=>{let{appStatus:e}=y();return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Block,{className:"mb-5",type:o.FlexHorizontal,children:(0,h.jsx)(Title,{children:"Waku RLN"})}),(0,h.jsx)(Status,{text:"Application status",mark:e})]})},Subtitle=e=>(0,h.jsx)("h2",{className:"text-2xl ".concat(e.className||""),children:e.children}),Button=e=>(0,h.jsx)("button",{onClick:e.onClick,className:"".concat(e.className||""," py-2.5 px-5 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-lg border border-gray-200 hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700"),children:e.children}),Waku_Waku=()=>{let{wakuStatus:e}=y(),{onSend:t,messages:r}=useWaku(),{nick:n,text:s,onNickChange:i,onMessageChange:a,resetText:o}=function(){let[e,t]=x.useState(""),[r,n]=x.useState("");return{nick:e,text:r,resetText:()=>{n("")},onNickChange:e=>{t(e.currentTarget.value||"")},onMessageChange:e=>{n(e.currentTarget.value||"")}}}(),onSendClick=async()=>{await t(n,s),o()},l=x.useMemo(()=>r.map(renderMessage),[r]);return(0,h.jsxs)(Block,{className:"mt-10",children:[(0,h.jsxs)(Subtitle,{children:["Waku",(0,h.jsx)("p",{className:"text-xs",children:"(select credentials to initialize)"})]}),(0,h.jsx)(Status,{text:"Waku status",mark:e}),(0,h.jsxs)(Block,{className:"mt-4",children:[(0,h.jsx)("label",{htmlFor:"nick-input",className:"block mb-2 text-sm font-medium text-gray-900 dark:text-white",children:"Your nickname"}),(0,h.jsx)("input",{type:"text",id:"nick-input",placeholder:"Choose a nickname",value:n,onChange:i,className:"w-full mr-2 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"})]}),(0,h.jsxs)(Block,{className:"mt-4",children:[(0,h.jsxs)(Block,{className:"mb-2",children:[(0,h.jsx)("label",{htmlFor:"message-input",className:"block mb-2 text-sm font-medium text-gray-900 dark:text-white",children:"Message"}),(0,h.jsx)("input",{type:"text",id:"message-input",value:s,onChange:a,placeholder:"Text your message here",className:"w-full mr-2 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"})]}),(0,h.jsx)(Button,{onClick:onSendClick,children:"Send"})]}),(0,h.jsxs)(Block,{className:"mt-8",children:[(0,h.jsx)("p",{className:"text-l mb-4",children:"Messages"}),(0,h.jsx)("div",{children:(0,h.jsx)("ul",{children:l})})]})]})};function renderMessage(e){return(0,h.jsxs)("li",{className:"mb-4",children:[(0,h.jsxs)("p",{children:[(0,h.jsx)("span",{className:"text-lg",children:e.nick}),(0,h.jsxs)("span",{className:"text-sm font-bold",children:["(",e.proofStatus,", ",e.time,")"]}),":"]}),(0,h.jsx)("p",{children:e.text})]},"".concat(e.nick,"-").concat(e.time))}let useKeystore=()=>{let{rln:e}=useRLN(),{credentials:t,setActiveCredential:r,setActiveMembershipID:n,setAppStatus:s,setCredentials:i}=y(),a=x.useCallback(async i=>{if(t&&(null==e?void 0:e.rlnContract)&&i)try{s(l.CREDENTIALS_REGISTERING);let a=await e.rlnContract.registerWithKey(t),o=a.index.toNumber(),c=await e.keystore.addCredential({membership:{treeIndex:o,chainId:f.d$.chainId,address:f.d$.address},identity:t},i);r(c),n(o),e.saveKeystore(),s(l.CREDENTIALS_REGISTERED)}catch(e){s(l.CREDENTIALS_FAILURE),console.error("Failed to register to RLN Contract: ",e);return}},[t,e,r,n,s]),o=x.useCallback(async(t,s)=>{if(e&&t&&s)try{let a=await e.keystore.readCredential(t,s);a&&(i(a.identity),r(t),n(a.membership.treeIndex))}catch(e){console.error("Failed to read credentials from Keystore.");return}},[e,r,n,i]);return{onRegisterCredentials:a,onReadCredentials:o}},Keystore=()=>{let{keystoreCredentials:e}=y(),{onGenerateCredentials:t}=useWallet(),{onReadCredentials:r,onRegisterCredentials:n}=useKeystore(),{password:s,onPasswordChanged:i}=function(){let[e,t]=x.useState("");return{password:e,onPasswordChanged:e=>{t(e.currentTarget.value)}}}(),{selectedKeystore:a,onKeystoreChanged:l}=function(){let[e,t]=x.useState("");return{selectedKeystore:e,onKeystoreChanged:e=>{t(e.currentTarget.value||"")}}}(),{onExportKeystore:c,onImportKeystoreFileChange:d}=function(){let{rln:e}=useRLN(),onImportKeystoreFileChange=async t=>{var r,n;let s=null===(n=t.currentTarget)||void 0===n?void 0:null===(r=n.files)||void 0===r?void 0:r[0];if(!s||!e)return;let i=await s.text();e.importKeystore(i)};return{onExportKeystore:()=>{if(!e)return;let t="keystore.json",r=e.keystore.toString(),n=new File([r],t,{type:"application/json"}),s=document.createElement("a");s.href=URL.createObjectURL(n),s.download=t,s.click()},onImportKeystoreFileChange}}(),u=x.useMemo(()=>e.map(e=>(0,h.jsx)("option",{value:e,children:e},e)),[e]);return(0,h.jsxs)(Block,{className:"mt-10",children:[(0,h.jsxs)(Block,{type:o.FlexHorizontal,children:[(0,h.jsx)(Subtitle,{children:"Keystore"}),(0,h.jsxs)("div",{children:[(0,h.jsx)(Button,{children:(0,h.jsx)("label",{htmlFor:"keystore-import",className:"cursor-pointer",children:"Import"})}),(0,h.jsx)("input",{id:"keystore-import",type:"file",className:"hidden",onChange:d}),(0,h.jsx)(Button,{className:"ml-2",onClick:c,children:"Export"})]})]}),(0,h.jsxs)(Block,{className:"mt-4",children:[(0,h.jsx)("label",{htmlFor:"keystore-input",className:"block mb-2 text-sm font-medium text-gray-900 dark:text-white",children:"Password(used for reading/saving into Keystore)"}),(0,h.jsx)("input",{type:"text",value:s,id:"keystore-input",onChange:i,className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm w-full rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"})]}),(0,h.jsxs)(Block,{className:"mt-4",children:[(0,h.jsx)("p",{className:"text-s mb-2",children:"Generate new credentials from wallet"}),(0,h.jsx)(Button,{onClick:t,children:"Generate new credentials"}),(0,h.jsx)(Button,{className:"ml-5",onClick:()=>n(s),children:"Register credentials"})]}),(0,h.jsxs)(Block,{className:"mt-4",children:[(0,h.jsx)("p",{className:"text-s",children:"Read from Keystore"}),(0,h.jsxs)(Block,{type:o.FlexHorizontal,children:[(0,h.jsx)("select",{value:a,onChange:l,className:"bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-3/4 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500",children:u}),(0,h.jsx)(Button,{onClick:()=>r(a,s),children:"Read credentials"})]})]})]})},BlockchainInfo=()=>{let{ethAccount:e,lastMembershipID:t}=y(),{onFetchContract:r}=useContract();return(0,h.jsxs)(Block,{className:"mt-10",children:[(0,h.jsxs)(Block,{className:"mb-3",type:o.FlexHorizontal,children:[(0,h.jsx)(Subtitle,{children:"Contract"}),(0,h.jsx)(Button,{onClick:r,children:"Fetch state"})]}),(0,h.jsxs)(Block,{type:o.FlexHorizontal,children:[(0,h.jsx)("p",{children:"Your address"}),(0,h.jsx)("code",{children:e||"Not loaded yet"})]}),(0,h.jsxs)(Block,{type:o.FlexHorizontal,children:[(0,h.jsx)("p",{children:"Latest membership ID on contract"}),(0,h.jsx)("code",{children:t||"Not loaded yet"})]})]})};var j=r(9710);let KeystoreDetails=()=>{let{credentials:e,activeCredential:t,activeMembershipID:r}=y();return(0,h.jsxs)(Block,{className:"mt-5",children:[(0,h.jsxs)(Block,{className:"mt-3",type:o.FlexHorizontal,children:[(0,h.jsx)("p",{children:"Keystore hash"}),(0,h.jsx)("code",{children:t||"none"})]}),(0,h.jsxs)(Block,{className:"mt-3",type:o.FlexHorizontal,children:[(0,h.jsx)("p",{children:"Membership ID"}),(0,h.jsx)("code",{children:r||"none"})]}),(0,h.jsxs)(Block,{className:"mt-3",type:o.FlexHorizontal,children:[(0,h.jsx)("p",{children:"Secret Hash"}),(0,h.jsx)("code",{children:renderBytes(null==e?void 0:e.IDSecretHash)})]}),(0,h.jsxs)(Block,{className:"mt-3",type:o.FlexHorizontal,children:[(0,h.jsx)("p",{children:"Commitment"}),(0,h.jsx)("code",{children:renderBytes(null==e?void 0:e.IDCommitment)})]}),(0,h.jsxs)(Block,{className:"mt-3",type:o.FlexHorizontal,children:[(0,h.jsx)("p",{children:"Nullifier"}),(0,h.jsx)("code",{children:renderBytes(null==e?void 0:e.IDNullifier)})]}),(0,h.jsxs)(Block,{className:"mt-3",type:o.FlexHorizontal,children:[(0,h.jsx)("p",{children:"Trapdoor"}),(0,h.jsx)("code",{children:renderBytes(null==e?void 0:e.IDTrapdoor)})]})]})};function renderBytes(e){return e?(0,j.ci)(e):"none"}function Home(){return(0,h.jsxs)("main",{className:"flex min-h-screen flex-col p-24 font-mono max-w-screen-lg m-auto",children:[(0,h.jsx)(Header,{}),(0,h.jsx)(BlockchainInfo,{}),(0,h.jsx)(Keystore,{}),(0,h.jsx)(KeystoreDetails,{}),(0,h.jsx)(Waku_Waku,{})]})}}}]); \ No newline at end of file diff --git a/rln-js/_next/static/chunks/472-904a395439c7cfd8.js b/rln-js/_next/static/chunks/472-904a395439c7cfd8.js new file mode 100644 index 0000000..9f7c441 --- /dev/null +++ b/rln-js/_next/static/chunks/472-904a395439c7cfd8.js @@ -0,0 +1,25 @@ +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[472],{5844:function(e,t){"use strict";function getDeploymentIdQueryOrEmptyString(){return""}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"getDeploymentIdQueryOrEmptyString",{enumerable:!0,get:function(){return getDeploymentIdQueryOrEmptyString}})},2335:function(){"trimStart"in String.prototype||(String.prototype.trimStart=String.prototype.trimLeft),"trimEnd"in String.prototype||(String.prototype.trimEnd=String.prototype.trimRight),"description"in Symbol.prototype||Object.defineProperty(Symbol.prototype,"description",{configurable:!0,get:function(){var e=/\((.*)\)/.exec(this.toString());return e?e[1]:void 0}}),Array.prototype.flat||(Array.prototype.flat=function(e,t){return t=this.concat.apply([],this),e>1&&t.some(Array.isArray)?t.flat(e-1):t},Array.prototype.flatMap=function(e,t){return this.map(e,t).flat()}),Promise.prototype.finally||(Promise.prototype.finally=function(e){if("function"!=typeof e)return this.then(e,e);var t=this.constructor||Promise;return this.then(function(r){return t.resolve(e()).then(function(){return r})},function(r){return t.resolve(e()).then(function(){throw r})})}),Object.fromEntries||(Object.fromEntries=function(e){return Array.from(e).reduce(function(e,t){return e[t[0]]=t[1],e},{})}),Array.prototype.at||(Array.prototype.at=function(e){var t=Math.trunc(e)||0;if(t<0&&(t+=this.length),!(t<0||t>=this.length))return this[t]})},9872:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"addBasePath",{enumerable:!0,get:function(){return addBasePath}});let n=r(8356),a=r(3997);function addBasePath(e,t){return(0,a.normalizePathTrailingSlash)((0,n.addPathPrefix)(e,""))}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},5354:function(e,t){"use strict";function appBootstrap(e){var t,r;t=self.__next_s,r=()=>{e()},t&&t.length?t.reduce((e,t)=>{let[r,n]=t;return e.then(()=>new Promise((e,t)=>{let a=document.createElement("script");if(n)for(let e in n)"children"!==e&&a.setAttribute(e,n[e]);r?(a.src=r,a.onload=()=>e(),a.onerror=t):n&&(a.innerHTML=n.children,setTimeout(e)),document.head.appendChild(a)}))},Promise.resolve()).catch(e=>{console.error(e)}).then(()=>{r()}):r()}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"appBootstrap",{enumerable:!0,get:function(){return appBootstrap}}),window.next={version:"13.5.6",appDir:!0},("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},5231:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"callServer",{enumerable:!0,get:function(){return callServer}});let n=r(3728);async function callServer(e,t){let r=(0,n.getServerActionDispatcher)();if(!r)throw Error("Invariant: missing action dispatcher.");return new Promise((n,a)=>{r({actionId:e,actionArgs:t,resolve:n,reject:a})})}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},811:function(e,t,r){"use strict";let n,a;Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"hydrate",{enumerable:!0,get:function(){return hydrate}});let o=r(1024),u=r(8533);r(2335);let l=o._(r(4040)),i=u._(r(2265)),s=r(6671),p=r(1852);r(6313);let _=o._(r(2504)),b=r(5231),v=r(4119),m=window.console.error;window.console.error=function(){for(var e=arguments.length,t=Array(e),r=0;r{if((0,v.isNextRouterError)(e.error)){e.preventDefault();return}});let E=document,getCacheKey=()=>{let{pathname:e,search:t}=location;return e+t},j=new TextEncoder,C=!1,w=!1,A=null;function nextServerDataCallback(e){if(0===e[0])n=[];else if(1===e[0]){if(!n)throw Error("Unexpected server data: missing bootstrap script.");a?a.enqueue(j.encode(e[1])):n.push(e[1])}else 2===e[0]&&(A=e[1])}let DOMContentLoaded=function(){a&&!w&&(a.close(),w=!0,n=void 0),C=!0};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",DOMContentLoaded,!1):DOMContentLoaded();let F=self.__next_f=self.__next_f||[];F.forEach(nextServerDataCallback),F.push=nextServerDataCallback;let D=new Map;function ServerRoot(e){let{cacheKey:t}=e;i.default.useEffect(()=>{D.delete(t)});let r=function(e){let t=D.get(e);if(t)return t;let r=new ReadableStream({start(e){n&&(n.forEach(t=>{e.enqueue(j.encode(t))}),C&&!w&&(e.close(),w=!0,n=void 0)),a=e}}),o=(0,s.createFromReadableStream)(r,{callServer:b.callServer});return D.set(e,o),o}(t),o=(0,i.use)(r);return o}let U=i.default.StrictMode;function Root(e){let{children:t}=e;return t}function RSCComponent(e){return i.default.createElement(ServerRoot,{...e,cacheKey:getCacheKey()})}function hydrate(){let e=i.default.createElement(U,null,i.default.createElement(p.HeadManagerContext.Provider,{value:{appDir:!0}},i.default.createElement(Root,null,i.default.createElement(RSCComponent,null)))),t={onRecoverableError:_.default},r="__next_error__"===document.documentElement.id;r?l.default.createRoot(E,t).render(e):i.default.startTransition(()=>l.default.hydrateRoot(E,e,{...t,experimental_formState:A}))}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},2019:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let n=r(5354);(0,n.appBootstrap)(()=>{r(1055);let{hydrate:e}=r(811);r(3728),r(6954),e()}),("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},1055:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),r(5844);{let e=r.u;r.u=function(){for(var t=arguments.length,r=Array(t),n=0;n{let e=function(){var e;let t=document.getElementsByName(o)[0];if(null==t?void 0:null==(e=t.shadowRoot)?void 0:e.childNodes[0])return t.shadowRoot.childNodes[0];{let e=document.createElement(o);e.style.cssText="position:absolute";let t=document.createElement("div");t.ariaLive="assertive",t.id="__next-route-announcer__",t.role="alert",t.style.cssText="position:absolute;border:0;height:1px;margin:-1px;padding:0;width:1px;clip:rect(0 0 0 0);overflow:hidden;white-space:nowrap;word-wrap:normal";let r=e.attachShadow({mode:"open"});return r.appendChild(t),document.body.appendChild(e),t}}();return u(e),()=>{let e=document.getElementsByTagName(o)[0];(null==e?void 0:e.isConnected)&&document.body.removeChild(e)}},[]);let[l,i]=(0,n.useState)(""),s=(0,n.useRef)();return(0,n.useEffect)(()=>{let e="";if(document.title)e=document.title;else{let t=document.querySelector("h1");t&&(e=t.innerText||t.textContent||"")}void 0!==s.current&&s.current!==e&&i(e),s.current=e},[t]),r?(0,a.createPortal)(l,r):null}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},8343:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{RSC:function(){return r},ACTION:function(){return n},NEXT_ROUTER_STATE_TREE:function(){return a},NEXT_ROUTER_PREFETCH:function(){return o},NEXT_URL:function(){return u},RSC_CONTENT_TYPE_HEADER:function(){return l},RSC_VARY_HEADER:function(){return i},FLIGHT_PARAMETERS:function(){return s},NEXT_RSC_UNION_QUERY:function(){return p}});let r="RSC",n="Next-Action",a="Next-Router-State-Tree",o="Next-Router-Prefetch",u="Next-Url",l="text/x-component",i=r+", "+a+", "+o+", "+u,s=[[r],[a],[o]],p="_rsc";("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},3728:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{getServerActionDispatcher:function(){return getServerActionDispatcher},urlToUrlWithoutFlightMarker:function(){return urlToUrlWithoutFlightMarker},default:function(){return AppRouter}});let n=r(8533),a=n._(r(2265)),o=r(6313),u=r(7205),l=r(9706),i=r(2301),s=r(7407),p=r(2327),_=r(9928),b=r(5311),v=r(2169),m=r(9872),E=r(8325),j=r(5138),C=r(6700),w=r(3085),A=r(8343),F=r(3714),D=r(6746),U=new Map,B=null;function getServerActionDispatcher(){return B}let $={refresh:()=>{}};function urlToUrlWithoutFlightMarker(e){let t=new URL(e,location.origin);if(t.searchParams.delete(A.NEXT_RSC_UNION_QUERY),t.pathname.endsWith(".txt")){let{pathname:e}=t,r=e.endsWith("/index.txt")?10:4;t.pathname=e.slice(0,-r)}return t}function isExternalURL(e){return e.origin!==window.location.origin}function HistoryUpdater(e){let{tree:t,pushRef:r,canonicalUrl:n,sync:o}=e;return(0,a.useInsertionEffect)(()=>{let e={__NA:!0,tree:t};r.pendingPush&&(0,i.createHrefFromUrl)(new URL(window.location.href))!==n?(r.pendingPush=!1,window.history.pushState(e,"",n)):window.history.replaceState(e,"",n),o()},[t,r,n,o]),null}let createEmptyCacheNode=()=>({status:o.CacheStates.LAZY_INITIALIZED,data:null,subTreeData:null,parallelRoutes:new Map});function Router(e){let{buildId:t,initialHead:r,initialTree:n,initialCanonicalUrl:_,children:A,assetPrefix:z}=e,K=(0,a.useMemo)(()=>(0,b.createInitialRouterState)({buildId:t,children:A,initialCanonicalUrl:_,initialTree:n,initialParallelRoutes:U,isServer:!1,location:window.location,initialHead:r}),[t,A,_,n,r]),[{tree:q,cache:ee,prefetchCache:et,pushRef:er,focusAndScrollRef:en,canonicalUrl:ea,nextUrl:eo},eu,el]=(0,p.useReducerWithReduxDevtools)(u.reducer,K);(0,a.useEffect)(()=>{U=null},[]);let{searchParams:ei,pathname:ec}=(0,a.useMemo)(()=>{let e=new URL(ea,window.location.href);return{searchParams:e.searchParams,pathname:(0,D.hasBasePath)(e.pathname)?(0,F.removeBasePath)(e.pathname):e.pathname}},[ea]),es=(0,a.useCallback)((e,t,r)=>{(0,a.startTransition)(()=>{eu({type:l.ACTION_SERVER_PATCH,flightData:t,previousTree:e,overrideCanonicalUrl:r,cache:createEmptyCacheNode(),mutable:{globalMutable:$}})})},[eu]),ef=(0,a.useCallback)((e,t,r,n)=>{let a=new URL((0,m.addBasePath)(e),location.href);return $.pendingNavigatePath=(0,i.createHrefFromUrl)(a),eu({type:l.ACTION_NAVIGATE,url:a,isExternalUrl:isExternalURL(a),locationSearch:location.search,forceOptimisticNavigation:r,shouldScroll:null==n||n,navigateType:t,cache:createEmptyCacheNode(),mutable:{globalMutable:$}})},[eu]);!function(e){let t=(0,a.useCallback)(t=>{(0,a.startTransition)(()=>{e({...t,type:l.ACTION_SERVER_ACTION,mutable:{globalMutable:$},cache:createEmptyCacheNode()})})},[e]);B=t}(eu);let ed=(0,a.useMemo)(()=>{let e={back:()=>window.history.back(),forward:()=>window.history.forward(),prefetch:(e,t)=>{if((0,v.isBot)(window.navigator.userAgent))return;let r=new URL((0,m.addBasePath)(e),location.href);isExternalURL(r)||(0,a.startTransition)(()=>{var e;eu({type:l.ACTION_PREFETCH,url:r,kind:null!=(e=null==t?void 0:t.kind)?e:l.PrefetchKind.FULL})})},replace:(e,t)=>{void 0===t&&(t={}),(0,a.startTransition)(()=>{var r;ef(e,"replace",!!t.forceOptimisticNavigation,null==(r=t.scroll)||r)})},push:(e,t)=>{void 0===t&&(t={}),(0,a.startTransition)(()=>{var r;ef(e,"push",!!t.forceOptimisticNavigation,null==(r=t.scroll)||r)})},refresh:()=>{(0,a.startTransition)(()=>{eu({type:l.ACTION_REFRESH,cache:createEmptyCacheNode(),mutable:{globalMutable:$},origin:window.location.origin})})},fastRefresh:()=>{throw Error("fastRefresh can only be used in development mode. Please use refresh instead.")}};return e},[eu,ef]);if((0,a.useEffect)(()=>{window.next&&(window.next.router=ed)},[ed]),(0,a.useEffect)(()=>{$.refresh=ed.refresh},[ed.refresh]),(0,a.useEffect)(()=>{function handlePageShow(e){var t;e.persisted&&(null==(t=window.history.state)?void 0:t.tree)&&eu({type:l.ACTION_RESTORE,url:new URL(window.location.href),tree:window.history.state.tree})}return window.addEventListener("pageshow",handlePageShow),()=>{window.removeEventListener("pageshow",handlePageShow)}},[eu]),er.mpaNavigation){if($.pendingMpaPath!==ea){let e=window.location;er.pendingPush?e.assign(ea):e.replace(ea),$.pendingMpaPath=ea}(0,a.use)((0,w.createInfinitePromise)())}let ep=(0,a.useCallback)(e=>{let{state:t}=e;if(t){if(!t.__NA){window.location.reload();return}(0,a.startTransition)(()=>{eu({type:l.ACTION_RESTORE,url:new URL(window.location.href),tree:t.tree})})}},[eu]);(0,a.useEffect)(()=>(window.addEventListener("popstate",ep),()=>{window.removeEventListener("popstate",ep)}),[ep]);let eh=(0,a.useMemo)(()=>(0,C.findHeadInCache)(ee,q[1]),[ee,q]),ey=a.default.createElement(j.RedirectBoundary,null,eh,ee.subTreeData,a.default.createElement(E.AppRouterAnnouncer,{tree:q}));return a.default.createElement(a.default.Fragment,null,a.default.createElement(HistoryUpdater,{tree:q,pushRef:er,canonicalUrl:ea,sync:el}),a.default.createElement(s.PathnameContext.Provider,{value:ec},a.default.createElement(s.SearchParamsContext.Provider,{value:ei},a.default.createElement(o.GlobalLayoutRouterContext.Provider,{value:{buildId:t,changeByServerResponse:es,tree:q,focusAndScrollRef:en,nextUrl:eo}},a.default.createElement(o.AppRouterContext.Provider,{value:ed},a.default.createElement(o.LayoutRouterContext.Provider,{value:{childNodes:ee.parallelRoutes,tree:q,url:ea}},ey))))))}function AppRouter(e){let{globalErrorComponent:t,...r}=e;return a.default.createElement(_.ErrorBoundary,{errorComponent:t},a.default.createElement(Router,r))}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},3940:function(e,t,r){"use strict";function clientHookInServerComponentError(e){}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"clientHookInServerComponentError",{enumerable:!0,get:function(){return clientHookInServerComponentError}}),r(1024),r(2265),("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},9928:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{ErrorBoundaryHandler:function(){return ErrorBoundaryHandler},GlobalError:function(){return GlobalError},default:function(){return l},ErrorBoundary:function(){return ErrorBoundary}});let n=r(1024),a=n._(r(2265)),o=r(94),u={error:{fontFamily:'system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"',height:"100vh",textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},text:{fontSize:"14px",fontWeight:400,lineHeight:"28px",margin:"0 8px"}};let ErrorBoundaryHandler=class ErrorBoundaryHandler extends a.default.Component{static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return e.pathname!==t.previousPathname&&t.error?{error:null,previousPathname:e.pathname}:{error:t.error,previousPathname:e.pathname}}render(){return this.state.error?a.default.createElement(a.default.Fragment,null,this.props.errorStyles,a.default.createElement(this.props.errorComponent,{error:this.state.error,reset:this.reset})):this.props.children}constructor(e){super(e),this.reset=()=>{this.setState({error:null})},this.state={error:null,previousPathname:this.props.pathname}}};function GlobalError(e){let{error:t}=e,r=null==t?void 0:t.digest;return a.default.createElement("html",{id:"__next_error__"},a.default.createElement("head",null),a.default.createElement("body",null,a.default.createElement("div",{style:u.error},a.default.createElement("div",null,a.default.createElement("h2",{style:u.text},"Application error: a "+(r?"server":"client")+"-side exception has occurred (see the "+(r?"server logs":"browser console")+" for more information)."),r?a.default.createElement("p",{style:u.text},"Digest: "+r):null))))}let l=GlobalError;function ErrorBoundary(e){let{errorComponent:t,errorStyles:r,children:n}=e,u=(0,o.usePathname)();return t?a.default.createElement(ErrorBoundaryHandler,{pathname:u,errorComponent:t,errorStyles:r},n):a.default.createElement(a.default.Fragment,null,n)}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},1351:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{DYNAMIC_ERROR_CODE:function(){return r},DynamicServerError:function(){return DynamicServerError}});let r="DYNAMIC_SERVER_USAGE";let DynamicServerError=class DynamicServerError extends Error{constructor(e){super("Dynamic server usage: "+e),this.digest=r}};("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},3085:function(e,t){"use strict";let r;function createInfinitePromise(){return r||(r=new Promise(()=>{})),r}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"createInfinitePromise",{enumerable:!0,get:function(){return createInfinitePromise}}),("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},4119:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"isNextRouterError",{enumerable:!0,get:function(){return isNextRouterError}});let n=r(9273),a=r(8466);function isNextRouterError(e){return e&&e.digest&&((0,a.isRedirectError)(e)||(0,n.isNotFoundError)(e))}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},6954:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return OuterLayoutRouter}});let n=r(1024),a=r(8533),o=a._(r(2265)),u=n._(r(4887)),l=r(6313),i=r(8146),s=r(3085),p=r(9928),_=r(8163),b=r(280),v=r(5138),m=r(3170),E=r(1263),j=r(3322),C=r(3559),w=["bottom","height","left","right","top","width","x","y"];function topOfElementInViewport(e,t){let r=e.getBoundingClientRect();return r.top>=0&&r.top<=t}let InnerScrollAndFocusHandler=class InnerScrollAndFocusHandler extends o.default.Component{componentDidMount(){this.handlePotentialScroll()}componentDidUpdate(){this.props.focusAndScrollRef.apply&&this.handlePotentialScroll()}render(){return this.props.children}constructor(...e){super(...e),this.handlePotentialScroll=()=>{let{focusAndScrollRef:e,segmentPath:t}=this.props;if(e.apply){var r;if(0!==e.segmentPaths.length&&!e.segmentPaths.some(e=>t.every((t,r)=>(0,_.matchSegment)(t,e[r]))))return;let n=null,a=e.hashFragment;if(a&&(n="top"===a?document.body:null!=(r=document.getElementById(a))?r:document.getElementsByName(a)[0]),n||(n=u.default.findDOMNode(this)),!(n instanceof Element))return;for(;!(n instanceof HTMLElement)||function(e){if(["sticky","fixed"].includes(getComputedStyle(e).position))return!0;let t=e.getBoundingClientRect();return w.every(e=>0===t[e])}(n);){if(null===n.nextElementSibling)return;n=n.nextElementSibling}e.apply=!1,e.hashFragment=null,e.segmentPaths=[],(0,b.handleSmoothScroll)(()=>{if(a){n.scrollIntoView();return}let e=document.documentElement,t=e.clientHeight;!topOfElementInViewport(n,t)&&(e.scrollTop=0,topOfElementInViewport(n,t)||n.scrollIntoView())},{dontForceLayout:!0,onlyHashChange:e.onlyHashChange}),e.onlyHashChange=!1,n.focus()}}}};function ScrollAndFocusHandler(e){let{segmentPath:t,children:r}=e,n=(0,o.useContext)(l.GlobalLayoutRouterContext);if(!n)throw Error("invariant global layout router not mounted");return o.default.createElement(InnerScrollAndFocusHandler,{segmentPath:t,focusAndScrollRef:n.focusAndScrollRef},r)}function InnerLayoutRouter(e){let{parallelRouterKey:t,url:r,childNodes:n,childProp:a,segmentPath:u,tree:p,cacheKey:b}=e,v=(0,o.useContext)(l.GlobalLayoutRouterContext);if(!v)throw Error("invariant global layout router not mounted");let{buildId:m,changeByServerResponse:E,tree:j}=v,w=n.get(b);if(a&&null!==a.current&&(w?w.status===l.CacheStates.LAZY_INITIALIZED&&(w.status=l.CacheStates.READY,w.subTreeData=a.current):(w={status:l.CacheStates.READY,data:null,subTreeData:a.current,parallelRoutes:new Map},n.set(b,w))),!w||w.status===l.CacheStates.LAZY_INITIALIZED){let e=function walkAddRefetch(e,t){if(e){let[r,n]=e,a=2===e.length;if((0,_.matchSegment)(t[0],r)&&t[1].hasOwnProperty(n)){if(a){let e=walkAddRefetch(void 0,t[1][n]);return[t[0],{...t[1],[n]:[e[0],e[1],e[2],"refetch"]}]}return[t[0],{...t[1],[n]:walkAddRefetch(e.slice(2),t[1][n])}]}}return t}(["",...u],j);w={status:l.CacheStates.DATA_FETCH,data:(0,C.createRecordFromThenable)((0,i.fetchServerResponse)(new URL(r,location.origin),e,v.nextUrl,m)),subTreeData:null,head:w&&w.status===l.CacheStates.LAZY_INITIALIZED?w.head:void 0,parallelRoutes:w&&w.status===l.CacheStates.LAZY_INITIALIZED?w.parallelRoutes:new Map},n.set(b,w)}if(!w)throw Error("Child node should always exist");if(w.subTreeData&&w.data)throw Error("Child node should not have both subTreeData and data");if(w.data){let[e,t]=(0,o.use)(w.data);w.data=null,setTimeout(()=>{(0,o.startTransition)(()=>{E(j,e,t)})}),(0,o.use)((0,s.createInfinitePromise)())}w.subTreeData||(0,o.use)((0,s.createInfinitePromise)());let A=o.default.createElement(l.LayoutRouterContext.Provider,{value:{tree:p[1][t],childNodes:w.parallelRoutes,url:r}},w.subTreeData);return A}function LoadingBoundary(e){let{children:t,loading:r,loadingStyles:n,hasLoading:a}=e;return a?o.default.createElement(o.Suspense,{fallback:o.default.createElement(o.default.Fragment,null,n,r)},t):o.default.createElement(o.default.Fragment,null,t)}function OuterLayoutRouter(e){let{parallelRouterKey:t,segmentPath:r,childProp:n,error:a,errorStyles:u,templateStyles:i,loading:s,loadingStyles:b,hasLoading:C,template:w,notFound:A,notFoundStyles:F,styles:D}=e,U=(0,o.useContext)(l.LayoutRouterContext);if(!U)throw Error("invariant expected layout router to be mounted");let{childNodes:B,tree:$,url:z}=U,K=B.get(t);K||(K=new Map,B.set(t,K));let q=$[1][t][0],ee=n.segment,et=(0,E.getSegmentValue)(q),er=[q];return o.default.createElement(o.default.Fragment,null,D,er.map(e=>{let D=(0,_.matchSegment)(e,ee),U=(0,E.getSegmentValue)(e),B=(0,j.createRouterCacheKey)(e);return o.default.createElement(l.TemplateContext.Provider,{key:(0,j.createRouterCacheKey)(e,!0),value:o.default.createElement(ScrollAndFocusHandler,{segmentPath:r},o.default.createElement(p.ErrorBoundary,{errorComponent:a,errorStyles:u},o.default.createElement(LoadingBoundary,{hasLoading:C,loading:s,loadingStyles:b},o.default.createElement(m.NotFoundBoundary,{notFound:A,notFoundStyles:F},o.default.createElement(v.RedirectBoundary,null,o.default.createElement(InnerLayoutRouter,{parallelRouterKey:t,url:z,tree:$,childNodes:K,childProp:D?n:null,segmentPath:r,cacheKey:B,isActive:et===U}))))))},i,w)}))}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},8163:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{matchSegment:function(){return matchSegment},canSegmentBeOverridden:function(){return canSegmentBeOverridden}});let n=r(5682),matchSegment=(e,t)=>"string"==typeof e?"string"==typeof t&&e===t:"string"!=typeof t&&e[0]===t[0]&&e[1]===t[1],canSegmentBeOverridden=(e,t)=>{var r;return!Array.isArray(e)&&!!Array.isArray(t)&&(null==(r=(0,n.getSegmentParam)(e))?void 0:r.param)===t[0]};("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},94:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{ReadonlyURLSearchParams:function(){return ReadonlyURLSearchParams},useSearchParams:function(){return useSearchParams},usePathname:function(){return usePathname},ServerInsertedHTMLContext:function(){return i.ServerInsertedHTMLContext},useServerInsertedHTML:function(){return i.useServerInsertedHTML},useRouter:function(){return useRouter},useParams:function(){return useParams},useSelectedLayoutSegments:function(){return useSelectedLayoutSegments},useSelectedLayoutSegment:function(){return useSelectedLayoutSegment},redirect:function(){return s.redirect},permanentRedirect:function(){return s.permanentRedirect},RedirectType:function(){return s.RedirectType},notFound:function(){return p.notFound}});let n=r(2265),a=r(6313),o=r(7407),u=r(3940),l=r(1263),i=r(3972),s=r(8466),p=r(9273),_=Symbol("internal for urlsearchparams readonly");function readonlyURLSearchParamsError(){return Error("ReadonlyURLSearchParams cannot be modified")}let ReadonlyURLSearchParams=class ReadonlyURLSearchParams{[Symbol.iterator](){return this[_][Symbol.iterator]()}append(){throw readonlyURLSearchParamsError()}delete(){throw readonlyURLSearchParamsError()}set(){throw readonlyURLSearchParamsError()}sort(){throw readonlyURLSearchParamsError()}constructor(e){this[_]=e,this.entries=e.entries.bind(e),this.forEach=e.forEach.bind(e),this.get=e.get.bind(e),this.getAll=e.getAll.bind(e),this.has=e.has.bind(e),this.keys=e.keys.bind(e),this.values=e.values.bind(e),this.toString=e.toString.bind(e),this.size=e.size}};function useSearchParams(){(0,u.clientHookInServerComponentError)("useSearchParams");let e=(0,n.useContext)(o.SearchParamsContext),t=(0,n.useMemo)(()=>e?new ReadonlyURLSearchParams(e):null,[e]);return t}function usePathname(){return(0,u.clientHookInServerComponentError)("usePathname"),(0,n.useContext)(o.PathnameContext)}function useRouter(){(0,u.clientHookInServerComponentError)("useRouter");let e=(0,n.useContext)(a.AppRouterContext);if(null===e)throw Error("invariant expected app router to be mounted");return e}function useParams(){(0,u.clientHookInServerComponentError)("useParams");let e=(0,n.useContext)(a.GlobalLayoutRouterContext),t=(0,n.useContext)(o.PathParamsContext);return(0,n.useMemo)(()=>(null==e?void 0:e.tree)?function getSelectedParams(e,t){void 0===t&&(t={});let r=e[1];for(let e of Object.values(r)){let r=e[0],n=Array.isArray(r),a=n?r[1]:r;if(!a||a.startsWith("__PAGE__"))continue;let o=n&&("c"===r[2]||"oc"===r[2]);o?t[r[0]]=r[1].split("/"):n&&(t[r[0]]=r[1]),t=getSelectedParams(e,t)}return t}(e.tree):t,[null==e?void 0:e.tree,t])}function useSelectedLayoutSegments(e){void 0===e&&(e="children"),(0,u.clientHookInServerComponentError)("useSelectedLayoutSegments");let{tree:t}=(0,n.useContext)(a.LayoutRouterContext);return function getSelectedLayoutSegmentPath(e,t,r,n){let a;if(void 0===r&&(r=!0),void 0===n&&(n=[]),r)a=e[1][t];else{var o;let t=e[1];a=null!=(o=t.children)?o:Object.values(t)[0]}if(!a)return n;let u=a[0],i=(0,l.getSegmentValue)(u);return!i||i.startsWith("__PAGE__")?n:(n.push(i),getSelectedLayoutSegmentPath(a,t,!1,n))}(t,e)}function useSelectedLayoutSegment(e){void 0===e&&(e="children"),(0,u.clientHookInServerComponentError)("useSelectedLayoutSegment");let t=useSelectedLayoutSegments(e);return 0===t.length?null:t[0]}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},3170:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"NotFoundBoundary",{enumerable:!0,get:function(){return NotFoundBoundary}});let n=r(1024),a=n._(r(2265)),o=r(94);let NotFoundErrorBoundary=class NotFoundErrorBoundary extends a.default.Component{static getDerivedStateFromError(e){if((null==e?void 0:e.digest)==="NEXT_NOT_FOUND")return{notFoundTriggered:!0};throw e}static getDerivedStateFromProps(e,t){return e.pathname!==t.previousPathname&&t.notFoundTriggered?{notFoundTriggered:!1,previousPathname:e.pathname}:{notFoundTriggered:t.notFoundTriggered,previousPathname:e.pathname}}render(){return this.state.notFoundTriggered?a.default.createElement(a.default.Fragment,null,a.default.createElement("meta",{name:"robots",content:"noindex"}),!1,this.props.notFoundStyles,this.props.notFound):this.props.children}constructor(e){super(e),this.state={notFoundTriggered:!!e.asNotFound,previousPathname:e.pathname}}};function NotFoundBoundary(e){let{notFound:t,notFoundStyles:r,asNotFound:n,children:u}=e,l=(0,o.usePathname)();return t?a.default.createElement(NotFoundErrorBoundary,{pathname:l,notFound:t,notFoundStyles:r,asNotFound:n},u):a.default.createElement(a.default.Fragment,null,u)}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},9273:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{notFound:function(){return notFound},isNotFoundError:function(){return isNotFoundError}});let r="NEXT_NOT_FOUND";function notFound(){let e=Error(r);throw e.digest=r,e}function isNotFoundError(e){return(null==e?void 0:e.digest)===r}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},839:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"PromiseQueue",{enumerable:!0,get:function(){return PromiseQueue}});let n=r(4677),a=r(6249);var o=a._("_maxConcurrency"),u=a._("_runningCount"),l=a._("_queue"),i=a._("_processNext");let PromiseQueue=class PromiseQueue{enqueue(e){let t,r;let a=new Promise((e,n)=>{t=e,r=n}),task=async()=>{try{n._(this,u)[u]++;let r=await e();t(r)}catch(e){r(e)}finally{n._(this,u)[u]--,n._(this,i)[i]()}};return n._(this,l)[l].push({promiseFn:a,task}),n._(this,i)[i](),a}bump(e){let t=n._(this,l)[l].findIndex(t=>t.promiseFn===e);if(t>-1){let e=n._(this,l)[l].splice(t,1)[0];n._(this,l)[l].unshift(e),n._(this,i)[i](!0)}}constructor(e=5){Object.defineProperty(this,i,{value:processNext}),Object.defineProperty(this,o,{writable:!0,value:void 0}),Object.defineProperty(this,u,{writable:!0,value:void 0}),Object.defineProperty(this,l,{writable:!0,value:void 0}),n._(this,o)[o]=e,n._(this,u)[u]=0,n._(this,l)[l]=[]}};function processNext(e){if(void 0===e&&(e=!1),(n._(this,u)[u]0){var t;null==(t=n._(this,l)[l].shift())||t.task()}}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},5138:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{RedirectErrorBoundary:function(){return RedirectErrorBoundary},RedirectBoundary:function(){return RedirectBoundary}});let n=r(8533),a=n._(r(2265)),o=r(94),u=r(8466);function HandleRedirect(e){let{redirect:t,reset:r,redirectType:n}=e,l=(0,o.useRouter)();return(0,a.useEffect)(()=>{a.default.startTransition(()=>{n===u.RedirectType.push?l.push(t,{}):l.replace(t,{}),r()})},[t,n,r,l]),null}let RedirectErrorBoundary=class RedirectErrorBoundary extends a.default.Component{static getDerivedStateFromError(e){if((0,u.isRedirectError)(e)){let t=(0,u.getURLFromRedirectError)(e),r=(0,u.getRedirectTypeFromError)(e);return{redirect:t,redirectType:r}}throw e}render(){let{redirect:e,redirectType:t}=this.state;return null!==e&&null!==t?a.default.createElement(HandleRedirect,{redirect:e,redirectType:t,reset:()=>this.setState({redirect:null})}):this.props.children}constructor(e){super(e),this.state={redirect:null,redirectType:null}}};function RedirectBoundary(e){let{children:t}=e,r=(0,o.useRouter)();return a.default.createElement(RedirectErrorBoundary,{router:r},t)}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},8466:function(e,t,r){"use strict";var n,a;Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{RedirectType:function(){return n},getRedirectError:function(){return getRedirectError},redirect:function(){return redirect},permanentRedirect:function(){return permanentRedirect},isRedirectError:function(){return isRedirectError},getURLFromRedirectError:function(){return getURLFromRedirectError},getRedirectTypeFromError:function(){return getRedirectTypeFromError}});let o=r(228),u="NEXT_REDIRECT";function getRedirectError(e,t,r){void 0===r&&(r=!1);let n=Error(u);n.digest=u+";"+t+";"+e+";"+r;let a=o.requestAsyncStorage.getStore();return a&&(n.mutableCookies=a.mutableCookies),n}function redirect(e,t){throw void 0===t&&(t="replace"),getRedirectError(e,t,!1)}function permanentRedirect(e,t){throw void 0===t&&(t="replace"),getRedirectError(e,t,!0)}function isRedirectError(e){if("string"!=typeof(null==e?void 0:e.digest))return!1;let[t,r,n,a]=e.digest.split(";",4);return t===u&&("replace"===r||"push"===r)&&"string"==typeof n&&("true"===a||"false"===a)}function getURLFromRedirectError(e){return isRedirectError(e)?e.digest.split(";",3)[2]:null}function getRedirectTypeFromError(e){if(!isRedirectError(e))throw Error("Not a redirect error");return e.digest.split(";",3)[1]}(a=n||(n={})).push="push",a.replace="replace",("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},7264:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return RenderFromTemplateContext}});let n=r(8533),a=n._(r(2265)),o=r(6313);function RenderFromTemplateContext(){let e=(0,a.useContext)(o.TemplateContext);return a.default.createElement(a.default.Fragment,null,e)}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},228:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"requestAsyncStorage",{enumerable:!0,get:function(){return a}});let n=r(7346),a=(0,n.createAsyncLocalStorage)();("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},2713:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"applyFlightData",{enumerable:!0,get:function(){return applyFlightData}});let n=r(6313),a=r(782),o=r(1956);function applyFlightData(e,t,r,u){void 0===u&&(u=!1);let[l,i,s]=r.slice(-3);return null!==i&&(3===r.length?(t.status=n.CacheStates.READY,t.subTreeData=i,(0,a.fillLazyItemsTillLeafWithHead)(t,e,l,s,u)):(t.status=n.CacheStates.READY,t.subTreeData=e.subTreeData,t.parallelRoutes=new Map(e.parallelRoutes),(0,o.fillCacheWithNewSubTreeData)(t,e,r,u)),!0)}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},8934:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"applyRouterStatePatchToTree",{enumerable:!0,get:function(){return function applyRouterStatePatchToTree(e,t,r){let a;let[o,u,,,l]=t;if(1===e.length){let e=applyPatch(t,r);return e}let[i,s]=e;if(!(0,n.matchSegment)(i,o))return null;let p=2===e.length;if(p)a=applyPatch(u[s],r);else if(null===(a=applyRouterStatePatchToTree(e.slice(2),u[s],r)))return null;let _=[e[0],{...u,[s]:a}];return l&&(_[4]=!0),_}}});let n=r(8163);function applyPatch(e,t){let[r,a]=e,[o,u]=t;if("__DEFAULT__"===o&&"__DEFAULT__"!==r)return e;if((0,n.matchSegment)(r,o)){let t={};for(let e in a){let r=void 0!==u[e];r?t[e]=applyPatch(a[e],u[e]):t[e]=a[e]}for(let e in u)t[e]||(t[e]=u[e]);let n=[r,t];return e[2]&&(n[2]=e[2]),e[3]&&(n[3]=e[3]),e[4]&&(n[4]=e[4]),n}return t}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},2082:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{extractPathFromFlightRouterState:function(){return extractPathFromFlightRouterState},computeChangedPath:function(){return computeChangedPath}});let n=r(4507),a=r(1706),o=r(8163),removeLeadingSlash=e=>"/"===e[0]?e.slice(1):e,segmentToPathname=e=>"string"==typeof e?e:e[1];function normalizeSegments(e){return e.reduce((e,t)=>""===(t=removeLeadingSlash(t))||(0,a.isGroupSegment)(t)?e:e+"/"+t,"")||"/"}function extractPathFromFlightRouterState(e){var t;let r=Array.isArray(e[0])?e[0][1]:e[0];if("__DEFAULT__"===r||n.INTERCEPTION_ROUTE_MARKERS.some(e=>r.startsWith(e)))return;if(r.startsWith("__PAGE__"))return"";let a=[r],o=null!=(t=e[1])?t:{},u=o.children?extractPathFromFlightRouterState(o.children):void 0;if(void 0!==u)a.push(u);else for(let[e,t]of Object.entries(o)){if("children"===e)continue;let r=extractPathFromFlightRouterState(t);void 0!==r&&a.push(r)}return normalizeSegments(a)}function computeChangedPath(e,t){let r=function computeChangedPathImpl(e,t){let[r,a]=e,[u,l]=t,i=segmentToPathname(r),s=segmentToPathname(u);if(n.INTERCEPTION_ROUTE_MARKERS.some(e=>i.startsWith(e)||s.startsWith(e)))return"";if(!(0,o.matchSegment)(r,u)){var p;return null!=(p=extractPathFromFlightRouterState(t))?p:""}for(let e in a)if(l[e]){let t=computeChangedPathImpl(a[e],l[e]);if(null!==t)return segmentToPathname(u)+"/"+t}return null}(e,t);return null==r||"/"===r?r:normalizeSegments(r.split("/"))}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},2301:function(e,t){"use strict";function createHrefFromUrl(e,t){return void 0===t&&(t=!0),e.pathname+e.search+(t?e.hash:"")}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"createHrefFromUrl",{enumerable:!0,get:function(){return createHrefFromUrl}}),("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},5311:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"createInitialRouterState",{enumerable:!0,get:function(){return createInitialRouterState}});let n=r(6313),a=r(2301),o=r(782),u=r(2082);function createInitialRouterState(e){var t;let{buildId:r,initialTree:l,children:i,initialCanonicalUrl:s,initialParallelRoutes:p,isServer:_,location:b,initialHead:v}=e,m={status:n.CacheStates.READY,data:null,subTreeData:i,parallelRoutes:_?new Map:p};return(null===p||0===p.size)&&(0,o.fillLazyItemsTillLeafWithHead)(m,void 0,l,v),{buildId:r,tree:l,cache:m,prefetchCache:new Map,pushRef:{pendingPush:!1,mpaNavigation:!1},focusAndScrollRef:{apply:!1,onlyHashChange:!1,hashFragment:null,segmentPaths:[]},canonicalUrl:b?(0,a.createHrefFromUrl)(b):s,nextUrl:null!=(t=(0,u.extractPathFromFlightRouterState)(l)||(null==b?void 0:b.pathname))?t:null}}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},180:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"createOptimisticTree",{enumerable:!0,get:function(){return function createOptimisticTree(e,t,r){let a;let[o,u,l,i,s]=t||[null,{}],p=e[0],_=1===e.length,b=null!==o&&(0,n.matchSegment)(o,p),v=Object.keys(u).length>1,m=!t||!b||v,E={};if(null!==o&&b&&(E=u),!_&&!v){let t=createOptimisticTree(e.slice(1),E?E.children:null,r||m);a=t}let j=[p,{...E,...a?{children:a}:{}}];return l&&(j[2]=l),!r&&m?j[3]="refetch":b&&i&&(j[3]=i),b&&s&&(j[4]=s),j}}});let n=r(8163);("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},3559:function(e,t){"use strict";function createRecordFromThenable(e){return e.status="pending",e.then(t=>{"pending"===e.status&&(e.status="fulfilled",e.value=t)},t=>{"pending"===e.status&&(e.status="rejected",e.reason=t)}),e}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"createRecordFromThenable",{enumerable:!0,get:function(){return createRecordFromThenable}}),("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},3322:function(e,t){"use strict";function createRouterCacheKey(e,t){return void 0===t&&(t=!1),Array.isArray(e)?(e[0]+"|"+e[1]+"|"+e[2]).toLowerCase():t&&e.startsWith("__PAGE__")?"__PAGE__":e}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"createRouterCacheKey",{enumerable:!0,get:function(){return createRouterCacheKey}}),("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},8146:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"fetchServerResponse",{enumerable:!0,get:function(){return fetchServerResponse}});let n=r(8343),a=r(3728),o=r(5231),u=r(9706),l=r(6360),{createFromFetch:i}=r(6671);function doMpaNavigation(e){return[(0,a.urlToUrlWithoutFlightMarker)(e).toString(),void 0]}async function fetchServerResponse(e,t,r,s,p){let _={[n.RSC]:"1",[n.NEXT_ROUTER_STATE_TREE]:encodeURIComponent(JSON.stringify(t))};p===u.PrefetchKind.AUTO&&(_[n.NEXT_ROUTER_PREFETCH]="1"),r&&(_[n.NEXT_URL]=r);let b=(0,l.hexHash)([_[n.NEXT_ROUTER_PREFETCH]||"0",_[n.NEXT_ROUTER_STATE_TREE],_[n.NEXT_URL]].join(","));try{let t=new URL(e);t.pathname.endsWith("/")?t.pathname+="index.txt":t.pathname+=".txt",t.searchParams.set(n.NEXT_RSC_UNION_QUERY,b);let r=await fetch(t,{credentials:"same-origin",headers:_}),u=(0,a.urlToUrlWithoutFlightMarker)(r.url),l=r.redirected?u:void 0,p=r.headers.get("content-type")||"",v=p===n.RSC_CONTENT_TYPE_HEADER;if(v||(v=p.startsWith("text/plain")),!v||!r.ok)return e.hash&&(u.hash=e.hash),doMpaNavigation(u.toString());let[m,E]=await i(Promise.resolve(r),{callServer:o.callServer});if(s!==m)return doMpaNavigation(r.url);return[E,l]}catch(t){return console.error("Failed to fetch RSC payload for "+e+". Falling back to browser navigation.",t),[e.toString(),void 0]}}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},6443:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"fillCacheWithDataProperty",{enumerable:!0,get:function(){return function fillCacheWithDataProperty(e,t,r,o,u){void 0===u&&(u=!1);let l=r.length<=2,[i,s]=r,p=(0,a.createRouterCacheKey)(s),_=t.parallelRoutes.get(i);if(!_||u&&t.parallelRoutes.size>1)return{bailOptimistic:!0};let b=e.parallelRoutes.get(i);b&&b!==_||(b=new Map(_),e.parallelRoutes.set(i,b));let v=_.get(p),m=b.get(p);if(l){m&&m.data&&m!==v||b.set(p,{status:n.CacheStates.DATA_FETCH,data:o(),subTreeData:null,parallelRoutes:new Map});return}if(!m||!v){m||b.set(p,{status:n.CacheStates.DATA_FETCH,data:o(),subTreeData:null,parallelRoutes:new Map});return}return m===v&&(m={status:m.status,data:m.data,subTreeData:m.subTreeData,parallelRoutes:new Map(m.parallelRoutes)},b.set(p,m)),fillCacheWithDataProperty(m,v,r.slice(2),o)}}});let n=r(6313),a=r(3322);("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},1956:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"fillCacheWithNewSubTreeData",{enumerable:!0,get:function(){return function fillCacheWithNewSubTreeData(e,t,r,l){let i=r.length<=5,[s,p]=r,_=(0,u.createRouterCacheKey)(p),b=t.parallelRoutes.get(s);if(!b)return;let v=e.parallelRoutes.get(s);v&&v!==b||(v=new Map(b),e.parallelRoutes.set(s,v));let m=b.get(_),E=v.get(_);if(i){E&&E.data&&E!==m||(E={status:n.CacheStates.READY,data:null,subTreeData:r[3],parallelRoutes:m?new Map(m.parallelRoutes):new Map},m&&(0,a.invalidateCacheByRouterState)(E,m,r[2]),(0,o.fillLazyItemsTillLeafWithHead)(E,m,r[2],r[4],l),v.set(_,E));return}E&&m&&(E===m&&(E={status:E.status,data:E.data,subTreeData:E.subTreeData,parallelRoutes:new Map(E.parallelRoutes)},v.set(_,E)),fillCacheWithNewSubTreeData(E,m,r.slice(2),l))}}});let n=r(6313),a=r(5303),o=r(782),u=r(3322);("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},782:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"fillLazyItemsTillLeafWithHead",{enumerable:!0,get:function(){return function fillLazyItemsTillLeafWithHead(e,t,r,o,u){let l=0===Object.keys(r[1]).length;if(l){e.head=o;return}for(let l in r[1]){let i=r[1][l],s=i[0],p=(0,a.createRouterCacheKey)(s);if(t){let r=t.parallelRoutes.get(l);if(r){let t=new Map(r),a=t.get(p),s=u&&a?{status:a.status,data:a.data,subTreeData:a.subTreeData,parallelRoutes:new Map(a.parallelRoutes)}:{status:n.CacheStates.LAZY_INITIALIZED,data:null,subTreeData:null,parallelRoutes:new Map(null==a?void 0:a.parallelRoutes)};t.set(p,s),fillLazyItemsTillLeafWithHead(s,a,i,o,u),e.parallelRoutes.set(l,t);continue}}let _={status:n.CacheStates.LAZY_INITIALIZED,data:null,subTreeData:null,parallelRoutes:new Map},b=e.parallelRoutes.get(l);b?b.set(p,_):e.parallelRoutes.set(l,new Map([[p,_]])),fillLazyItemsTillLeafWithHead(_,void 0,i,o,u)}}}});let n=r(6313),a=r(3322);("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},2800:function(e,t){"use strict";var r,n;function getPrefetchEntryCacheStatus(e){let{kind:t,prefetchTime:r,lastUsedTime:n}=e;return Date.now()<(null!=n?n:r)+3e4?n?"reusable":"fresh":"auto"===t&&Date.now()["children",e]).flat(),v=(0,s.fillCacheWithDataProperty)(i,e.cache,b,()=>(_||(_=(0,o.createRecordFromThenable)((0,a.fetchServerResponse)(r,u,e.nextUrl,e.buildId))),_),!0);if(!(null==v?void 0:v.bailOptimistic))return B.previousTree=e.tree,B.patchedTree=u,B.pendingPush=et,B.hashFragment=q,B.shouldScroll=z,B.scrollableSegments=[],B.cache=i,B.canonicalUrl=ee,e.prefetchCache.set((0,l.createHrefFromUrl)(r,!1),{data:_?(0,o.createRecordFromThenable)(Promise.resolve(_)):null,kind:m.PrefetchKind.TEMPORARY,prefetchTime:Date.now(),treeAtTimeOfPrefetch:e.tree,lastUsedTime:Date.now()}),(0,E.handleMutable)(e,B)}if(!en){let t=(0,o.createRecordFromThenable)((0,a.fetchServerResponse)(r,e.tree,e.nextUrl,e.buildId,void 0)),n={data:(0,o.createRecordFromThenable)(Promise.resolve(t)),kind:m.PrefetchKind.TEMPORARY,prefetchTime:Date.now(),treeAtTimeOfPrefetch:e.tree,lastUsedTime:null};e.prefetchCache.set((0,l.createHrefFromUrl)(r,!1),n),en=n}let ea=(0,C.getPrefetchEntryCacheStatus)(en),{treeAtTimeOfPrefetch:eo,data:eu}=en;A.prefetchQueue.bump(eu);let[el,ei]=(0,u.readRecordValue)(eu);if(en.lastUsedTime||(en.lastUsedTime=Date.now()),"string"==typeof el)return handleExternalUrl(e,B,el,et);let ec=e.tree,es=e.cache,ef=[];for(let t of el){let u=t.slice(0,-4),l=t.slice(-3)[0],p=["",...u],m=(0,_.applyRouterStatePatchToTree)(p,ec,l);if(null===m&&(m=(0,_.applyRouterStatePatchToTree)(p,eo,l)),null!==m){if((0,v.isNavigatingToNewRootLayout)(ec,m))return handleExternalUrl(e,B,ee,et);let _=(0,j.applyFlightData)(es,U,t,"auto"===en.kind&&ea===C.PrefetchCacheEntryStatus.reusable);_||ea!==C.PrefetchCacheEntryStatus.stale||(_=function(e,t,r,a,o){let u=!1;e.status=n.CacheStates.READY,e.subTreeData=t.subTreeData,e.parallelRoutes=new Map(t.parallelRoutes);let l=generateSegmentsFromPatch(a).map(e=>[...r,...e]);for(let r of l){let n=(0,s.fillCacheWithDataProperty)(e,t,r,o);(null==n?void 0:n.bailOptimistic)||(u=!0)}return u}(U,es,u,l,()=>(0,o.createRecordFromThenable)((0,a.fetchServerResponse)(r,ec,e.nextUrl,e.buildId))));let E=(0,b.shouldHardNavigate)(p,ec);for(let e of(E?(U.status=n.CacheStates.READY,U.subTreeData=es.subTreeData,(0,i.invalidateCacheBelowFlightSegmentPath)(U,es,u),B.cache=U):_&&(B.cache=U),es=U,ec=m,generateSegmentsFromPatch(l))){let t=[...u,...e];"__DEFAULT__"!==t[t.length-1]&&ef.push(t)}}}return B.previousTree=e.tree,B.patchedTree=ec,B.canonicalUrl=ei?(0,l.createHrefFromUrl)(ei):ee,B.pendingPush=et,B.scrollableSegments=ef,B.hashFragment=q,B.shouldScroll=z,(0,E.handleMutable)(e,B)}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},3709:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{prefetchQueue:function(){return p},prefetchReducer:function(){return prefetchReducer}});let n=r(2301),a=r(8146),o=r(9706),u=r(3559),l=r(3627),i=r(8343),s=r(839),p=new s.PromiseQueue(5);function prefetchReducer(e,t){(0,l.prunePrefetchCache)(e.prefetchCache);let{url:r}=t;r.searchParams.delete(i.NEXT_RSC_UNION_QUERY);let s=(0,n.createHrefFromUrl)(r,!1),_=e.prefetchCache.get(s);if(_&&(_.kind===o.PrefetchKind.TEMPORARY&&e.prefetchCache.set(s,{..._,kind:t.kind}),!(_.kind===o.PrefetchKind.AUTO&&t.kind===o.PrefetchKind.FULL)))return e;let b=(0,u.createRecordFromThenable)(p.enqueue(()=>(0,a.fetchServerResponse)(r,e.tree,e.nextUrl,e.buildId,t.kind)));return e.prefetchCache.set(s,{treeAtTimeOfPrefetch:e.tree,data:b,kind:t.kind,prefetchTime:Date.now(),lastUsedTime:null}),e}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},3627:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"prunePrefetchCache",{enumerable:!0,get:function(){return prunePrefetchCache}});let n=r(2800);function prunePrefetchCache(e){for(let[t,r]of e)(0,n.getPrefetchEntryCacheStatus)(r)===n.PrefetchCacheEntryStatus.expired&&e.delete(t)}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},2701:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"refreshReducer",{enumerable:!0,get:function(){return refreshReducer}});let n=r(8146),a=r(3559),o=r(929),u=r(2301),l=r(8934),i=r(2782),s=r(8640),p=r(8543),_=r(6313),b=r(782);function refreshReducer(e,t){let{cache:r,mutable:v,origin:m}=t,E=e.canonicalUrl,j=e.tree,C=JSON.stringify(v.previousTree)===JSON.stringify(j);if(C)return(0,p.handleMutable)(e,v);r.data||(r.data=(0,a.createRecordFromThenable)((0,n.fetchServerResponse)(new URL(E,m),[j[0],j[1],j[2],"refetch"],e.nextUrl,e.buildId)));let[w,A]=(0,o.readRecordValue)(r.data);if("string"==typeof w)return(0,s.handleExternalUrl)(e,v,w,e.pushRef.pendingPush);for(let t of(r.data=null,w)){if(3!==t.length)return console.log("REFRESH FAILED"),e;let[n]=t,a=(0,l.applyRouterStatePatchToTree)([""],j,n);if(null===a)throw Error("SEGMENT MISMATCH");if((0,i.isNavigatingToNewRootLayout)(j,a))return(0,s.handleExternalUrl)(e,v,E,e.pushRef.pendingPush);let o=A?(0,u.createHrefFromUrl)(A):void 0;A&&(v.canonicalUrl=o);let[p,m]=t.slice(-2);null!==p&&(r.status=_.CacheStates.READY,r.subTreeData=p,(0,b.fillLazyItemsTillLeafWithHead)(r,void 0,n,m),v.cache=r,v.prefetchCache=new Map),v.previousTree=j,v.patchedTree=a,v.canonicalUrl=E,j=a}return(0,p.handleMutable)(e,v)}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},1705:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"restoreReducer",{enumerable:!0,get:function(){return restoreReducer}});let n=r(2301);function restoreReducer(e,t){let{url:r,tree:a}=t,o=(0,n.createHrefFromUrl)(r);return{buildId:e.buildId,canonicalUrl:o,pushRef:e.pushRef,focusAndScrollRef:e.focusAndScrollRef,cache:e.cache,prefetchCache:e.prefetchCache,tree:a,nextUrl:r.pathname}}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},1383:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"serverActionReducer",{enumerable:!0,get:function(){return serverActionReducer}});let n=r(5231),a=r(8343),o=r(3559),u=r(929),l=r(9872),i=r(2301),s=r(8640),p=r(8934),_=r(2782),b=r(6313),v=r(8543),m=r(782),{createFromFetch:E,encodeReply:j}=r(6671);async function fetchServerAction(e,t){let r,{actionId:o,actionArgs:u}=t,i=await j(u),s=await fetch("",{method:"POST",headers:{Accept:a.RSC_CONTENT_TYPE_HEADER,[a.ACTION]:o,[a.NEXT_ROUTER_STATE_TREE]:encodeURIComponent(JSON.stringify(e.tree)),...e.nextUrl?{[a.NEXT_URL]:e.nextUrl}:{}},body:i}),p=s.headers.get("x-action-redirect");try{let e=JSON.parse(s.headers.get("x-action-revalidated")||"[[],0,0]");r={paths:e[0]||[],tag:!!e[1],cookie:e[2]}}catch(e){r={paths:[],tag:!1,cookie:!1}}let _=p?new URL((0,l.addBasePath)(p),new URL(e.canonicalUrl,window.location.href)):void 0;if(s.headers.get("content-type")===a.RSC_CONTENT_TYPE_HEADER){let e=await E(Promise.resolve(s),{callServer:n.callServer});if(p){let[,t]=null!=e?e:[];return{actionFlightData:t,redirectLocation:_,revalidatedParts:r}}let[t,[,a]]=null!=e?e:[];return{actionResult:t,actionFlightData:a,redirectLocation:_,revalidatedParts:r}}return{redirectLocation:_,revalidatedParts:r}}function serverActionReducer(e,t){let{mutable:r,cache:n,resolve:a,reject:l}=t,E=e.canonicalUrl,j=e.tree,C=JSON.stringify(r.previousTree)===JSON.stringify(j);if(C)return(0,v.handleMutable)(e,r);if(r.inFlightServerAction){if("fulfilled"!==r.inFlightServerAction.status&&r.globalMutable.pendingNavigatePath&&r.globalMutable.pendingNavigatePath!==E)return r.inFlightServerAction.then(()=>{r.actionResultResolved||(r.inFlightServerAction=null,r.globalMutable.pendingNavigatePath=void 0,r.globalMutable.refresh(),r.actionResultResolved=!0)},()=>{}),e}else r.inFlightServerAction=(0,o.createRecordFromThenable)(fetchServerAction(e,t));try{let{actionResult:t,actionFlightData:o,redirectLocation:l}=(0,u.readRecordValue)(r.inFlightServerAction);if(l&&(e.pushRef.pendingPush=!0,r.pendingPush=!0),r.previousTree=e.tree,!o){if(r.actionResultResolved||(a(t),r.actionResultResolved=!0),l)return(0,s.handleExternalUrl)(e,r,l.href,e.pushRef.pendingPush);return e}if("string"==typeof o)return(0,s.handleExternalUrl)(e,r,o,e.pushRef.pendingPush);for(let t of(r.inFlightServerAction=null,o)){if(3!==t.length)return console.log("SERVER ACTION APPLY FAILED"),e;let[a]=t,o=(0,p.applyRouterStatePatchToTree)([""],j,a);if(null===o)throw Error("SEGMENT MISMATCH");if((0,_.isNavigatingToNewRootLayout)(j,o))return(0,s.handleExternalUrl)(e,r,E,e.pushRef.pendingPush);let[u,l]=t.slice(-2);null!==u&&(n.status=b.CacheStates.READY,n.subTreeData=u,(0,m.fillLazyItemsTillLeafWithHead)(n,void 0,a,l),r.cache=n,r.prefetchCache=new Map),r.previousTree=j,r.patchedTree=o,r.canonicalUrl=E,j=o}if(l){let e=(0,i.createHrefFromUrl)(l,!1);r.canonicalUrl=e}return r.actionResultResolved||(a(t),r.actionResultResolved=!0),(0,v.handleMutable)(e,r)}catch(t){if("rejected"===t.status)return r.actionResultResolved||(l(t.reason),r.actionResultResolved=!0),e;throw t}}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},5330:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"serverPatchReducer",{enumerable:!0,get:function(){return serverPatchReducer}});let n=r(2301),a=r(8934),o=r(2782),u=r(8640),l=r(2713),i=r(8543);function serverPatchReducer(e,t){let{flightData:r,previousTree:s,overrideCanonicalUrl:p,cache:_,mutable:b}=t,v=JSON.stringify(s)===JSON.stringify(e.tree);if(!v)return console.log("TREE MISMATCH"),e;if(b.previousTree)return(0,i.handleMutable)(e,b);if("string"==typeof r)return(0,u.handleExternalUrl)(e,b,r,e.pushRef.pendingPush);let m=e.tree,E=e.cache;for(let t of r){let r=t.slice(0,-4),[i]=t.slice(-3,-2),s=(0,a.applyRouterStatePatchToTree)(["",...r],m,i);if(null===s)throw Error("SEGMENT MISMATCH");if((0,o.isNavigatingToNewRootLayout)(m,s))return(0,u.handleExternalUrl)(e,b,e.canonicalUrl,e.pushRef.pendingPush);let v=p?(0,n.createHrefFromUrl)(p):void 0;v&&(b.canonicalUrl=v),(0,l.applyFlightData)(E,_,t),b.previousTree=m,b.patchedTree=s,b.cache=_,E=_,m=s}return(0,i.handleMutable)(e,b)}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},9706:function(e,t){"use strict";var r,n;Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{PrefetchKind:function(){return r},ACTION_REFRESH:function(){return a},ACTION_NAVIGATE:function(){return o},ACTION_RESTORE:function(){return u},ACTION_SERVER_PATCH:function(){return l},ACTION_PREFETCH:function(){return i},ACTION_FAST_REFRESH:function(){return s},ACTION_SERVER_ACTION:function(){return p}});let a="refresh",o="navigate",u="restore",l="server-patch",i="prefetch",s="fast-refresh",p="server-action";(n=r||(r={})).AUTO="auto",n.FULL="full",n.TEMPORARY="temporary",("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},7205:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"reducer",{enumerable:!0,get:function(){return reducer}});let n=r(9706),a=r(8640),o=r(5330),u=r(1705),l=r(2701),i=r(3709),s=r(3682),p=r(1383),reducer=function(e,t){switch(t.type){case n.ACTION_NAVIGATE:return(0,a.navigateReducer)(e,t);case n.ACTION_SERVER_PATCH:return(0,o.serverPatchReducer)(e,t);case n.ACTION_RESTORE:return(0,u.restoreReducer)(e,t);case n.ACTION_REFRESH:return(0,l.refreshReducer)(e,t);case n.ACTION_FAST_REFRESH:return(0,s.fastRefreshReducer)(e,t);case n.ACTION_PREFETCH:return(0,i.prefetchReducer)(e,t);case n.ACTION_SERVER_ACTION:return(0,p.serverActionReducer)(e,t);default:throw Error("Unknown action")}};("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},3006:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"shouldHardNavigate",{enumerable:!0,get:function(){return function shouldHardNavigate(e,t){let[r,a]=t,[o,u]=e;if(!(0,n.matchSegment)(o,r))return!!Array.isArray(o);let l=e.length<=2;return!l&&shouldHardNavigate(e.slice(2),a[u])}}});let n=r(8163);("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},8519:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"createSearchParamsBailoutProxy",{enumerable:!0,get:function(){return createSearchParamsBailoutProxy}});let n=r(2004);function createSearchParamsBailoutProxy(){return new Proxy({},{get(e,t){"string"==typeof t&&(0,n.staticGenerationBailout)("searchParams."+t)}})}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},8985:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"staticGenerationAsyncStorage",{enumerable:!0,get:function(){return a}});let n=r(7346),a=(0,n.createAsyncLocalStorage)();("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},2004:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"staticGenerationBailout",{enumerable:!0,get:function(){return staticGenerationBailout}});let n=r(1351),a=r(8985);let StaticGenBailoutError=class StaticGenBailoutError extends Error{constructor(...e){super(...e),this.code="NEXT_STATIC_GEN_BAILOUT"}};function formatErrorMessage(e,t){let{dynamic:r,link:n}=t||{};return"Page"+(r?' with `dynamic = "'+r+'"`':"")+" couldn't be rendered statically because it used `"+e+"`."+(n?" See more info here: "+n:"")}let staticGenerationBailout=(e,t)=>{let r=a.staticGenerationAsyncStorage.getStore();if(null==r?void 0:r.forceStatic)return!0;if(null==r?void 0:r.dynamicShouldError){var o;throw new StaticGenBailoutError(formatErrorMessage(e,{...t,dynamic:null!=(o=null==t?void 0:t.dynamic)?o:"error"}))}if(!r||(r.revalidate=0,(null==t?void 0:t.dynamic)||(r.staticPrefetchBailout=!0)),null==r?void 0:r.isStaticGeneration){let a=new n.DynamicServerError(formatErrorMessage(e,{...t,link:"https://nextjs.org/docs/messages/dynamic-server-error"}));throw r.dynamicUsageDescription=e,r.dynamicUsageStack=a.stack,a}return!1};("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},8297:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return StaticGenerationSearchParamsBailoutProvider}});let n=r(1024),a=n._(r(2265)),o=r(8519);function StaticGenerationSearchParamsBailoutProvider(e){let{Component:t,propsForComponent:r,isStaticGeneration:n}=e;if(n){let e=(0,o.createSearchParamsBailoutProxy)();return a.default.createElement(t,{searchParams:e,...r})}return a.default.createElement(t,r)}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},2327:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"useReducerWithReduxDevtools",{enumerable:!0,get:function(){return useReducerWithReduxDevtools}});let n=r(2265);function normalizeRouterState(e){if(e instanceof Map){let t={};for(let[r,n]of e.entries()){if("function"==typeof n){t[r]="fn()";continue}if("object"==typeof n&&null!==n){if(n.$$typeof){t[r]=n.$$typeof.toString();continue}if(n._bundlerConfig){t[r]="FlightData";continue}}t[r]=normalizeRouterState(n)}return t}if("object"==typeof e&&null!==e){let t={};for(let r in e){let n=e[r];if("function"==typeof n){t[r]="fn()";continue}if("object"==typeof n&&null!==n){if(n.$$typeof){t[r]=n.$$typeof.toString();continue}if(n.hasOwnProperty("_bundlerConfig")){t[r]="FlightData";continue}}t[r]=normalizeRouterState(n)}return t}return Array.isArray(e)?e.map(normalizeRouterState):e}let useReducerWithReduxDevtools=function(e,t){let r=(0,n.useRef)(),a=(0,n.useRef)();(0,n.useEffect)(()=>{if(!r.current&&!1!==a.current){if(void 0===a.current&&void 0===window.__REDUX_DEVTOOLS_EXTENSION__){a.current=!1;return}return r.current=window.__REDUX_DEVTOOLS_EXTENSION__.connect({instanceId:8e3,name:"next-router"}),r.current&&r.current.init(normalizeRouterState(t)),()=>{r.current=void 0}}},[t]);let[o,u]=(0,n.useReducer)((t,n)=>{let a=e(t,n);return r.current&&r.current.send(n,normalizeRouterState(a)),a},t),l=(0,n.useCallback)(()=>{r.current&&r.current.send({type:"RENDER_SYNC"},normalizeRouterState(o))},[o]);return[o,u,l]};("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},6746:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"hasBasePath",{enumerable:!0,get:function(){return hasBasePath}});let n=r(1446);function hasBasePath(e){return(0,n.pathHasPrefix)(e,"")}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},3997:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"normalizePathTrailingSlash",{enumerable:!0,get:function(){return normalizePathTrailingSlash}});let n=r(9006),a=r(9466),normalizePathTrailingSlash=e=>{if(!e.startsWith("/"))return e;let{pathname:t,query:r,hash:o}=(0,a.parsePath)(e);return""+(0,n.removeTrailingSlash)(t)+r+o};("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},2504:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return onRecoverableError}});let n=r(1283);function onRecoverableError(e){let t="function"==typeof reportError?reportError:e=>{window.console.error(e)};e.digest!==n.NEXT_DYNAMIC_NO_SSR_CODE&&t(e)}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},3714:function(e,t,r){"use strict";function removeBasePath(e){return e}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"removeBasePath",{enumerable:!0,get:function(){return removeBasePath}}),r(6746),("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},6313:function(e,t,r){"use strict";var n,a;Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{CacheStates:function(){return n},AppRouterContext:function(){return l},LayoutRouterContext:function(){return i},GlobalLayoutRouterContext:function(){return s},TemplateContext:function(){return p}});let o=r(1024),u=o._(r(2265));(a=n||(n={})).LAZY_INITIALIZED="LAZYINITIALIZED",a.DATA_FETCH="DATAFETCH",a.READY="READY";let l=u.default.createContext(null),i=u.default.createContext(null),s=u.default.createContext(null),p=u.default.createContext(null)},6360:function(e,t){"use strict";function djb2Hash(e){let t=5381;for(let r=0;r!t||(0,a.isGroupSegment)(t)||"@"===t[0]||("page"===t||"route"===t)&&r===n.length-1?e:e+"/"+t,""))}function normalizeRscPath(e,t){return t?e.replace(/\.rsc($|\?)/,"$1"):e}},280:function(e,t){"use strict";function handleSmoothScroll(e,t){if(void 0===t&&(t={}),t.onlyHashChange){e();return}let r=document.documentElement,n=r.style.scrollBehavior;r.style.scrollBehavior="auto",t.dontForceLayout||r.getClientRects(),e(),r.style.scrollBehavior=n}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"handleSmoothScroll",{enumerable:!0,get:function(){return handleSmoothScroll}})},2169:function(e,t){"use strict";function isBot(e){return/Googlebot|Mediapartners-Google|AdsBot-Google|googleweblight|Storebot-Google|Google-PageRenderer|Bingbot|BingPreview|Slurp|DuckDuckBot|baiduspider|yandex|sogou|LinkedInBot|bitlybot|tumblr|vkShare|quora link preview|facebookexternalhit|facebookcatalog|Twitterbot|applebot|redditbot|Slackbot|Discordbot|WhatsApp|SkypeUriPreview|ia_archiver/i.test(e)}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"isBot",{enumerable:!0,get:function(){return isBot}})},9466:function(e,t){"use strict";function parsePath(e){let t=e.indexOf("#"),r=e.indexOf("?"),n=r>-1&&(t<0||r-1?{pathname:e.substring(0,n?r:t),query:n?e.substring(r,t>-1?t:void 0):"",hash:t>-1?e.slice(t):""}:{pathname:e,query:"",hash:""}}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"parsePath",{enumerable:!0,get:function(){return parsePath}})},1446:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"pathHasPrefix",{enumerable:!0,get:function(){return pathHasPrefix}});let n=r(9466);function pathHasPrefix(e,t){if("string"!=typeof e)return!1;let{pathname:r}=(0,n.parsePath)(e);return r===t||r.startsWith(t+"/")}},9006:function(e,t){"use strict";function removeTrailingSlash(e){return e.replace(/\/$/,"")||"/"}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"removeTrailingSlash",{enumerable:!0,get:function(){return removeTrailingSlash}})},1706:function(e,t){"use strict";function isGroupSegment(e){return"("===e[0]&&e.endsWith(")")}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"isGroupSegment",{enumerable:!0,get:function(){return isGroupSegment}})},3972:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{ServerInsertedHTMLContext:function(){return o},useServerInsertedHTML:function(){return useServerInsertedHTML}});let n=r(8533),a=n._(r(2265)),o=a.default.createContext(null);function useServerInsertedHTML(e){let t=(0,a.useContext)(o);t&&t(e)}},7346:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"createAsyncLocalStorage",{enumerable:!0,get:function(){return createAsyncLocalStorage}});let r=Error("Invariant: AsyncLocalStorage accessed in runtime where it is not available");let FakeAsyncLocalStorage=class FakeAsyncLocalStorage{disable(){throw r}getStore(){}run(){throw r}exit(){throw r}enterWith(){throw r}};let n=globalThis.AsyncLocalStorage;function createAsyncLocalStorage(){return n?new n:new FakeAsyncLocalStorage}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},4040:function(e,t,r){"use strict";var n=r(4887);t.createRoot=n.createRoot,t.hydrateRoot=n.hydrateRoot},4887:function(e,t,r){"use strict";!function checkDCE(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE)}catch(e){console.error(e)}}(),e.exports=r(4417)},7950:function(e,t,r){"use strict";/** + * @license React + * react-server-dom-webpack-client.browser.production.min.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var n=r(4887),a=r(2265),o={stream:!0},u=new Map;function x(e){var t=r(e);return"function"!=typeof t.then||"fulfilled"===t.status?null:(t.then(function(e){t.status="fulfilled",t.value=e},function(e){t.status="rejected",t.reason=e}),t)}function y(){}var l=new Map,i=r.u;r.u=function(e){var t=l.get(e);return void 0!==t?t:i(e)};var s=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Dispatcher,p=Symbol.for("react.element"),_=Symbol.for("react.provider"),b=Symbol.for("react.server_context"),v=Symbol.for("react.lazy"),m=Symbol.for("react.default_value"),E=Symbol.iterator,j=Array.isArray,C=new WeakMap,w=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ContextRegistry;function L(e,t,r,n){this.status=e,this.value=t,this.reason=r,this._response=n}function ia(e){switch(e.status){case"resolved_model":M(e);break;case"resolved_module":N(e)}switch(e.status){case"fulfilled":return e.value;case"pending":case"blocked":throw e;default:throw e.reason}}function O(e,t){for(var r=0;rp?(b=p,p=3,i++):(b=0,p=3);continue;case 2:44===(E=a[i++])?p=4:v=v<<4|(96a.length&&(E=-1)}var j=a.byteOffset+i;if(-1>>1,a=e[n];if(0>>1;ng(l,r))ig(s,l)?(e[n]=s,e[i]=r,n=i):(e[n]=l,e[u]=r,n=u);else if(ig(s,r))e[n]=s,e[i]=r,n=i;else break}}return t}function g(e,t){var r=e.sortIndex-t.sortIndex;return 0!==r?r:e.id-t.id}if(t.unstable_now=void 0,"object"==typeof performance&&"function"==typeof performance.now){var r,n=performance;t.unstable_now=function(){return n.now()}}else{var a=Date,o=a.now();t.unstable_now=function(){return a.now()-o}}var u=[],l=[],i=1,s=null,p=3,_=!1,b=!1,v=!1,m="function"==typeof setTimeout?setTimeout:null,E="function"==typeof clearTimeout?clearTimeout:null,j="undefined"!=typeof setImmediate?setImmediate:null;function G(e){for(var t=h(l);null!==t;){if(null===t.callback)k(l);else if(t.startTime<=e)k(l),t.sortIndex=t.expirationTime,f(u,t);else break;t=h(l)}}function H(e){if(v=!1,G(e),!b){if(null!==h(u))b=!0,I();else{var t=h(l);null!==t&&J(H,t.startTime-e)}}}"undefined"!=typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var C=!1,w=-1,A=5,F=-1;function O(){return!(t.unstable_now()-Fe&&O());){var o=s.callback;if("function"==typeof o){s.callback=null,p=s.priorityLevel;var i=o(s.expirationTime<=e);if(e=t.unstable_now(),"function"==typeof i){s.callback=i,G(e),n=!0;break t}s===h(u)&&k(u),G(e)}else k(u);s=h(u)}if(null!==s)n=!0;else{var m=h(l);null!==m&&J(H,m.startTime-e),n=!1}}break e}finally{s=null,p=a,_=!1}n=void 0}}finally{n?r():C=!1}}}if("function"==typeof j)r=function(){j(P)};else if("undefined"!=typeof MessageChannel){var D=new MessageChannel,U=D.port2;D.port1.onmessage=P,r=function(){U.postMessage(null)}}else r=function(){m(P,0)};function I(){C||(C=!0,r())}function J(e,r){w=m(function(){e(t.unstable_now())},r)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(e){e.callback=null},t.unstable_continueExecution=function(){b||_||(b=!0,I())},t.unstable_forceFrameRate=function(e){0>e||125a?(e.sortIndex=n,f(l,e),null===h(u)&&e===h(l)&&(v?(E(w),w=-1):v=!0,J(H,n-a))):(e.sortIndex=o,f(u,e),b||_||(b=!0,I())),e},t.unstable_shouldYield=O,t.unstable_wrapCallback=function(e){var t=p;return function(){var r=p;p=t;try{return e.apply(this,arguments)}finally{p=r}}}},8261:function(e,t,r){"use strict";e.exports=r(1756)},5682:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"getSegmentParam",{enumerable:!0,get:function(){return getSegmentParam}});let n=r(4507);function getSegmentParam(e){let t=n.INTERCEPTION_ROUTE_MARKERS.find(t=>e.startsWith(t));return(t&&(e=e.slice(t.length)),e.startsWith("[[...")&&e.endsWith("]]"))?{type:"optional-catchall",param:e.slice(5,-2)}:e.startsWith("[...")&&e.endsWith("]")?{type:"catchall",param:e.slice(4,-1)}:e.startsWith("[")&&e.endsWith("]")?{type:"dynamic",param:e.slice(1,-1)}:null}},4507:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{INTERCEPTION_ROUTE_MARKERS:function(){return a},isInterceptionRouteAppPath:function(){return isInterceptionRouteAppPath},extractInterceptionRouteInformation:function(){return extractInterceptionRouteInformation}});let n=r(3701),a=["(..)(..)","(.)","(..)","(...)"];function isInterceptionRouteAppPath(e){return void 0!==e.split("/").find(e=>a.find(t=>e.startsWith(t)))}function extractInterceptionRouteInformation(e){let t,r,o;for(let n of e.split("/"))if(r=a.find(e=>n.startsWith(e))){[t,o]=e.split(r,2);break}if(!t||!r||!o)throw Error(`Invalid interception route: ${e}. Must be in the format //(..|...|..)(..)/`);switch(t=(0,n.normalizeAppPath)(t),r){case"(.)":o="/"===t?`/${o}`:t+"/"+o;break;case"(..)":if("/"===t)throw Error(`Invalid interception route: ${e}. Cannot use (..) marker at the root level, use (.) instead.`);o=t.split("/").slice(0,-1).concat(o).join("/");break;case"(...)":o="/"+o;break;case"(..)(..)":let u=t.split("/");if(u.length<=2)throw Error(`Invalid interception route: ${e}. Cannot use (..)(..) marker at the root level or one level up.`);o=u.slice(0,-2).concat(o).join("/");break;default:throw Error("Invariant: unexpected marker")}return{interceptingRoute:t,interceptedRoute:o}}},4677:function(e,t,r){"use strict";function _class_private_field_loose_base(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}r.r(t),r.d(t,{_:function(){return _class_private_field_loose_base},_class_private_field_loose_base:function(){return _class_private_field_loose_base}})},6249:function(e,t,r){"use strict";r.r(t),r.d(t,{_:function(){return _class_private_field_loose_key},_class_private_field_loose_key:function(){return _class_private_field_loose_key}});var n=0;function _class_private_field_loose_key(e){return"__private_"+n+++"_"+e}},1024:function(e,t,r){"use strict";function _interop_require_default(e){return e&&e.__esModule?e:{default:e}}r.r(t),r.d(t,{_:function(){return _interop_require_default},_interop_require_default:function(){return _interop_require_default}})},8533:function(e,t,r){"use strict";function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(_getRequireWildcardCache=function(e){return e?r:t})(e)}function _interop_require_wildcard(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=_getRequireWildcardCache(t);if(r&&r.has(e))return r.get(e);var n={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var u=a?Object.getOwnPropertyDescriptor(e,o):null;u&&(u.get||u.set)?Object.defineProperty(n,o,u):n[o]=e[o]}return n.default=e,r&&r.set(e,n),n}r.r(t),r.d(t,{_:function(){return _interop_require_wildcard},_interop_require_wildcard:function(){return _interop_require_wildcard}})}}]); \ No newline at end of file diff --git a/rln-js/_next/static/chunks/822-38a22d62478b24fa.js b/rln-js/_next/static/chunks/822-38a22d62478b24fa.js new file mode 100644 index 0000000..7accc81 --- /dev/null +++ b/rln-js/_next/static/chunks/822-38a22d62478b24fa.js @@ -0,0 +1,73 @@ +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[822],{1376:function(O,U,$){"use strict";O.exports=$.p+"static/media/rln.74fdf8f1.wasm"},3019:function(O,U,$){"use strict";O.exports=$.p+"static/media/rln_final.8e7b6e79.zkey"},632:function(O,U,$){"use strict";O.exports=$.p+"static/media/rln_wasm_bg.b774b68e.wasm"},3121:function(O,U,$){"use strict";var J=this&&this.__awaiter||function(O,U,$,J){function adopt(O){return O instanceof $?O:new $(function(U){U(O)})}return new($||($=Promise))(function($,en){function fulfilled(O){try{step(J.next(O))}catch(O){en(O)}}function rejected(O){try{step(J.throw(O))}catch(O){en(O)}}function step(O){O.done?$(O.value):adopt(O.value).then(fulfilled,rejected)}step((J=J.apply(O,U||[])).next())})};Object.defineProperty(U,"__esModule",{value:!0}),U.verifyChecksum=U.checksum=U.defaultSha256Module=void 0;let en=$(8207),es=$(9449);function defaultSha256Module(){return{function:"sha256"}}function checksumData(O,U){return es.concatBytes(O.slice(16),U)}function checksum(O,U,$){if("sha256"===O.function)return Promise.resolve(en.sha256(checksumData(U,$)));throw Error("Invalid checksum type")}function verifyChecksum(O,U,$){return J(this,void 0,void 0,function*(){if("sha256"===O.function)return es.equalsBytes(es.hexToBytes(O.message),en.sha256(checksumData(U,$)));throw Error("Invalid checksum type")})}U.defaultSha256Module=defaultSha256Module,U.checksum=checksum,U.verifyChecksum=verifyChecksum},4589:function(O,U,$){"use strict";var J=this&&this.__awaiter||function(O,U,$,J){function adopt(O){return O instanceof $?O:new $(function(U){U(O)})}return new($||($=Promise))(function($,en){function fulfilled(O){try{step(J.next(O))}catch(O){en(O)}}function rejected(O){try{step(J.throw(O))}catch(O){en(O)}}function step(O){O.done?$(O.value):adopt(O.value).then(fulfilled,rejected)}step((J=J.apply(O,U||[])).next())})};Object.defineProperty(U,"__esModule",{value:!0}),U.cipherDecrypt=U.cipherEncrypt=U.defaultAes128CtrModule=void 0;let en=$(4610),es=$(215),eo=$(9449);function defaultAes128CtrModule(){return{function:"aes-128-ctr",params:{iv:eo.bytesToHex(en.getRandomBytesSync(16))}}}function cipherEncrypt(O,U,$){return J(this,void 0,void 0,function*(){if("aes-128-ctr"===O.function)try{return yield es.encrypt($,U,eo.hexToBytes(O.params.iv),O.function,!1)}catch(O){throw Error("Unable to encrypt")}else throw Error("Invalid cipher type")})}function cipherDecrypt(O,U){return J(this,void 0,void 0,function*(){if("aes-128-ctr"===O.function)try{return yield es.decrypt(eo.hexToBytes(O.message),U,eo.hexToBytes(O.params.iv),O.function,!1)}catch(O){throw Error("Unable to decrypt")}else throw Error("Invalid cipher type")})}U.defaultAes128CtrModule=defaultAes128CtrModule,U.cipherEncrypt=cipherEncrypt,U.cipherDecrypt=cipherDecrypt},2172:function(O,U,$){"use strict";var J=this&&this.__awaiter||function(O,U,$,J){function adopt(O){return O instanceof $?O:new $(function(U){U(O)})}return new($||($=Promise))(function($,en){function fulfilled(O){try{step(J.next(O))}catch(O){en(O)}}function rejected(O){try{step(J.throw(O))}catch(O){en(O)}}function step(O){O.done?$(O.value):adopt(O.value).then(fulfilled,rejected)}step((J=J.apply(O,U||[])).next())})};Object.defineProperty(U,"__esModule",{value:!0}),U.Keystore=void 0;let en=$(9686),es=$(3121),eo=$(4589),ea=$(5852),eu=$(7041);let Keystore=class Keystore{constructor(O){this.version=O.version,this.uuid=O.uuid,this.description=O.description,this.path=O.path,this.pubkey=O.pubkey,this.crypto={kdf:Object.assign({},O.crypto.kdf),checksum:Object.assign({},O.crypto.checksum),cipher:Object.assign({},O.crypto.cipher)}}static create(O,U,$,eu,ef=null,eg=en.defaultPbkdfModule(),ev=es.defaultSha256Module(),e_=eo.defaultAes128CtrModule()){return J(this,void 0,void 0,function*(){let J=yield ea.create(O,U,$,eu,ef,eg,ev,e_);return new Keystore(J)})}static fromObject(O){return eu.validateKeystore(O),new Keystore(O)}static parse(O){return Keystore.fromObject(JSON.parse(O))}decrypt(O){return J(this,void 0,void 0,function*(){return ea.decrypt(this,O)})}verifyPassword(O){return J(this,void 0,void 0,function*(){return ea.verifyPassword(this,O)})}toObject(){return Object.assign({},this)}stringify(){return JSON.stringify(this.toObject(),null,2)}};U.Keystore=Keystore},5852:function(O,U,$){"use strict";var J=this&&this.__awaiter||function(O,U,$,J){function adopt(O){return O instanceof $?O:new $(function(U){U(O)})}return new($||($=Promise))(function($,en){function fulfilled(O){try{step(J.next(O))}catch(O){en(O)}}function rejected(O){try{step(J.throw(O))}catch(O){en(O)}}function step(O){O.done?$(O.value):adopt(O.value).then(fulfilled,rejected)}step((J=J.apply(O,U||[])).next())})};Object.defineProperty(U,"__esModule",{value:!0}),U.decrypt=U.verifyPassword=U.create=U.defaultAes128CtrModule=U.defaultSha256Module=U.defaultScryptModule=U.defaultPbkdfModule=void 0;let en=$(6509),es=$(9686);Object.defineProperty(U,"defaultPbkdfModule",{enumerable:!0,get:function(){return es.defaultPbkdfModule}}),Object.defineProperty(U,"defaultScryptModule",{enumerable:!0,get:function(){return es.defaultScryptModule}});let eo=$(3121);Object.defineProperty(U,"defaultSha256Module",{enumerable:!0,get:function(){return eo.defaultSha256Module}});let ea=$(4589);Object.defineProperty(U,"defaultAes128CtrModule",{enumerable:!0,get:function(){return ea.defaultAes128CtrModule}});let eu=$(6357),ef=$(9449);function create(O,U,$,eg,ev=null,e_=es.defaultPbkdfModule(),ew=eo.defaultSha256Module(),eE=ea.defaultAes128CtrModule()){return J(this,void 0,void 0,function*(){let J=yield es.kdf(e_,eu.normalizePassword(O)),eS=yield ea.cipherEncrypt(eE,J.slice(0,16),U);return{version:4,uuid:en.v4(),description:ev||void 0,path:eg,pubkey:ef.bytesToHex($),crypto:{kdf:{function:e_.function,params:Object.assign({},e_.params),message:""},checksum:{function:ew.function,params:{},message:ef.bytesToHex((yield eo.checksum(ew,J,eS)))},cipher:{function:eE.function,params:Object.assign({},eE.params),message:ef.bytesToHex(eS)}}}})}function verifyPassword(O,U){return J(this,void 0,void 0,function*(){let $=yield es.kdf(O.crypto.kdf,eu.normalizePassword(U)),J=ef.hexToBytes(O.crypto.cipher.message);return eo.verifyChecksum(O.crypto.checksum,$,J)})}function decrypt(O,U){return J(this,void 0,void 0,function*(){let $=yield es.kdf(O.crypto.kdf,eu.normalizePassword(U)),J=ef.hexToBytes(O.crypto.cipher.message);if(!(yield eo.verifyChecksum(O.crypto.checksum,$,J)))throw Error("Invalid password");return ea.cipherDecrypt(O.crypto.cipher,$.slice(0,16))})}U.create=create,U.verifyPassword=verifyPassword,U.decrypt=decrypt},8063:function(O,U,$){"use strict";var J=this&&this.__createBinding||(Object.create?function(O,U,$,J){void 0===J&&(J=$),Object.defineProperty(O,J,{enumerable:!0,get:function(){return U[$]}})}:function(O,U,$,J){void 0===J&&(J=$),O[J]=U[$]}),en=this&&this.__exportStar||function(O,U){for(var $ in O)"default"===$||U.hasOwnProperty($)||J(U,O,$)};Object.defineProperty(U,"__esModule",{value:!0}),en($(1474),U),en($(5852),U),en($(2172),U),en($(7041),U)},9686:function(O,U,$){"use strict";var J=this&&this.__awaiter||function(O,U,$,J){function adopt(O){return O instanceof $?O:new $(function(U){U(O)})}return new($||($=Promise))(function($,en){function fulfilled(O){try{step(J.next(O))}catch(O){en(O)}}function rejected(O){try{step(J.throw(O))}catch(O){en(O)}}function step(O){O.done?$(O.value):adopt(O.value).then(fulfilled,rejected)}step((J=J.apply(O,U||[])).next())})};Object.defineProperty(U,"__esModule",{value:!0}),U.kdf=U.defaultScryptModule=U.defaultPbkdfModule=void 0;let en=$(4610),es=$(1406),eo=$(4468),ea=$(9449);function defaultPbkdfModule(){return{function:"pbkdf2",params:{dklen:32,c:262144,prf:"hmac-sha256",salt:ea.bytesToHex(en.getRandomBytesSync(32))}}}function defaultScryptModule(){return{function:"scrypt",params:{dklen:32,n:262144,r:8,p:1,salt:ea.bytesToHex(en.getRandomBytesSync(32))}}}function kdf(O,U){return J(this,void 0,void 0,function*(){if("pbkdf2"===O.function)return yield doPbkdf2(O.params,U);if("scrypt"===O.function)return yield doScrypt(O.params,U);throw Error("Invalid kdf type")})}function doPbkdf2(O,U){return J(this,void 0,void 0,function*(){return es.pbkdf2(U,ea.hexToBytes(O.salt),O.c,O.dklen,O.prf.slice(5))})}function doScrypt(O,U){return J(this,void 0,void 0,function*(){return eo.scrypt(U,ea.hexToBytes(O.salt),O.n,O.p,O.r,O.dklen)})}U.defaultPbkdfModule=defaultPbkdfModule,U.defaultScryptModule=defaultScryptModule,U.kdf=kdf},6357:function(O,U,$){"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.normalizePassword=void 0;let J=$(9449);function normalizePassword(O){return"string"==typeof O?J.utf8ToBytes(O.normalize("NFKD")):O}U.normalizePassword=normalizePassword},1318:function(O,U){"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.Keystore=void 0,U.Keystore=validate19;let $=RegExp("^pbkdf2$","u"),J=RegExp("^hmac-sha256$","u"),en=RegExp("^$","u"),es=RegExp("^scrypt$","u"),eo=RegExp("^([A-Fa-f0-9]{2}){32}$","u");function validate12(O,{instancePath:U="",parentData:ea,parentDataProperty:eu,rootData:ef=O}={}){let eg=null,ev=0,e_=ev,ew=ev;if(ev===ew){if(!O||"object"!=typeof O||Array.isArray(O))return validate12.errors=[{instancePath:U,schemaPath:"#/definitions/Module/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;{let $;if(void 0===O.function&&($="function")||void 0===O.message&&($="message")||void 0===O.params&&($="params"))return validate12.errors=[{instancePath:U,schemaPath:"#/definitions/Module/required",keyword:"required",params:{missingProperty:$},message:"must have required property '"+$+"'"}],!1;if(void 0!==O.function){let $=ev;if("string"!=typeof O.function)return validate12.errors=[{instancePath:U+"/function",schemaPath:"#/definitions/Module/properties/function/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var eE=$===ev}else var eE=!0;if(eE){if(void 0!==O.params){let $=O.params,J=ev;if(!($&&"object"==typeof $&&!Array.isArray($)))return validate12.errors=[{instancePath:U+"/params",schemaPath:"#/definitions/Module/properties/params/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var eE=J===ev}else var eE=!0;if(eE){if(void 0!==O.message){let $=ev;if("string"!=typeof O.message)return validate12.errors=[{instancePath:U+"/message",schemaPath:"#/definitions/Module/properties/message/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var eE=$===ev}else var eE=!0}}}}var eS=e_===ev;if(eS){let ea=ev,eu=ev,ef=!1,e_=null,ew=ev,eE=ev;if(ev===eE){if(O&&"object"==typeof O&&!Array.isArray(O)){if(void 0!==O.function){let J=O.function,en=ev;if(ev===en){if("string"==typeof J){if(!$.test(J)){let O={instancePath:U+"/function",schemaPath:"#/definitions/Pbkdf2Module/properties/function/pattern",keyword:"pattern",params:{pattern:"^pbkdf2$"},message:'must match pattern "^pbkdf2$"'};null===eg?eg=[O]:eg.push(O),ev++}}else{let O={instancePath:U+"/function",schemaPath:"#/definitions/Pbkdf2Module/properties/function/type",keyword:"type",params:{type:"string"},message:"must be string"};null===eg?eg=[O]:eg.push(O),ev++}}var eA=en===ev}else var eA=!0;if(eA){if(void 0!==O.params){let $=O.params,en=ev;if(ev===en){if($&&"object"==typeof $&&!Array.isArray($)){let O;if(void 0===$.dklen&&(O="dklen")||void 0===$.c&&(O="c")||void 0===$.prf&&(O="prf")||void 0===$.salt&&(O="salt")){let $={instancePath:U+"/params",schemaPath:"#/definitions/Pbkdf2Module/properties/params/required",keyword:"required",params:{missingProperty:O},message:"must have required property '"+O+"'"};null===eg?eg=[$]:eg.push($),ev++}else{if(void 0!==$.dklen){let O=$.dklen,J=ev;if(!("number"==typeof O&&!(O%1)&&!isNaN(O)&&isFinite(O))){let O={instancePath:U+"/params/dklen",schemaPath:"#/definitions/Pbkdf2Module/properties/params/properties/dklen/type",keyword:"type",params:{type:"integer"},message:"must be integer"};null===eg?eg=[O]:eg.push(O),ev++}if(ev===J&&"number"==typeof O&&isFinite(O)&&(O<0||isNaN(O))){let O={instancePath:U+"/params/dklen",schemaPath:"#/definitions/Pbkdf2Module/properties/params/properties/dklen/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};null===eg?eg=[O]:eg.push(O),ev++}var eI=J===ev}else var eI=!0;if(eI){if(void 0!==$.c){let O=$.c,J=ev;if(!("number"==typeof O&&!(O%1)&&!isNaN(O)&&isFinite(O))){let O={instancePath:U+"/params/c",schemaPath:"#/definitions/Pbkdf2Module/properties/params/properties/c/type",keyword:"type",params:{type:"integer"},message:"must be integer"};null===eg?eg=[O]:eg.push(O),ev++}if(ev===J&&"number"==typeof O&&isFinite(O)&&(O<0||isNaN(O))){let O={instancePath:U+"/params/c",schemaPath:"#/definitions/Pbkdf2Module/properties/params/properties/c/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};null===eg?eg=[O]:eg.push(O),ev++}var eI=J===ev}else var eI=!0;if(eI){if(void 0!==$.prf){let O=$.prf,en=ev;if(ev===en){if("string"==typeof O){if(!J.test(O)){let O={instancePath:U+"/params/prf",schemaPath:"#/definitions/Pbkdf2Module/properties/params/properties/prf/pattern",keyword:"pattern",params:{pattern:"^hmac-sha256$"},message:'must match pattern "^hmac-sha256$"'};null===eg?eg=[O]:eg.push(O),ev++}}else{let O={instancePath:U+"/params/prf",schemaPath:"#/definitions/Pbkdf2Module/properties/params/properties/prf/type",keyword:"type",params:{type:"string"},message:"must be string"};null===eg?eg=[O]:eg.push(O),ev++}}var eI=en===ev}else var eI=!0;if(eI){if(void 0!==$.salt){let O=ev;if("string"!=typeof $.salt){let O={instancePath:U+"/params/salt",schemaPath:"#/definitions/Pbkdf2Module/properties/params/properties/salt/type",keyword:"type",params:{type:"string"},message:"must be string"};null===eg?eg=[O]:eg.push(O),ev++}var eI=O===ev}else var eI=!0}}}}}else{let O={instancePath:U+"/params",schemaPath:"#/definitions/Pbkdf2Module/properties/params/type",keyword:"type",params:{type:"object"},message:"must be object"};null===eg?eg=[O]:eg.push(O),ev++}}var eA=en===ev}else var eA=!0;if(eA){if(void 0!==O.message){let $=O.message,J=ev;if(ev===J){if("string"==typeof $){if(!en.test($)){let O={instancePath:U+"/message",schemaPath:"#/definitions/Pbkdf2Module/properties/message/pattern",keyword:"pattern",params:{pattern:"^$"},message:'must match pattern "^$"'};null===eg?eg=[O]:eg.push(O),ev++}}else{let O={instancePath:U+"/message",schemaPath:"#/definitions/Pbkdf2Module/properties/message/type",keyword:"type",params:{type:"string"},message:"must be string"};null===eg?eg=[O]:eg.push(O),ev++}}var eA=J===ev}else var eA=!0}}}else{let O={instancePath:U,schemaPath:"#/definitions/Pbkdf2Module/type",keyword:"type",params:{type:"object"},message:"must be object"};null===eg?eg=[O]:eg.push(O),ev++}}var eP=ew===ev;eP&&(ef=!0,e_=0);let eR=ev,eC=ev;if(ev===eC){if(O&&"object"==typeof O&&!Array.isArray(O)){if(void 0!==O.function){let $=O.function,J=ev;if(ev===J){if("string"==typeof $){if(!es.test($)){let O={instancePath:U+"/function",schemaPath:"#/definitions/ScryptModule/properties/function/pattern",keyword:"pattern",params:{pattern:"^scrypt$"},message:'must match pattern "^scrypt$"'};null===eg?eg=[O]:eg.push(O),ev++}}else{let O={instancePath:U+"/function",schemaPath:"#/definitions/ScryptModule/properties/function/type",keyword:"type",params:{type:"string"},message:"must be string"};null===eg?eg=[O]:eg.push(O),ev++}}var ek=J===ev}else var ek=!0;if(ek){if(void 0!==O.params){let $=O.params,J=ev;if(ev===J){if($&&"object"==typeof $&&!Array.isArray($)){let O;if(void 0===$.dklen&&(O="dklen")||void 0===$.n&&(O="n")||void 0===$.p&&(O="p")||void 0===$.r&&(O="r")||void 0===$.salt&&(O="salt")){let $={instancePath:U+"/params",schemaPath:"#/definitions/ScryptModule/properties/params/required",keyword:"required",params:{missingProperty:O},message:"must have required property '"+O+"'"};null===eg?eg=[$]:eg.push($),ev++}else{if(void 0!==$.dklen){let O=$.dklen,J=ev;if(!("number"==typeof O&&!(O%1)&&!isNaN(O)&&isFinite(O))){let O={instancePath:U+"/params/dklen",schemaPath:"#/definitions/ScryptModule/properties/params/properties/dklen/type",keyword:"type",params:{type:"integer"},message:"must be integer"};null===eg?eg=[O]:eg.push(O),ev++}if(ev===J&&"number"==typeof O&&isFinite(O)&&(O<0||isNaN(O))){let O={instancePath:U+"/params/dklen",schemaPath:"#/definitions/ScryptModule/properties/params/properties/dklen/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};null===eg?eg=[O]:eg.push(O),ev++}var eT=J===ev}else var eT=!0;if(eT){if(void 0!==$.n){let O=$.n,J=ev;if(!("number"==typeof O&&!(O%1)&&!isNaN(O)&&isFinite(O))){let O={instancePath:U+"/params/n",schemaPath:"#/definitions/ScryptModule/properties/params/properties/n/type",keyword:"type",params:{type:"integer"},message:"must be integer"};null===eg?eg=[O]:eg.push(O),ev++}if(ev===J&&"number"==typeof O&&isFinite(O)&&(O<0||isNaN(O))){let O={instancePath:U+"/params/n",schemaPath:"#/definitions/ScryptModule/properties/params/properties/n/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};null===eg?eg=[O]:eg.push(O),ev++}var eT=J===ev}else var eT=!0;if(eT){if(void 0!==$.p){let O=$.p,J=ev;if(!("number"==typeof O&&!(O%1)&&!isNaN(O)&&isFinite(O))){let O={instancePath:U+"/params/p",schemaPath:"#/definitions/ScryptModule/properties/params/properties/p/type",keyword:"type",params:{type:"integer"},message:"must be integer"};null===eg?eg=[O]:eg.push(O),ev++}if(ev===J&&"number"==typeof O&&isFinite(O)&&(O<0||isNaN(O))){let O={instancePath:U+"/params/p",schemaPath:"#/definitions/ScryptModule/properties/params/properties/p/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};null===eg?eg=[O]:eg.push(O),ev++}var eT=J===ev}else var eT=!0;if(eT){if(void 0!==$.r){let O=$.r,J=ev;if(!("number"==typeof O&&!(O%1)&&!isNaN(O)&&isFinite(O))){let O={instancePath:U+"/params/r",schemaPath:"#/definitions/ScryptModule/properties/params/properties/r/type",keyword:"type",params:{type:"integer"},message:"must be integer"};null===eg?eg=[O]:eg.push(O),ev++}if(ev===J&&"number"==typeof O&&isFinite(O)&&(O<0||isNaN(O))){let O={instancePath:U+"/params/r",schemaPath:"#/definitions/ScryptModule/properties/params/properties/r/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};null===eg?eg=[O]:eg.push(O),ev++}var eT=J===ev}else var eT=!0;if(eT){if(void 0!==$.salt){let O=$.salt,J=ev;if(ev===J){if("string"==typeof O){if(!eo.test(O)){let O={instancePath:U+"/params/salt",schemaPath:"#/definitions/ScryptModule/properties/params/properties/salt/pattern",keyword:"pattern",params:{pattern:"^([A-Fa-f0-9]{2}){32}$"},message:'must match pattern "^([A-Fa-f0-9]{2}){32}$"'};null===eg?eg=[O]:eg.push(O),ev++}}else{let O={instancePath:U+"/params/salt",schemaPath:"#/definitions/ScryptModule/properties/params/properties/salt/type",keyword:"type",params:{type:"string"},message:"must be string"};null===eg?eg=[O]:eg.push(O),ev++}}var eT=J===ev}else var eT=!0}}}}}}else{let O={instancePath:U+"/params",schemaPath:"#/definitions/ScryptModule/properties/params/type",keyword:"type",params:{type:"object"},message:"must be object"};null===eg?eg=[O]:eg.push(O),ev++}}var ek=J===ev}else var ek=!0;if(ek){if(void 0!==O.message){let $=O.message,J=ev;if(ev===J){if("string"==typeof $){if(!en.test($)){let O={instancePath:U+"/message",schemaPath:"#/definitions/ScryptModule/properties/message/pattern",keyword:"pattern",params:{pattern:"^$"},message:'must match pattern "^$"'};null===eg?eg=[O]:eg.push(O),ev++}}else{let O={instancePath:U+"/message",schemaPath:"#/definitions/ScryptModule/properties/message/type",keyword:"type",params:{type:"string"},message:"must be string"};null===eg?eg=[O]:eg.push(O),ev++}}var ek=J===ev}else var ek=!0}}}else{let O={instancePath:U,schemaPath:"#/definitions/ScryptModule/type",keyword:"type",params:{type:"object"},message:"must be object"};null===eg?eg=[O]:eg.push(O),ev++}}var eP=eR===ev;if(eP&&ef?(ef=!1,e_=[e_,1]):eP&&(ef=!0,e_=1),ef)ev=eu,null!==eg&&(eu?eg.length=eu:eg=null);else{let O={instancePath:U,schemaPath:"#/allOf/1/oneOf",keyword:"oneOf",params:{passingSchemas:e_},message:"must match exactly one schema in oneOf"};return null===eg?eg=[O]:eg.push(O),ev++,validate12.errors=eg,!1}var eS=ea===ev}return validate12.errors=eg,0===ev}let ea=RegExp("^sha256$","u");function validate14(O,{instancePath:U="",parentData:$,parentDataProperty:J,rootData:en=O}={}){let es=null,eu=0,ef=eu,eg=eu;if(eu===eg){if(!O||"object"!=typeof O||Array.isArray(O))return validate14.errors=[{instancePath:U,schemaPath:"#/definitions/Module/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;{let $;if(void 0===O.function&&($="function")||void 0===O.message&&($="message")||void 0===O.params&&($="params"))return validate14.errors=[{instancePath:U,schemaPath:"#/definitions/Module/required",keyword:"required",params:{missingProperty:$},message:"must have required property '"+$+"'"}],!1;if(void 0!==O.function){let $=eu;if("string"!=typeof O.function)return validate14.errors=[{instancePath:U+"/function",schemaPath:"#/definitions/Module/properties/function/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var ev=$===eu}else var ev=!0;if(ev){if(void 0!==O.params){let $=O.params,J=eu;if(!($&&"object"==typeof $&&!Array.isArray($)))return validate14.errors=[{instancePath:U+"/params",schemaPath:"#/definitions/Module/properties/params/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var ev=J===eu}else var ev=!0;if(ev){if(void 0!==O.message){let $=eu;if("string"!=typeof O.message)return validate14.errors=[{instancePath:U+"/message",schemaPath:"#/definitions/Module/properties/message/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var ev=$===eu}else var ev=!0}}}}var e_=ef===eu;if(e_){let $=eu,J=eu,en=!1,ef=null,eg=eu,ev=eu;if(eu===ev){if(O&&"object"==typeof O&&!Array.isArray(O)){if(void 0!==O.function){let $=O.function,J=eu;if(eu===J){if("string"==typeof $){if(!ea.test($)){let O={instancePath:U+"/function",schemaPath:"#/definitions/Sha2Module/properties/function/pattern",keyword:"pattern",params:{pattern:"^sha256$"},message:'must match pattern "^sha256$"'};null===es?es=[O]:es.push(O),eu++}}else{let O={instancePath:U+"/function",schemaPath:"#/definitions/Sha2Module/properties/function/type",keyword:"type",params:{type:"string"},message:"must be string"};null===es?es=[O]:es.push(O),eu++}}var ew=J===eu}else var ew=!0;if(ew){if(void 0!==O.params){let $=O.params,J=eu;if(eu===J){if($&&"object"==typeof $&&!Array.isArray($))for(let O in $){let $={instancePath:U+"/params",schemaPath:"#/definitions/Sha2Module/properties/params/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:O},message:"must NOT have additional properties"};null===es?es=[$]:es.push($),eu++;break}else{let O={instancePath:U+"/params",schemaPath:"#/definitions/Sha2Module/properties/params/type",keyword:"type",params:{type:"object"},message:"must be object"};null===es?es=[O]:es.push(O),eu++}}var ew=J===eu}else var ew=!0;if(ew){if(void 0!==O.message){let $=O.message,J=eu;if(eu===J){if("string"==typeof $){if(!eo.test($)){let O={instancePath:U+"/message",schemaPath:"#/definitions/Sha2Module/properties/message/pattern",keyword:"pattern",params:{pattern:"^([A-Fa-f0-9]{2}){32}$"},message:'must match pattern "^([A-Fa-f0-9]{2}){32}$"'};null===es?es=[O]:es.push(O),eu++}}else{let O={instancePath:U+"/message",schemaPath:"#/definitions/Sha2Module/properties/message/type",keyword:"type",params:{type:"string"},message:"must be string"};null===es?es=[O]:es.push(O),eu++}}var ew=J===eu}else var ew=!0}}}else{let O={instancePath:U,schemaPath:"#/definitions/Sha2Module/type",keyword:"type",params:{type:"object"},message:"must be object"};null===es?es=[O]:es.push(O),eu++}}if(eg===eu&&(en=!0,ef=0),en)eu=J,null!==es&&(J?es.length=J:es=null);else{let O={instancePath:U,schemaPath:"#/allOf/1/oneOf",keyword:"oneOf",params:{passingSchemas:ef},message:"must match exactly one schema in oneOf"};return null===es?es=[O]:es.push(O),eu++,validate14.errors=es,!1}var e_=$===eu}return validate14.errors=es,0===eu}let eu=RegExp("^aes-128-ctr$","u"),ef=RegExp("^([A-Fa-f0-9]{2}){16}$","u");function validate16(O,{instancePath:U="",parentData:$,parentDataProperty:J,rootData:en=O}={}){let es=null,ea=0,eg=ea,ev=ea;if(ea===ev){if(!O||"object"!=typeof O||Array.isArray(O))return validate16.errors=[{instancePath:U,schemaPath:"#/definitions/Module/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;{let $;if(void 0===O.function&&($="function")||void 0===O.message&&($="message")||void 0===O.params&&($="params"))return validate16.errors=[{instancePath:U,schemaPath:"#/definitions/Module/required",keyword:"required",params:{missingProperty:$},message:"must have required property '"+$+"'"}],!1;if(void 0!==O.function){let $=ea;if("string"!=typeof O.function)return validate16.errors=[{instancePath:U+"/function",schemaPath:"#/definitions/Module/properties/function/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var e_=$===ea}else var e_=!0;if(e_){if(void 0!==O.params){let $=O.params,J=ea;if(!($&&"object"==typeof $&&!Array.isArray($)))return validate16.errors=[{instancePath:U+"/params",schemaPath:"#/definitions/Module/properties/params/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var e_=J===ea}else var e_=!0;if(e_){if(void 0!==O.message){let $=ea;if("string"!=typeof O.message)return validate16.errors=[{instancePath:U+"/message",schemaPath:"#/definitions/Module/properties/message/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var e_=$===ea}else var e_=!0}}}}var ew=eg===ea;if(ew){let $=ea,J=ea,en=!1,eg=null,ev=ea,e_=ea;if(ea===e_){if(O&&"object"==typeof O&&!Array.isArray(O)){if(void 0!==O.function){let $=O.function,J=ea;if(ea===J){if("string"==typeof $){if(!eu.test($)){let O={instancePath:U+"/function",schemaPath:"#/definitions/Aes128CtrModule/properties/function/pattern",keyword:"pattern",params:{pattern:"^aes-128-ctr$"},message:'must match pattern "^aes-128-ctr$"'};null===es?es=[O]:es.push(O),ea++}}else{let O={instancePath:U+"/function",schemaPath:"#/definitions/Aes128CtrModule/properties/function/type",keyword:"type",params:{type:"string"},message:"must be string"};null===es?es=[O]:es.push(O),ea++}}var eE=J===ea}else var eE=!0;if(eE){if(void 0!==O.params){let $=O.params,J=ea;if(ea===J){if($&&"object"==typeof $&&!Array.isArray($)){let O;if(void 0===$.iv&&(O="iv")){let $={instancePath:U+"/params",schemaPath:"#/definitions/Aes128CtrModule/properties/params/required",keyword:"required",params:{missingProperty:O},message:"must have required property '"+O+"'"};null===es?es=[$]:es.push($),ea++}else if(void 0!==$.iv){let O=$.iv,J=ea;if(ea===J){if("string"==typeof O){if(!ef.test(O)){let O={instancePath:U+"/params/iv",schemaPath:"#/definitions/Aes128CtrModule/properties/params/properties/iv/pattern",keyword:"pattern",params:{pattern:"^([A-Fa-f0-9]{2}){16}$"},message:'must match pattern "^([A-Fa-f0-9]{2}){16}$"'};null===es?es=[O]:es.push(O),ea++}}else{let O={instancePath:U+"/params/iv",schemaPath:"#/definitions/Aes128CtrModule/properties/params/properties/iv/type",keyword:"type",params:{type:"string"},message:"must be string"};null===es?es=[O]:es.push(O),ea++}}}}else{let O={instancePath:U+"/params",schemaPath:"#/definitions/Aes128CtrModule/properties/params/type",keyword:"type",params:{type:"object"},message:"must be object"};null===es?es=[O]:es.push(O),ea++}}var eE=J===ea}else var eE=!0;if(eE){if(void 0!==O.message){let $=O.message,J=ea;if(ea===J){if("string"==typeof $){if(!eo.test($)){let O={instancePath:U+"/message",schemaPath:"#/definitions/Aes128CtrModule/properties/message/pattern",keyword:"pattern",params:{pattern:"^([A-Fa-f0-9]{2}){32}$"},message:'must match pattern "^([A-Fa-f0-9]{2}){32}$"'};null===es?es=[O]:es.push(O),ea++}}else{let O={instancePath:U+"/message",schemaPath:"#/definitions/Aes128CtrModule/properties/message/type",keyword:"type",params:{type:"string"},message:"must be string"};null===es?es=[O]:es.push(O),ea++}}var eE=J===ea}else var eE=!0}}}else{let O={instancePath:U,schemaPath:"#/definitions/Aes128CtrModule/type",keyword:"type",params:{type:"object"},message:"must be object"};null===es?es=[O]:es.push(O),ea++}}if(ev===ea&&(en=!0,eg=0),en)ea=J,null!==es&&(J?es.length=J:es=null);else{let O={instancePath:U,schemaPath:"#/allOf/1/oneOf",keyword:"oneOf",params:{passingSchemas:eg},message:"must match exactly one schema in oneOf"};return null===es?es=[O]:es.push(O),ea++,validate16.errors=es,!1}var ew=$===ea}return validate16.errors=es,0===ea}let eg=RegExp("^([A-Fa-f0-9]{2}){48}$","u"),ev=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;function validate19(O,{instancePath:U="",parentData:$,parentDataProperty:J,rootData:en=O}={}){let es=null,eo=0;if(!O||"object"!=typeof O||Array.isArray(O))return validate19.errors=[{instancePath:U,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;{let $;if(void 0===O.crypto&&($="crypto")||void 0===O.path&&($="path")||void 0===O.uuid&&($="uuid")||void 0===O.version&&($="version"))return validate19.errors=[{instancePath:U,schemaPath:"#/required",keyword:"required",params:{missingProperty:$},message:"must have required property '"+$+"'"}],!1;if(void 0!==O.crypto){let $=O.crypto,J=eo;if(eo===J){if(!$||"object"!=typeof $||Array.isArray($))return validate19.errors=[{instancePath:U+"/crypto",schemaPath:"#/properties/crypto/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;{let O;if(void 0===$.kdf&&(O="kdf")||void 0===$.checksum&&(O="checksum")||void 0===$.cipher&&(O="cipher"))return validate19.errors=[{instancePath:U+"/crypto",schemaPath:"#/properties/crypto/required",keyword:"required",params:{missingProperty:O},message:"must have required property '"+O+"'"}],!1;if(void 0!==$.kdf){let O=eo;validate12($.kdf,{instancePath:U+"/crypto/kdf",parentData:$,parentDataProperty:"kdf",rootData:en})||(eo=(es=null===es?validate12.errors:es.concat(validate12.errors)).length);var ea=O===eo}else var ea=!0;if(ea){if(void 0!==$.checksum){let O=eo;validate14($.checksum,{instancePath:U+"/crypto/checksum",parentData:$,parentDataProperty:"checksum",rootData:en})||(eo=(es=null===es?validate14.errors:es.concat(validate14.errors)).length);var ea=O===eo}else var ea=!0;if(ea){if(void 0!==$.cipher){let O=eo;validate16($.cipher,{instancePath:U+"/crypto/cipher",parentData:$,parentDataProperty:"cipher",rootData:en})||(eo=(es=null===es?validate16.errors:es.concat(validate16.errors)).length);var ea=O===eo}else var ea=!0}}}}var eu=J===eo}else var eu=!0;if(eu){if(void 0!==O.pubkey){let $=O.pubkey,J=eo;if(eo===J){if("string"!=typeof $)return validate19.errors=[{instancePath:U+"/pubkey",schemaPath:"#/properties/pubkey/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!eg.test($))return validate19.errors=[{instancePath:U+"/pubkey",schemaPath:"#/properties/pubkey/pattern",keyword:"pattern",params:{pattern:"^([A-Fa-f0-9]{2}){48}$"},message:'must match pattern "^([A-Fa-f0-9]{2}){48}$"'}],!1}var eu=J===eo}else var eu=!0;if(eu){if(void 0!==O.path){let $=eo;if("string"!=typeof O.path)return validate19.errors=[{instancePath:U+"/path",schemaPath:"#/properties/path/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var eu=$===eo}else var eu=!0;if(eu){if(void 0!==O.description){let $=eo;if("string"!=typeof O.description)return validate19.errors=[{instancePath:U+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var eu=$===eo}else var eu=!0;if(eu){if(void 0!==O.uuid){let $=O.uuid,J=eo;if(eo===J&&eo===J){if("string"!=typeof $)return validate19.errors=[{instancePath:U+"/uuid",schemaPath:"#/properties/uuid/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;if(!ev.test($))return validate19.errors=[{instancePath:U+"/uuid",schemaPath:"#/properties/uuid/format",keyword:"format",params:{format:"uuid"},message:'must match format "uuid"'}],!1}var eu=J===eo}else var eu=!0;if(eu){if(void 0!==O.version){let $=O.version,J=eo;if(!("number"==typeof $&&!($%1)&&!isNaN($)&&isFinite($)))return validate19.errors=[{instancePath:U+"/version",schemaPath:"#/properties/version/type",keyword:"type",params:{type:"integer"},message:"must be integer"}],!1;if(eo===J&&"number"==typeof $&&isFinite($)){if($>4||isNaN($))return validate19.errors=[{instancePath:U+"/version",schemaPath:"#/properties/version/maximum",keyword:"maximum",params:{comparison:"<=",limit:4},message:"must be <= 4"}],!1;if($<4||isNaN($))return validate19.errors=[{instancePath:U+"/version",schemaPath:"#/properties/version/minimum",keyword:"minimum",params:{comparison:">=",limit:4},message:"must be >= 4"}],!1}var eu=J===eo}else var eu=!0}}}}}}return validate19.errors=es,0===eo}},7041:function(O,U,$){"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.isValidKeystore=U.validateKeystore=U.schemaValidationErrors=void 0;let J=$(1318),en=J.Keystore;function schemaValidationErrors(O){let U=en(O);return U?null:en.errors}function validateKeystore(O){let U=schemaValidationErrors(O);if(U)throw Error(U.map(O=>`${O.instancePath}: ${O.message}`).join("\n"))}function isValidKeystore(O){return!schemaValidationErrors(O)}U.schemaValidationErrors=schemaValidationErrors,U.validateKeystore=validateKeystore,U.isValidKeystore=isValidKeystore},1474:function(O,U){"use strict";Object.defineProperty(U,"__esModule",{value:!0})},4390:function(O,U){"use strict";function number(O){if(!Number.isSafeInteger(O)||O<0)throw Error(`Wrong positive integer: ${O}`)}function bool(O){if("boolean"!=typeof O)throw Error(`Expected boolean, not ${O}`)}function bytes(O,...U){if(!(O instanceof Uint8Array))throw TypeError("Expected Uint8Array");if(U.length>0&&!U.includes(O.length))throw TypeError(`Expected Uint8Array of length ${U}, not of length=${O.length}`)}function hash(O){if("function"!=typeof O||"function"!=typeof O.create)throw Error("Hash should be wrapped by utils.wrapConstructor");number(O.outputLen),number(O.blockLen)}function exists(O,U=!0){if(O.destroyed)throw Error("Hash instance has been destroyed");if(U&&O.finished)throw Error("Hash#digest() has already been called")}function output(O,U){bytes(O);let $=U.outputLen;if(O.length<$)throw Error(`digestInto() expects output buffer of length at least ${$}`)}Object.defineProperty(U,"__esModule",{value:!0}),U.output=U.exists=U.hash=U.bytes=U.bool=U.number=void 0,U.number=number,U.bool=bool,U.bytes=bytes,U.hash=hash,U.exists=exists,U.output=output;let $={number,bool,bytes,hash,exists,output};U.default=$},2495:function(O,U,$){"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.SHA2=void 0;let J=$(4390),en=$(5158);function setBigUint64(O,U,$,J){if("function"==typeof O.setBigUint64)return O.setBigUint64(U,$,J);let en=BigInt(32),es=BigInt(4294967295),eo=Number($>>en&es),ea=Number($&es),eu=J?4:0,ef=J?0:4;O.setUint32(U+eu,eo,J),O.setUint32(U+ef,ea,J)}let SHA2=class SHA2 extends en.Hash{constructor(O,U,$,J){super(),this.blockLen=O,this.outputLen=U,this.padOffset=$,this.isLE=J,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(O),this.view=(0,en.createView)(this.buffer)}update(O){J.default.exists(this);let{view:U,buffer:$,blockLen:es}=this;O=(0,en.toBytes)(O);let eo=O.length;for(let J=0;Jes-ea&&(this.process($,0),ea=0);for(let O=ea;Oev.length)throw Error("_sha2: outputLen bigger than state");for(let O=0;O>J&$)}:{h:0|Number(O>>J&$),l:0|Number(O&$)}}function split(O,U=!1){let $=new Uint32Array(O.length),J=new Uint32Array(O.length);for(let en=0;enBigInt(O>>>0)<>>0);U.toBig=toBig;let shrSH=(O,U,$)=>O>>>$,shrSL=(O,U,$)=>O<<32-$|U>>>$,rotrSH=(O,U,$)=>O>>>$|U<<32-$,rotrSL=(O,U,$)=>O<<32-$|U>>>$,rotrBH=(O,U,$)=>O<<64-$|U>>>$-32,rotrBL=(O,U,$)=>O>>>$-32|U<<64-$,rotr32H=(O,U)=>U,rotr32L=(O,U)=>O,rotlSH=(O,U,$)=>O<<$|U>>>32-$,rotlSL=(O,U,$)=>U<<$|O>>>32-$,rotlBH=(O,U,$)=>U<<$-32|O>>>64-$,rotlBL=(O,U,$)=>O<<$-32|U>>>64-$;function add(O,U,$,J){let en=(U>>>0)+(J>>>0);return{h:O+$+(en/4294967296|0)|0,l:0|en}}U.add=add;let add3L=(O,U,$)=>(O>>>0)+(U>>>0)+($>>>0),add3H=(O,U,$,J)=>U+$+J+(O/4294967296|0)|0,add4L=(O,U,$,J)=>(O>>>0)+(U>>>0)+($>>>0)+(J>>>0),add4H=(O,U,$,J,en)=>U+$+J+en+(O/4294967296|0)|0,add5L=(O,U,$,J,en)=>(O>>>0)+(U>>>0)+($>>>0)+(J>>>0)+(en>>>0),add5H=(O,U,$,J,en,es)=>U+$+J+en+es+(O/4294967296|0)|0,en={fromBig,split,toBig:U.toBig,shrSH,shrSL,rotrSH,rotrSL,rotrBH,rotrBL,rotr32H,rotr32L,rotlSH,rotlSL,rotlBH,rotlBL,add,add3L,add3H,add4L,add4H,add5H,add5L};U.default=en},9761:function(O,U){"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.crypto=void 0,U.crypto={node:void 0,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0}},8119:function(O,U,$){"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.hmac=void 0;let J=$(4390),en=$(5158);let HMAC=class HMAC extends en.Hash{constructor(O,U){super(),this.finished=!1,this.destroyed=!1,J.default.hash(O);let $=(0,en.toBytes)(U);if(this.iHash=O.create(),"function"!=typeof this.iHash.update)throw TypeError("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let es=this.blockLen,eo=new Uint8Array(es);eo.set($.length>es?O.create().update($).digest():$);for(let O=0;Onew HMAC(O,U).update($).digest();U.hmac=hmac,U.hmac.create=(O,U)=>new HMAC(O,U)},4618:function(O,U,$){"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.pbkdf2Async=U.pbkdf2=void 0;let J=$(4390),en=$(8119),es=$(5158);function pbkdf2Init(O,U,$,eo){J.default.hash(O);let ea=(0,es.checkOpts)({dkLen:32,asyncTick:10},eo),{c:eu,dkLen:ef,asyncTick:eg}=ea;if(J.default.number(eu),J.default.number(ef),J.default.number(eg),eu<1)throw Error("PBKDF2: iterations (c) should be >= 1");let ev=(0,es.toBytes)(U),e_=(0,es.toBytes)($),ew=new Uint8Array(ef),eE=en.hmac.create(O,ev),eS=eE._cloneInto().update(e_);return{c:eu,dkLen:ef,asyncTick:eg,DK:ew,PRF:eE,PRFSalt:eS}}function pbkdf2Output(O,U,$,J,en){return O.destroy(),U.destroy(),J&&J.destroy(),en.fill(0),$}function pbkdf2(O,U,$,J){let en;let{c:eo,dkLen:ea,DK:eu,PRF:ef,PRFSalt:eg}=pbkdf2Init(O,U,$,J),ev=new Uint8Array(4),e_=(0,es.createView)(ev),ew=new Uint8Array(ef.outputLen);for(let O=1,U=0;U{eg._cloneInto(en).update(eE).digestInto(eE);for(let O=0;O<$.length;O++)$[O]^=eE[O]})}return pbkdf2Output(eg,ev,ef,en,eE)}U.pbkdf2=pbkdf2,U.pbkdf2Async=pbkdf2Async},6906:function(O,U,$){"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.scryptAsync=U.scrypt=void 0;let J=$(4390),en=$(938),es=$(4618),eo=$(5158),rotl=(O,U)=>O<>>32-U;function XorAndSalsa(O,U,$,J,en,es){let eo=O[U++]^$[J++],ea=O[U++]^$[J++],eu=O[U++]^$[J++],ef=O[U++]^$[J++],eg=O[U++]^$[J++],ev=O[U++]^$[J++],e_=O[U++]^$[J++],ew=O[U++]^$[J++],eE=O[U++]^$[J++],eS=O[U++]^$[J++],eA=O[U++]^$[J++],eI=O[U++]^$[J++],eP=O[U++]^$[J++],ek=O[U++]^$[J++],eT=O[U++]^$[J++],eR=O[U++]^$[J++],eC=eo,eB=ea,eN=eu,eD=ef,eM=eg,eO=ev,eL=e_,eU=ew,eF=eE,eK=eS,ej=eA,eH=eI,eq=eP,eV=ek,eG=eT,e$=eR;for(let O=0;O<8;O+=2)eM^=rotl(eC+eq|0,7),eF^=rotl(eM+eC|0,9),eq^=rotl(eF+eM|0,13),eC^=rotl(eq+eF|0,18),eK^=rotl(eO+eB|0,7),eV^=rotl(eK+eO|0,9),eB^=rotl(eV+eK|0,13),eO^=rotl(eB+eV|0,18),eG^=rotl(ej+eL|0,7),eN^=rotl(eG+ej|0,9),eL^=rotl(eN+eG|0,13),ej^=rotl(eL+eN|0,18),eD^=rotl(e$+eH|0,7),eU^=rotl(eD+e$|0,9),eH^=rotl(eU+eD|0,13),e$^=rotl(eH+eU|0,18),eB^=rotl(eC+eD|0,7),eN^=rotl(eB+eC|0,9),eD^=rotl(eN+eB|0,13),eC^=rotl(eD+eN|0,18),eL^=rotl(eO+eM|0,7),eU^=rotl(eL+eO|0,9),eM^=rotl(eU+eL|0,13),eO^=rotl(eM+eU|0,18),eH^=rotl(ej+eK|0,7),eF^=rotl(eH+ej|0,9),eK^=rotl(eF+eH|0,13),ej^=rotl(eK+eF|0,18),eq^=rotl(e$+eG|0,7),eV^=rotl(eq+e$|0,9),eG^=rotl(eV+eq|0,13),e$^=rotl(eG+eV|0,18);en[es++]=eo+eC|0,en[es++]=ea+eB|0,en[es++]=eu+eN|0,en[es++]=ef+eD|0,en[es++]=eg+eM|0,en[es++]=ev+eO|0,en[es++]=e_+eL|0,en[es++]=ew+eU|0,en[es++]=eE+eF|0,en[es++]=eS+eK|0,en[es++]=eA+ej|0,en[es++]=eI+eH|0,en[es++]=eP+eq|0,en[es++]=ek+eV|0,en[es++]=eT+eG|0,en[es++]=eR+e$|0}function BlockMix(O,U,$,J,en){let es=J+0,eo=J+16*en;for(let J=0;J<16;J++)$[eo+J]=O[U+(2*en-1)*16+J];for(let J=0;J0&&(eo+=16),XorAndSalsa($,es,O,U+=16,$,eo)}function scryptInit(O,U,$){let ea=(0,eo.checkOpts)({dkLen:32,asyncTick:10,maxmem:1073742848},$),{N:eu,r:ef,p:eg,dkLen:ev,asyncTick:e_,maxmem:ew,onProgress:eE}=ea;if(J.default.number(eu),J.default.number(ef),J.default.number(eg),J.default.number(ev),J.default.number(e_),J.default.number(ew),void 0!==eE&&"function"!=typeof eE)throw Error("progressCb should be function");let eS=128*ef,eA=eS/4;if(eu<=1||(eu&eu-1)!=0||eu>=2**(eS/8)||eu>4294967296)throw Error("Scrypt: N must be larger than 1, a power of 2, less than 2^(128 * r / 8) and less than 2^32");if(eg<0||eg>(4294967296-1)*32/eS)throw Error("Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)");if(ev<0||ev>(4294967296-1)*32)throw Error("Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32");let eI=eS*(eu+eg);if(eI>ew)throw Error(`Scrypt: parameters too large, ${eI} (128 * r * (N + p)) > ${ew} (maxmem)`);let eP=(0,es.pbkdf2)(en.sha256,O,U,{c:1,dkLen:eS*eg}),ek=(0,eo.u32)(eP),eT=(0,eo.u32)(new Uint8Array(eS*eu)),eR=(0,eo.u32)(new Uint8Array(eS)),blockMixCb=()=>{};if(eE){let O=2*eu*eg,U=Math.max(Math.floor(O/1e4),1),$=0;blockMixCb=()=>{$++,eE&&(!($%U)||$===O)&&eE($/O)}}return{N:eu,r:ef,p:eg,dkLen:ev,blockSize32:eA,V:eT,B32:ek,B:eP,tmp:eR,blockMixCb,asyncTick:e_}}function scryptOutput(O,U,$,J,eo){let ea=(0,es.pbkdf2)(en.sha256,O,$,{c:1,dkLen:U});return $.fill(0),J.fill(0),eo.fill(0),ea}function scrypt(O,U,$){let{N:J,r:en,p:es,dkLen:eo,blockSize32:ea,V:eu,B32:ef,B:eg,tmp:ev,blockMixCb:e_}=scryptInit(O,U,$);for(let O=0;O{BlockMix(ef,$,ef,$+=eu,en),ew()}),BlockMix(ef,(J-1)*eu,eg,U,en),ew(),await (0,eo.asyncLoop)(J,eE,O=>{let $=eg[U+eu-16]%J;for(let O=0;OO&U^~O&$,Maj=(O,U,$)=>O&U^O&$^U&$,es=new Uint32Array([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]),eo=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ea=new Uint32Array(64);let SHA256=class SHA256 extends J.SHA2{constructor(){super(64,32,8,!1),this.A=0|eo[0],this.B=0|eo[1],this.C=0|eo[2],this.D=0|eo[3],this.E=0|eo[4],this.F=0|eo[5],this.G=0|eo[6],this.H=0|eo[7]}get(){let{A:O,B:U,C:$,D:J,E:en,F:es,G:eo,H:ea}=this;return[O,U,$,J,en,es,eo,ea]}set(O,U,$,J,en,es,eo,ea){this.A=0|O,this.B=0|U,this.C=0|$,this.D=0|J,this.E=0|en,this.F=0|es,this.G=0|eo,this.H=0|ea}process(O,U){for(let $=0;$<16;$++,U+=4)ea[$]=O.getUint32(U,!1);for(let O=16;O<64;O++){let U=ea[O-15],$=ea[O-2],J=(0,en.rotr)(U,7)^(0,en.rotr)(U,18)^U>>>3,es=(0,en.rotr)($,17)^(0,en.rotr)($,19)^$>>>10;ea[O]=es+ea[O-7]+J+ea[O-16]|0}let{A:$,B:J,C:eo,D:eu,E:ef,F:eg,G:ev,H:e_}=this;for(let O=0;O<64;O++){let U=(0,en.rotr)(ef,6)^(0,en.rotr)(ef,11)^(0,en.rotr)(ef,25),ew=e_+U+Chi(ef,eg,ev)+es[O]+ea[O]|0,eE=(0,en.rotr)($,2)^(0,en.rotr)($,13)^(0,en.rotr)($,22),eS=eE+Maj($,J,eo)|0;e_=ev,ev=eg,eg=ef,ef=eu+ew|0,eu=eo,eo=J,J=$,$=ew+eS|0}$=$+this.A|0,J=J+this.B|0,eo=eo+this.C|0,eu=eu+this.D|0,ef=ef+this.E|0,eg=eg+this.F|0,ev=ev+this.G|0,e_=e_+this.H|0,this.set($,J,eo,eu,ef,eg,ev,e_)}roundClean(){ea.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};let SHA224=class SHA224 extends SHA256{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};U.sha256=(0,en.wrapConstructor)(()=>new SHA256),U.sha224=(0,en.wrapConstructor)(()=>new SHA224)},1791:function(O,U,$){"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.sha384=U.sha512_256=U.sha512_224=U.sha512=U.SHA512=void 0;let J=$(2495),en=$(3991),es=$(5158),[eo,ea]=en.default.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(O=>BigInt(O))),eu=new Uint32Array(80),ef=new Uint32Array(80);let SHA512=class SHA512 extends J.SHA2{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:O,Al:U,Bh:$,Bl:J,Ch:en,Cl:es,Dh:eo,Dl:ea,Eh:eu,El:ef,Fh:eg,Fl:ev,Gh:e_,Gl:ew,Hh:eE,Hl:eS}=this;return[O,U,$,J,en,es,eo,ea,eu,ef,eg,ev,e_,ew,eE,eS]}set(O,U,$,J,en,es,eo,ea,eu,ef,eg,ev,e_,ew,eE,eS){this.Ah=0|O,this.Al=0|U,this.Bh=0|$,this.Bl=0|J,this.Ch=0|en,this.Cl=0|es,this.Dh=0|eo,this.Dl=0|ea,this.Eh=0|eu,this.El=0|ef,this.Fh=0|eg,this.Fl=0|ev,this.Gh=0|e_,this.Gl=0|ew,this.Hh=0|eE,this.Hl=0|eS}process(O,U){for(let $=0;$<16;$++,U+=4)eu[$]=O.getUint32(U),ef[$]=O.getUint32(U+=4);for(let O=16;O<80;O++){let U=0|eu[O-15],$=0|ef[O-15],J=en.default.rotrSH(U,$,1)^en.default.rotrSH(U,$,8)^en.default.shrSH(U,$,7),es=en.default.rotrSL(U,$,1)^en.default.rotrSL(U,$,8)^en.default.shrSL(U,$,7),eo=0|eu[O-2],ea=0|ef[O-2],eg=en.default.rotrSH(eo,ea,19)^en.default.rotrBH(eo,ea,61)^en.default.shrSH(eo,ea,6),ev=en.default.rotrSL(eo,ea,19)^en.default.rotrBL(eo,ea,61)^en.default.shrSL(eo,ea,6),e_=en.default.add4L(es,ev,ef[O-7],ef[O-16]),ew=en.default.add4H(e_,J,eg,eu[O-7],eu[O-16]);eu[O]=0|ew,ef[O]=0|e_}let{Ah:$,Al:J,Bh:es,Bl:eg,Ch:ev,Cl:e_,Dh:ew,Dl:eE,Eh:eS,El:eA,Fh:eI,Fl:eP,Gh:ek,Gl:eT,Hh:eR,Hl:eC}=this;for(let O=0;O<80;O++){let U=en.default.rotrSH(eS,eA,14)^en.default.rotrSH(eS,eA,18)^en.default.rotrBH(eS,eA,41),eB=en.default.rotrSL(eS,eA,14)^en.default.rotrSL(eS,eA,18)^en.default.rotrBL(eS,eA,41),eN=eS&eI^~eS&ek,eD=eA&eP^~eA&eT,eM=en.default.add5L(eC,eB,eD,ea[O],ef[O]),eO=en.default.add5H(eM,eR,U,eN,eo[O],eu[O]),eL=0|eM,eU=en.default.rotrSH($,J,28)^en.default.rotrBH($,J,34)^en.default.rotrBH($,J,39),eF=en.default.rotrSL($,J,28)^en.default.rotrBL($,J,34)^en.default.rotrBL($,J,39),eK=$&es^$&ev^es&ev,ej=J&eg^J&e_^eg&e_;eR=0|ek,eC=0|eT,ek=0|eI,eT=0|eP,eI=0|eS,eP=0|eA,({h:eS,l:eA}=en.default.add(0|ew,0|eE,0|eO,0|eL)),ew=0|ev,eE=0|e_,ev=0|es,e_=0|eg,es=0|$,eg=0|J;let eH=en.default.add3L(eL,eF,ej);$=en.default.add3H(eH,eO,eU,eK),J=0|eH}({h:$,l:J}=en.default.add(0|this.Ah,0|this.Al,0|$,0|J)),({h:es,l:eg}=en.default.add(0|this.Bh,0|this.Bl,0|es,0|eg)),({h:ev,l:e_}=en.default.add(0|this.Ch,0|this.Cl,0|ev,0|e_)),({h:ew,l:eE}=en.default.add(0|this.Dh,0|this.Dl,0|ew,0|eE)),({h:eS,l:eA}=en.default.add(0|this.Eh,0|this.El,0|eS,0|eA)),({h:eI,l:eP}=en.default.add(0|this.Fh,0|this.Fl,0|eI,0|eP)),({h:ek,l:eT}=en.default.add(0|this.Gh,0|this.Gl,0|ek,0|eT)),({h:eR,l:eC}=en.default.add(0|this.Hh,0|this.Hl,0|eR,0|eC)),this.set($,J,es,eg,ev,e_,ew,eE,eS,eA,eI,eP,ek,eT,eR,eC)}roundClean(){eu.fill(0),ef.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};U.SHA512=SHA512;let SHA512_224=class SHA512_224 extends SHA512{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}};let SHA512_256=class SHA512_256 extends SHA512{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}};let SHA384=class SHA384 extends SHA512{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}};U.sha512=(0,es.wrapConstructor)(()=>new SHA512),U.sha512_224=(0,es.wrapConstructor)(()=>new SHA512_224),U.sha512_256=(0,es.wrapConstructor)(()=>new SHA512_256),U.sha384=(0,es.wrapConstructor)(()=>new SHA384)},5158:function(O,U,$){"use strict";/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.defineProperty(U,"__esModule",{value:!0}),U.randomBytes=U.wrapConstructorWithOpts=U.wrapConstructor=U.checkOpts=U.Hash=U.concatBytes=U.toBytes=U.utf8ToBytes=U.asyncLoop=U.nextTick=U.hexToBytes=U.bytesToHex=U.isLE=U.rotr=U.createView=U.u32=U.u8=void 0;let J=$(9761),u8=O=>new Uint8Array(O.buffer,O.byteOffset,O.byteLength);U.u8=u8;let u32=O=>new Uint32Array(O.buffer,O.byteOffset,Math.floor(O.byteLength/4));U.u32=u32;let createView=O=>new DataView(O.buffer,O.byteOffset,O.byteLength);U.createView=createView;let rotr=(O,U)=>O<<32-U|O>>>U;if(U.rotr=rotr,U.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],!U.isLE)throw Error("Non little-endian hardware is not supported");let en=Array.from({length:256},(O,U)=>U.toString(16).padStart(2,"0"));function bytesToHex(O){if(!(O instanceof Uint8Array))throw Error("Uint8Array expected");let U="";for(let $=0;${};async function asyncLoop(O,$,J){let en=Date.now();for(let es=0;es=0&&O<$||(await (0,U.nextTick)(),en+=O)}}function utf8ToBytes(O){if("string"!=typeof O)throw TypeError(`utf8ToBytes expected string, got ${typeof O}`);return new TextEncoder().encode(O)}function toBytes(O){if("string"==typeof O&&(O=utf8ToBytes(O)),!(O instanceof Uint8Array))throw TypeError(`Expected input type is Uint8Array (got ${typeof O})`);return O}function concatBytes(...O){if(!O.every(O=>O instanceof Uint8Array))throw Error("Uint8Array list expected");if(1===O.length)return O[0];let U=O.reduce((O,U)=>O+U.length,0),$=new Uint8Array(U);for(let U=0,J=0;U"[object Object]"===Object.prototype.toString.call(O)&&O.constructor===Object;function checkOpts(O,U){if(void 0!==U&&("object"!=typeof U||!isPlainObject(U)))throw TypeError("Options should be object or undefined");let $=Object.assign(O,U);return $}function wrapConstructor(O){let hashC=U=>O().update(toBytes(U)).digest(),U=O();return hashC.outputLen=U.outputLen,hashC.blockLen=U.blockLen,hashC.create=()=>O(),hashC}function wrapConstructorWithOpts(O){let hashC=(U,$)=>O($).update(toBytes(U)).digest(),U=O({});return hashC.outputLen=U.outputLen,hashC.blockLen=U.blockLen,hashC.create=U=>O(U),hashC}function randomBytes(O=32){if(J.crypto.web)return J.crypto.web.getRandomValues(new Uint8Array(O));if(J.crypto.node)return new Uint8Array(J.crypto.node.randomBytes(O).buffer);throw Error("The environment doesn't have randomBytes function")}U.checkOpts=checkOpts,U.wrapConstructor=wrapConstructor,U.wrapConstructorWithOpts=wrapConstructorWithOpts,U.randomBytes=randomBytes},215:function(O,U,$){"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.decrypt=U.encrypt=void 0;let J=$(9761),en=$(9449);function validateOpt(O,U,$){if(!$.startsWith("aes-"))throw Error(`AES submodule doesn't support mode ${$}`);if(16!==U.length)throw Error("AES: wrong IV length");if($.startsWith("aes-128")&&16!==O.length||$.startsWith("aes-256")&&32!==O.length)throw Error("AES: wrong key length")}async function getBrowserKey(O,U,$){let en;if(!J.crypto.web)throw Error("Browser crypto not available.");if(["aes-128-cbc","aes-256-cbc"].includes(O)&&(en="cbc"),["aes-128-ctr","aes-256-ctr"].includes(O)&&(en="ctr"),!en)throw Error("AES: unsupported mode");let es=await J.crypto.web.subtle.importKey("raw",U,{name:`AES-${en.toUpperCase()}`,length:8*U.length},!0,["encrypt","decrypt"]);return[es,{name:`aes-${en}`,iv:$,counter:$,length:128}]}async function encrypt(O,U,$,es="aes-128-ctr",eo=!0){if(validateOpt(U,$,es),J.crypto.web){let[en,ea]=await getBrowserKey(es,U,$),eu=await J.crypto.web.subtle.encrypt(ea,en,O),ef=new Uint8Array(eu);return eo||"aes-cbc"!==ea.name||O.length%16||(ef=ef.slice(0,-16)),ef}if(J.crypto.node){let ea=J.crypto.node.createCipheriv(es,U,$);return ea.setAutoPadding(eo),(0,en.concatBytes)(ea.update(O),ea.final())}throw Error("The environment doesn't have AES module")}async function getPadding(O,U,$,J){let en=O.slice(-16);for(let O=0;O<16;O++)en[O]^=16^$[O];let es=await encrypt(en,U,$,J);return es.slice(0,16)}async function decrypt(O,U,$,es="aes-128-ctr",eo=!0){if(validateOpt(U,$,es),J.crypto.web){let[ea,eu]=await getBrowserKey(es,U,$);if(!eo&&"aes-cbc"===eu.name){let J=await getPadding(O,U,$,es);O=(0,en.concatBytes)(O,J)}let ef=await J.crypto.web.subtle.decrypt(eu,ea,O),eg=new Uint8Array(ef);if("aes-cbc"===eu.name){let J=await encrypt(eg,U,$,es);if(!(0,en.equalsBytes)(J,O))throw Error("AES: wrong padding")}return eg}if(J.crypto.node){let ea=J.crypto.node.createDecipheriv(es,U,$);return ea.setAutoPadding(eo),(0,en.concatBytes)(ea.update(O),ea.final())}throw Error("The environment doesn't have AES module")}U.encrypt=encrypt,U.decrypt=decrypt},1406:function(O,U,$){"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.pbkdf2Sync=U.pbkdf2=void 0;let J=$(4618),en=$(938),es=$(1791),eo=$(9449);async function pbkdf2(O,U,$,ea,eu){if(!["sha256","sha512"].includes(eu))throw Error("Only sha256 and sha512 are supported");return(0,eo.assertBytes)(O),(0,eo.assertBytes)(U),(0,J.pbkdf2Async)("sha256"===eu?en.sha256:es.sha512,O,U,{c:$,dkLen:ea})}function pbkdf2Sync(O,U,$,ea,eu){if(!["sha256","sha512"].includes(eu))throw Error("Only sha256 and sha512 are supported");return(0,eo.assertBytes)(O),(0,eo.assertBytes)(U),(0,J.pbkdf2)("sha256"===eu?en.sha256:es.sha512,O,U,{c:$,dkLen:ea})}U.pbkdf2=pbkdf2,U.pbkdf2Sync=pbkdf2Sync},4610:function(O,U,$){"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.getRandomBytes=U.getRandomBytesSync=void 0;let J=$(5158);function getRandomBytesSync(O){return(0,J.randomBytes)(O)}async function getRandomBytes(O){return(0,J.randomBytes)(O)}U.getRandomBytesSync=getRandomBytesSync,U.getRandomBytes=getRandomBytes},4468:function(O,U,$){"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.scryptSync=U.scrypt=void 0;let J=$(6906),en=$(9449);async function scrypt(O,U,$,es,eo,ea,eu){return(0,en.assertBytes)(O),(0,en.assertBytes)(U),(0,J.scryptAsync)(O,U,{N:$,r:eo,p:es,dkLen:ea,onProgress:eu})}function scryptSync(O,U,$,es,eo,ea,eu){return(0,en.assertBytes)(O),(0,en.assertBytes)(U),(0,J.scrypt)(O,U,{N:$,r:eo,p:es,dkLen:ea,onProgress:eu})}U.scrypt=scrypt,U.scryptSync=scryptSync},8207:function(O,U,$){"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.sha256=void 0;let J=$(938),en=$(9449);U.sha256=(0,en.wrapHash)(J.sha256)},9449:function(O,U,$){"use strict";O=$.nmd(O);var J=this&&this.__importDefault||function(O){return O&&O.__esModule?O:{default:O}};Object.defineProperty(U,"__esModule",{value:!0}),U.crypto=U.wrapHash=U.equalsBytes=U.hexToBytes=U.bytesToUtf8=U.utf8ToBytes=U.createView=U.concatBytes=U.toHex=U.bytesToHex=U.assertBytes=U.assertBool=void 0;let en=J($(4390)),es=$(5158),eo=en.default.bool;U.assertBool=eo;let ea=en.default.bytes;U.assertBytes=ea;var eu=$(5158);function bytesToUtf8(O){if(!(O instanceof Uint8Array))throw TypeError(`bytesToUtf8 expected Uint8Array, got ${typeof O}`);return new TextDecoder().decode(O)}function hexToBytes(O){let U=O.startsWith("0x")?O.substring(2):O;return(0,es.hexToBytes)(U)}function equalsBytes(O,U){if(O.length!==U.length)return!1;for(let $=0;$(en.default.bytes(U),O(U))}Object.defineProperty(U,"bytesToHex",{enumerable:!0,get:function(){return eu.bytesToHex}}),Object.defineProperty(U,"toHex",{enumerable:!0,get:function(){return eu.bytesToHex}}),Object.defineProperty(U,"concatBytes",{enumerable:!0,get:function(){return eu.concatBytes}}),Object.defineProperty(U,"createView",{enumerable:!0,get:function(){return eu.createView}}),Object.defineProperty(U,"utf8ToBytes",{enumerable:!0,get:function(){return eu.utf8ToBytes}}),U.bytesToUtf8=bytesToUtf8,U.hexToBytes=hexToBytes,U.equalsBytes=equalsBytes,U.wrapHash=wrapHash,U.crypto=(()=>{let U="object"==typeof self&&"crypto"in self?self.crypto:void 0,$="function"==typeof O.require&&O.require.bind(O);return{node:$&&!U?$("crypto"):void 0,web:U}})()},6509:function(O,U,$){"use strict";$.r(U),$.d(U,{NIL:function(){return eA},parse:function(){return esm_browser_parse},stringify:function(){return esm_browser_stringify},v1:function(){return esm_browser_v1},v3:function(){return eE},v4:function(){return esm_browser_v4},v5:function(){return eS},validate:function(){return esm_browser_validate},version:function(){return esm_browser_version}});var J,en,es,eo=new Uint8Array(16);function rng(){if(!J&&!(J="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return J(eo)}for(var ea=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,esm_browser_validate=function(O){return"string"==typeof O&&ea.test(O)},eu=[],ef=0;ef<256;++ef)eu.push((ef+256).toString(16).substr(1));var esm_browser_stringify=function(O){var U=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,$=(eu[O[U+0]]+eu[O[U+1]]+eu[O[U+2]]+eu[O[U+3]]+"-"+eu[O[U+4]]+eu[O[U+5]]+"-"+eu[O[U+6]]+eu[O[U+7]]+"-"+eu[O[U+8]]+eu[O[U+9]]+"-"+eu[O[U+10]]+eu[O[U+11]]+eu[O[U+12]]+eu[O[U+13]]+eu[O[U+14]]+eu[O[U+15]]).toLowerCase();if(!esm_browser_validate($))throw TypeError("Stringified UUID is invalid");return $},eg=0,ev=0,esm_browser_v1=function(O,U,$){var J=U&&$||0,eo=U||Array(16),ea=(O=O||{}).node||en,eu=void 0!==O.clockseq?O.clockseq:es;if(null==ea||null==eu){var ef=O.random||(O.rng||rng)();null==ea&&(ea=en=[1|ef[0],ef[1],ef[2],ef[3],ef[4],ef[5]]),null==eu&&(eu=es=(ef[6]<<8|ef[7])&16383)}var e_=void 0!==O.msecs?O.msecs:Date.now(),ew=void 0!==O.nsecs?O.nsecs:ev+1,eE=e_-eg+(ew-ev)/1e4;if(eE<0&&void 0===O.clockseq&&(eu=eu+1&16383),(eE<0||e_>eg)&&void 0===O.nsecs&&(ew=0),ew>=1e4)throw Error("uuid.v1(): Can't create more than 10M uuids/sec");eg=e_,ev=ew,es=eu;var eS=((268435455&(e_+=122192928e5))*1e4+ew)%4294967296;eo[J++]=eS>>>24&255,eo[J++]=eS>>>16&255,eo[J++]=eS>>>8&255,eo[J++]=255&eS;var eA=e_/4294967296*1e4&268435455;eo[J++]=eA>>>8&255,eo[J++]=255&eA,eo[J++]=eA>>>24&15|16,eo[J++]=eA>>>16&255,eo[J++]=eu>>>8|128,eo[J++]=255&eu;for(var eI=0;eI<6;++eI)eo[J+eI]=ea[eI];return U||esm_browser_stringify(eo)},esm_browser_parse=function(O){if(!esm_browser_validate(O))throw TypeError("Invalid UUID");var U,$=new Uint8Array(16);return $[0]=(U=parseInt(O.slice(0,8),16))>>>24,$[1]=U>>>16&255,$[2]=U>>>8&255,$[3]=255&U,$[4]=(U=parseInt(O.slice(9,13),16))>>>8,$[5]=255&U,$[6]=(U=parseInt(O.slice(14,18),16))>>>8,$[7]=255&U,$[8]=(U=parseInt(O.slice(19,23),16))>>>8,$[9]=255&U,$[10]=(U=parseInt(O.slice(24,36),16))/1099511627776&255,$[11]=U/4294967296&255,$[12]=U>>>24&255,$[13]=U>>>16&255,$[14]=U>>>8&255,$[15]=255&U,$};function stringToBytes(O){O=unescape(encodeURIComponent(O));for(var U=[],$=0;$>5]>>>en%32&255,eo=parseInt(J.charAt(es>>>4&15)+J.charAt(15&es),16);U.push(eo)}return U}function getOutputLength(O){return(O+64>>>9<<4)+14+1}function wordsToMd5(O,U){O[U>>5]|=128<>5]|=(255&O[J/8])<>16)+(U>>16)+($>>16)<<16|65535&$}function bitRotateLeft(O,U){return O<>>32-U}function md5cmn(O,U,$,J,en,es){return safeAdd(bitRotateLeft(safeAdd(safeAdd(U,O),safeAdd(J,es)),en),$)}function md5ff(O,U,$,J,en,es,eo){return md5cmn(U&$|~U&J,O,U,en,es,eo)}function md5gg(O,U,$,J,en,es,eo){return md5cmn(U&J|$&~J,O,U,en,es,eo)}function md5hh(O,U,$,J,en,es,eo){return md5cmn(U^$^J,O,U,en,es,eo)}function md5ii(O,U,$,J,en,es,eo){return md5cmn($^(U|~J),O,U,en,es,eo)}var eE=v35("v3",48,function(O){if("string"==typeof O){var U=unescape(encodeURIComponent(O));O=new Uint8Array(U.length);for(var $=0;$>>32-U}var eS=v35("v5",80,function(O){var U=[1518500249,1859775393,2400959708,3395469782],$=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof O){var J=unescape(encodeURIComponent(O));O=[];for(var en=0;en>>0;eP=eI,eI=eA,eA=ROTL(eS,30)>>>0,eS=eE,eE=eR}$[0]=$[0]+eE>>>0,$[1]=$[1]+eS>>>0,$[2]=$[2]+eA>>>0,$[3]=$[3]+eI>>>0,$[4]=$[4]+eP>>>0}return[$[0]>>24&255,$[0]>>16&255,$[0]>>8&255,255&$[0],$[1]>>24&255,$[1]>>16&255,$[1]>>8&255,255&$[1],$[2]>>24&255,$[2]>>16&255,$[2]>>8&255,255&$[2],$[3]>>24&255,$[3]>>16&255,$[3]>>8&255,255&$[3],$[4]>>24&255,$[4]>>16&255,$[4]>>8&255,255&$[4]]}),eA="00000000-0000-0000-0000-000000000000",esm_browser_version=function(O){if(!esm_browser_validate(O))throw TypeError("Invalid UUID");return parseInt(O.substr(14,1),16)}},4999:function(O,U,$){"use strict";$.d(U,{Sg:function(){return ForkEvent},zt:function(){return Provider}});var J=$(2278),en=$(7213),es=$(6288);let eo="abstract-provider/5.7.0";var __awaiter=function(O,U,$,J){function adopt(O){return O instanceof $?O:new $(function(U){U(O)})}return new($||($=Promise))(function($,en){function fulfilled(O){try{step(J.next(O))}catch(O){en(O)}}function rejected(O){try{step(J.throw(O))}catch(O){en(O)}}function step(O){O.done?$(O.value):adopt(O.value).then(fulfilled,rejected)}step((J=J.apply(O,U||[])).next())})};let ea=new es.Yd(eo);let ForkEvent=class ForkEvent extends en.dk{static isForkEvent(O){return!!(O&&O._isForkEvent)}};let Provider=class Provider{constructor(){ea.checkAbstract(new.target,Provider),(0,en.zG)(this,"_isProvider",!0)}getFeeData(){return __awaiter(this,void 0,void 0,function*(){let{block:O,gasPrice:U}=yield(0,en.mE)({block:this.getBlock("latest"),gasPrice:this.getGasPrice().catch(O=>null)}),$=null,es=null,eo=null;return O&&O.baseFeePerGas&&($=O.baseFeePerGas,eo=J.O$.from("1500000000"),es=O.baseFeePerGas.mul(2).add(eo)),{lastBaseFeePerGas:$,maxFeePerGas:es,maxPriorityFeePerGas:eo,gasPrice:U}})}addListener(O,U){return this.on(O,U)}removeListener(O,U){return this.off(O,U)}static isProvider(O){return!!(O&&O._isProvider)}}},4941:function(O,U,$){"use strict";$.d(U,{E:function(){return Signer},b:function(){return VoidSigner}});var J=$(7213),en=$(6288);let es="abstract-signer/5.7.0";var __awaiter=function(O,U,$,J){function adopt(O){return O instanceof $?O:new $(function(U){U(O)})}return new($||($=Promise))(function($,en){function fulfilled(O){try{step(J.next(O))}catch(O){en(O)}}function rejected(O){try{step(J.throw(O))}catch(O){en(O)}}function step(O){O.done?$(O.value):adopt(O.value).then(fulfilled,rejected)}step((J=J.apply(O,U||[])).next())})};let eo=new en.Yd(es),ea=["accessList","ccipReadEnabled","chainId","customData","data","from","gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","nonce","to","type","value"],eu=[en.Yd.errors.INSUFFICIENT_FUNDS,en.Yd.errors.NONCE_EXPIRED,en.Yd.errors.REPLACEMENT_UNDERPRICED];let Signer=class Signer{constructor(){eo.checkAbstract(new.target,Signer),(0,J.zG)(this,"_isSigner",!0)}getBalance(O){return __awaiter(this,void 0,void 0,function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),O)})}getTransactionCount(O){return __awaiter(this,void 0,void 0,function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),O)})}estimateGas(O){return __awaiter(this,void 0,void 0,function*(){this._checkProvider("estimateGas");let U=yield(0,J.mE)(this.checkTransaction(O));return yield this.provider.estimateGas(U)})}call(O,U){return __awaiter(this,void 0,void 0,function*(){this._checkProvider("call");let $=yield(0,J.mE)(this.checkTransaction(O));return yield this.provider.call($,U)})}sendTransaction(O){return __awaiter(this,void 0,void 0,function*(){this._checkProvider("sendTransaction");let U=yield this.populateTransaction(O),$=yield this.signTransaction(U);return yield this.provider.sendTransaction($)})}getChainId(){return __awaiter(this,void 0,void 0,function*(){this._checkProvider("getChainId");let O=yield this.provider.getNetwork();return O.chainId})}getGasPrice(){return __awaiter(this,void 0,void 0,function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()})}getFeeData(){return __awaiter(this,void 0,void 0,function*(){return this._checkProvider("getFeeData"),yield this.provider.getFeeData()})}resolveName(O){return __awaiter(this,void 0,void 0,function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(O)})}checkTransaction(O){for(let U in O)-1===ea.indexOf(U)&&eo.throwArgumentError("invalid transaction key: "+U,"transaction",O);let U=(0,J.DC)(O);return null==U.from?U.from=this.getAddress():U.from=Promise.all([Promise.resolve(U.from),this.getAddress()]).then(U=>(U[0].toLowerCase()!==U[1].toLowerCase()&&eo.throwArgumentError("from address mismatch","transaction",O),U[0])),U}populateTransaction(O){return __awaiter(this,void 0,void 0,function*(){let U=yield(0,J.mE)(this.checkTransaction(O));null!=U.to&&(U.to=Promise.resolve(U.to).then(O=>__awaiter(this,void 0,void 0,function*(){if(null==O)return null;let U=yield this.resolveName(O);return null==U&&eo.throwArgumentError("provided ENS name resolves to null","tx.to",O),U})),U.to.catch(O=>{}));let $=null!=U.maxFeePerGas||null!=U.maxPriorityFeePerGas;if(null!=U.gasPrice&&(2===U.type||$)?eo.throwArgumentError("eip-1559 transaction do not support gasPrice","transaction",O):(0===U.type||1===U.type)&&$&&eo.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","transaction",O),(2===U.type||null==U.type)&&null!=U.maxFeePerGas&&null!=U.maxPriorityFeePerGas)U.type=2;else if(0===U.type||1===U.type)null==U.gasPrice&&(U.gasPrice=this.getGasPrice());else{let O=yield this.getFeeData();if(null==U.type){if(null!=O.maxFeePerGas&&null!=O.maxPriorityFeePerGas){if(U.type=2,null!=U.gasPrice){let O=U.gasPrice;delete U.gasPrice,U.maxFeePerGas=O,U.maxPriorityFeePerGas=O}else null==U.maxFeePerGas&&(U.maxFeePerGas=O.maxFeePerGas),null==U.maxPriorityFeePerGas&&(U.maxPriorityFeePerGas=O.maxPriorityFeePerGas)}else null!=O.gasPrice?($&&eo.throwError("network does not support EIP-1559",en.Yd.errors.UNSUPPORTED_OPERATION,{operation:"populateTransaction"}),null==U.gasPrice&&(U.gasPrice=O.gasPrice),U.type=0):eo.throwError("failed to get consistent fee data",en.Yd.errors.UNSUPPORTED_OPERATION,{operation:"signer.getFeeData"})}else 2===U.type&&(null==U.maxFeePerGas&&(U.maxFeePerGas=O.maxFeePerGas),null==U.maxPriorityFeePerGas&&(U.maxPriorityFeePerGas=O.maxPriorityFeePerGas))}return null==U.nonce&&(U.nonce=this.getTransactionCount("pending")),null==U.gasLimit&&(U.gasLimit=this.estimateGas(U).catch(O=>{if(eu.indexOf(O.code)>=0)throw O;return eo.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",en.Yd.errors.UNPREDICTABLE_GAS_LIMIT,{error:O,tx:U})})),null==U.chainId?U.chainId=this.getChainId():U.chainId=Promise.all([Promise.resolve(U.chainId),this.getChainId()]).then(U=>(0!==U[1]&&U[0]!==U[1]&&eo.throwArgumentError("chainId address mismatch","transaction",O),U[0])),yield(0,J.mE)(U)})}_checkProvider(O){this.provider||eo.throwError("missing provider",en.Yd.errors.UNSUPPORTED_OPERATION,{operation:O||"_checkProvider"})}static isSigner(O){return!!(O&&O._isSigner)}};let VoidSigner=class VoidSigner extends Signer{constructor(O,U){super(),(0,J.zG)(this,"address",O),(0,J.zG)(this,"provider",U||null)}getAddress(){return Promise.resolve(this.address)}_fail(O,U){return Promise.resolve().then(()=>{eo.throwError(O,en.Yd.errors.UNSUPPORTED_OPERATION,{operation:U})})}signMessage(O){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(O){return this._fail("VoidSigner cannot sign transactions","signTransaction")}_signTypedData(O,U,$){return this._fail("VoidSigner cannot sign typed data","signTypedData")}connect(O){return new VoidSigner(this.address,O)}}},8994:function(O,U,$){"use strict";$.d(U,{Kn:function(){return getAddress},CR:function(){return getContractAddress}});var J=$(7273),en=$(2278),es=$(4184),eo=$(7054),ea=$(6288);let eu="address/5.7.0",ef=new ea.Yd(eu);function getChecksumAddress(O){(0,J.A7)(O,20)||ef.throwArgumentError("invalid address","address",O),O=O.toLowerCase();let U=O.substring(2).split(""),$=new Uint8Array(40);for(let O=0;O<40;O++)$[O]=U[O].charCodeAt(0);let en=(0,J.lE)((0,es.w)($));for(let O=0;O<40;O+=2)en[O>>1]>>4>=8&&(U[O]=U[O].toUpperCase()),(15&en[O>>1])>=8&&(U[O+1]=U[O+1].toUpperCase());return"0x"+U.join("")}let eg=9007199254740991;function log10(O){return Math.log10?Math.log10(O):Math.log(O)/Math.LN10}let ev={};for(let O=0;O<10;O++)ev[String(O)]=String(O);for(let O=0;O<26;O++)ev[String.fromCharCode(65+O)]=String(10+O);let e_=Math.floor(log10(eg));function ibanChecksum(O){let U=(O=(O=O.toUpperCase()).substring(4)+O.substring(0,2)+"00").split("").map(O=>ev[O]).join("");for(;U.length>=e_;){let O=U.substring(0,e_);U=parseInt(O,10)%97+U.substring(O.length)}let $=String(98-parseInt(U,10)%97);for(;$.length<2;)$="0"+$;return $}function getAddress(O){let U=null;if("string"!=typeof O&&ef.throwArgumentError("invalid address","address",O),O.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==O.substring(0,2)&&(O="0x"+O),U=getChecksumAddress(O),O.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&U!==O&&ef.throwArgumentError("bad address checksum","address",O);else if(O.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(O.substring(2,4)!==ibanChecksum(O)&&ef.throwArgumentError("bad icap checksum","address",O),U=(0,en.g$)(O.substring(4));U.length<40;)U="0"+U;U=getChecksumAddress("0x"+U)}else ef.throwArgumentError("invalid address","address",O);return U}function getContractAddress(O){let U=null;try{U=getAddress(O.from)}catch(U){ef.throwArgumentError("missing from address","transaction",O)}let $=(0,J.G1)((0,J.lE)(en.O$.from(O.nonce).toHexString()));return getAddress((0,J.p3)((0,es.w)((0,eo.c)([U,$])),12))}},2278:function(O,U,$){"use strict";$.d(U,{O$:function(){return BigNumber},g$:function(){return _base36To16}});var J=$(6662),en=$.n(J),es=$(7273),eo=$(6288);let ea="bignumber/5.7.0";var eu=en().BN;let ef=new eo.Yd(ea),eg={},ev=9007199254740991,e_=!1;let BigNumber=class BigNumber{constructor(O,U){O!==eg&&ef.throwError("cannot call constructor directly; use BigNumber.from",eo.Yd.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=U,this._isBigNumber=!0,Object.freeze(this)}fromTwos(O){return toBigNumber(toBN(this).fromTwos(O))}toTwos(O){return toBigNumber(toBN(this).toTwos(O))}abs(){return"-"===this._hex[0]?BigNumber.from(this._hex.substring(1)):this}add(O){return toBigNumber(toBN(this).add(toBN(O)))}sub(O){return toBigNumber(toBN(this).sub(toBN(O)))}div(O){let U=BigNumber.from(O);return U.isZero()&&throwFault("division-by-zero","div"),toBigNumber(toBN(this).div(toBN(O)))}mul(O){return toBigNumber(toBN(this).mul(toBN(O)))}mod(O){let U=toBN(O);return U.isNeg()&&throwFault("division-by-zero","mod"),toBigNumber(toBN(this).umod(U))}pow(O){let U=toBN(O);return U.isNeg()&&throwFault("negative-power","pow"),toBigNumber(toBN(this).pow(U))}and(O){let U=toBN(O);return(this.isNegative()||U.isNeg())&&throwFault("unbound-bitwise-result","and"),toBigNumber(toBN(this).and(U))}or(O){let U=toBN(O);return(this.isNegative()||U.isNeg())&&throwFault("unbound-bitwise-result","or"),toBigNumber(toBN(this).or(U))}xor(O){let U=toBN(O);return(this.isNegative()||U.isNeg())&&throwFault("unbound-bitwise-result","xor"),toBigNumber(toBN(this).xor(U))}mask(O){return(this.isNegative()||O<0)&&throwFault("negative-width","mask"),toBigNumber(toBN(this).maskn(O))}shl(O){return(this.isNegative()||O<0)&&throwFault("negative-width","shl"),toBigNumber(toBN(this).shln(O))}shr(O){return(this.isNegative()||O<0)&&throwFault("negative-width","shr"),toBigNumber(toBN(this).shrn(O))}eq(O){return toBN(this).eq(toBN(O))}lt(O){return toBN(this).lt(toBN(O))}lte(O){return toBN(this).lte(toBN(O))}gt(O){return toBN(this).gt(toBN(O))}gte(O){return toBN(this).gte(toBN(O))}isNegative(){return"-"===this._hex[0]}isZero(){return toBN(this).isZero()}toNumber(){try{return toBN(this).toNumber()}catch(O){throwFault("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(O){}return ef.throwError("this platform does not support BigInt",eo.Yd.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?e_||(e_=!0,ef.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?ef.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",eo.Yd.errors.UNEXPECTED_ARGUMENT,{}):ef.throwError("BigNumber.toString does not accept parameters",eo.Yd.errors.UNEXPECTED_ARGUMENT,{})),toBN(this).toString(10)}toHexString(){return this._hex}toJSON(O){return{type:"BigNumber",hex:this.toHexString()}}static from(O){if(O instanceof BigNumber)return O;if("string"==typeof O)return O.match(/^-?0x[0-9a-f]+$/i)?new BigNumber(eg,toHex(O)):O.match(/^-?[0-9]+$/)?new BigNumber(eg,toHex(new eu(O))):ef.throwArgumentError("invalid BigNumber string","value",O);if("number"==typeof O)return O%1&&throwFault("underflow","BigNumber.from",O),(O>=ev||O<=-ev)&&throwFault("overflow","BigNumber.from",O),BigNumber.from(String(O));let U=O;if("bigint"==typeof U)return BigNumber.from(U.toString());if((0,es._t)(U))return BigNumber.from((0,es.Dv)(U));if(U){if(U.toHexString){let O=U.toHexString();if("string"==typeof O)return BigNumber.from(O)}else{let O=U._hex;if(null==O&&"BigNumber"===U.type&&(O=U.hex),"string"==typeof O&&((0,es.A7)(O)||"-"===O[0]&&(0,es.A7)(O.substring(1))))return BigNumber.from(O)}}return ef.throwArgumentError("invalid BigNumber value","value",O)}static isBigNumber(O){return!!(O&&O._isBigNumber)}};function toHex(O){if("string"!=typeof O)return toHex(O.toString(16));if("-"===O[0])return("-"===(O=O.substring(1))[0]&&ef.throwArgumentError("invalid hex","value",O),"0x00"===(O=toHex(O)))?O:"-"+O;if("0x"!==O.substring(0,2)&&(O="0x"+O),"0x"===O)return"0x00";for(O.length%2&&(O="0x0"+O.substring(2));O.length>4&&"0x00"===O.substring(0,4);)O="0x"+O.substring(4);return O}function toBigNumber(O){return BigNumber.from(toHex(O))}function toBN(O){let U=BigNumber.from(O).toHexString();return"-"===U[0]?new eu("-"+U.substring(3),16):new eu(U.substring(2),16)}function throwFault(O,U,$){let J={fault:O,operation:U};return null!=$&&(J.value=$),ef.throwError(O,eo.Yd.errors.NUMERIC_FAULT,J)}function _base36To16(O){return new eu(O,36).toString(16)}},7273:function(O,U,$){"use strict";$.d(U,{lE:function(){return arrayify},zo:function(){return concat},xs:function(){return hexConcat},E1:function(){return hexDataLength},p3:function(){return hexDataSlice},$P:function(){return hexValue},$m:function(){return hexZeroPad},Dv:function(){return hexlify},_t:function(){return isBytes},Zq:function(){return isBytesLike},A7:function(){return isHexString},N:function(){return splitSignature},G1:function(){return stripZeros},Bu:function(){return zeroPad}});var J=$(6288);let en="bytes/5.7.0",es=new J.Yd(en);function isHexable(O){return!!O.toHexString}function addSlice(O){return O.slice||(O.slice=function(){let U=Array.prototype.slice.call(arguments);return addSlice(new Uint8Array(Array.prototype.slice.apply(O,U)))}),O}function isBytesLike(O){return isHexString(O)&&!(O.length%2)||isBytes(O)}function isInteger(O){return"number"==typeof O&&O==O&&O%1==0}function isBytes(O){if(null==O)return!1;if(O.constructor===Uint8Array)return!0;if("string"==typeof O||!isInteger(O.length)||O.length<0)return!1;for(let U=0;U=256)return!1}return!0}function arrayify(O,U){if(U||(U={}),"number"==typeof O){es.checkSafeUint53(O,"invalid arrayify value");let U=[];for(;O;)U.unshift(255&O),O=parseInt(String(O/256));return 0===U.length&&U.push(0),addSlice(new Uint8Array(U))}if(U.allowMissingPrefix&&"string"==typeof O&&"0x"!==O.substring(0,2)&&(O="0x"+O),isHexable(O)&&(O=O.toHexString()),isHexString(O)){let $=O.substring(2);$.length%2&&("left"===U.hexPad?$="0"+$:"right"===U.hexPad?$+="0":es.throwArgumentError("hex data is odd-length","value",O));let J=[];for(let O=0;O<$.length;O+=2)J.push(parseInt($.substring(O,O+2),16));return addSlice(new Uint8Array(J))}return isBytes(O)?addSlice(new Uint8Array(O)):es.throwArgumentError("invalid arrayify value","value",O)}function concat(O){let U=O.map(O=>arrayify(O)),$=U.reduce((O,U)=>O+U.length,0),J=new Uint8Array($);return U.reduce((O,U)=>(J.set(U,O),O+U.length),0),addSlice(J)}function stripZeros(O){let U=arrayify(O);if(0===U.length)return U;let $=0;for(;$U&&es.throwArgumentError("value out of range","value",arguments[0]);let $=new Uint8Array(U);return $.set(O,U-O.length),addSlice($)}function isHexString(O,U){return"string"==typeof O&&!!O.match(/^0x[0-9A-Fa-f]*$/)&&(!U||O.length===2+2*U)}let eo="0123456789abcdef";function hexlify(O,U){if(U||(U={}),"number"==typeof O){es.checkSafeUint53(O,"invalid hexlify value");let U="";for(;O;)U=eo[15&O]+U,O=Math.floor(O/16);return U.length?(U.length%2&&(U="0"+U),"0x"+U):"0x00"}if("bigint"==typeof O)return(O=O.toString(16)).length%2?"0x0"+O:"0x"+O;if(U.allowMissingPrefix&&"string"==typeof O&&"0x"!==O.substring(0,2)&&(O="0x"+O),isHexable(O))return O.toHexString();if(isHexString(O))return O.length%2&&("left"===U.hexPad?O="0x0"+O.substring(2):"right"===U.hexPad?O+="0":es.throwArgumentError("hex data is odd-length","value",O)),O.toLowerCase();if(isBytes(O)){let U="0x";for(let $=0;$>4]+eo[15&J]}return U}return es.throwArgumentError("invalid hexlify value","value",O)}function hexDataLength(O){if("string"!=typeof O)O=hexlify(O);else if(!isHexString(O)||O.length%2)return null;return(O.length-2)/2}function hexDataSlice(O,U,$){return("string"!=typeof O?O=hexlify(O):(!isHexString(O)||O.length%2)&&es.throwArgumentError("invalid hexData","value",O),U=2+2*U,null!=$)?"0x"+O.substring(U,2+2*$):"0x"+O.substring(U)}function hexConcat(O){let U="0x";return O.forEach(O=>{U+=hexlify(O).substring(2)}),U}function hexValue(O){let U=hexStripZeros(hexlify(O,{hexPad:"left"}));return"0x"===U?"0x0":U}function hexStripZeros(O){"string"!=typeof O&&(O=hexlify(O)),isHexString(O)||es.throwArgumentError("invalid hex string","value",O),O=O.substring(2);let U=0;for(;U2*U+2&&es.throwArgumentError("value out of range","value",arguments[1]);O.length<2*U+2;)O="0x0"+O.substring(2);return O}function splitSignature(O){let U={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(isBytesLike(O)){let $=arrayify(O);64===$.length?(U.v=27+($[32]>>7),$[32]&=127,U.r=hexlify($.slice(0,32)),U.s=hexlify($.slice(32,64))):65===$.length?(U.r=hexlify($.slice(0,32)),U.s=hexlify($.slice(32,64)),U.v=$[64]):es.throwArgumentError("invalid signature string","signature",O),U.v<27&&(0===U.v||1===U.v?U.v+=27:es.throwArgumentError("signature invalid v byte","signature",O)),U.recoveryParam=1-U.v%2,U.recoveryParam&&($[32]|=128),U._vs=hexlify($.slice(32,64))}else{if(U.r=O.r,U.s=O.s,U.v=O.v,U.recoveryParam=O.recoveryParam,U._vs=O._vs,null!=U._vs){let $=zeroPad(arrayify(U._vs),32);U._vs=hexlify($);let J=$[0]>=128?1:0;null==U.recoveryParam?U.recoveryParam=J:U.recoveryParam!==J&&es.throwArgumentError("signature recoveryParam mismatch _vs","signature",O),$[0]&=127;let en=hexlify($);null==U.s?U.s=en:U.s!==en&&es.throwArgumentError("signature v mismatch _vs","signature",O)}if(null==U.recoveryParam)null==U.v?es.throwArgumentError("signature missing v and recoveryParam","signature",O):0===U.v||1===U.v?U.recoveryParam=U.v:U.recoveryParam=1-U.v%2;else if(null==U.v)U.v=27+U.recoveryParam;else{let $=0===U.v||1===U.v?U.v:1-U.v%2;U.recoveryParam!==$&&es.throwArgumentError("signature recoveryParam mismatch v","signature",O)}null!=U.r&&isHexString(U.r)?U.r=hexZeroPad(U.r,32):es.throwArgumentError("signature missing or invalid r","signature",O),null!=U.s&&isHexString(U.s)?U.s=hexZeroPad(U.s,32):es.throwArgumentError("signature missing or invalid s","signature",O);let $=arrayify(U.s);$[0]>=128&&es.throwArgumentError("signature s out of range","signature",O),U.recoveryParam&&($[0]|=128);let J=hexlify($);U._vs&&(isHexString(U._vs)||es.throwArgumentError("signature invalid _vs","signature",O),U._vs=hexZeroPad(U._vs,32)),null==U._vs?U._vs=J:U._vs!==J&&es.throwArgumentError("signature _vs mismatch v and s","signature",O)}return U.yParityAndS=U._vs,U.compact=U.r+U.yParityAndS.substring(2),U}},5572:function(O,U,$){"use strict";$.d(U,{d:function(){return J}});let J="0x0000000000000000000000000000000000000000"},3690:function(O,U,$){"use strict";$.d(U,{Bz:function(){return ea},_Y:function(){return es},fh:function(){return eo},tL:function(){return en}});var J=$(2278);let en=J.O$.from(-1),es=J.O$.from(0),eo=J.O$.from(1),ea=J.O$.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")},6339:function(O,U,$){"use strict";$.d(U,{id:function(){return id}});var J=$(4184),en=$(8337);function id(O){return(0,J.w)((0,en.Y0)(O))}},4184:function(O,U,$){"use strict";$.d(U,{w:function(){return keccak256}});var J=$(6398),en=$.n(J),es=$(7273);function keccak256(O){return"0x"+en().keccak_256((0,es.lE)(O))}},6288:function(O,U,$){"use strict";var J,en;$.d(U,{Yd:function(){return Logger}});let es="logger/5.7.0",eo=!1,ea=!1,eu={debug:1,default:2,info:2,warning:3,error:4,off:5},ef=2,eg=null;function _checkNormalize(){try{let O=[];if(["NFD","NFC","NFKD","NFKC"].forEach(U=>{try{if("test"!=="test".normalize(U))throw Error("bad normalize")}catch($){O.push(U)}}),O.length)throw Error("missing "+O.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw Error("broken implementation")}catch(O){return O.message}return null}let ev=_checkNormalize();!function(O){O.DEBUG="DEBUG",O.INFO="INFO",O.WARNING="WARNING",O.ERROR="ERROR",O.OFF="OFF"}(J||(J={})),function(O){O.UNKNOWN_ERROR="UNKNOWN_ERROR",O.NOT_IMPLEMENTED="NOT_IMPLEMENTED",O.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",O.NETWORK_ERROR="NETWORK_ERROR",O.SERVER_ERROR="SERVER_ERROR",O.TIMEOUT="TIMEOUT",O.BUFFER_OVERRUN="BUFFER_OVERRUN",O.NUMERIC_FAULT="NUMERIC_FAULT",O.MISSING_NEW="MISSING_NEW",O.INVALID_ARGUMENT="INVALID_ARGUMENT",O.MISSING_ARGUMENT="MISSING_ARGUMENT",O.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",O.CALL_EXCEPTION="CALL_EXCEPTION",O.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",O.NONCE_EXPIRED="NONCE_EXPIRED",O.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",O.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",O.TRANSACTION_REPLACED="TRANSACTION_REPLACED",O.ACTION_REJECTED="ACTION_REJECTED"}(en||(en={}));let e_="0123456789abcdef";let Logger=class Logger{constructor(O){Object.defineProperty(this,"version",{enumerable:!0,value:O,writable:!1})}_log(O,U){let $=O.toLowerCase();null==eu[$]&&this.throwArgumentError("invalid log level name","logLevel",O),ef>eu[$]||console.log.apply(console,U)}debug(...O){this._log(Logger.levels.DEBUG,O)}info(...O){this._log(Logger.levels.INFO,O)}warn(...O){this._log(Logger.levels.WARNING,O)}makeError(O,U,$){if(ea)return this.makeError("censored error",U,{});U||(U=Logger.errors.UNKNOWN_ERROR),$||($={});let J=[];Object.keys($).forEach(O=>{let U=$[O];try{if(U instanceof Uint8Array){let $="";for(let O=0;O>4]+e_[15&U[O]];J.push(O+"=Uint8Array(0x"+$+")")}else J.push(O+"="+JSON.stringify(U))}catch(U){J.push(O+"="+JSON.stringify($[O].toString()))}}),J.push(`code=${U}`),J.push(`version=${this.version}`);let es=O,eo="";switch(U){case en.NUMERIC_FAULT:{eo="NUMERIC_FAULT";let U=O;switch(U){case"overflow":case"underflow":case"division-by-zero":eo+="-"+U;break;case"negative-power":case"negative-width":eo+="-unsupported";break;case"unbound-bitwise-result":eo+="-unbound-result"}break}case en.CALL_EXCEPTION:case en.INSUFFICIENT_FUNDS:case en.MISSING_NEW:case en.NONCE_EXPIRED:case en.REPLACEMENT_UNDERPRICED:case en.TRANSACTION_REPLACED:case en.UNPREDICTABLE_GAS_LIMIT:eo=U}eo&&(O+=" [ See: https://links.ethers.org/v5-errors-"+eo+" ]"),J.length&&(O+=" ("+J.join(", ")+")");let eu=Error(O);return eu.reason=es,eu.code=U,Object.keys($).forEach(function(O){eu[O]=$[O]}),eu}throwError(O,U,$){throw this.makeError(O,U,$)}throwArgumentError(O,U,$){return this.throwError(O,Logger.errors.INVALID_ARGUMENT,{argument:U,value:$})}assert(O,U,$,J){O||this.throwError(U,$,J)}assertArgument(O,U,$,J){O||this.throwArgumentError(U,$,J)}checkNormalize(O){null==O&&(O="platform missing String.prototype.normalize"),ev&&this.throwError("platform missing String.prototype.normalize",Logger.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:ev})}checkSafeUint53(O,U){"number"==typeof O&&(null==U&&(U="value not safe"),(O<0||O>=9007199254740991)&&this.throwError(U,Logger.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:O}),O%1&&this.throwError(U,Logger.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:O}))}checkArgumentCount(O,U,$){$=$?": "+$:"",OU&&this.throwError("too many arguments"+$,Logger.errors.UNEXPECTED_ARGUMENT,{count:O,expectedCount:U})}checkNew(O,U){(O===Object||null==O)&&this.throwError("missing new",Logger.errors.MISSING_NEW,{name:U.name})}checkAbstract(O,U){O===U?this.throwError("cannot instantiate abstract class "+JSON.stringify(U.name)+" directly; use a sub-class",Logger.errors.UNSUPPORTED_OPERATION,{name:O.name,operation:"new"}):(O===Object||null==O)&&this.throwError("missing new",Logger.errors.MISSING_NEW,{name:U.name})}static globalLogger(){return eg||(eg=new Logger(es)),eg}static setCensorship(O,U){if(!O&&U&&this.globalLogger().throwError("cannot permanently disable censorship",Logger.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),eo){if(!O)return;this.globalLogger().throwError("error censorship permanent",Logger.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}ea=!!O,eo=!!U}static setLogLevel(O){let U=eu[O.toLowerCase()];if(null==U){Logger.globalLogger().warn("invalid log level - "+O);return}ef=U}static from(O){return new Logger(O)}};Logger.errors=en,Logger.levels=J},7213:function(O,U,$){"use strict";$.d(U,{dk:function(){return Description},uj:function(){return checkProperties},p$:function(){return deepCopy},zG:function(){return defineReadOnly},tu:function(){return getStatic},mE:function(){return resolveProperties},DC:function(){return shallowCopy}});var J=$(6288);let en="properties/5.7.0";var __awaiter=function(O,U,$,J){function adopt(O){return O instanceof $?O:new $(function(U){U(O)})}return new($||($=Promise))(function($,en){function fulfilled(O){try{step(J.next(O))}catch(O){en(O)}}function rejected(O){try{step(J.throw(O))}catch(O){en(O)}}function step(O){O.done?$(O.value):adopt(O.value).then(fulfilled,rejected)}step((J=J.apply(O,U||[])).next())})};let es=new J.Yd(en);function defineReadOnly(O,U,$){Object.defineProperty(O,U,{enumerable:!0,value:$,writable:!1})}function getStatic(O,U){for(let $=0;$<32;$++){if(O[U])return O[U];if(!O.prototype||"object"!=typeof O.prototype)break;O=Object.getPrototypeOf(O.prototype).constructor}return null}function resolveProperties(O){return __awaiter(this,void 0,void 0,function*(){let U=Object.keys(O).map(U=>{let $=O[U];return Promise.resolve($).then(O=>({key:U,value:O}))}),$=yield Promise.all(U);return $.reduce((O,U)=>(O[U.key]=U.value,O),{})})}function checkProperties(O,U){O&&"object"==typeof O||es.throwArgumentError("invalid object","object",O),Object.keys(O).forEach($=>{U[$]||es.throwArgumentError("invalid object key - "+$,"transaction:"+$,O)})}function shallowCopy(O){let U={};for(let $ in O)U[$]=O[$];return U}let eo={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function _isFrozen(O){if(null==O||eo[typeof O])return!0;if(Array.isArray(O)||"object"==typeof O){if(!Object.isFrozen(O))return!1;let U=Object.keys(O);for(let $=0;$deepCopy(O)));if("object"==typeof O){let U={};for(let $ in O){let J=O[$];void 0!==J&&defineReadOnly(U,$,deepCopy(J))}return U}return es.throwArgumentError(`Cannot deepCopy ${typeof O}`,"object",O)}function deepCopy(O){return _deepCopy(O)}let Description=class Description{constructor(O){for(let U in O)this[U]=deepCopy(O[U])}}},379:function(O,U,$){"use strict";$.d(U,{Q:function(){return Web3Provider}});var J=$(7213),en=$(6288);let es="providers/5.7.2";var eo=$(4941),ea=$(2278),eu=$(7273),ef=$(8994),eg=$(4184);let ev="hash/5.7.0";var e_=$(6339),__awaiter=function(O,U,$,J){function adopt(O){return O instanceof $?O:new $(function(U){U(O)})}return new($||($=Promise))(function($,en){function fulfilled(O){try{step(J.next(O))}catch(O){en(O)}}function rejected(O){try{step(J.throw(O))}catch(O){en(O)}}function step(O){O.done?$(O.value):adopt(O.value).then(fulfilled,rejected)}step((J=J.apply(O,U||[])).next())})};let ew=new en.Yd(ev),eE=new Uint8Array(32);eE.fill(0);let eS=ea.O$.from(-1),eA=ea.O$.from(0),eI=ea.O$.from(1),eP=ea.O$.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function hexPadRight(O){let U=(0,eu.lE)(O),$=U.length%32;return $?(0,eu.xs)([U,eE.slice($)]):(0,eu.Dv)(U)}let ek=(0,eu.$m)(eI.toHexString(),32),eT=(0,eu.$m)(eA.toHexString(),32),eR={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},eC=["name","version","chainId","verifyingContract","salt"];function checkString(O){return function(U){return"string"!=typeof U&&ew.throwArgumentError(`invalid domain value for ${JSON.stringify(O)}`,`domain.${O}`,U),U}}let eB={name:checkString("name"),version:checkString("version"),chainId:function(O){try{return ea.O$.from(O).toString()}catch(O){}return ew.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",O)},verifyingContract:function(O){try{return(0,ef.Kn)(O).toLowerCase()}catch(O){}return ew.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",O)},salt:function(O){try{let U=(0,eu.lE)(O);if(32!==U.length)throw Error("bad length");return(0,eu.Dv)(U)}catch(O){}return ew.throwArgumentError('invalid domain value "salt"',"domain.salt",O)}};function getBaseEncoder(O){{let U=O.match(/^(u?)int(\d*)$/);if(U){let $=""===U[1],J=parseInt(U[2]||"256");(J%8!=0||J>256||U[2]&&U[2]!==String(J))&&ew.throwArgumentError("invalid numeric width","type",O);let en=eP.mask($?J-1:J),es=$?en.add(eI).mul(eS):eA;return function(U){let $=ea.O$.from(U);return($.lt(es)||$.gt(en))&&ew.throwArgumentError(`value out-of-bounds for ${O}`,"value",U),(0,eu.$m)($.toTwos(256).toHexString(),32)}}}{let U=O.match(/^bytes(\d+)$/);if(U){let $=parseInt(U[1]);return(0===$||$>32||U[1]!==String($))&&ew.throwArgumentError("invalid bytes width","type",O),function(U){let J=(0,eu.lE)(U);return J.length!==$&&ew.throwArgumentError(`invalid length for ${O}`,"value",U),hexPadRight(U)}}}switch(O){case"address":return function(O){return(0,eu.$m)((0,ef.Kn)(O),32)};case"bool":return function(O){return O?ek:eT};case"bytes":return function(O){return(0,eg.w)(O)};case"string":return function(O){return(0,e_.id)(O)}}return null}function encodeType(O,U){return`${O}(${U.map(({name:O,type:U})=>U+" "+O).join(",")})`}let TypedDataEncoder=class TypedDataEncoder{constructor(O){(0,J.zG)(this,"types",Object.freeze((0,J.p$)(O))),(0,J.zG)(this,"_encoderCache",{}),(0,J.zG)(this,"_types",{});let U={},$={},en={};for(let J in Object.keys(O).forEach(O=>{U[O]={},$[O]=[],en[O]={}}),O){let en={};O[J].forEach(es=>{en[es.name]&&ew.throwArgumentError(`duplicate variable name ${JSON.stringify(es.name)} in ${JSON.stringify(J)}`,"types",O),en[es.name]=!0;let eo=es.type.match(/^([^\x5b]*)(\x5b|$)/)[1];eo===J&&ew.throwArgumentError(`circular type reference to ${JSON.stringify(eo)}`,"types",O);let ea=getBaseEncoder(eo);ea||($[eo]||ew.throwArgumentError(`unknown type ${JSON.stringify(eo)}`,"types",O),$[eo].push(J),U[J][eo]=!0)})}let es=Object.keys($).filter(O=>0===$[O].length);function checkCircular(J,es){es[J]&&ew.throwArgumentError(`circular type reference to ${JSON.stringify(J)}`,"types",O),es[J]=!0,Object.keys(U[J]).forEach(O=>{$[O]&&(checkCircular(O,es),Object.keys(es).forEach(U=>{en[U][O]=!0}))}),delete es[J]}for(let U in 0===es.length?ew.throwArgumentError("missing primary type","types",O):es.length>1&&ew.throwArgumentError(`ambiguous primary types or unused types: ${es.map(O=>JSON.stringify(O)).join(", ")}`,"types",O),(0,J.zG)(this,"primaryType",es[0]),checkCircular(this.primaryType,{}),en){let $=Object.keys(en[U]);$.sort(),this._types[U]=encodeType(U,O[U])+$.map(U=>encodeType(U,O[U])).join("")}}getEncoder(O){let U=this._encoderCache[O];return U||(U=this._encoderCache[O]=this._getEncoder(O)),U}_getEncoder(O){{let U=getBaseEncoder(O);if(U)return U}let U=O.match(/^(.*)(\x5b(\d*)\x5d)$/);if(U){let O=U[1],$=this.getEncoder(O),J=parseInt(U[3]);return U=>{J>=0&&U.length!==J&&ew.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",U);let en=U.map($);return this._types[O]&&(en=en.map(eg.w)),(0,eg.w)((0,eu.xs)(en))}}let $=this.types[O];if($){let U=(0,e_.id)(this._types[O]);return O=>{let J=$.map(({name:U,type:$})=>{let J=this.getEncoder($)(O[U]);return this._types[$]?(0,eg.w)(J):J});return J.unshift(U),(0,eu.xs)(J)}}return ew.throwArgumentError(`unknown type: ${O}`,"type",O)}encodeType(O){let U=this._types[O];return U||ew.throwArgumentError(`unknown type: ${JSON.stringify(O)}`,"name",O),U}encodeData(O,U){return this.getEncoder(O)(U)}hashStruct(O,U){return(0,eg.w)(this.encodeData(O,U))}encode(O){return this.encodeData(this.primaryType,O)}hash(O){return this.hashStruct(this.primaryType,O)}_visit(O,U,$){{let J=getBaseEncoder(O);if(J)return $(O,U)}let J=O.match(/^(.*)(\x5b(\d*)\x5d)$/);if(J){let O=J[1],en=parseInt(J[3]);return en>=0&&U.length!==en&&ew.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",U),U.map(U=>this._visit(O,U,$))}let en=this.types[O];return en?en.reduce((O,{name:J,type:en})=>(O[J]=this._visit(en,U[J],$),O),{}):ew.throwArgumentError(`unknown type: ${O}`,"type",O)}visit(O,U){return this._visit(this.primaryType,O,U)}static from(O){return new TypedDataEncoder(O)}static getPrimaryType(O){return TypedDataEncoder.from(O).primaryType}static hashStruct(O,U,$){return TypedDataEncoder.from(U).hashStruct(O,$)}static hashDomain(O){let U=[];for(let $ in O){let J=eR[$];J||ew.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify($)}`,"domain",O),U.push({name:$,type:J})}return U.sort((O,U)=>eC.indexOf(O.name)-eC.indexOf(U.name)),TypedDataEncoder.hashStruct("EIP712Domain",{EIP712Domain:U},O)}static encode(O,U,$){return(0,eu.xs)(["0x1901",TypedDataEncoder.hashDomain(O),TypedDataEncoder.from(U).hash($)])}static hash(O,U,$){return(0,eg.w)(TypedDataEncoder.encode(O,U,$))}static resolveNames(O,U,$,en){return __awaiter(this,void 0,void 0,function*(){O=(0,J.DC)(O);let es={};O.verifyingContract&&!(0,eu.A7)(O.verifyingContract,20)&&(es[O.verifyingContract]="0x");let eo=TypedDataEncoder.from(U);for(let O in eo.visit($,(O,U)=>("address"!==O||(0,eu.A7)(U,20)||(es[U]="0x"),U)),es)es[O]=yield en(O);return O.verifyingContract&&es[O.verifyingContract]&&(O.verifyingContract=es[O.verifyingContract]),{domain:O,value:$=eo.visit($,(O,U)=>"address"===O&&es[U]?es[U]:U)}})}static getPayload(O,U,$){TypedDataEncoder.hashDomain(O);let en={},es=[];eC.forEach(U=>{let $=O[U];null!=$&&(en[U]=eB[U]($),es.push({name:U,type:eR[U]}))});let eo=TypedDataEncoder.from(U),ef=(0,J.DC)(U);return ef.EIP712Domain?ew.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",U):ef.EIP712Domain=es,eo.encode($),{types:ef,domain:en,primaryType:eo.primaryType,message:eo.visit($,(O,U)=>{if(O.match(/^bytes(\d*)/))return(0,eu.Dv)((0,eu.lE)(U));if(O.match(/^u?int/))return ea.O$.from(U).toString();switch(O){case"address":return U.toLowerCase();case"bool":return!!U;case"string":return"string"!=typeof U&&ew.throwArgumentError("invalid string","value",U),U}return ew.throwArgumentError("unsupported type","type",O)})}}};var eN=$(8337),eD=$(2501);function decode(O){O=atob(O);let U=[];for(let $=0;${es[U.toLowerCase()]=O}):J.headers.keys().forEach(O=>{es[O.toLowerCase()]=J.headers.get(O)}),{headers:es,statusCode:J.status,statusMessage:J.statusText,body:(0,eu.lE)(new Uint8Array(en))}})}var lib_esm_awaiter=function(O,U,$,J){function adopt(O){return O instanceof $?O:new $(function(U){U(O)})}return new($||($=Promise))(function($,en){function fulfilled(O){try{step(J.next(O))}catch(O){en(O)}}function rejected(O){try{step(J.throw(O))}catch(O){en(O)}}function step(O){O.done?$(O.value):adopt(O.value).then(fulfilled,rejected)}step((J=J.apply(O,U||[])).next())})};let eO=new en.Yd(eM);function staller(O){return new Promise(U=>{setTimeout(U,O)})}function bodyify(O,U){if(null==O)return null;if("string"==typeof O)return O;if((0,eu.Zq)(O)){if(U&&("text"===U.split("/")[0]||"application/json"===U.split(";")[0].trim()))try{return(0,eN.ZN)(O)}catch(O){}return(0,eu.Dv)(O)}return O}function unpercent(O){return(0,eN.Y0)(O.replace(/%([0-9a-f][0-9a-f])/gi,(O,U)=>String.fromCharCode(parseInt(U,16))))}function _fetchData(O,U,$){let es="object"==typeof O&&null!=O.throttleLimit?O.throttleLimit:12;eO.assertArgument(es>0&&es%1==0,"invalid connection throttle limit","connection.throttleLimit",es);let eo="object"==typeof O?O.throttleCallback:null,ea="object"==typeof O&&"number"==typeof O.throttleSlotInterval?O.throttleSlotInterval:100;eO.assertArgument(ea>0&&ea%1==0,"invalid connection throttle slot interval","connection.throttleSlotInterval",ea);let eu="object"==typeof O&&!!O.errorPassThrough,ef={},eg=null,ev={method:"GET"},e_=!1,ew=12e4;if("string"==typeof O)eg=O;else if("object"==typeof O){if((null==O||null==O.url)&&eO.throwArgumentError("missing URL","connection.url",O),eg=O.url,"number"==typeof O.timeout&&O.timeout>0&&(ew=O.timeout),O.headers)for(let U in O.headers)ef[U.toLowerCase()]={key:U,value:String(O.headers[U])},["if-none-match","if-modified-since"].indexOf(U.toLowerCase())>=0&&(e_=!0);if(ev.allowGzip=!!O.allowGzip,null!=O.user&&null!=O.password){"https:"!==eg.substring(0,6)&&!0!==O.allowInsecureAuthentication&&eO.throwError("basic authentication requires a secure https url",en.Yd.errors.INVALID_ARGUMENT,{argument:"url",url:eg,user:O.user,password:"[REDACTED]"});let U=O.user+":"+O.password;ef.authorization={key:"Authorization",value:"Basic "+encode((0,eN.Y0)(U))}}null!=O.skipFetchSetup&&(ev.skipFetchSetup=!!O.skipFetchSetup),null!=O.fetchOptions&&(ev.fetchOptions=(0,J.DC)(O.fetchOptions))}let eE=RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),eS=eg?eg.match(eE):null;if(eS)try{let O={statusCode:200,statusMessage:"OK",headers:{"content-type":eS[1]||"text/plain"},body:eS[2]?decode(eS[3]):unpercent(eS[3])},U=O.body;return $&&(U=$(O.body,O)),Promise.resolve(U)}catch(O){eO.throwError("processing response error",en.Yd.errors.SERVER_ERROR,{body:bodyify(eS[1],eS[2]),error:O,requestBody:null,requestMethod:"GET",url:eg})}U&&(ev.method="POST",ev.body=U,null==ef["content-type"]&&(ef["content-type"]={key:"Content-Type",value:"application/octet-stream"}),null==ef["content-length"]&&(ef["content-length"]={key:"Content-Length",value:String(U.length)}));let eA={};Object.keys(ef).forEach(O=>{let U=ef[O];eA[U.key]=U.value}),ev.headers=eA;let eI=function(){let O=null,U=new Promise(function(U,$){ew&&(O=setTimeout(()=>{null!=O&&(O=null,$(eO.makeError("timeout",en.Yd.errors.TIMEOUT,{requestBody:bodyify(ev.body,eA["content-type"]),requestMethod:ev.method,timeout:ew,url:eg})))},ew))}),cancel=function(){null!=O&&(clearTimeout(O),O=null)};return{promise:U,cancel}}(),eP=function(){return lib_esm_awaiter(this,void 0,void 0,function*(){for(let O=0;O=300)&&(eI.cancel(),eO.throwError("bad response",en.Yd.errors.SERVER_ERROR,{status:U.statusCode,headers:U.headers,body:bodyify(J,U.headers?U.headers["content-type"]:null),requestBody:bodyify(ev.body,eA["content-type"]),requestMethod:ev.method,url:eg})),$)try{let O=yield $(J,U);return eI.cancel(),O}catch($){if($.throttleRetry&&O{let J=null;if(null!=O)try{J=JSON.parse((0,eN.ZN)(O))}catch(U){eO.throwError("invalid JSON",en.Yd.errors.SERVER_ERROR,{body:O,error:U})}return $&&(J=$(J,U)),J},es=null;if(null!=U){es=(0,eN.Y0)(U);let $="string"==typeof O?{url:O}:(0,J.DC)(O);if($.headers){let O=0!==Object.keys($.headers).filter(O=>"content-type"===O.toLowerCase()).length;O||($.headers=(0,J.DC)($.headers),$.headers["content-type"]="application/json")}else $.headers={"content-type":"application/json"};O=$}return _fetchData(O,es,processJsonFunc)}function poll(O,U){return U||(U={}),null==(U=(0,J.DC)(U)).floor&&(U.floor=0),null==U.ceiling&&(U.ceiling=1e4),null==U.interval&&(U.interval=250),new Promise(function($,J){let en=null,es=!1,cancel=()=>!es&&(es=!0,en&&clearTimeout(en),!0);U.timeout&&(en=setTimeout(()=>{cancel()&&J(Error("timeout"))},U.timeout));let eo=U.retryLimit,ea=0;function check(){return O().then(function(O){if(void 0!==O)cancel()&&$(O);else if(U.oncePoll)U.oncePoll.once("poll",check);else if(U.onceBlock)U.onceBlock.once("block",check);else if(!es){if(++ea>eo){cancel()&&J(Error("retry limit reached"));return}let O=U.interval*parseInt(String(Math.random()*Math.pow(2,ea)));OU.ceiling&&(O=U.ceiling),setTimeout(check,O)}return null},function(O){cancel()&&J(O)})}check()})}var eL=$(4999);let BaseX=class BaseX{constructor(O){(0,J.zG)(this,"alphabet",O),(0,J.zG)(this,"base",O.length),(0,J.zG)(this,"_alphabetMap",{}),(0,J.zG)(this,"_leader",O.charAt(0));for(let U=0;U0;)$.push(J%this.base),J=J/this.base|0}let J="";for(let O=0;0===U[O]&&O=0;--O)J+=this.alphabet[$[O]];return J}decode(O){if("string"!=typeof O)throw TypeError("Expected String");let U=[];if(0===O.length)return new Uint8Array(U);U.push(0);for(let $=0;$>=8;for(;en>0;)U.push(255&en),en>>=8}for(let $=0;O[$]===this._leader&&$0&&Array.isArray(O)?flatDeep(O,U-1):$.push(O)})};return flatDeep(O,U),$}function fromEntries(O){let U={};for(let $=0;$>--ea&1}let ef=31,eg=Math.pow(2,ef),ev=eg>>>1,e_=ev>>1,ew=eg-1,eE=0;for(let O=0;O1;){let $=U+es>>>1;O>>1|read_bit(),eo=eo<<1^ev,ea=(ea^ev)<<1|ev|1;eA=eo,eI=1+ea-eo}let eP=$-4;return eS.map(U=>{switch(U-eP){case 3:return eP+65792+(O[eo++]<<16|O[eo++]<<8|O[eo++]);case 2:return eP+256+(O[eo++]<<8|O[eo++]);case 1:return eP+O[eo++];default:return U-1}})}function read_payload(O){let U=0;return()=>O[U++]}function read_compressed_payload(O){return read_payload(decode_arithmetic(O))}function signed(O){return 1&O?~O>>1:O>>1}function read_counts(O,U){let $=Array(O);for(let J=0;JU[O]):$}function read_mapped_map(O){let U=[];for(;;){let $=O();if(0==$)break;U.push(read_linear_table($,O))}for(;;){let $=O()-1;if($<0)break;U.push(read_replacement_table($,O))}return fromEntries(flat(U))}function read_zero_terminated_array(O){let U=[];for(;;){let $=O();if(0==$)break;U.push($)}return U}function read_transposed(O,U,$){let J=Array(O).fill(void 0).map(()=>[]);for(let en=0;enJ[U].push(O));return J}function read_linear_table(O,U){let $=1+U(),J=U(),en=read_zero_terminated_array(U);return flat(read_transposed(en.length,1+O,U).map((O,U)=>{let es=O[0],eo=O.slice(1);return Array(en[U]).fill(void 0).map((O,U)=>{let en=U*J;return[es+U*$,eo.map(O=>O+en)]})}))}function read_replacement_table(O,U){return read_transposed(1+U(),1+O,U).map(O=>[O[0],O.slice(1)])}function read_emoji_trie(O){let U=read_member_array(O).sort((O,U)=>O-U);return read();function read(){let $=[];for(;;){let J=read_member_array(O,U);if(0==J.length)break;$.push({set:new Set(J),node:read()})}$.sort((O,U)=>U.set.size-O.set.size);let J=O();return{branches:$,valid:J%3,fe0f:!!(1&(J=J/3|0)),save:1==(J>>=1),check:2==J}}}function getData(){return read_compressed_payload(decode("AEQF2AO2DEsA2wIrAGsBRABxAN8AZwCcAEwAqgA0AGwAUgByADcATAAVAFYAIQAyACEAKAAYAFgAGwAjABQAMAAmADIAFAAfABQAKwATACoADgAbAA8AHQAYABoAGQAxADgALAAoADwAEwA9ABMAGgARAA4ADwAWABMAFgAIAA8AHgQXBYMA5BHJAS8JtAYoAe4AExozi0UAH21tAaMnBT8CrnIyhrMDhRgDygIBUAEHcoFHUPe8AXBjAewCjgDQR8IICIcEcQLwATXCDgzvHwBmBoHNAqsBdBcUAykgDhAMShskMgo8AY8jqAQfAUAfHw8BDw87MioGlCIPBwZCa4ELatMAAMspJVgsDl8AIhckSg8XAHdvTwBcIQEiDT4OPhUqbyECAEoAS34Aej8Ybx83JgT/Xw8gHxZ/7w8RICxPHA9vBw+Pfw8PHwAPFv+fAsAvCc8vEr8ivwD/EQ8Bol8OEBa/A78hrwAPCU8vESNvvwWfHwNfAVoDHr+ZAAED34YaAdJPAK7PLwSEgDLHAGo1Pz8Pvx9fUwMrpb8O/58VTzAPIBoXIyQJNF8hpwIVAT8YGAUADDNBaX3RAMomJCg9EhUeA29MABsZBTMNJipjOhc19gcIDR8bBwQHEggCWi6DIgLuAQYA+BAFCha3A5XiAEsqM7UFFgFLhAMjFTMYE1Klnw74nRVBG/ASCm0BYRN/BrsU3VoWy+S0vV8LQx+vN8gF2AC2AK5EAWwApgYDKmAAroQ0NDQ0AT+OCg7wAAIHRAbpNgVcBV0APTA5BfbPFgMLzcYL/QqqA82eBALKCjQCjqYCht0/k2+OAsXQAoP3ASTKDgDw6ACKAUYCMpIKJpRaAE4A5womABzZvs0REEKiACIQAd5QdAECAj4Ywg/wGqY2AVgAYADYvAoCGAEubA0gvAY2ALAAbpbvqpyEAGAEpgQAJgAG7gAgAEACmghUFwCqAMpAINQIwC4DthRAAPcycKgApoIdABwBfCisABoATwBqASIAvhnSBP8aH/ECeAKXAq40NjgDBTwFYQU6AXs3oABgAD4XNgmcCY1eCl5tIFZeUqGgyoNHABgAEQAaABNwWQAmABMATPMa3T34ADldyprmM1M2XociUQgLzvwAXT3xABgAEQAaABNwIGFAnADD8AAgAD4BBJWzaCcIAIEBFMAWwKoAAdq9BWAF5wLQpALEtQAKUSGkahR4GnJM+gsAwCgeFAiUAECQ0BQuL8AAIAAAADKeIheclvFqQAAETr4iAMxIARMgAMIoHhQIAn0E0pDQFC4HhznoAAAAIAI2C0/4lvFqQAAETgBJJwYCAy4ABgYAFAA8MBKYEH4eRhTkAjYeFcgACAYAeABsOqyQ5gRwDayqugEgaIIAtgoACgDmEABmBAWGme5OBJJA2m4cDeoAmITWAXwrMgOgAGwBCh6CBXYF1Tzg1wKAAFdiuABRAFwAXQBsAG8AdgBrAHYAbwCEAHEwfxQBVE5TEQADVFhTBwBDANILAqcCzgLTApQCrQL6vAAMAL8APLhNBKkE6glGKTAU4Dr4N2EYEwBCkABKk8rHAbYBmwIoAiU4Ajf/Aq4CowCAANIChzgaNBsCsTgeODcFXrgClQKdAqQBiQGYAqsCsjTsNHsfNPA0ixsAWTWiOAMFPDQSNCk2BDZHNow2TTZUNhk28Jk9VzI3QkEoAoICoQKwAqcAQAAxBV4FXbS9BW47YkIXP1ciUqs05DS/FwABUwJW11e6nHuYZmSh/RAYA8oMKvZ8KASoUAJYWAJ6ILAsAZSoqjpgA0ocBIhmDgDWAAawRDQoAAcuAj5iAHABZiR2AIgiHgCaAU68ACxuHAG0ygM8MiZIAlgBdF4GagJqAPZOHAMuBgoATkYAsABiAHgAMLoGDPj0HpKEBAAOJgAuALggTAHWAeAMEDbd20Uege0ADwAWADkAQgA9OHd+2MUQZBBhBgNNDkxxPxUQArEPqwvqERoM1irQ090ANK4H8ANYB/ADWANYB/AH8ANYB/ADWANYA1gDWBwP8B/YxRBkD00EcgWTBZAE2wiIJk4RhgctCNdUEnQjHEwDSgEBIypJITuYMxAlR0wRTQgIATZHbKx9PQNMMbBU+pCnA9AyVDlxBgMedhKlAC8PeCE1uk6DekxxpQpQT7NX9wBFBgASqwAS5gBJDSgAUCwGPQBI4zTYABNGAE2bAE3KAExdGABKaAbgAFBXAFCOAFBJABI2SWdObALDOq0//QomCZhvwHdTBkIQHCemEPgMNAG2ATwN7kvZBPIGPATKH34ZGg/OlZ0Ipi3eDO4m5C6igFsj9iqEBe5L9TzeC05RaQ9aC2YJ5DpkgU8DIgEOIowK3g06CG4Q9ArKbA3mEUYHOgPWSZsApgcCCxIdNhW2JhFirQsKOXgG/Br3C5AmsBMqev0F1BoiBk4BKhsAANAu6IWxWjJcHU9gBgQLJiPIFKlQIQ0mQLh4SRocBxYlqgKSQ3FKiFE3HpQh9zw+DWcuFFF9B/Y8BhlQC4I8n0asRQ8R0z6OPUkiSkwtBDaALDAnjAnQD4YMunxzAVoJIgmyDHITMhEYN8YIOgcaLpclJxYIIkaWYJsE+KAD9BPSAwwFQAlCBxQDthwuEy8VKgUOgSXYAvQ21i60ApBWgQEYBcwPJh/gEFFH4Q7qCJwCZgOEJewALhUiABginAhEZABgj9lTBi7MCMhqbSN1A2gU6GIRdAeSDlgHqBw0FcAc4nDJXgyGCSiksAlcAXYJmgFgBOQICjVcjKEgQmdUi1kYnCBiQUBd/QIyDGYVoES+h3kCjA9sEhwBNgF0BzoNAgJ4Ee4RbBCWCOyGBTW2M/k6JgRQIYQgEgooA1BszwsoJvoM+WoBpBJjAw00PnfvZ6xgtyUX/gcaMsZBYSHyC5NPzgydGsIYQ1QvGeUHwAP0GvQn60FYBgADpAQUOk4z7wS+C2oIjAlAAEoOpBgH2BhrCnKM0QEyjAG4mgNYkoQCcJAGOAcMAGgMiAV65gAeAqgIpAAGANADWAA6Aq4HngAaAIZCAT4DKDABIuYCkAOUCDLMAZYwAfQqBBzEDBYA+DhuSwLDsgKAa2ajBd5ZAo8CSjYBTiYEBk9IUgOwcuIA3ABMBhTgSAEWrEvMG+REAeBwLADIAPwABjYHBkIBzgH0bgC4AWALMgmjtLYBTuoqAIQAFmwB2AKKAN4ANgCA8gFUAE4FWvoF1AJQSgESMhksWGIBvAMgATQBDgB6BsyOpsoIIARuB9QCEBwV4gLvLwe2AgMi4BPOQsYCvd9WADIXUu5eZwqoCqdeaAC0YTQHMnM9UQAPH6k+yAdy/BZIiQImSwBQ5gBQQzSaNTFWSTYBpwGqKQK38AFtqwBI/wK37gK3rQK3sAK6280C0gK33AK3zxAAUEIAUD9SklKDArekArw5AEQAzAHCO147WTteO1k7XjtZO147WTteO1kDmChYI03AVU0oJqkKbV9GYewMpw3VRMk6ShPcYFJgMxPJLbgUwhXPJVcZPhq9JwYl5VUKDwUt1GYxCC00dhe9AEApaYNCY4ceMQpMHOhTklT5LRwAskujM7ANrRsWREEFSHXuYisWDwojAmSCAmJDXE6wXDchAqH4AmiZAmYKAp+FOBwMAmY8AmYnBG8EgAN/FAN+kzkHOXgYOYM6JCQCbB4CMjc4CwJtyAJtr/CLADRoRiwBaADfAOIASwYHmQyOAP8MwwAOtgJ3MAJ2o0ACeUxEAni7Hl3cRa9G9AJ8QAJ6yQJ9CgJ88UgBSH5kJQAsFklZSlwWGErNAtECAtDNSygDiFADh+dExpEzAvKiXQQDA69Lz0wuJgTQTU1NsAKLQAKK2cIcCB5EaAa4Ao44Ao5dQZiCAo7aAo5deVG1UzYLUtVUhgKT/AKTDQDqAB1VH1WwVdEHLBwplocy4nhnRTw6ApegAu+zWCKpAFomApaQApZ9nQCqWa1aCoJOADwClrYClk9cRVzSApnMApllXMtdCBoCnJw5wzqeApwXAp+cAp65iwAeEDIrEAKd8gKekwC2PmE1YfACntQCoG8BqgKeoCACnk+mY8lkKCYsAiewAiZ/AqD8AqBN2AKmMAKlzwKoAAB+AqfzaH1osgAESmodatICrOQCrK8CrWgCrQMCVx4CVd0CseLYAx9PbJgCsr4OArLpGGzhbWRtSWADJc4Ctl08QG6RAylGArhfArlIFgK5K3hwN3DiAr0aAy2zAzISAr6JcgMDM3ICvhtzI3NQAsPMAsMFc4N0TDZGdOEDPKgDPJsDPcACxX0CxkgCxhGKAshqUgLIRQLJUALJLwJkngLd03h6YniveSZL0QMYpGcDAmH1GfSVJXsMXpNevBICz2wCz20wTFTT9BSgAMeuAs90ASrrA04TfkwGAtwoAtuLAtJQA1JdA1NgAQIDVY2AikABzBfuYUZ2AILPg44C2sgC2d+EEYRKpz0DhqYAMANkD4ZyWvoAVgLfZgLeuXR4AuIw7RUB8zEoAfScAfLTiALr9ALpcXoAAur6AurlAPpIAboC7ooC652Wq5cEAu5AA4XhmHpw4XGiAvMEAGoDjheZlAL3FAORbwOSiAL3mQL52gL4Z5odmqy8OJsfA52EAv77ARwAOp8dn7QDBY4DpmsDptoA0sYDBmuhiaIGCgMMSgFgASACtgNGAJwEgLpoBgC8BGzAEowcggCEDC6kdjoAJAM0C5IKRoABZCgiAIzw3AYBLACkfng9ogigkgNmWAN6AEQCvrkEVqTGAwCsBRbAA+4iQkMCHR072jI2PTbUNsk2RjY5NvA23TZKNiU3EDcZN5I+RTxDRTBCJkK5VBYKFhZfwQCWygU3AJBRHpu+OytgNxa61A40GMsYjsn7BVwFXQVcBV0FaAVdBVwFXQVcBV0FXAVdBVwFXUsaCNyKAK4AAQUHBwKU7oICoW1e7jAEzgPxA+YDwgCkBFDAwADABKzAAOxFLhitA1UFTDeyPkM+bj51QkRCuwTQWWQ8X+0AWBYzsACNA8xwzAGm7EZ/QisoCTAbLDs6fnLfb8H2GccsbgFw13M1HAVkBW/Jxsm9CNRO8E8FDD0FBQw9FkcClOYCoMFegpDfADgcMiA2AJQACB8AsigKAIzIEAJKeBIApY5yPZQIAKQiHb4fvj5BKSRPQrZCOz0oXyxgOywfKAnGbgMClQaCAkILXgdeCD9IIGUgQj5fPoY+dT52Ao5CM0dAX9BTVG9SDzFwWTQAbxBzJF/lOEIQQglCCkKJIAls5AcClQICoKPMODEFxhi6KSAbiyfIRrMjtCgdWCAkPlFBIitCsEJRzAbMAV/OEyQzDg0OAQQEJ36i328/Mk9AybDJsQlq3tDRApUKAkFzXf1d/j9uALYP6hCoFgCTGD8kPsFKQiobrm0+zj0KSD8kPnVCRBwMDyJRTHFgMTJa5rwXQiQ2YfI/JD7BMEJEHGINTw4TOFlIRzwJO0icMQpyPyQ+wzJCRBv6DVgnKB01NgUKj2bwYzMqCoBkznBgEF+zYDIocwRIX+NgHj4HICNfh2C4CwdwFWpTG/lgUhYGAwRfv2Ts8mAaXzVgml/XYIJfuWC4HI1gUF9pYJZgMR6ilQHMAOwLAlDRefC0in4AXAEJA6PjCwc0IamOANMMCAECRQDFNRTZBgd+CwQlRA+r6+gLBDEFBnwUBXgKATIArwAGRAAHA3cDdAN2A3kDdwN9A3oDdQN7A30DfAN4A3oDfQAYEAAlAtYASwMAUAFsAHcKAHcAmgB3AHUAdQB2AHVu8UgAygDAAHcAdQB1AHYAdQALCgB3AAsAmgB3AAsCOwB3AAtu8UgAygDAAHgKAJoAdwB3AHUAdQB2AHUAeAB1AHUAdgB1bvFIAMoAwAALCgCaAHcACwB3AAsCOwB3AAtu8UgAygDAAH4ACwGgALcBpwC6AahdAu0COwLtbvFIAMoAwAALCgCaAu0ACwLtAAsCOwLtAAtu8UgAygDAA24ACwNvAAu0VsQAAzsAABCkjUIpAAsAUIusOggWcgMeBxVsGwL67U/2HlzmWOEeOgALASvuAAseAfpKUpnpGgYJDCIZM6YyARUE9ThqAD5iXQgnAJYJPnOzw0ZAEZxEKsIAkA4DhAHnTAIDxxUDK0lxCQlPYgIvIQVYJQBVqE1GakUAKGYiDToSBA1EtAYAXQJYAIF8GgMHRyAAIAjOe9YncekRAA0KACUrjwE7Ayc6AAYWAqaiKG4McEcqANoN3+Mg9TwCBhIkuCny+JwUQ29L008JluRxu3K+oAdqiHOqFH0AG5SUIfUJ5SxCGfxdipRzqTmT4V5Zb+r1Uo4Vm+NqSSEl2mNvR2JhIa8SpYO6ntdwFXHCWTCK8f2+Hxo7uiG3drDycAuKIMP5bhi06ACnqArH1rz4Rqg//lm6SgJGEVbF9xJHISaR6HxqxSnkw6shDnelHKNEfGUXSJRJ1GcsmtJw25xrZMDK9gXSm1/YMkdX4/6NKYOdtk/NQ3/NnDASjTc3fPjIjW/5sVfVObX2oTDWkr1dF9f3kxBsD3/3aQO8hPfRz+e0uEiJqt1161griu7gz8hDDwtpy+F+BWtefnKHZPAxcZoWbnznhJpy0e842j36bcNzGnIEusgGX0a8ZxsnjcSsPDZ09yZ36fCQbriHeQ72JRMILNl6ePPf2HWoVwgWAm1fb3V2sAY0+B6rAXqSwPBgseVmoqsBTSrm91+XasMYYySI8eeRxH3ZvHkMz3BQ5aJ3iUVbYPNM3/7emRtjlsMgv/9VyTsyt/mK+8fgWeT6SoFaclXqn42dAIsvAarF5vNNWHzKSkKQ/8Hfk5ZWK7r9yliOsooyBjRhfkHP4Q2DkWXQi6FG/9r/IwbmkV5T7JSopHKn1pJwm9tb5Ot0oyN1Z2mPpKXHTxx2nlK08fKk1hEYA8WgVVWL5lgx0iTv+KdojJeU23ZDjmiubXOxVXJKKi2Wjuh2HLZOFLiSC7Tls5SMh4f+Pj6xUSrNjFqLGehRNB8lC0QSLNmkJJx/wSG3MnjE9T1CkPwJI0wH2lfzwETIiVqUxg0dfu5q39Gt+hwdcxkhhNvQ4TyrBceof3Mhs/IxFci1HmHr4FMZgXEEczPiGCx0HRwzAqDq2j9AVm1kwN0mRVLWLylgtoPNapF5cY4Y1wJh/e0BBwZj44YgZrDNqvD/9Hv7GFYdUQeDJuQ3EWI4HaKqavU1XjC/n41kT4L79kqGq0kLhdTZvgP3TA3fS0ozVz+5piZsoOtIvBUFoMKbNcmBL6YxxaUAusHB38XrS8dQMnQwJfUUkpRoGr5AUeWicvBTzyK9g77+yCkf5PAysL7r/JjcZgrbvRpMW9iyaxZvKO6ceZN2EwIxKwVFPuvFuiEPGCoagbMo+SpydLrXqBzNCDGFCrO/rkcwa2xhokQZ5CdZ0AsU3JfSqJ6n5I14YA+P/uAgfhPU84Tlw7cEFfp7AEE8ey4sP12PTt4Cods1GRgDOB5xvyiR5m+Bx8O5nBCNctU8BevfV5A08x6RHd5jcwPTMDSZJOedIZ1cGQ704lxbAzqZOP05ZxaOghzSdvFBHYqomATARyAADK4elP8Ly3IrUZKfWh23Xy20uBUmLS4Pfagu9+oyVa2iPgqRP3F2CTUsvJ7+RYnN8fFZbU/HVvxvcFFDKkiTqV5UBZ3Gz54JAKByi9hkKMZJvuGgcSYXFmw08UyoQyVdfTD1/dMkCHXcTGAKeROgArsvmRrQTLUOXioOHGK2QkjHuoYFgXciZoTJd6Fs5q1QX1G+p/e26hYsEf7QZD1nnIyl/SFkNtYYmmBhpBrxl9WbY0YpHWRuw2Ll/tj9mD8P4snVzJl4F9J+1arVeTb9E5r2ILH04qStjxQNwn3m4YNqxmaNbLAqW2TN6LidwuJRqS+NXbtqxoeDXpxeGWmxzSkWxjkyCkX4NQRme6q5SAcC+M7+9ETfA/EwrzQajKakCwYyeunP6ZFlxU2oMEn1Pz31zeStW74G406ZJFCl1wAXIoUKkWotYEpOuXB1uVNxJ63dpJEqfxBeptwIHNrPz8BllZoIcBoXwgfJ+8VAUnVPvRvexnw0Ma/WiGYuJO5y8QTvEYBigFmhUxY5RqzE8OcywN/8m4UYrlaniJO75XQ6KSo9+tWHlu+hMi0UVdiKQp7NelnoZUzNaIyBPVeOwK6GNp+FfHuPOoyhaWuNvTYFkvxscMQWDh+zeFCFkgwbXftiV23ywJ4+uwRqmg9k3KzwIQpzppt8DBBOMbrqwQM5Gb05sEwdKzMiAqOloaA/lr0KA+1pr0/+HiWoiIjHA/wir2nIuS3PeU/ji3O6ZwoxcR1SZ9FhtLC5S0FIzFhbBWcGVP/KpxOPSiUoAdWUpqKH++6Scz507iCcxYI6rdMBICPJZea7OcmeFw5mObJSiqpjg2UoWNIs+cFhyDSt6geV5qgi3FunmwwDoGSMgerFOZGX1m0dMCYo5XOruxO063dwENK9DbnVM9wYFREzh4vyU1WYYJ/LRRp6oxgjqP/X5a8/4Af6p6NWkQferzBmXme0zY/4nwMJm/wd1tIqSwGz+E3xPEAOoZlJit3XddD7/BT1pllzOx+8bmQtANQ/S6fZexc6qi3W+Q2xcmXTUhuS5mpHQRvcxZUN0S5+PL9lXWUAaRZhEH8hTdAcuNMMCuVNKTEGtSUKNi3O6KhSaTzck8csZ2vWRZ+d7mW8c4IKwXIYd25S/zIftPkwPzufjEvOHWVD1m+FjpDVUTV0DGDuHj6QnaEwLu/dEgdLQOg9E1Sro9XHJ8ykLAwtPu+pxqKDuFexqON1sKQm7rwbE1E68UCfA/erovrTCG+DBSNg0l4goDQvZN6uNlbyLpcZAwj2UclycvLpIZMgv4yRlpb3YuMftozorbcGVHt/VeDV3+Fdf1TP0iuaCsPi2G4XeGhsyF1ubVDxkoJhmniQ0/jSg/eYML9KLfnCFgISWkp91eauR3IQvED0nAPXK+6hPCYs+n3+hCZbiskmVMG2da+0EsZPonUeIY8EbfusQXjsK/eFDaosbPjEfQS0RKG7yj5GG69M7MeO1HmiUYocgygJHL6M1qzUDDwUSmr99V7Sdr2F3JjQAJY+F0yH33Iv3+C9M38eML7gTgmNu/r2bUMiPvpYbZ6v1/IaESirBHNa7mPKn4dEmYg7v/+HQgPN1G79jBQ1+soydfDC2r+h2Bl/KIc5KjMK7OH6nb1jLsNf0EHVe2KBiE51ox636uyG6Lho0t3J34L5QY/ilE3mikaF4HKXG1mG1rCevT1Vv6GavltxoQe/bMrpZvRggnBxSEPEeEzkEdOxTnPXHVjUYdw8JYvjB/o7Eegc3Ma+NUxLLnsK0kJlinPmUHzHGtrk5+CAbVzFOBqpyy3QVUnzTDfC/0XD94/okH+OB+i7g9lolhWIjSnfIb+Eq43ZXOWmwvjyV/qqD+t0e+7mTEM74qP/Ozt8nmC7mRpyu63OB4KnUzFc074SqoyPUAgM+/TJGFo6T44EHnQU4X4z6qannVqgw/U7zCpwcmXV1AubIrvOmkKHazJAR55ePjp5tLBsN8vAqs3NAHdcEHOR2xQ0lsNAFzSUuxFQCFYvXLZJdOj9p4fNq6p0HBGUik2YzaI4xySy91KzhQ0+q1hjxvImRwPRf76tChlRkhRCi74NXZ9qUNeIwP+s5p+3m5nwPdNOHgSLD79n7O9m1n1uDHiMntq4nkYwV5OZ1ENbXxFd4PgrlvavZsyUO4MqYlqqn1O8W/I1dEZq5dXhrbETLaZIbC2Kj/Aa/QM+fqUOHdf0tXAQ1huZ3cmWECWSXy/43j35+Mvq9xws7JKseriZ1pEWKc8qlzNrGPUGcVgOa9cPJYIJsGnJTAUsEcDOEVULO5x0rXBijc1lgXEzQQKhROf8zIV82w8eswc78YX11KYLWQRcgHNJElBxfXr72lS2RBSl07qTKorO2uUDZr3sFhYsvnhLZn0A94KRzJ/7DEGIAhW5ZWFpL8gEwu1aLA9MuWZzNwl8Oze9Y+bX+v9gywRVnoB5I/8kXTXU3141yRLYrIOOz6SOnyHNy4SieqzkBXharjfjqq1q6tklaEbA8Qfm2DaIPs7OTq/nvJBjKfO2H9bH2cCMh1+5gspfycu8f/cuuRmtDjyqZ7uCIMyjdV3a+p3fqmXsRx4C8lujezIFHnQiVTXLXuI1XrwN3+siYYj2HHTvESUx8DlOTXpak9qFRK+L3mgJ1WsD7F4cu1aJoFoYQnu+wGDMOjJM3kiBQWHCcvhJ/HRdxodOQp45YZaOTA22Nb4XKCVxqkbwMYFhzYQYIAnCW8FW14uf98jhUG2zrKhQQ0q0CEq0t5nXyvUyvR8DvD69LU+g3i+HFWQMQ8PqZuHD+sNKAV0+M6EJC0szq7rEr7B5bQ8BcNHzvDMc9eqB5ZCQdTf80Obn4uzjwpYU7SISdtV0QGa9D3Wrh2BDQtpBKxaNFV+/Cy2P/Sv+8s7Ud0Fd74X4+o/TNztWgETUapy+majNQ68Lq3ee0ZO48VEbTZYiH1Co4OlfWef82RWeyUXo7woM03PyapGfikTnQinoNq5z5veLpeMV3HCAMTaZmA1oGLAn7XS3XYsz+XK7VMQsc4XKrmDXOLU/pSXVNUq8dIqTba///3x6LiLS6xs1xuCAYSfcQ3+rQgmu7uvf3THKt5Ooo97TqcbRqxx7EASizaQCBQllG/rYxVapMLgtLbZS64w1MDBMXX+PQpBKNwqUKOf2DDRDUXQf9EhOS0Qj4nTmlA8dzSLz/G1d+Ud8MTy/6ghhdiLpeerGY/UlDOfiuqFsMUU5/UYlP+BAmgRLuNpvrUaLlVkrqDievNVEAwF+4CoM1MZTmjxjJMsKJq+u8Zd7tNCUFy6LiyYXRJQ4VyvEQFFaCGKsxIwQkk7EzZ6LTJq2hUuPhvAW+gQnSG6J+MszC+7QCRHcnqDdyNRJ6T9xyS87A6MDutbzKGvGktpbXqtzWtXb9HsfK2cBMomjN9a4y+TaJLnXxAeX/HWzmf4cR4vALt/P4w4qgKY04ml4ZdLOinFYS6cup3G/1ie4+t1eOnpBNlqGqs75ilzkT4+DsZQxNvaSKJ//6zIbbk/M7LOhFmRc/1R+kBtz7JFGdZm/COotIdvQoXpTqP/1uqEUmCb/QWoGLMwO5ANcHzxdY48IGP5+J+zKOTBFZ4Pid+GTM+Wq12MV/H86xEJptBa6T+p3kgpwLedManBHC2GgNrFpoN2xnrMz9WFWX/8/ygSBkavq2Uv7FdCsLEYLu9LLIvAU0bNRDtzYl+/vXmjpIvuJFYjmI0im6QEYqnIeMsNjXG4vIutIGHijeAG/9EDBozKV5cldkHbLxHh25vT+ZEzbhXlqvpzKJwcEgfNwLAKFeo0/pvEE10XDB+EXRTXtSzJozQKFFAJhMxYkVaCW+E9AL7tMeU8acxidHqzb6lX4691UsDpy/LLRmT+epgW56+5Cw8tB4kMUv6s9lh3eRKbyGs+H/4mQMaYzPTf2OOdokEn+zzgvoD3FqNKk8QqGAXVsqcGdXrT62fSPkR2vROFi68A6se86UxRUk4cajfPyCC4G5wDhD+zNq4jodQ4u4n/m37Lr36n4LIAAsVr02dFi9AiwA81MYs2rm4eDlDNmdMRvEKRHfBwW5DdMNp0jPFZMeARqF/wL4XBfd+EMLBfMzpH5GH6NaW+1vrvMdg+VxDzatk3MXgO3ro3P/DpcC6+Mo4MySJhKJhSR01SGGGp5hPWmrrUgrv3lDnP+HhcI3nt3YqBoVAVTBAQT5iuhTg8nvPtd8ZeYj6w1x6RqGUBrSku7+N1+BaasZvjTk64RoIDlL8brpEcJx3OmY7jLoZsswdtmhfC/G21llXhITOwmvRDDeTTPbyASOa16cF5/A1fZAidJpqju3wYAy9avPR1ya6eNp9K8XYrrtuxlqi+bDKwlfrYdR0RRiKRVTLOH85+ZY7XSmzRpfZBJjaTa81VDcJHpZnZnSQLASGYW9l51ZV/h7eVzTi3Hv6hUsgc/51AqJRTkpbFVLXXszoBL8nBX0u/0jBLT8nH+fJePbrwURT58OY+UieRjd1vs04w0VG5VN2U6MoGZkQzKN/ptz0Q366dxoTGmj7i1NQGHi9GgnquXFYdrCfZBmeb7s0T6yrdlZH5cZuwHFyIJ/kAtGsTg0xH5taAAq44BAk1CPk9KVVbqQzrCUiFdF/6gtlPQ8bHHc1G1W92MXGZ5HEHftyLYs8mbD/9xYRUWkHmlM0zC2ilJlnNgV4bfALpQghxOUoZL7VTqtCHIaQSXm+YUMnpkXybnV+A6xlm2CVy8fn0Xlm2XRa0+zzOa21JWWmixfiPMSCZ7qA4rS93VN3pkpF1s5TonQjisHf7iU9ZGvUPOAKZcR1pbeVf/Ul7OhepGCaId9wOtqo7pJ7yLcBZ0pFkOF28y4zEI/kcUNmutBHaQpBdNM8vjCS6HZRokkeo88TBAjGyG7SR+6vUgTcyK9Imalj0kuxz0wmK+byQU11AiJFk/ya5dNduRClcnU64yGu/ieWSeOos1t3ep+RPIWQ2pyTYVbZltTbsb7NiwSi3AV+8KLWk7LxCnfZUetEM8ThnsSoGH38/nyAwFguJp8FjvlHtcWZuU4hPva0rHfr0UhOOJ/F6vS62FW7KzkmRll2HEc7oUq4fyi5T70Vl7YVIfsPHUCdHesf9Lk7WNVWO75JDkYbMI8TOW8JKVtLY9d6UJRITO8oKo0xS+o99Yy04iniGHAaGj88kEWgwv0OrHdY/nr76DOGNS59hXCGXzTKUvDl9iKpLSWYN1lxIeyywdNpTkhay74w2jFT6NS8qkjo5CxA1yfSYwp6AJIZNKIeEK5PJAW7ORgWgwp0VgzYpqovMrWxbu+DGZ6Lhie1RAqpzm8VUzKJOH3mCzWuTOLsN3VT/dv2eeYe9UjbR8YTBsLz7q60VN1sU51k+um1f8JxD5pPhbhSC8rRaB454tmh6YUWrJI3+GWY0qeWioj/tbkYITOkJaeuGt4JrJvHA+l0Gu7kY7XOaa05alMnRWVCXqFgLIwSY4uF59Ue5SU4QKuc/HamDxbr0x6csCetXGoP7Qn1Bk/J9DsynO/UD6iZ1Hyrz+jit0hDCwi/E9OjgKTbB3ZQKQ/0ZOvevfNHG0NK4Aj3Cp7NpRk07RT1i/S0EL93Ag8GRgKI9CfpajKyK6+Jj/PI1KO5/85VAwz2AwzP8FTBb075IxCXv6T9RVvWT2tUaqxDS92zrGUbWzUYk9mSs82pECH+fkqsDt93VW++4YsR/dHCYcQSYTO/KaBMDj9LSD/J/+z20Kq8XvZUAIHtm9hRPP3ItbuAu2Hm5lkPs92pd7kCxgRs0xOVBnZ13ccdA0aunrwv9SdqElJRC3g+oCu+nXyCgmXUs9yMjTMAIHfxZV+aPKcZeUBWt057Xo85Ks1Ir5gzEHCWqZEhrLZMuF11ziGtFQUds/EESajhagzcKsxamcSZxGth4UII+adPhQkUnx2WyN+4YWR+r3f8MnkyGFuR4zjzxJS8WsQYR5PTyRaD9ixa6Mh741nBHbzfjXHskGDq179xaRNrCIB1z1xRfWfjqw2pHc1zk9xlPpL8sQWAIuETZZhbnmL54rceXVNRvUiKrrqIkeogsl0XXb17ylNb0f4GA9Wd44vffEG8FSZGHEL2fbaTGRcSiCeA8PmA/f6Hz8HCS76fXUHwgwkzSwlI71ekZ7Fapmlk/KC+Hs8hUcw3N2LN5LhkVYyizYFl/uPeVP5lsoJHhhfWvvSWruCUW1ZcJOeuTbrDgywJ/qG07gZJplnTvLcYdNaH0KMYOYMGX+rB4NGPFmQsNaIwlWrfCezxre8zXBrsMT+edVLbLqN1BqB76JH4BvZTqUIMfGwPGEn+EnmTV86fPBaYbFL3DFEhjB45CewkXEAtJxk4/Ms2pPXnaRqdky0HOYdcUcE2zcXq4vaIvW2/v0nHFJH2XXe22ueDmq/18XGtELSq85j9X8q0tcNSSKJIX8FTuJF/Pf8j5PhqG2u+osvsLxYrvvfeVJL+4tkcXcr9JV7v0ERmj/X6fM3NC4j6dS1+9Umr2oPavqiAydTZPLMNRGY23LO9zAVDly7jD+70G5TPPLdhRIl4WxcYjLnM+SNcJ26FOrkrISUtPObIz5Zb3AG612krnpy15RMW+1cQjlnWFI6538qky9axd2oJmHIHP08KyP0ubGO+TQNOYuv2uh17yCIvR8VcStw7o1g0NM60sk+8Tq7YfIBJrtp53GkvzXH7OA0p8/n/u1satf/VJhtR1l8Wa6Gmaug7haSpaCaYQax6ta0mkutlb+eAOSG1aobM81D9A4iS1RRlzBBoVX6tU1S6WE2N9ORY6DfeLRC4l9Rvr5h95XDWB2mR1d4WFudpsgVYwiTwT31ljskD8ZyDOlm5DkGh9N/UB/0AI5Xvb8ZBmai2hQ4BWMqFwYnzxwB26YHSOv9WgY3JXnvoN+2R4rqGVh/LLDMtpFP+SpMGJNWvbIl5SOodbCczW2RKleksPoUeGEzrjtKHVdtZA+kfqO+rVx/iclCqwoopepvJpSTDjT+b9GWylGRF8EDbGlw6eUzmJM95Ovoz+kwLX3c2fTjFeYEsE7vUZm3mqdGJuKh2w9/QGSaqRHs99aScGOdDqkFcACoqdbBoQqqjamhH6Q9ng39JCg3lrGJwd50Qk9ovnqBTr8MME7Ps2wiVfygUmPoUBJJfJWX5Nda0nuncbFkA=="))}let eK=getData(),ej=new Set(read_member_array(eK)),eH=new Set(read_member_array(eK)),eq=read_mapped_map(eK),eV=read_emoji_trie(eK),eG=45,e$=95;function explode_cp(O){return(0,eN.XL)(O)}function filter_fe0f(O){return O.filter(O=>65039!=O)}function ens_normalize_post_check(O){for(let U of O.split(".")){let O=explode_cp(U);try{for(let U=O.lastIndexOf(e$)-1;U>=0;U--)if(O[U]!==e$)throw Error("underscore only allowed at start");if(O.length>=4&&O.every(O=>O<128)&&O[2]===eG&&O[3]===eG)throw Error("invalid label extension")}catch(O){throw Error(`Invalid label "${U}": ${O.message}`)}}return O}function ens_normalize(O){return ens_normalize_post_check(normalize(O,filter_fe0f))}function normalize(O,U){let $=explode_cp(O).reverse(),J=[];for(;$.length;){let O=consume_emoji_reversed($);if(O){J.push(...U(O));continue}let en=$.pop();if(ej.has(en)){J.push(en);continue}if(eH.has(en))continue;let es=eq[en];if(es){J.push(...es);continue}throw Error(`Disallowed codepoint: 0x${en.toString(16).toUpperCase()}`)}return ens_normalize_post_check(nfc(String.fromCodePoint(...J)))}function nfc(O){return O.normalize("NFC")}function consume_emoji_reversed(O,U){var $;let J,en;let es=eV,eo=[],ea=O.length;for(U&&(U.length=0);ea;){let eu=O[--ea];if(!(es=null===($=es.branches.find(O=>O.set.has(eu)))||void 0===$?void 0:$.node))break;if(es.save)en=eu;else if(es.check&&eu===en)break;eo.push(eu),es.fe0f&&(eo.push(65039),ea>0&&65039==O[ea-1]&&ea--),es.valid&&(J=eo.slice(),2==es.valid&&J.splice(1,1),U&&U.push(...O.slice(ea).reverse()),O.length=ea)}return J}let eW=new en.Yd(ev),eY=new Uint8Array(32);function checkComponent(O){if(0===O.length)throw Error("invalid ENS name; empty component");return O}function ensNameSplit(O){let U=(0,eN.Y0)(ens_normalize(O)),$=[];if(0===O.length)return $;let J=0;for(let O=0;O=U.length)throw Error("invalid ENS name; empty component");return $.push(checkComponent(U.slice(J))),$}function namehash(O){"string"!=typeof O&&eW.throwArgumentError("invalid ENS name; not a string","name",O);let U=eY,$=ensNameSplit(O);for(;$.length;)U=(0,eg.w)((0,eu.zo)([U,(0,eg.w)($.pop())]));return(0,eu.Dv)(U)}function dnsEncode(O){return(0,eu.Dv)((0,eu.zo)(ensNameSplit(O).map(O=>{if(O.length>63)throw Error("invalid DNS encoded entry; length exceeds 63 bytes");let U=new Uint8Array(O.length+1);return U.set(O,1),U[0]=U.length-1,U})))+"00"}eY.fill(0);let eJ="networks/5.7.1",eQ=new en.Yd(eJ);function isRenetworkable(O){return O&&"function"==typeof O.renetwork}function ethDefaultProvider(O){let func=function(U,$){null==$&&($={});let J=[];if(U.InfuraProvider&&"-"!==$.infura)try{J.push(new U.InfuraProvider(O,$.infura))}catch(O){}if(U.EtherscanProvider&&"-"!==$.etherscan)try{J.push(new U.EtherscanProvider(O,$.etherscan))}catch(O){}if(U.AlchemyProvider&&"-"!==$.alchemy)try{J.push(new U.AlchemyProvider(O,$.alchemy))}catch(O){}if(U.PocketProvider&&"-"!==$.pocket){let en=["goerli","ropsten","rinkeby","sepolia"];try{let es=new U.PocketProvider(O,$.pocket);es.network&&-1===en.indexOf(es.network.name)&&J.push(es)}catch(O){}}if(U.CloudflareProvider&&"-"!==$.cloudflare)try{J.push(new U.CloudflareProvider(O))}catch(O){}if(U.AnkrProvider&&"-"!==$.ankr)try{let en=["ropsten"],es=new U.AnkrProvider(O,$.ankr);es.network&&-1===en.indexOf(es.network.name)&&J.push(es)}catch(O){}if(0===J.length)return null;if(U.FallbackProvider){let en=1;return null!=$.quorum?en=$.quorum:"homestead"===O&&(en=2),new U.FallbackProvider(J,en)}return J[0]};return func.renetwork=function(O){return ethDefaultProvider(O)},func}function etcDefaultProvider(O,U){let func=function($,J){return $.JsonRpcProvider?new $.JsonRpcProvider(O,U):null};return func.renetwork=function(U){return etcDefaultProvider(O,U)},func}let eZ={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:ethDefaultProvider("homestead")},eX={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:ethDefaultProvider("ropsten")},e0={chainId:63,name:"classicMordor",_defaultProvider:etcDefaultProvider("https://www.ethercluster.com/mordor","classicMordor")},e1={unspecified:{chainId:0,name:"unspecified"},homestead:eZ,mainnet:eZ,morden:{chainId:2,name:"morden"},ropsten:eX,testnet:eX,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:ethDefaultProvider("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:ethDefaultProvider("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:ethDefaultProvider("goerli")},kintsugi:{chainId:1337702,name:"kintsugi"},sepolia:{chainId:11155111,name:"sepolia",_defaultProvider:ethDefaultProvider("sepolia")},classic:{chainId:61,name:"classic",_defaultProvider:etcDefaultProvider("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor:e0,classicTestnet:e0,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:etcDefaultProvider("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic",_defaultProvider:ethDefaultProvider("matic")},maticmum:{chainId:80001,name:"maticmum"},optimism:{chainId:10,name:"optimism",_defaultProvider:ethDefaultProvider("optimism")},"optimism-kovan":{chainId:69,name:"optimism-kovan"},"optimism-goerli":{chainId:420,name:"optimism-goerli"},arbitrum:{chainId:42161,name:"arbitrum"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},"arbitrum-goerli":{chainId:421613,name:"arbitrum-goerli"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};function getNetwork(O){if(null==O)return null;if("number"==typeof O){for(let U in e1){let $=e1[U];if($.chainId===O)return{name:$.name,chainId:$.chainId,ensAddress:$.ensAddress||null,_defaultProvider:$._defaultProvider||null}}return{chainId:O,name:"unknown"}}if("string"==typeof O){let U=e1[O];return null==U?null:{name:U.name,chainId:U.chainId,ensAddress:U.ensAddress,_defaultProvider:U._defaultProvider||null}}let U=e1[O.name];if(!U)return"number"!=typeof O.chainId&&eQ.throwArgumentError("invalid network chainId","network",O),O;0!==O.chainId&&O.chainId!==U.chainId&&eQ.throwArgumentError("network chainId mismatch","network",O);let $=O._defaultProvider||null;return null==$&&U._defaultProvider&&($=isRenetworkable(U._defaultProvider)?U._defaultProvider.renetwork(O):U._defaultProvider),{name:O.name,chainId:U.chainId,ensAddress:O.ensAddress||U.ensAddress||null,_defaultProvider:$}}var e3=$(5336),e6=$.n(e3);let e5="sha2/5.7.0";function sha256(O){return"0x"+e6().sha256().update((0,eu.lE)(O)).digest("hex")}new en.Yd(e5);var e9=$(6942),e7=$.n(e9),te=$(5572);let tt=new en.Yd(es);let Formatter=class Formatter{constructor(){this.formats=this.getDefaultFormats()}getDefaultFormats(){let O={},U=this.address.bind(this),$=this.bigNumber.bind(this),en=this.blockTag.bind(this),es=this.data.bind(this),eo=this.hash.bind(this),ea=this.hex.bind(this),eu=this.number.bind(this),ef=this.type.bind(this),strictData=O=>this.data(O,!0);return O.transaction={hash:eo,type:ef,accessList:Formatter.allowNull(this.accessList.bind(this),null),blockHash:Formatter.allowNull(eo,null),blockNumber:Formatter.allowNull(eu,null),transactionIndex:Formatter.allowNull(eu,null),confirmations:Formatter.allowNull(eu,null),from:U,gasPrice:Formatter.allowNull($),maxPriorityFeePerGas:Formatter.allowNull($),maxFeePerGas:Formatter.allowNull($),gasLimit:$,to:Formatter.allowNull(U,null),value:$,nonce:eu,data:es,r:Formatter.allowNull(this.uint256),s:Formatter.allowNull(this.uint256),v:Formatter.allowNull(eu),creates:Formatter.allowNull(U,null),raw:Formatter.allowNull(es)},O.transactionRequest={from:Formatter.allowNull(U),nonce:Formatter.allowNull(eu),gasLimit:Formatter.allowNull($),gasPrice:Formatter.allowNull($),maxPriorityFeePerGas:Formatter.allowNull($),maxFeePerGas:Formatter.allowNull($),to:Formatter.allowNull(U),value:Formatter.allowNull($),data:Formatter.allowNull(strictData),type:Formatter.allowNull(eu),accessList:Formatter.allowNull(this.accessList.bind(this),null)},O.receiptLog={transactionIndex:eu,blockNumber:eu,transactionHash:eo,address:U,topics:Formatter.arrayOf(eo),data:es,logIndex:eu,blockHash:eo},O.receipt={to:Formatter.allowNull(this.address,null),from:Formatter.allowNull(this.address,null),contractAddress:Formatter.allowNull(U,null),transactionIndex:eu,root:Formatter.allowNull(ea),gasUsed:$,logsBloom:Formatter.allowNull(es),blockHash:eo,transactionHash:eo,logs:Formatter.arrayOf(this.receiptLog.bind(this)),blockNumber:eu,confirmations:Formatter.allowNull(eu,null),cumulativeGasUsed:$,effectiveGasPrice:Formatter.allowNull($),status:Formatter.allowNull(eu),type:ef},O.block={hash:Formatter.allowNull(eo),parentHash:eo,number:eu,timestamp:eu,nonce:Formatter.allowNull(ea),difficulty:this.difficulty.bind(this),gasLimit:$,gasUsed:$,miner:Formatter.allowNull(U),extraData:es,transactions:Formatter.allowNull(Formatter.arrayOf(eo)),baseFeePerGas:Formatter.allowNull($)},O.blockWithTransactions=(0,J.DC)(O.block),O.blockWithTransactions.transactions=Formatter.allowNull(Formatter.arrayOf(this.transactionResponse.bind(this))),O.filter={fromBlock:Formatter.allowNull(en,void 0),toBlock:Formatter.allowNull(en,void 0),blockHash:Formatter.allowNull(eo,void 0),address:Formatter.allowNull(U,void 0),topics:Formatter.allowNull(this.topics.bind(this),void 0)},O.filterLog={blockNumber:Formatter.allowNull(eu),blockHash:Formatter.allowNull(eo),transactionIndex:eu,removed:Formatter.allowNull(this.boolean.bind(this)),address:U,data:Formatter.allowFalsish(es,"0x"),topics:Formatter.arrayOf(eo),transactionHash:eo,logIndex:eu},O}accessList(O){return(0,eD.z7)(O||[])}number(O){return"0x"===O?0:ea.O$.from(O).toNumber()}type(O){return"0x"===O||null==O?0:ea.O$.from(O).toNumber()}bigNumber(O){return ea.O$.from(O)}boolean(O){if("boolean"==typeof O)return O;if("string"==typeof O){if("true"===(O=O.toLowerCase()))return!0;if("false"===O)return!1}throw Error("invalid boolean - "+O)}hex(O,U){return"string"==typeof O&&(U||"0x"===O.substring(0,2)||(O="0x"+O),(0,eu.A7)(O))?O.toLowerCase():tt.throwArgumentError("invalid hash","value",O)}data(O,U){let $=this.hex(O,U);if($.length%2!=0)throw Error("invalid data; odd-length - "+O);return $}address(O){return(0,ef.Kn)(O)}callAddress(O){if(!(0,eu.A7)(O,32))return null;let U=(0,ef.Kn)((0,eu.p3)(O,12));return U===te.d?null:U}contractAddress(O){return(0,ef.CR)(O)}blockTag(O){if(null==O)return"latest";if("earliest"===O)return"0x0";switch(O){case"earliest":return"0x0";case"latest":case"pending":case"safe":case"finalized":return O}if("number"==typeof O||(0,eu.A7)(O))return(0,eu.$P)(O);throw Error("invalid blockTag")}hash(O,U){let $=this.hex(O,U);return 32!==(0,eu.E1)($)?tt.throwArgumentError("invalid hash","value",O):$}difficulty(O){if(null==O)return null;let U=ea.O$.from(O);try{return U.toNumber()}catch(O){}return null}uint256(O){if(!(0,eu.A7)(O))throw Error("invalid uint256");return(0,eu.$m)(O,32)}_block(O,U){null!=O.author&&null==O.miner&&(O.miner=O.author);let $=null!=O._difficulty?O._difficulty:O.difficulty,J=Formatter.check(U,O);return J._difficulty=null==$?null:ea.O$.from($),J}block(O){return this._block(O,this.formats.block)}blockWithTransactions(O){return this._block(O,this.formats.blockWithTransactions)}transactionRequest(O){return Formatter.check(this.formats.transactionRequest,O)}transactionResponse(O){null!=O.gas&&null==O.gasLimit&&(O.gasLimit=O.gas),O.to&&ea.O$.from(O.to).isZero()&&(O.to="0x0000000000000000000000000000000000000000"),null!=O.input&&null==O.data&&(O.data=O.input),null==O.to&&null==O.creates&&(O.creates=this.contractAddress(O)),(1===O.type||2===O.type)&&null==O.accessList&&(O.accessList=[]);let U=Formatter.check(this.formats.transaction,O);if(null!=O.chainId){let $=O.chainId;(0,eu.A7)($)&&($=ea.O$.from($).toNumber()),U.chainId=$}else{let $=O.networkId;null==$&&null==U.v&&($=O.chainId),(0,eu.A7)($)&&($=ea.O$.from($).toNumber()),"number"!=typeof $&&null!=U.v&&(($=(U.v-35)/2)<0&&($=0),$=parseInt($)),"number"!=typeof $&&($=0),U.chainId=$}return U.blockHash&&"x"===U.blockHash.replace(/0/g,"")&&(U.blockHash=null),U}transaction(O){return(0,eD.Qc)(O)}receiptLog(O){return Formatter.check(this.formats.receiptLog,O)}receipt(O){let U=Formatter.check(this.formats.receipt,O);if(null!=U.root){if(U.root.length<=4){let O=ea.O$.from(U.root).toNumber();0===O||1===O?(null!=U.status&&U.status!==O&&tt.throwArgumentError("alt-root-status/status mismatch","value",{root:U.root,status:U.status}),U.status=O,delete U.root):tt.throwArgumentError("invalid alt-root-status","value.root",U.root)}else 66!==U.root.length&&tt.throwArgumentError("invalid root hash","value.root",U.root)}return null!=U.status&&(U.byzantium=!0),U}topics(O){return Array.isArray(O)?O.map(O=>this.topics(O)):null!=O?this.hash(O,!0):null}filter(O){return Formatter.check(this.formats.filter,O)}filterLog(O){return Formatter.check(this.formats.filterLog,O)}static check(O,U){let $={};for(let J in O)try{let en=O[J](U[J]);void 0!==en&&($[J]=en)}catch(O){throw O.checkKey=J,O.checkValue=U[J],O}return $}static allowNull(O,U){return function($){return null==$?U:O($)}}static allowFalsish(O,U){return function($){return $?O($):U}}static arrayOf(O){return function(U){if(!Array.isArray(U))throw Error("not an array");let $=[];return U.forEach(function(U){$.push(O(U))}),$}}};var base_provider_awaiter=function(O,U,$,J){function adopt(O){return O instanceof $?O:new $(function(U){U(O)})}return new($||($=Promise))(function($,en){function fulfilled(O){try{step(J.next(O))}catch(O){en(O)}}function rejected(O){try{step(J.throw(O))}catch(O){en(O)}}function step(O){O.done?$(O.value):adopt(O.value).then(fulfilled,rejected)}step((J=J.apply(O,U||[])).next())})};let tr=new en.Yd(es),ta=10;function checkTopic(O){return null==O?"null":(32!==(0,eu.E1)(O)&&tr.throwArgumentError("invalid topic","topic",O),O.toLowerCase())}function serializeTopics(O){for(O=O.slice();O.length>0&&null==O[O.length-1];)O.pop();return O.map(O=>{if(!Array.isArray(O))return checkTopic(O);{let U={};O.forEach(O=>{U[checkTopic(O)]=!0});let $=Object.keys(U);return $.sort(),$.join("|")}}).join("&")}function deserializeTopics(O){return""===O?[]:O.split(/&/g).map(O=>{if(""===O)return[];let U=O.split("|").map(O=>"null"===O?null:O);return 1===U.length?U[0]:U})}function getEventTag(O){if("string"==typeof O){if(O=O.toLowerCase(),32===(0,eu.E1)(O))return"tx:"+O;if(-1===O.indexOf(":"))return O}else if(Array.isArray(O))return"filter:*:"+serializeTopics(O);else if(eL.Sg.isForkEvent(O))throw tr.warn("not implemented"),Error("not implemented");else if(O&&"object"==typeof O)return"filter:"+(O.address||"*")+":"+serializeTopics(O.topics||[]);throw Error("invalid event - "+O)}function getTime(){return new Date().getTime()}function stall(O){return new Promise(U=>{setTimeout(U,O)})}let tu=["block","network","pending","poll"];let Event=class Event{constructor(O,U,$){(0,J.zG)(this,"tag",O),(0,J.zG)(this,"listener",U),(0,J.zG)(this,"once",$),this._lastBlockNumber=-2,this._inflight=!1}get event(){switch(this.type){case"tx":return this.hash;case"filter":return this.filter}return this.tag}get type(){return this.tag.split(":")[0]}get hash(){let O=this.tag.split(":");return"tx"!==O[0]?null:O[1]}get filter(){let O=this.tag.split(":");if("filter"!==O[0])return null;let U=O[1],$=deserializeTopics(O[2]),J={};return $.length>0&&(J.topics=$),U&&"*"!==U&&(J.address=U),J}pollable(){return this.tag.indexOf(":")>=0||tu.indexOf(this.tag)>=0}};let th={0:{symbol:"btc",p2pkh:0,p2sh:5,prefix:"bc"},2:{symbol:"ltc",p2pkh:48,p2sh:50,prefix:"ltc"},3:{symbol:"doge",p2pkh:30,p2sh:22},60:{symbol:"eth",ilk:"eth"},61:{symbol:"etc",ilk:"eth"},700:{symbol:"xdai",ilk:"eth"}};function bytes32ify(O){return(0,eu.$m)(ea.O$.from(O).toHexString(),32)}function base58Encode(O){return eU.encode((0,eu.zo)([O,(0,eu.p3)(sha256(sha256(O)),0,4)]))}let td=RegExp("^(ipfs)://(.*)$","i"),tf=[RegExp("^(https)://(.*)$","i"),RegExp("^(data):(.*)$","i"),td,RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];function _parseString(O,U){try{return(0,eN.ZN)(_parseBytes(O,U))}catch(O){}return null}function _parseBytes(O,U){if("0x"===O)return null;let $=ea.O$.from((0,eu.p3)(O,U,U+32)).toNumber(),J=ea.O$.from((0,eu.p3)(O,$,$+32)).toNumber();return(0,eu.p3)(O,$+32,$+32+J)}function getIpfsLink(O){return O.match(/^ipfs:\/\/ipfs\//i)?O=O.substring(12):O.match(/^ipfs:\/\//i)?O=O.substring(7):tr.throwArgumentError("unsupported IPFS format","link",O),`https://gateway.ipfs.io/ipfs/${O}`}function numPad(O){let U=(0,eu.lE)(O);if(U.length>32)throw Error("internal; should not happen");let $=new Uint8Array(32);return $.set(U,32-U.length),$}function bytesPad(O){if(O.length%32==0)return O;let U=new Uint8Array(32*Math.ceil(O.length/32));return U.set(O),U}function encodeBytes(O){let U=[],$=0;for(let J=0;Jea.O$.from(O).eq(1)).catch(O=>{if(O.code===en.Yd.errors.CALL_EXCEPTION)return!1;throw this._supportsEip2544=null,O})),this._supportsEip2544}_fetch(O,U){return base_provider_awaiter(this,void 0,void 0,function*(){let $={to:this.address,ccipReadEnabled:!0,data:(0,eu.xs)([O,namehash(this.name),U||"0x"])},J=!1;(yield this.supportsWildcard())&&(J=!0,$.data=(0,eu.xs)(["0x9061b923",encodeBytes([dnsEncode(this.name),$.data])]));try{let O=yield this.provider.call($);return(0,eu.lE)(O).length%32==4&&tr.throwError("resolver threw error",en.Yd.errors.CALL_EXCEPTION,{transaction:$,data:O}),J&&(O=_parseBytes(O,0)),O}catch(O){if(O.code===en.Yd.errors.CALL_EXCEPTION)return null;throw O}})}_fetchBytes(O,U){return base_provider_awaiter(this,void 0,void 0,function*(){let $=yield this._fetch(O,U);return null!=$?_parseBytes($,0):null})}_getAddress(O,U){let $=th[String(O)];if(null==$&&tr.throwError(`unsupported coin type: ${O}`,en.Yd.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${O})`}),"eth"===$.ilk)return this.provider.formatter.address(U);let J=(0,eu.lE)(U);if(null!=$.p2pkh){let O=U.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(O){let U=parseInt(O[1],16);if(O[2].length===2*U&&U>=1&&U<=75)return base58Encode((0,eu.zo)([[$.p2pkh],"0x"+O[2]]))}}if(null!=$.p2sh){let O=U.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(O){let U=parseInt(O[1],16);if(O[2].length===2*U&&U>=1&&U<=75)return base58Encode((0,eu.zo)([[$.p2sh],"0x"+O[2]]))}}if(null!=$.prefix){let O=J[1],U=J[0];if(0===U?20!==O&&32!==O&&(U=-1):U=-1,U>=0&&J.length===2+O&&O>=1&&O<=75){let O=e7().toWords(J.slice(2));return O.unshift(U),e7().encode($.prefix,O)}}return null}getAddress(O){return base_provider_awaiter(this,void 0,void 0,function*(){if(null==O&&(O=60),60===O)try{let O=yield this._fetch("0x3b3b57de");if("0x"===O||O===eF)return null;return this.provider.formatter.callAddress(O)}catch(O){if(O.code===en.Yd.errors.CALL_EXCEPTION)return null;throw O}let U=yield this._fetchBytes("0xf1cb7e06",bytes32ify(O));if(null==U||"0x"===U)return null;let $=this._getAddress(O,U);return null==$&&tr.throwError("invalid or unsupported coin data",en.Yd.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${O})`,coinType:O,data:U}),$})}getAvatar(){return base_provider_awaiter(this,void 0,void 0,function*(){let O=[{type:"name",content:this.name}];try{let U=yield this.getText("avatar");if(null==U)return null;for(let $=0;$O[U]);return"sia://"+U}return tr.throwError("invalid or unsupported content hash data",en.Yd.errors.UNSUPPORTED_OPERATION,{operation:"getContentHash()",data:O})})}getText(O){return base_provider_awaiter(this,void 0,void 0,function*(){let U=(0,eN.Y0)(O);(U=(0,eu.zo)([bytes32ify(64),bytes32ify(U.length),U])).length%32!=0&&(U=(0,eu.zo)([U,(0,eu.$m)("0x",32-O.length%32)]));let $=yield this._fetchBytes("0x59d1d43c",(0,eu.Dv)(U));return null==$||"0x"===$?null:(0,eN.ZN)($)})}};let tp=null,tg=1;let BaseProvider=class BaseProvider extends eL.zt{constructor(O){if(super(),this._events=[],this._emitted={block:-2},this.disableCcipRead=!1,this.formatter=new.target.getFormatter(),(0,J.zG)(this,"anyNetwork","any"===O),this.anyNetwork&&(O=this.detectNetwork()),O instanceof Promise)this._networkPromise=O,O.catch(O=>{}),this._ready().catch(O=>{});else{let U=(0,J.tu)(new.target,"getNetwork")(O);U?((0,J.zG)(this,"_network",U),this.emit("network",U,null)):tr.throwArgumentError("invalid network","network",O)}this._maxInternalBlockNumber=-1024,this._lastBlockNumber=-2,this._maxFilterBlockRange=10,this._pollingInterval=4e3,this._fastQueryDate=0}_ready(){return base_provider_awaiter(this,void 0,void 0,function*(){if(null==this._network){let O=null;if(this._networkPromise)try{O=yield this._networkPromise}catch(O){}null==O&&(O=yield this.detectNetwork()),O||tr.throwError("no network detected",en.Yd.errors.UNKNOWN_ERROR,{}),null==this._network&&(this.anyNetwork?this._network=O:(0,J.zG)(this,"_network",O),this.emit("network",O,null))}return this._network})}get ready(){return poll(()=>this._ready().then(O=>O,O=>{if(O.code!==en.Yd.errors.NETWORK_ERROR||"noNetwork"!==O.event)throw O}))}static getFormatter(){return null==tp&&(tp=new Formatter),tp}static getNetwork(O){return getNetwork(null==O?"homestead":O)}ccipReadFetch(O,U,$){return base_provider_awaiter(this,void 0,void 0,function*(){if(this.disableCcipRead||0===$.length)return null;let J=O.to.toLowerCase(),es=U.toLowerCase(),eo=[];for(let O=0;O<$.length;O++){let U=$[O],ea=U.replace("{sender}",J).replace("{data}",es),eu=U.indexOf("{data}")>=0?null:JSON.stringify({data:es,sender:J}),ef=yield fetchJson({url:ea,errorPassThrough:!0},eu,(O,U)=>(O.status=U.statusCode,O));if(ef.data)return ef.data;let eg=ef.message||"unknown error";if(ef.status>=400&&ef.status<500)return tr.throwError(`response not found during CCIP fetch: ${eg}`,en.Yd.errors.SERVER_ERROR,{url:U,errorMessage:eg});eo.push(eg)}return tr.throwError(`error encountered during CCIP fetch: ${eo.map(O=>JSON.stringify(O)).join(", ")}`,en.Yd.errors.SERVER_ERROR,{urls:$,errorMessages:eo})})}_getInternalBlockNumber(O){return base_provider_awaiter(this,void 0,void 0,function*(){if(yield this._ready(),O>0)for(;this._internalBlockNumber;){let U=this._internalBlockNumber;try{let $=yield U;if(getTime()-$.respTime<=O)return $.blockNumber;break}catch(O){if(this._internalBlockNumber===U)break}}let U=getTime(),$=(0,J.mE)({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then(O=>null,O=>O)}).then(({blockNumber:O,networkError:J})=>{if(J)throw this._internalBlockNumber===$&&(this._internalBlockNumber=null),J;let en=getTime();return(O=ea.O$.from(O).toNumber()){this._internalBlockNumber===$&&(this._internalBlockNumber=null)}),(yield $).blockNumber})}poll(){return base_provider_awaiter(this,void 0,void 0,function*(){let O=tg++,U=[],$=null;try{$=yield this._getInternalBlockNumber(100+this.pollingInterval/2)}catch(O){this.emit("error",O);return}if(this._setFastBlockNumber($),this.emit("poll",O,$),$===this._lastBlockNumber){this.emit("didPoll",O);return}if(-2===this._emitted.block&&(this._emitted.block=$-1),Math.abs(this._emitted.block-$)>1e3)tr.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${$})`),this.emit("error",tr.makeError("network block skew detected",en.Yd.errors.NETWORK_ERROR,{blockNumber:$,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",$);else for(let O=this._emitted.block+1;O<=$;O++)this.emit("block",O);this._emitted.block!==$&&(this._emitted.block=$,Object.keys(this._emitted).forEach(O=>{if("block"===O)return;let U=this._emitted[O];"pending"!==U&&$-U>12&&delete this._emitted[O]})),-2===this._lastBlockNumber&&(this._lastBlockNumber=$-1),this._events.forEach(O=>{switch(O.type){case"tx":{let $=O.hash,J=this.getTransactionReceipt($).then(O=>(O&&null!=O.blockNumber&&(this._emitted["t:"+$]=O.blockNumber,this.emit($,O)),null)).catch(O=>{this.emit("error",O)});U.push(J);break}case"filter":if(!O._inflight){O._inflight=!0,-2===O._lastBlockNumber&&(O._lastBlockNumber=$-1);let J=O.filter;J.fromBlock=O._lastBlockNumber+1,J.toBlock=$;let en=J.toBlock-this._maxFilterBlockRange;en>J.fromBlock&&(J.fromBlock=en),J.fromBlock<0&&(J.fromBlock=0);let es=this.getLogs(J).then(U=>{O._inflight=!1,0!==U.length&&U.forEach(U=>{U.blockNumber>O._lastBlockNumber&&(O._lastBlockNumber=U.blockNumber),this._emitted["b:"+U.blockHash]=U.blockNumber,this._emitted["t:"+U.transactionHash]=U.blockNumber,this.emit(J,U)})}).catch(U=>{this.emit("error",U),O._inflight=!1});U.push(es)}}}),this._lastBlockNumber=$,Promise.all(U).then(()=>{this.emit("didPoll",O)}).catch(O=>{this.emit("error",O)})})}resetEventsBlock(O){this._lastBlockNumber=O-1,this.polling&&this.poll()}get network(){return this._network}detectNetwork(){return base_provider_awaiter(this,void 0,void 0,function*(){return tr.throwError("provider does not support network detection",en.Yd.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})})}getNetwork(){return base_provider_awaiter(this,void 0,void 0,function*(){let O=yield this._ready(),U=yield this.detectNetwork();if(O.chainId!==U.chainId){if(this.anyNetwork)return this._network=U,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",U,O),yield stall(0),this._network;let $=tr.makeError("underlying network changed",en.Yd.errors.NETWORK_ERROR,{event:"changed",network:O,detectedNetwork:U});throw this.emit("error",$),$}return O})}get blockNumber(){return this._getInternalBlockNumber(100+this.pollingInterval/2).then(O=>{this._setFastBlockNumber(O)},O=>{}),null!=this._fastBlockNumber?this._fastBlockNumber:-1}get polling(){return null!=this._poller}set polling(O){O&&!this._poller?(this._poller=setInterval(()=>{this.poll()},this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout(()=>{this.poll(),this._bootstrapPoll=setTimeout(()=>{this._poller||this.poll(),this._bootstrapPoll=null},this.pollingInterval)},0))):!O&&this._poller&&(clearInterval(this._poller),this._poller=null)}get pollingInterval(){return this._pollingInterval}set pollingInterval(O){if("number"!=typeof O||O<=0||parseInt(String(O))!=O)throw Error("invalid polling interval");this._pollingInterval=O,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){let O=getTime();return O-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=O,this._fastBlockNumberPromise=this.getBlockNumber().then(O=>((null==this._fastBlockNumber||O>this._fastBlockNumber)&&(this._fastBlockNumber=O),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(O){(null==this._fastBlockNumber||!(Othis._fastBlockNumber)&&(this._fastBlockNumber=O,this._fastBlockNumberPromise=Promise.resolve(O)))}waitForTransaction(O,U,$){return base_provider_awaiter(this,void 0,void 0,function*(){return this._waitForTransaction(O,null==U?1:U,$||0,null)})}_waitForTransaction(O,U,$,J){return base_provider_awaiter(this,void 0,void 0,function*(){let es=yield this.getTransactionReceipt(O);return(es?es.confirmations:0)>=U?es:new Promise((es,eo)=>{let ea=[],eu=!1,alreadyDone=function(){return!!eu||(eu=!0,ea.forEach(O=>{O()}),!1)},minedHandler=O=>{O.confirmations{this.removeListener(O,minedHandler)}),J){let $=J.startBlock,es=null,replaceHandler=ea=>base_provider_awaiter(this,void 0,void 0,function*(){eu||(yield stall(1e3),this.getTransactionCount(J.from).then(ef=>base_provider_awaiter(this,void 0,void 0,function*(){if(!eu){if(ef<=J.nonce)$=ea;else{{let U=yield this.getTransaction(O);if(U&&null!=U.blockNumber)return}for(null==es&&(es=$-3){eu||this.once("block",replaceHandler)}))});if(eu)return;this.once("block",replaceHandler),ea.push(()=>{this.removeListener("block",replaceHandler)})}if("number"==typeof $&&$>0){let O=setTimeout(()=>{alreadyDone()||eo(tr.makeError("timeout exceeded",en.Yd.errors.TIMEOUT,{timeout:$}))},$);O.unref&&O.unref(),ea.push(()=>{clearTimeout(O)})}})})}getBlockNumber(){return base_provider_awaiter(this,void 0,void 0,function*(){return this._getInternalBlockNumber(0)})}getGasPrice(){return base_provider_awaiter(this,void 0,void 0,function*(){yield this.getNetwork();let O=yield this.perform("getGasPrice",{});try{return ea.O$.from(O)}catch(U){return tr.throwError("bad result from backend",en.Yd.errors.SERVER_ERROR,{method:"getGasPrice",result:O,error:U})}})}getBalance(O,U){return base_provider_awaiter(this,void 0,void 0,function*(){yield this.getNetwork();let $=yield(0,J.mE)({address:this._getAddress(O),blockTag:this._getBlockTag(U)}),es=yield this.perform("getBalance",$);try{return ea.O$.from(es)}catch(O){return tr.throwError("bad result from backend",en.Yd.errors.SERVER_ERROR,{method:"getBalance",params:$,result:es,error:O})}})}getTransactionCount(O,U){return base_provider_awaiter(this,void 0,void 0,function*(){yield this.getNetwork();let $=yield(0,J.mE)({address:this._getAddress(O),blockTag:this._getBlockTag(U)}),es=yield this.perform("getTransactionCount",$);try{return ea.O$.from(es).toNumber()}catch(O){return tr.throwError("bad result from backend",en.Yd.errors.SERVER_ERROR,{method:"getTransactionCount",params:$,result:es,error:O})}})}getCode(O,U){return base_provider_awaiter(this,void 0,void 0,function*(){yield this.getNetwork();let $=yield(0,J.mE)({address:this._getAddress(O),blockTag:this._getBlockTag(U)}),es=yield this.perform("getCode",$);try{return(0,eu.Dv)(es)}catch(O){return tr.throwError("bad result from backend",en.Yd.errors.SERVER_ERROR,{method:"getCode",params:$,result:es,error:O})}})}getStorageAt(O,U,$){return base_provider_awaiter(this,void 0,void 0,function*(){yield this.getNetwork();let es=yield(0,J.mE)({address:this._getAddress(O),blockTag:this._getBlockTag($),position:Promise.resolve(U).then(O=>(0,eu.$P)(O))}),eo=yield this.perform("getStorageAt",es);try{return(0,eu.Dv)(eo)}catch(O){return tr.throwError("bad result from backend",en.Yd.errors.SERVER_ERROR,{method:"getStorageAt",params:es,result:eo,error:O})}})}_wrapTransaction(O,U,$){if(null!=U&&32!==(0,eu.E1)(U))throw Error("invalid response - sendTransaction");let J=O;return null!=U&&O.hash!==U&&tr.throwError("Transaction hash mismatch from Provider.sendTransaction.",en.Yd.errors.UNKNOWN_ERROR,{expectedHash:O.hash,returnedHash:U}),J.wait=(U,J)=>base_provider_awaiter(this,void 0,void 0,function*(){let es;null==U&&(U=1),null==J&&(J=0),0!==U&&null!=$&&(es={data:O.data,from:O.from,nonce:O.nonce,to:O.to,value:O.value,startBlock:$});let eo=yield this._waitForTransaction(O.hash,U,J,es);return null==eo&&0===U?null:(this._emitted["t:"+O.hash]=eo.blockNumber,0===eo.status&&tr.throwError("transaction failed",en.Yd.errors.CALL_EXCEPTION,{transactionHash:O.hash,transaction:O,receipt:eo}),eo)}),J}sendTransaction(O){return base_provider_awaiter(this,void 0,void 0,function*(){yield this.getNetwork();let U=yield Promise.resolve(O).then(O=>(0,eu.Dv)(O)),$=this.formatter.transaction(O);null==$.confirmations&&($.confirmations=0);let J=yield this._getInternalBlockNumber(100+2*this.pollingInterval);try{let O=yield this.perform("sendTransaction",{signedTransaction:U});return this._wrapTransaction($,O,J)}catch(O){throw O.transaction=$,O.transactionHash=$.hash,O}})}_getTransactionRequest(O){return base_provider_awaiter(this,void 0,void 0,function*(){let U=yield O,$={};return["from","to"].forEach(O=>{null!=U[O]&&($[O]=Promise.resolve(U[O]).then(O=>O?this._getAddress(O):null))}),["gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","value"].forEach(O=>{null!=U[O]&&($[O]=Promise.resolve(U[O]).then(O=>O?ea.O$.from(O):null))}),["type"].forEach(O=>{null!=U[O]&&($[O]=Promise.resolve(U[O]).then(O=>null!=O?O:null))}),U.accessList&&($.accessList=this.formatter.accessList(U.accessList)),["data"].forEach(O=>{null!=U[O]&&($[O]=Promise.resolve(U[O]).then(O=>O?(0,eu.Dv)(O):null))}),this.formatter.transactionRequest((yield(0,J.mE)($)))})}_getFilter(O){return base_provider_awaiter(this,void 0,void 0,function*(){O=yield O;let U={};return null!=O.address&&(U.address=this._getAddress(O.address)),["blockHash","topics"].forEach($=>{null!=O[$]&&(U[$]=O[$])}),["fromBlock","toBlock"].forEach($=>{null!=O[$]&&(U[$]=this._getBlockTag(O[$]))}),this.formatter.filter((yield(0,J.mE)(U)))})}_call(O,U,$){return base_provider_awaiter(this,void 0,void 0,function*(){$>=ta&&tr.throwError("CCIP read exceeded maximum redirections",en.Yd.errors.SERVER_ERROR,{redirects:$,transaction:O});let J=O.to,es=yield this.perform("call",{transaction:O,blockTag:U});if($>=0&&"latest"===U&&null!=J&&"0x556f1830"===es.substring(0,10)&&(0,eu.E1)(es)%32==4)try{let eo=(0,eu.p3)(es,4),ef=(0,eu.p3)(eo,0,32);ea.O$.from(ef).eq(J)||tr.throwError("CCIP Read sender did not match",en.Yd.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:O,data:es});let eg=[],ev=ea.O$.from((0,eu.p3)(eo,32,64)).toNumber(),e_=ea.O$.from((0,eu.p3)(eo,ev,ev+32)).toNumber(),ew=(0,eu.p3)(eo,ev+32);for(let U=0;Ubase_provider_awaiter(this,void 0,void 0,function*(){let O=yield this.perform("getBlock",J);if(null==O)return null!=J.blockHash&&null==this._emitted["b:"+J.blockHash]||null!=J.blockTag&&$>this._emitted.block?null:void 0;if(U){let U=null;for(let $=0;$this._wrapTransaction(O)),$}return this.formatter.block(O)}),{oncePoll:this})})}getBlock(O){return this._getBlock(O,!1)}getBlockWithTransactions(O){return this._getBlock(O,!0)}getTransaction(O){return base_provider_awaiter(this,void 0,void 0,function*(){yield this.getNetwork(),O=yield O;let U={transactionHash:this.formatter.hash(O,!0)};return poll(()=>base_provider_awaiter(this,void 0,void 0,function*(){let $=yield this.perform("getTransaction",U);if(null==$)return null==this._emitted["t:"+O]?null:void 0;let J=this.formatter.transactionResponse($);if(null==J.blockNumber)J.confirmations=0;else if(null==J.confirmations){let O=yield this._getInternalBlockNumber(100+2*this.pollingInterval),U=O-J.blockNumber+1;U<=0&&(U=1),J.confirmations=U}return this._wrapTransaction(J)}),{oncePoll:this})})}getTransactionReceipt(O){return base_provider_awaiter(this,void 0,void 0,function*(){yield this.getNetwork(),O=yield O;let U={transactionHash:this.formatter.hash(O,!0)};return poll(()=>base_provider_awaiter(this,void 0,void 0,function*(){let $=yield this.perform("getTransactionReceipt",U);if(null==$)return null==this._emitted["t:"+O]?null:void 0;if(null==$.blockHash)return;let J=this.formatter.receipt($);if(null==J.blockNumber)J.confirmations=0;else if(null==J.confirmations){let O=yield this._getInternalBlockNumber(100+2*this.pollingInterval),U=O-J.blockNumber+1;U<=0&&(U=1),J.confirmations=U}return J}),{oncePoll:this})})}getLogs(O){return base_provider_awaiter(this,void 0,void 0,function*(){yield this.getNetwork();let U=yield(0,J.mE)({filter:this._getFilter(O)}),$=yield this.perform("getLogs",U);return $.forEach(O=>{null==O.removed&&(O.removed=!1)}),Formatter.arrayOf(this.formatter.filterLog.bind(this.formatter))($)})}getEtherPrice(){return base_provider_awaiter(this,void 0,void 0,function*(){return yield this.getNetwork(),this.perform("getEtherPrice",{})})}_getBlockTag(O){return base_provider_awaiter(this,void 0,void 0,function*(){if("number"==typeof(O=yield O)&&O<0){O%1&&tr.throwArgumentError("invalid BlockTag","blockTag",O);let U=yield this._getInternalBlockNumber(100+2*this.pollingInterval);return(U+=O)<0&&(U=0),this.formatter.blockTag(U)}return this.formatter.blockTag(O)})}getResolver(O){return base_provider_awaiter(this,void 0,void 0,function*(){let U=O;for(;;){if(""===U||"."===U||"eth"!==O&&"eth"===U)return null;let $=yield this._getResolver(U,"getResolver");if(null!=$){let J=new Resolver(this,$,O);if(U!==O&&!(yield J.supportsWildcard()))return null;return J}U=U.split(".").slice(1).join(".")}})}_getResolver(O,U){return base_provider_awaiter(this,void 0,void 0,function*(){null==U&&(U="ENS");let $=yield this.getNetwork();$.ensAddress||tr.throwError("network does not support ENS",en.Yd.errors.UNSUPPORTED_OPERATION,{operation:U,network:$.name});try{let U=yield this.call({to:$.ensAddress,data:"0x0178b8bf"+namehash(O).substring(2)});return this.formatter.callAddress(U)}catch(O){}return null})}resolveName(O){return base_provider_awaiter(this,void 0,void 0,function*(){O=yield O;try{return Promise.resolve(this.formatter.address(O))}catch(U){if((0,eu.A7)(O))throw U}"string"!=typeof O&&tr.throwArgumentError("invalid ENS name","name",O);let U=yield this.getResolver(O);return U?yield U.getAddress():null})}lookupAddress(O){return base_provider_awaiter(this,void 0,void 0,function*(){O=yield O,O=this.formatter.address(O);let U=O.substring(2).toLowerCase()+".addr.reverse",$=yield this._getResolver(U,"lookupAddress");if(null==$)return null;let J=_parseString((yield this.call({to:$,data:"0x691f3431"+namehash(U).substring(2)})),0),en=yield this.resolveName(J);return en!=O?null:J})}getAvatar(O){return base_provider_awaiter(this,void 0,void 0,function*(){let U=null;if((0,eu.A7)(O)){let $=this.formatter.address(O),J=$.substring(2).toLowerCase()+".addr.reverse",es=yield this._getResolver(J,"getAvatar");if(!es)return null;U=new Resolver(this,es,J);try{let O=yield U.getAvatar();if(O)return O.url}catch(O){if(O.code!==en.Yd.errors.CALL_EXCEPTION)throw O}try{let O=_parseString((yield this.call({to:es,data:"0x691f3431"+namehash(J).substring(2)})),0);U=yield this.getResolver(O)}catch(O){if(O.code!==en.Yd.errors.CALL_EXCEPTION)throw O;return null}}else if(!(U=yield this.getResolver(O)))return null;let $=yield U.getAvatar();return null==$?null:$.url})}perform(O,U){return tr.throwError(O+" not implemented",en.Yd.errors.NOT_IMPLEMENTED,{operation:O})}_startEvent(O){this.polling=this._events.filter(O=>O.pollable()).length>0}_stopEvent(O){this.polling=this._events.filter(O=>O.pollable()).length>0}_addEventListener(O,U,$){let J=new Event(getEventTag(O),U,$);return this._events.push(J),this._startEvent(J),this}on(O,U){return this._addEventListener(O,U,!1)}once(O,U){return this._addEventListener(O,U,!0)}emit(O,...U){let $=!1,J=[],en=getEventTag(O);return this._events=this._events.filter(O=>O.tag!==en||(setTimeout(()=>{O.listener.apply(this,U)},0),$=!0,!O.once||(J.push(O),!1))),J.forEach(O=>{this._stopEvent(O)}),$}listenerCount(O){if(!O)return this._events.length;let U=getEventTag(O);return this._events.filter(O=>O.tag===U).length}listeners(O){if(null==O)return this._events.map(O=>O.listener);let U=getEventTag(O);return this._events.filter(O=>O.tag===U).map(O=>O.listener)}off(O,U){if(null==U)return this.removeAllListeners(O);let $=[],J=!1,en=getEventTag(O);return this._events=this._events.filter(O=>O.tag!==en||O.listener!=U||!!J||(J=!0,$.push(O),!1)),$.forEach(O=>{this._stopEvent(O)}),this}removeAllListeners(O){let U=[];if(null==O)U=this._events,this._events=[];else{let $=getEventTag(O);this._events=this._events.filter(O=>O.tag!==$||(U.push(O),!1))}return U.forEach(O=>{this._stopEvent(O)}),this}};var json_rpc_provider_awaiter=function(O,U,$,J){function adopt(O){return O instanceof $?O:new $(function(U){U(O)})}return new($||($=Promise))(function($,en){function fulfilled(O){try{step(J.next(O))}catch(O){en(O)}}function rejected(O){try{step(J.throw(O))}catch(O){en(O)}}function step(O){O.done?$(O.value):adopt(O.value).then(fulfilled,rejected)}step((J=J.apply(O,U||[])).next())})};let tm=new en.Yd(es),ty=["call","estimateGas"];function spelunk(O,U){if(null==O)return null;if("string"==typeof O.message&&O.message.match("reverted")){let $=(0,eu.A7)(O.data)?O.data:null;if(!U||$)return{message:O.message,data:$}}if("object"==typeof O){for(let $ in O){let J=spelunk(O[$],U);if(J)return J}return null}if("string"==typeof O)try{return spelunk(JSON.parse(O),U)}catch(O){}return null}function checkError(O,U,$){let J=$.transaction||$.signedTransaction;if("call"===O){let O=spelunk(U,!0);if(O)return O.data;tm.throwError("missing revert data in call exception; Transaction reverted without a reason string",en.Yd.errors.CALL_EXCEPTION,{data:"0x",transaction:J,error:U})}if("estimateGas"===O){let $=spelunk(U.body,!1);null==$&&($=spelunk(U,!1)),$&&tm.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",en.Yd.errors.UNPREDICTABLE_GAS_LIMIT,{reason:$.message,method:O,transaction:J,error:U})}let es=U.message;throw U.code===en.Yd.errors.SERVER_ERROR&&U.error&&"string"==typeof U.error.message?es=U.error.message:"string"==typeof U.body?es=U.body:"string"==typeof U.responseText&&(es=U.responseText),(es=(es||"").toLowerCase()).match(/insufficient funds|base fee exceeds gas limit|InsufficientFunds/i)&&tm.throwError("insufficient funds for intrinsic transaction cost",en.Yd.errors.INSUFFICIENT_FUNDS,{error:U,method:O,transaction:J}),es.match(/nonce (is )?too low/i)&&tm.throwError("nonce has already been used",en.Yd.errors.NONCE_EXPIRED,{error:U,method:O,transaction:J}),es.match(/replacement transaction underpriced|transaction gas price.*too low/i)&&tm.throwError("replacement fee too low",en.Yd.errors.REPLACEMENT_UNDERPRICED,{error:U,method:O,transaction:J}),es.match(/only replay-protected/i)&&tm.throwError("legacy pre-eip-155 transactions not supported",en.Yd.errors.UNSUPPORTED_OPERATION,{error:U,method:O,transaction:J}),ty.indexOf(O)>=0&&es.match(/gas required exceeds allowance|always failing transaction|execution reverted|revert/)&&tm.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",en.Yd.errors.UNPREDICTABLE_GAS_LIMIT,{error:U,method:O,transaction:J}),U}function timer(O){return new Promise(function(U){setTimeout(U,O)})}function getResult(O){if(O.error){let U=Error(O.error.message);throw U.code=O.error.code,U.data=O.error.data,U}return O.result}function getLowerCase(O){return O?O.toLowerCase():O}let tb={};let JsonRpcSigner=class JsonRpcSigner extends eo.E{constructor(O,U,$){if(super(),O!==tb)throw Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");(0,J.zG)(this,"provider",U),null==$&&($=0),"string"==typeof $?((0,J.zG)(this,"_address",this.provider.formatter.address($)),(0,J.zG)(this,"_index",null)):"number"==typeof $?((0,J.zG)(this,"_index",$),(0,J.zG)(this,"_address",null)):tm.throwArgumentError("invalid address or index","addressOrIndex",$)}connect(O){return tm.throwError("cannot alter JSON-RPC Signer connection",en.Yd.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new UncheckedJsonRpcSigner(tb,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(O=>(O.length<=this._index&&tm.throwError("unknown account #"+this._index,en.Yd.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(O[this._index])))}sendUncheckedTransaction(O){O=(0,J.DC)(O);let U=this.getAddress().then(O=>(O&&(O=O.toLowerCase()),O));if(null==O.gasLimit){let $=(0,J.DC)(O);$.from=U,O.gasLimit=this.provider.estimateGas($)}return null!=O.to&&(O.to=Promise.resolve(O.to).then(O=>json_rpc_provider_awaiter(this,void 0,void 0,function*(){if(null==O)return null;let U=yield this.provider.resolveName(O);return null==U&&tm.throwArgumentError("provided ENS name resolves to null","tx.to",O),U}))),(0,J.mE)({tx:(0,J.mE)(O),sender:U}).then(({tx:U,sender:$})=>{null!=U.from?U.from.toLowerCase()!==$&&tm.throwArgumentError("from address mismatch","transaction",O):U.from=$;let J=this.provider.constructor.hexlifyTransaction(U,{from:!0});return this.provider.send("eth_sendTransaction",[J]).then(O=>O,O=>("string"==typeof O.message&&O.message.match(/user denied/i)&&tm.throwError("user rejected transaction",en.Yd.errors.ACTION_REJECTED,{action:"sendTransaction",transaction:U}),checkError("sendTransaction",O,J)))})}signTransaction(O){return tm.throwError("signing transactions is unsupported",en.Yd.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(O){return json_rpc_provider_awaiter(this,void 0,void 0,function*(){let U=yield this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval),$=yield this.sendUncheckedTransaction(O);try{return yield poll(()=>json_rpc_provider_awaiter(this,void 0,void 0,function*(){let O=yield this.provider.getTransaction($);if(null!==O)return this.provider._wrapTransaction(O,$,U)}),{oncePoll:this.provider})}catch(O){throw O.transactionHash=$,O}})}signMessage(O){return json_rpc_provider_awaiter(this,void 0,void 0,function*(){let U="string"==typeof O?(0,eN.Y0)(O):O,$=yield this.getAddress();try{return yield this.provider.send("personal_sign",[(0,eu.Dv)(U),$.toLowerCase()])}catch(U){throw"string"==typeof U.message&&U.message.match(/user denied/i)&&tm.throwError("user rejected signing",en.Yd.errors.ACTION_REJECTED,{action:"signMessage",from:$,messageData:O}),U}})}_legacySignMessage(O){return json_rpc_provider_awaiter(this,void 0,void 0,function*(){let U="string"==typeof O?(0,eN.Y0)(O):O,$=yield this.getAddress();try{return yield this.provider.send("eth_sign",[$.toLowerCase(),(0,eu.Dv)(U)])}catch(U){throw"string"==typeof U.message&&U.message.match(/user denied/i)&&tm.throwError("user rejected signing",en.Yd.errors.ACTION_REJECTED,{action:"_legacySignMessage",from:$,messageData:O}),U}})}_signTypedData(O,U,$){return json_rpc_provider_awaiter(this,void 0,void 0,function*(){let J=yield TypedDataEncoder.resolveNames(O,U,$,O=>this.provider.resolveName(O)),es=yield this.getAddress();try{return yield this.provider.send("eth_signTypedData_v4",[es.toLowerCase(),JSON.stringify(TypedDataEncoder.getPayload(J.domain,U,J.value))])}catch(O){throw"string"==typeof O.message&&O.message.match(/user denied/i)&&tm.throwError("user rejected signing",en.Yd.errors.ACTION_REJECTED,{action:"_signTypedData",from:es,messageData:{domain:J.domain,types:U,value:J.value}}),O}})}unlock(O){return json_rpc_provider_awaiter(this,void 0,void 0,function*(){let U=this.provider,$=yield this.getAddress();return U.send("personal_unlockAccount",[$.toLowerCase(),O,null])})}};let UncheckedJsonRpcSigner=class UncheckedJsonRpcSigner extends JsonRpcSigner{sendTransaction(O){return this.sendUncheckedTransaction(O).then(O=>({hash:O,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:U=>this.provider.waitForTransaction(O,U)}))}};let tv={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0,maxFeePerGas:!0,maxPriorityFeePerGas:!0};let JsonRpcProvider=class JsonRpcProvider extends BaseProvider{constructor(O,U){let $=U;null==$&&($=new Promise((O,U)=>{setTimeout(()=>{this.detectNetwork().then(U=>{O(U)},O=>{U(O)})},0)})),super($),O||(O=(0,J.tu)(this.constructor,"defaultUrl")()),"string"==typeof O?(0,J.zG)(this,"connection",Object.freeze({url:O})):(0,J.zG)(this,"connection",Object.freeze((0,J.DC)(O))),this._nextId=42}get _cache(){return null==this._eventLoopCache&&(this._eventLoopCache={}),this._eventLoopCache}static defaultUrl(){return"http://localhost:8545"}detectNetwork(){return this._cache.detectNetwork||(this._cache.detectNetwork=this._uncachedDetectNetwork(),setTimeout(()=>{this._cache.detectNetwork=null},0)),this._cache.detectNetwork}_uncachedDetectNetwork(){return json_rpc_provider_awaiter(this,void 0,void 0,function*(){yield timer(0);let O=null;try{O=yield this.send("eth_chainId",[])}catch(U){try{O=yield this.send("net_version",[])}catch(O){}}if(null!=O){let U=(0,J.tu)(this.constructor,"getNetwork");try{return U(ea.O$.from(O).toNumber())}catch(U){return tm.throwError("could not detect network",en.Yd.errors.NETWORK_ERROR,{chainId:O,event:"invalidNetwork",serverError:U})}}return tm.throwError("could not detect network",en.Yd.errors.NETWORK_ERROR,{event:"noNetwork"})})}getSigner(O){return new JsonRpcSigner(tb,this,O)}getUncheckedSigner(O){return this.getSigner(O).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(O=>O.map(O=>this.formatter.address(O)))}send(O,U){let $={method:O,params:U,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:(0,J.p$)($),provider:this});let en=["eth_chainId","eth_blockNumber"].indexOf(O)>=0;if(en&&this._cache[O])return this._cache[O];let es=fetchJson(this.connection,JSON.stringify($),getResult).then(O=>(this.emit("debug",{action:"response",request:$,response:O,provider:this}),O),O=>{throw this.emit("debug",{action:"response",error:O,request:$,provider:this}),O});return en&&(this._cache[O]=es,setTimeout(()=>{this._cache[O]=null},0)),es}prepareRequest(O,U){switch(O){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[getLowerCase(U.address),U.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[getLowerCase(U.address),U.blockTag]];case"getCode":return["eth_getCode",[getLowerCase(U.address),U.blockTag]];case"getStorageAt":return["eth_getStorageAt",[getLowerCase(U.address),(0,eu.$m)(U.position,32),U.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[U.signedTransaction]];case"getBlock":if(U.blockTag)return["eth_getBlockByNumber",[U.blockTag,!!U.includeTransactions]];if(U.blockHash)return["eth_getBlockByHash",[U.blockHash,!!U.includeTransactions]];break;case"getTransaction":return["eth_getTransactionByHash",[U.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[U.transactionHash]];case"call":{let O=(0,J.tu)(this.constructor,"hexlifyTransaction");return["eth_call",[O(U.transaction,{from:!0}),U.blockTag]]}case"estimateGas":{let O=(0,J.tu)(this.constructor,"hexlifyTransaction");return["eth_estimateGas",[O(U.transaction,{from:!0})]]}case"getLogs":return U.filter&&null!=U.filter.address&&(U.filter.address=getLowerCase(U.filter.address)),["eth_getLogs",[U.filter]]}return null}perform(O,U){return json_rpc_provider_awaiter(this,void 0,void 0,function*(){if("call"===O||"estimateGas"===O){let O=U.transaction;if(O&&null!=O.type&&ea.O$.from(O.type).isZero()&&null==O.maxFeePerGas&&null==O.maxPriorityFeePerGas){let $=yield this.getFeeData();null==$.maxFeePerGas&&null==$.maxPriorityFeePerGas&&((U=(0,J.DC)(U)).transaction=(0,J.DC)(O),delete U.transaction.type)}}let $=this.prepareRequest(O,U);null==$&&tm.throwError(O+" not implemented",en.Yd.errors.NOT_IMPLEMENTED,{operation:O});try{return yield this.send($[0],$[1])}catch($){return checkError(O,$,U)}})}_startEvent(O){"pending"===O.tag&&this._startPending(),super._startEvent(O)}_startPending(){if(null!=this._pendingFilter)return;let O=this,U=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=U,U.then(function($){function poll(){O.send("eth_getFilterChanges",[$]).then(function($){if(O._pendingFilter!=U)return null;let J=Promise.resolve();return $.forEach(function(U){O._emitted["t:"+U.toLowerCase()]="pending",J=J.then(function(){return O.getTransaction(U).then(function(U){return O.emit("pending",U),null})})}),J.then(function(){return timer(1e3)})}).then(function(){if(O._pendingFilter!=U){O.send("eth_uninstallFilter",[$]);return}return setTimeout(function(){poll()},0),null}).catch(O=>{})}return poll(),$}).catch(O=>{})}_stopEvent(O){"pending"===O.tag&&0===this.listenerCount("pending")&&(this._pendingFilter=null),super._stopEvent(O)}static hexlifyTransaction(O,U){let $=(0,J.DC)(tv);if(U)for(let O in U)U[O]&&($[O]=!0);(0,J.uj)(O,$);let en={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(function(U){if(null==O[U])return;let $=(0,eu.$P)(ea.O$.from(O[U]));"gasLimit"===U&&(U="gas"),en[U]=$}),["from","to","data"].forEach(function(U){null!=O[U]&&(en[U]=(0,eu.Dv)(O[U]))}),O.accessList&&(en.accessList=(0,eD.z7)(O.accessList)),en}};let t_=new en.Yd(es),tw=1;function buildWeb3LegacyFetcher(O,U){let $="Web3LegacyFetcher";return function(O,en){let es={method:O,params:en,id:tw++,jsonrpc:"2.0"};return new Promise((O,en)=>{this.emit("debug",{action:"request",fetcher:$,request:(0,J.p$)(es),provider:this}),U(es,(U,J)=>{if(U)return this.emit("debug",{action:"response",fetcher:$,error:U,request:es,provider:this}),en(U);if(this.emit("debug",{action:"response",fetcher:$,request:es,response:J,provider:this}),J.error){let O=Error(J.error.message);return O.code=J.error.code,O.data=J.error.data,en(O)}O(J.result)})})}}function buildEip1193Fetcher(O){return function(U,$){null==$&&($=[]);let en={method:U,params:$};return this.emit("debug",{action:"request",fetcher:"Eip1193Fetcher",request:(0,J.p$)(en),provider:this}),O.request(en).then(O=>(this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:en,response:O,provider:this}),O),O=>{throw this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:en,error:O,provider:this}),O})}}let Web3Provider=class Web3Provider extends JsonRpcProvider{constructor(O,U){null==O&&t_.throwArgumentError("missing provider","provider",O);let $=null,en=null,es=null;"function"==typeof O?($="unknown:",en=O):(($=O.host||O.path||"")||!O.isMetaMask||($="metamask"),es=O,O.request?(""===$&&($="eip-1193:"),en=buildEip1193Fetcher(O)):O.sendAsync?en=buildWeb3LegacyFetcher(O,O.sendAsync.bind(O)):O.send?en=buildWeb3LegacyFetcher(O,O.send.bind(O)):t_.throwArgumentError("unsupported provider","provider",O),$||($="unknown:")),super($,U),(0,J.zG)(this,"jsonRpcFetchFunc",en),(0,J.zG)(this,"provider",es)}send(O,U){return this.jsonRpcFetchFunc(O,U)}}},7054:function(O,U,$){"use strict";$.d(U,{J:function(){return decode},c:function(){return encode}});var J=$(7273),en=$(6288);let es="rlp/5.7.0",eo=new en.Yd(es);function arrayifyInteger(O){let U=[];for(;O;)U.unshift(255&O),O>>=8;return U}function unarrayifyInteger(O,U,$){let J=0;for(let en=0;en<$;en++)J=256*J+O[U+en];return J}function _encode(O){if(Array.isArray(O)){let U=[];if(O.forEach(function(O){U=U.concat(_encode(O))}),U.length<=55)return U.unshift(192+U.length),U;let $=arrayifyInteger(U.length);return $.unshift(247+$.length),$.concat(U)}(0,J.Zq)(O)||eo.throwArgumentError("RLP object must be BytesLike","object",O);let U=Array.prototype.slice.call((0,J.lE)(O));if(1===U.length&&U[0]<=127)return U;if(U.length<=55)return U.unshift(128+U.length),U;let $=arrayifyInteger(U.length);return $.unshift(183+$.length),$.concat(U)}function encode(O){return(0,J.Dv)(_encode(O))}function _decodeChildren(O,U,$,J){let es=[];for(;$U+1+J&&eo.throwError("child data too short",en.Yd.errors.BUFFER_OVERRUN,{})}return{consumed:1+J,result:es}}function _decode(O,U){if(0===O.length&&eo.throwError("data too short",en.Yd.errors.BUFFER_OVERRUN,{}),O[U]>=248){let $=O[U]-247;U+1+$>O.length&&eo.throwError("data short segment too short",en.Yd.errors.BUFFER_OVERRUN,{});let J=unarrayifyInteger(O,U+1,$);return U+1+$+J>O.length&&eo.throwError("data long segment too short",en.Yd.errors.BUFFER_OVERRUN,{}),_decodeChildren(O,U,U+1+$,$+J)}if(O[U]>=192){let $=O[U]-192;return U+1+$>O.length&&eo.throwError("data array too short",en.Yd.errors.BUFFER_OVERRUN,{}),_decodeChildren(O,U,U+1,$)}if(O[U]>=184){let $=O[U]-183;U+1+$>O.length&&eo.throwError("data array too short",en.Yd.errors.BUFFER_OVERRUN,{});let es=unarrayifyInteger(O,U+1,$);U+1+$+es>O.length&&eo.throwError("data array too short",en.Yd.errors.BUFFER_OVERRUN,{});let ea=(0,J.Dv)(O.slice(U+1+$,U+1+$+es));return{consumed:1+$+es,result:ea}}if(O[U]>=128){let $=O[U]-128;U+1+$>O.length&&eo.throwError("data too short",en.Yd.errors.BUFFER_OVERRUN,{});let es=(0,J.Dv)(O.slice(U+1,U+1+$));return{consumed:1+$,result:es}}return{consumed:1,result:(0,J.Dv)(O[U])}}function decode(O){let U=(0,J.lE)(O),$=_decode(U,0);return $.consumed!==U.length&&eo.throwArgumentError("invalid rlp data","data",O),$.result}},8337:function(O,U,$){"use strict";$.d(U,{Y0:function(){return toUtf8Bytes},XL:function(){return toUtf8CodePoints},ZN:function(){return toUtf8String}});var J,en,es=$(7273),eo=$(6288);let ea="strings/5.7.0",eu=new eo.Yd(ea);function errorFunc(O,U,$,J,en){return eu.throwArgumentError(`invalid codepoint at offset ${U}; ${O}`,"bytes",$)}function ignoreFunc(O,U,$,J,es){if(O===en.BAD_PREFIX||O===en.UNEXPECTED_CONTINUE){let O=0;for(let J=U+1;J<$.length&&$[J]>>6==2;J++)O++;return O}return O===en.OVERRUN?$.length-U-1:0}function replaceFunc(O,U,$,J,es){return O===en.OVERLONG?(J.push(es),0):(J.push(65533),ignoreFunc(O,U,$,J,es))}!function(O){O.current="",O.NFC="NFC",O.NFD="NFD",O.NFKC="NFKC",O.NFKD="NFKD"}(J||(J={})),function(O){O.UNEXPECTED_CONTINUE="unexpected continuation byte",O.BAD_PREFIX="bad codepoint prefix",O.OVERRUN="string overrun",O.MISSING_CONTINUE="missing continuation byte",O.OUT_OF_RANGE="out of UTF-8 range",O.UTF16_SURROGATE="UTF-16 surrogate",O.OVERLONG="overlong representation"}(en||(en={}));let ef=Object.freeze({error:errorFunc,ignore:ignoreFunc,replace:replaceFunc});function getUtf8CodePoints(O,U){null==U&&(U=ef.error),O=(0,es.lE)(O);let $=[],J=0;for(;J>7==0){$.push(es);continue}let eo=null,ea=null;if((224&es)==192)eo=1,ea=127;else if((240&es)==224)eo=2,ea=2047;else if((248&es)==240)eo=3,ea=65535;else{(192&es)==128?J+=U(en.UNEXPECTED_CONTINUE,J-1,O,$):J+=U(en.BAD_PREFIX,J-1,O,$);continue}if(J-1+eo>=O.length){J+=U(en.OVERRUN,J-1,O,$);continue}let eu=es&(1<<8-eo-1)-1;for(let es=0;es1114111){J+=U(en.OUT_OF_RANGE,J-1-eo,O,$,eu);continue}if(eu>=55296&&eu<=57343){J+=U(en.UTF16_SURROGATE,J-1-eo,O,$,eu);continue}if(eu<=ea){J+=U(en.OVERLONG,J-1-eo,O,$,eu);continue}$.push(eu)}}return $}function toUtf8Bytes(O,U=J.current){U!=J.current&&(eu.checkNormalize(),O=O.normalize(U));let $=[];for(let U=0;U>6|192),$.push(63&J|128);else if((64512&J)==55296){U++;let en=O.charCodeAt(U);if(U>=O.length||(64512&en)!=56320)throw Error("invalid utf-8 string");let es=65536+((1023&J)<<10)+(1023&en);$.push(es>>18|240),$.push(es>>12&63|128),$.push(es>>6&63|128),$.push(63&es|128)}else $.push(J>>12|224),$.push(J>>6&63|128),$.push(63&J|128)}return(0,es.lE)($)}function _toUtf8String(O){return O.map(O=>O<=65535?String.fromCharCode(O):String.fromCharCode(((O-=65536)>>10&1023)+55296,(1023&O)+56320)).join("")}function toUtf8String(O,U){return _toUtf8String(getUtf8CodePoints(O,U))}function toUtf8CodePoints(O,U=J.current){return getUtf8CodePoints(toUtf8Bytes(O,U))}},2501:function(O,U,$){"use strict";$.d(U,{z7:function(){return accessListify},Qc:function(){return parse}});var J,en=$(8994),es=$(2278),eo=$(7273),ea=$(3690),eu=$(4184),ef=$(7054),eg=$(6662),ev=$.n(eg),e_=$(5336),ew=$.n(e_);function createCommonjsModule(O,U,$){return O($={path:U,exports:{},require:function(O,U){return commonjsRequire(O,null==U?$.path:U)}},$.exports),$.exports}function commonjsRequire(){throw Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==$.g?$.g:"undefined"!=typeof self&&self;var eE=assert;function assert(O,U){if(!O)throw Error(U||"Assertion failed")}assert.equal=function(O,U,$){if(O!=U)throw Error($||"Assertion failed: "+O+" != "+U)};var eS=createCommonjsModule(function(O,U){var $=U;function toArray(O,U){if(Array.isArray(O))return O.slice();if(!O)return[];var $=[];if("string"!=typeof O){for(var J=0;J>8,eo=255&en;es?$.push(es,eo):$.push(eo)}return $}function zero2(O){return 1===O.length?"0"+O:O}function toHex(O){for(var U="",$=0;$(en>>1)-1?(en>>1)-eu:eu,es.isubn(ea)):ea=0,J[eo]=ea,es.iushrn(1)}return J}function getJSF(O,U){var $=[[],[]];O=O.clone(),U=U.clone();for(var J=0,en=0;O.cmpn(-J)>0||U.cmpn(-en)>0;){var es,eo,ea,eu=O.andln(3)+J&3,ef=U.andln(3)+en&3;3===eu&&(eu=-1),3===ef&&(ef=-1),eo=(1&eu)==0?0:(3==(es=O.andln(7)+J&7)||5===es)&&2===ef?-eu:eu,$[0].push(eo),ea=(1&ef)==0?0:(3==(es=U.andln(7)+en&7)||5===es)&&2===eu?-ef:ef,$[1].push(ea),2*J===eo+1&&(J=1-J),2*en===ea+1&&(en=1-en),O.iushrn(1),U.iushrn(1)}return $}function cachedProperty(O,U,$){var J="_"+U;O.prototype[U]=function(){return void 0!==this[J]?this[J]:this[J]=$.call(this)}}function parseBytes(O){return"string"==typeof O?$.toArray(O,"hex"):O}function intFromLE(O){return new(ev())(O,"hex","le")}$.assert=eE,$.toArray=eS.toArray,$.zero2=eS.zero2,$.toHex=eS.toHex,$.encode=eS.encode,$.getNAF=getNAF,$.getJSF=getJSF,$.cachedProperty=cachedProperty,$.parseBytes=parseBytes,$.intFromLE=intFromLE}),eI=eA.getNAF,eP=eA.getJSF,ek=eA.assert;function BaseCurve(O,U){this.type=O,this.p=new(ev())(U.p,16),this.red=U.prime?ev().red(U.prime):ev().mont(this.p),this.zero=new(ev())(0).toRed(this.red),this.one=new(ev())(1).toRed(this.red),this.two=new(ev())(2).toRed(this.red),this.n=U.n&&new(ev())(U.n,16),this.g=U.g&&this.pointFromJSON(U.g,U.gRed),this._wnafT1=[,,,,],this._wnafT2=[,,,,],this._wnafT3=[,,,,],this._wnafT4=[,,,,],this._bitLength=this.n?this.n.bitLength():0;var $=this.n&&this.p.div(this.n);!$||$.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var eT=BaseCurve;function BasePoint(O,U){this.curve=O,this.type=U,this.precomputed=null}BaseCurve.prototype.point=function(){throw Error("Not implemented")},BaseCurve.prototype.validate=function(){throw Error("Not implemented")},BaseCurve.prototype._fixedNafMul=function(O,U){ek(O.precomputed);var $,J,en=O._getDoubles(),es=eI(U,1,this._bitLength),eo=(1<=$;eu--)J=(J<<1)+es[eu];ea.push(J)}for(var ef=this.jpoint(null,null,null),eg=this.jpoint(null,null,null),ev=eo;ev>0;ev--){for($=0;$=0;ea--){for(var eu=0;ea>=0&&0===es[ea];ea--)eu++;if(ea>=0&&eu++,eo=eo.dblp(eu),ea<0)break;var ef=es[ea];ek(0!==ef),eo="affine"===O.type?ef>0?eo.mixedAdd(en[ef-1>>1]):eo.mixedAdd(en[-ef-1>>1].neg()):ef>0?eo.add(en[ef-1>>1]):eo.add(en[-ef-1>>1].neg())}return"affine"===O.type?eo.toP():eo},BaseCurve.prototype._wnafMulAdd=function(O,U,$,J,en){var es,eo,ea,eu=this._wnafT1,ef=this._wnafT2,eg=this._wnafT3,ev=0;for(es=0;es=1;es-=2){var ew=es-1,eE=es;if(1!==eu[ew]||1!==eu[eE]){eg[ew]=eI($[ew],eu[ew],this._bitLength),eg[eE]=eI($[eE],eu[eE],this._bitLength),ev=Math.max(eg[ew].length,ev),ev=Math.max(eg[eE].length,ev);continue}var eS=[U[ew],null,null,U[eE]];0===U[ew].y.cmp(U[eE].y)?(eS[1]=U[ew].add(U[eE]),eS[2]=U[ew].toJ().mixedAdd(U[eE].neg())):0===U[ew].y.cmp(U[eE].y.redNeg())?(eS[1]=U[ew].toJ().mixedAdd(U[eE]),eS[2]=U[ew].add(U[eE].neg())):(eS[1]=U[ew].toJ().mixedAdd(U[eE]),eS[2]=U[ew].toJ().mixedAdd(U[eE].neg()));var eA=[-3,-1,-5,-7,0,7,5,1,3],ek=eP($[ew],$[eE]);for(eo=0,ev=Math.max(ek[0].length,ev),eg[ew]=Array(ev),eg[eE]=Array(ev);eo=0;es--){for(var eN=0;es>=0;){var eD=!0;for(eo=0;eo=0&&eN++,eC=eC.dblp(eN),es<0)break;for(eo=0;eo0?ea=ef[eo][eM-1>>1]:eM<0&&(ea=ef[eo][-eM-1>>1].neg()),eC="affine"===ea.type?eC.mixedAdd(ea):eC.add(ea))}}for(es=0;es=Math.ceil((O.bitLength()+1)/U.step)},BasePoint.prototype._getDoubles=function(O,U){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var $=[this],J=this,en=0;enen[0].cmp(en[1])?en[0]:en[1]).toRed(this.red)}if(O.lambda)$=new(ev())(O.lambda,16);else{var es=this._getEndoRoots(this.n);0===this.g.mul(es[0]).x.cmp(this.g.x.redMul(U))?$=es[0]:($=es[1],eC(0===this.g.mul($).x.cmp(this.g.x.redMul(U))))}return J=O.basis?O.basis.map(function(O){return{a:new(ev())(O.a,16),b:new(ev())(O.b,16)}}):this._getEndoBasis($),{beta:U,lambda:$,basis:J}}},ShortCurve.prototype._getEndoRoots=function(O){var U=O===this.p?this.red:ev().mont(O),$=new(ev())(2).toRed(U).redInvm(),J=$.redNeg(),en=new(ev())(3).toRed(U).redNeg().redSqrt().redMul($);return[J.redAdd(en).fromRed(),J.redSub(en).fromRed()]},ShortCurve.prototype._getEndoBasis=function(O){for(var U,$,J,en,es,eo,ea,eu,ef,eg=this.n.ushrn(Math.floor(this.n.bitLength()/2)),e_=O,ew=this.n.clone(),eE=new(ev())(1),eS=new(ev())(0),eA=new(ev())(0),eI=new(ev())(1),eP=0;0!==e_.cmpn(0);){var ek=ew.div(e_);eu=ew.sub(ek.mul(e_)),ef=eA.sub(ek.mul(eE));var eT=eI.sub(ek.mul(eS));if(!J&&0>eu.cmp(eg))U=ea.neg(),$=eE,J=eu.neg(),en=ef;else if(J&&2==++eP)break;ea=eu,ew=e_,e_=eu,eA=eE,eE=ef,eI=eS,eS=eT}es=eu.neg(),eo=ef;var eR=J.sqr().add(en.sqr());return es.sqr().add(eo.sqr()).cmp(eR)>=0&&(es=U,eo=$),J.negative&&(J=J.neg(),en=en.neg()),es.negative&&(es=es.neg(),eo=eo.neg()),[{a:J,b:en},{a:es,b:eo}]},ShortCurve.prototype._endoSplit=function(O){var U=this.endo.basis,$=U[0],J=U[1],en=J.b.mul(O).divRound(this.n),es=$.b.neg().mul(O).divRound(this.n),eo=en.mul($.a),ea=es.mul(J.a),eu=en.mul($.b),ef=es.mul(J.b);return{k1:O.sub(eo).sub(ea),k2:eu.add(ef).neg()}},ShortCurve.prototype.pointFromX=function(O,U){(O=new(ev())(O,16)).red||(O=O.toRed(this.red));var $=O.redSqr().redMul(O).redIAdd(O.redMul(this.a)).redIAdd(this.b),J=$.redSqrt();if(0!==J.redSqr().redSub($).cmp(this.zero))throw Error("invalid point");var en=J.fromRed().isOdd();return(U&&!en||!U&&en)&&(J=J.redNeg()),this.point(O,J)},ShortCurve.prototype.validate=function(O){if(O.inf)return!0;var U=O.x,$=O.y,J=this.a.redMul(U),en=U.redSqr().redMul(U).redIAdd(J).redIAdd(this.b);return 0===$.redSqr().redISub(en).cmpn(0)},ShortCurve.prototype._endoWnafMulAdd=function(O,U,$){for(var J=this._endoWnafT1,en=this._endoWnafT2,es=0;es":""},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(O){if(this.inf)return O;if(O.inf)return this;if(this.eq(O))return this.dbl();if(this.neg().eq(O)||0===this.x.cmp(O.x))return this.curve.point(null,null);var U=this.y.redSub(O.y);0!==U.cmpn(0)&&(U=U.redMul(this.x.redSub(O.x).redInvm()));var $=U.redSqr().redISub(this.x).redISub(O.x),J=U.redMul(this.x.redSub($)).redISub(this.y);return this.curve.point($,J)},Point.prototype.dbl=function(){if(this.inf)return this;var O=this.y.redAdd(this.y);if(0===O.cmpn(0))return this.curve.point(null,null);var U=this.curve.a,$=this.x.redSqr(),J=O.redInvm(),en=$.redAdd($).redIAdd($).redIAdd(U).redMul(J),es=en.redSqr().redISub(this.x.redAdd(this.x)),eo=en.redMul(this.x.redSub(es)).redISub(this.y);return this.curve.point(es,eo)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(O){return(O=new(ev())(O,16),this.isInfinity())?this:this._hasDoubles(O)?this.curve._fixedNafMul(this,O):this.curve.endo?this.curve._endoWnafMulAdd([this],[O]):this.curve._wnafMul(this,O)},Point.prototype.mulAdd=function(O,U,$){var J=[this,U],en=[O,$];return this.curve.endo?this.curve._endoWnafMulAdd(J,en):this.curve._wnafMulAdd(1,J,en,2)},Point.prototype.jmulAdd=function(O,U,$){var J=[this,U],en=[O,$];return this.curve.endo?this.curve._endoWnafMulAdd(J,en,!0):this.curve._wnafMulAdd(1,J,en,2,!0)},Point.prototype.eq=function(O){return this===O||this.inf===O.inf&&(this.inf||0===this.x.cmp(O.x)&&0===this.y.cmp(O.y))},Point.prototype.neg=function(O){if(this.inf)return this;var U=this.curve.point(this.x,this.y.redNeg());if(O&&this.precomputed){var $=this.precomputed,negate=function(O){return O.neg()};U.precomputed={naf:$.naf&&{wnd:$.naf.wnd,points:$.naf.points.map(negate)},doubles:$.doubles&&{step:$.doubles.step,points:$.doubles.points.map(negate)}}}return U},Point.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},eR(JPoint,eT.BasePoint),ShortCurve.prototype.jpoint=function(O,U,$){return new JPoint(this,O,U,$)},JPoint.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var O=this.z.redInvm(),U=O.redSqr(),$=this.x.redMul(U),J=this.y.redMul(U).redMul(O);return this.curve.point($,J)},JPoint.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},JPoint.prototype.add=function(O){if(this.isInfinity())return O;if(O.isInfinity())return this;var U=O.z.redSqr(),$=this.z.redSqr(),J=this.x.redMul(U),en=O.x.redMul($),es=this.y.redMul(U.redMul(O.z)),eo=O.y.redMul($.redMul(this.z)),ea=J.redSub(en),eu=es.redSub(eo);if(0===ea.cmpn(0))return 0!==eu.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var ef=ea.redSqr(),eg=ef.redMul(ea),ev=J.redMul(ef),e_=eu.redSqr().redIAdd(eg).redISub(ev).redISub(ev),ew=eu.redMul(ev.redISub(e_)).redISub(es.redMul(eg)),eE=this.z.redMul(O.z).redMul(ea);return this.curve.jpoint(e_,ew,eE)},JPoint.prototype.mixedAdd=function(O){if(this.isInfinity())return O.toJ();if(O.isInfinity())return this;var U=this.z.redSqr(),$=this.x,J=O.x.redMul(U),en=this.y,es=O.y.redMul(U).redMul(this.z),eo=$.redSub(J),ea=en.redSub(es);if(0===eo.cmpn(0))return 0!==ea.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var eu=eo.redSqr(),ef=eu.redMul(eo),eg=$.redMul(eu),ev=ea.redSqr().redIAdd(ef).redISub(eg).redISub(eg),e_=ea.redMul(eg.redISub(ev)).redISub(en.redMul(ef)),ew=this.z.redMul(eo);return this.curve.jpoint(ev,e_,ew)},JPoint.prototype.dblp=function(O){if(0===O||this.isInfinity())return this;if(!O)return this.dbl();if(this.curve.zeroA||this.curve.threeA){var U,$=this;for(U=0;U=0)return!1;if($.redIAdd(en),0===this.x.cmp($))return!0}},JPoint.prototype.inspect=function(){return this.isInfinity()?"":""},JPoint.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var eN=createCommonjsModule(function(O,U){var $=U;$.base=eT,$.short=eB,$.mont=null,$.edwards=null}),eD=createCommonjsModule(function(O,U){var $,J=U,en=eA.assert;function PresetCurve(O){"short"===O.type?this.curve=new eN.short(O):"edwards"===O.type?this.curve=new eN.edwards(O):this.curve=new eN.mont(O),this.g=this.curve.g,this.n=this.curve.n,this.hash=O.hash,en(this.g.validate(),"Invalid curve"),en(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function defineCurve(O,U){Object.defineProperty(J,O,{configurable:!0,enumerable:!0,get:function(){var $=new PresetCurve(U);return Object.defineProperty(J,O,{configurable:!0,enumerable:!0,value:$}),$}})}J.PresetCurve=PresetCurve,defineCurve("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:ew().sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),defineCurve("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:ew().sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),defineCurve("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:ew().sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),defineCurve("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:ew().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"]}),defineCurve("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:ew().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"]}),defineCurve("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:ew().sha256,gRed:!1,g:["9"]}),defineCurve("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:ew().sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{$=null.crash()}catch(O){$=void 0}defineCurve("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:ew().sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",$]})});function HmacDRBG(O){if(!(this instanceof HmacDRBG))return new HmacDRBG(O);this.hash=O.hash,this.predResist=!!O.predResist,this.outLen=this.hash.outSize,this.minEntropy=O.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var U=eS.toArray(O.entropy,O.entropyEnc||"hex"),$=eS.toArray(O.nonce,O.nonceEnc||"hex"),J=eS.toArray(O.pers,O.persEnc||"hex");eE(U.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(U,$,J)}var eM=HmacDRBG;HmacDRBG.prototype._init=function(O,U,$){var J=O.concat(U).concat($);this.K=Array(this.outLen/8),this.V=Array(this.outLen/8);for(var en=0;en=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(O.concat($||[])),this._reseed=1},HmacDRBG.prototype.generate=function(O,U,$,J){if(this._reseed>this.reseedInterval)throw Error("Reseed is required");"string"!=typeof U&&(J=$,$=U,U=null),$&&($=eS.toArray($,J||"hex"),this._update($));for(var en=[];en.length"};var eU=eA.assert;function Signature(O,U){if(O instanceof Signature)return O;this._importDER(O,U)||(eU(O.r&&O.s,"Signature without r or s"),this.r=new(ev())(O.r,16),this.s=new(ev())(O.s,16),void 0===O.recoveryParam?this.recoveryParam=null:this.recoveryParam=O.recoveryParam)}var eF=Signature;function Position(){this.place=0}function getLength(O,U){var $=O[U.place++];if(!(128&$))return $;var J=15&$;if(0===J||J>4)return!1;for(var en=0,es=0,eo=U.place;es>>=0;return!(en<=127)&&(U.place=eo,en)}function rmPadding(O){for(var U=0,$=O.length-1;!O[U]&&!(128&O[U+1])&&U<$;)U++;return 0===U?O:O.slice(U)}function constructLength(O,U){if(U<128){O.push(U);return}var $=1+(Math.log(U)/Math.LN2>>>3);for(O.push(128|$);--$;)O.push(U>>>($<<3)&255);O.push(U)}Signature.prototype._importDER=function(O,U){O=eA.toArray(O,U);var $=new Position;if(48!==O[$.place++])return!1;var J=getLength(O,$);if(!1===J||J+$.place!==O.length||2!==O[$.place++])return!1;var en=getLength(O,$);if(!1===en)return!1;var es=O.slice($.place,en+$.place);if($.place+=en,2!==O[$.place++])return!1;var eo=getLength(O,$);if(!1===eo||O.length!==eo+$.place)return!1;var ea=O.slice($.place,eo+$.place);if(0===es[0]){if(!(128&es[1]))return!1;es=es.slice(1)}if(0===ea[0]){if(!(128&ea[1]))return!1;ea=ea.slice(1)}return this.r=new(ev())(es),this.s=new(ev())(ea),this.recoveryParam=null,!0},Signature.prototype.toDER=function(O){var U=this.r.toArray(),$=this.s.toArray();for(128&U[0]&&(U=[0].concat(U)),128&$[0]&&($=[0].concat($)),U=rmPadding(U),$=rmPadding($);!$[0]&&!(128&$[1]);)$=$.slice(1);var J=[2];constructLength(J,U.length),(J=J.concat(U)).push(2),constructLength(J,$.length);var en=J.concat($),es=[48];return constructLength(es,en.length),es=es.concat(en),eA.encode(es,O)};var rand=function(){throw Error("unsupported")},eK=eA.assert;function EC(O){if(!(this instanceof EC))return new EC(O);"string"==typeof O&&(eK(Object.prototype.hasOwnProperty.call(eD,O),"Unknown curve "+O),O=eD[O]),O instanceof eD.PresetCurve&&(O={curve:O}),this.curve=O.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=O.curve.g,this.g.precompute(O.curve.n.bitLength()+1),this.hash=O.hash||O.curve.hash}var ej=EC;EC.prototype.keyPair=function(O){return new eL(this,O)},EC.prototype.keyFromPrivate=function(O,U){return eL.fromPrivate(this,O,U)},EC.prototype.keyFromPublic=function(O,U){return eL.fromPublic(this,O,U)},EC.prototype.genKeyPair=function(O){O||(O={});for(var U=new eM({hash:this.hash,pers:O.pers,persEnc:O.persEnc||"utf8",entropy:O.entropy||rand(this.hash.hmacStrength),entropyEnc:O.entropy&&O.entropyEnc||"utf8",nonce:this.n.toArray()}),$=this.n.byteLength(),J=this.n.sub(new(ev())(2));;){var en=new(ev())(U.generate($));if(!(en.cmp(J)>0))return en.iaddn(1),this.keyFromPrivate(en)}},EC.prototype._truncateToN=function(O,U){var $=8*O.byteLength()-this.n.bitLength();return($>0&&(O=O.ushrn($)),!U&&O.cmp(this.n)>=0)?O.sub(this.n):O},EC.prototype.sign=function(O,U,$,J){"object"==typeof $&&(J=$,$=null),J||(J={}),U=this.keyFromPrivate(U,$),O=this._truncateToN(new(ev())(O,16));for(var en=this.n.byteLength(),es=U.getPrivate().toArray("be",en),eo=O.toArray("be",en),ea=new eM({hash:this.hash,entropy:es,nonce:eo,pers:J.pers,persEnc:J.persEnc||"utf8"}),eu=this.n.sub(new(ev())(1)),ef=0;;ef++){var eg=J.k?J.k(ef):new(ev())(ea.generate(this.n.byteLength()));if(!(0>=(eg=this._truncateToN(eg,!0)).cmpn(1)||eg.cmp(eu)>=0)){var e_=this.g.mul(eg);if(!e_.isInfinity()){var ew=e_.getX(),eE=ew.umod(this.n);if(0!==eE.cmpn(0)){var eS=eg.invm(this.n).mul(eE.mul(U.getPrivate()).iadd(O));if(0!==(eS=eS.umod(this.n)).cmpn(0)){var eA=(e_.getY().isOdd()?1:0)|(0!==ew.cmp(eE)?2:0);return J.canonical&&eS.cmp(this.nh)>0&&(eS=this.n.sub(eS),eA^=1),new eF({r:eE,s:eS,recoveryParam:eA})}}}}}},EC.prototype.verify=function(O,U,$,J){O=this._truncateToN(new(ev())(O,16)),$=this.keyFromPublic($,J);var en,es=(U=new eF(U,"hex")).r,eo=U.s;if(0>es.cmpn(1)||es.cmp(this.n)>=0||0>eo.cmpn(1)||eo.cmp(this.n)>=0)return!1;var ea=eo.invm(this.n),eu=ea.mul(O).umod(this.n),ef=ea.mul(es).umod(this.n);return this.curve._maxwellTrick?!(en=this.g.jmulAdd(eu,$.getPublic(),ef)).isInfinity()&&en.eqXToP(es):!(en=this.g.mulAdd(eu,$.getPublic(),ef)).isInfinity()&&0===en.getX().umod(this.n).cmp(es)},EC.prototype.recoverPubKey=function(O,U,$,J){eK((3&$)===$,"The recovery param is more than two bits"),U=new eF(U,J);var en=this.n,es=new(ev())(O),eo=U.r,ea=U.s,eu=1&$,ef=$>>1;if(eo.cmp(this.curve.p.umod(this.curve.n))>=0&&ef)throw Error("Unable to find sencond key candinate");eo=ef?this.curve.pointFromX(eo.add(this.curve.n),eu):this.curve.pointFromX(eo,eu);var eg=U.r.invm(en),e_=en.sub(es).mul(eg).umod(en),ew=ea.mul(eg).umod(en);return this.g.mulAdd(e_,eo,ew)},EC.prototype.getKeyRecoveryParam=function(O,U,$,J){if(null!==(U=new eF(U,J)).recoveryParam)return U.recoveryParam;for(var en,es=0;es<4;es++){try{en=this.recoverPubKey(O,U,es)}catch(O){continue}if(en.eq($))return es}throw Error("Unable to find valid recovery factor")};var eH=createCommonjsModule(function(O,U){var $=U;$.version="6.5.4",$.utils=eA,$.rand=function(){throw Error("unsupported")},$.curve=eN,$.curves=eD,$.ec=ej,$.eddsa=null}).ec,eq=$(7213),eV=$(6288);let eG="signing-key/5.7.0",e$=new eV.Yd(eG),eW=null;function getCurve(){return eW||(eW=new eH("secp256k1")),eW}let SigningKey=class SigningKey{constructor(O){(0,eq.zG)(this,"curve","secp256k1"),(0,eq.zG)(this,"privateKey",(0,eo.Dv)(O)),32!==(0,eo.E1)(this.privateKey)&&e$.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");let U=getCurve().keyFromPrivate((0,eo.lE)(this.privateKey));(0,eq.zG)(this,"publicKey","0x"+U.getPublic(!1,"hex")),(0,eq.zG)(this,"compressedPublicKey","0x"+U.getPublic(!0,"hex")),(0,eq.zG)(this,"_isSigningKey",!0)}_addPoint(O){let U=getCurve().keyFromPublic((0,eo.lE)(this.publicKey)),$=getCurve().keyFromPublic((0,eo.lE)(O));return"0x"+U.pub.add($.pub).encodeCompressed("hex")}signDigest(O){let U=getCurve().keyFromPrivate((0,eo.lE)(this.privateKey)),$=(0,eo.lE)(O);32!==$.length&&e$.throwArgumentError("bad digest length","digest",O);let J=U.sign($,{canonical:!0});return(0,eo.N)({recoveryParam:J.recoveryParam,r:(0,eo.$m)("0x"+J.r.toString(16),32),s:(0,eo.$m)("0x"+J.s.toString(16),32)})}computeSharedSecret(O){let U=getCurve().keyFromPrivate((0,eo.lE)(this.privateKey)),$=getCurve().keyFromPublic((0,eo.lE)(computePublicKey(O)));return(0,eo.$m)("0x"+U.derive($.getPublic()).toString(16),32)}static isSigningKey(O){return!!(O&&O._isSigningKey)}};function recoverPublicKey(O,U){let $=(0,eo.N)(U),J={r:(0,eo.lE)($.r),s:(0,eo.lE)($.s)};return"0x"+getCurve().recoverPubKey((0,eo.lE)(O),J,$.recoveryParam).encode("hex",!1)}function computePublicKey(O,U){let $=(0,eo.lE)(O);if(32===$.length){let O=new SigningKey($);return U?"0x"+getCurve().keyFromPrivate($).getPublic(!0,"hex"):O.publicKey}return 33===$.length?U?(0,eo.Dv)($):"0x"+getCurve().keyFromPublic($).getPublic(!1,"hex"):65===$.length?U?"0x"+getCurve().keyFromPublic($).getPublic(!0,"hex"):(0,eo.Dv)($):e$.throwArgumentError("invalid public or private key","key","[REDACTED]")}let eY="transactions/5.7.0",eJ=new eV.Yd(eY);function handleAddress(O){return"0x"===O?null:(0,en.Kn)(O)}function handleNumber(O){return"0x"===O?ea._Y:es.O$.from(O)}function computeAddress(O){let U=computePublicKey(O);return(0,en.Kn)((0,eo.p3)((0,eu.w)((0,eo.p3)(U,1)),12))}function recoverAddress(O,U){return computeAddress(recoverPublicKey((0,eo.lE)(O),U))}function formatNumber(O,U){let $=(0,eo.G1)(es.O$.from(O).toHexString());return $.length>32&&eJ.throwArgumentError("invalid length for "+U,"transaction:"+U,O),$}function accessSetify(O,U){return{address:(0,en.Kn)(O),storageKeys:(U||[]).map((U,$)=>(32!==(0,eo.E1)(U)&&eJ.throwArgumentError("invalid access list storageKey",`accessList[${O}:${$}]`,U),U.toLowerCase()))}}function accessListify(O){if(Array.isArray(O))return O.map((O,U)=>Array.isArray(O)?(O.length>2&&eJ.throwArgumentError("access list expected to be [ address, storageKeys[] ]",`value[${U}]`,O),accessSetify(O[0],O[1])):accessSetify(O.address,O.storageKeys));let U=Object.keys(O).map(U=>{let $=O[U].reduce((O,U)=>(O[U]=!0,O),{});return accessSetify(U,Object.keys($).sort())});return U.sort((O,U)=>O.address.localeCompare(U.address)),U}function formatAccessList(O){return accessListify(O).map(O=>[O.address,O.storageKeys])}function _serializeEip1559(O,U){if(null!=O.gasPrice){let U=es.O$.from(O.gasPrice),$=es.O$.from(O.maxFeePerGas||0);U.eq($)||eJ.throwArgumentError("mismatch EIP-1559 gasPrice != maxFeePerGas","tx",{gasPrice:U,maxFeePerGas:$})}let $=[formatNumber(O.chainId||0,"chainId"),formatNumber(O.nonce||0,"nonce"),formatNumber(O.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),formatNumber(O.maxFeePerGas||0,"maxFeePerGas"),formatNumber(O.gasLimit||0,"gasLimit"),null!=O.to?(0,en.Kn)(O.to):"0x",formatNumber(O.value||0,"value"),O.data||"0x",formatAccessList(O.accessList||[])];if(U){let O=(0,eo.N)(U);$.push(formatNumber(O.recoveryParam,"recoveryParam")),$.push((0,eo.G1)(O.r)),$.push((0,eo.G1)(O.s))}return(0,eo.xs)(["0x02",ef.c($)])}function _serializeEip2930(O,U){let $=[formatNumber(O.chainId||0,"chainId"),formatNumber(O.nonce||0,"nonce"),formatNumber(O.gasPrice||0,"gasPrice"),formatNumber(O.gasLimit||0,"gasLimit"),null!=O.to?(0,en.Kn)(O.to):"0x",formatNumber(O.value||0,"value"),O.data||"0x",formatAccessList(O.accessList||[])];if(U){let O=(0,eo.N)(U);$.push(formatNumber(O.recoveryParam,"recoveryParam")),$.push((0,eo.G1)(O.r)),$.push((0,eo.G1)(O.s))}return(0,eo.xs)(["0x01",ef.c($)])}function _parseEipSignature(O,U,$){try{let $=handleNumber(U[0]).toNumber();if(0!==$&&1!==$)throw Error("bad recid");O.v=$}catch(O){eJ.throwArgumentError("invalid v for transaction type: 1","v",U[0])}O.r=(0,eo.$m)(U[1],32),O.s=(0,eo.$m)(U[2],32);try{let U=(0,eu.w)($(O));O.from=recoverAddress(U,{r:O.r,s:O.s,recoveryParam:O.v})}catch(O){}}function _parseEip1559(O){let U=ef.J(O.slice(1));9!==U.length&&12!==U.length&&eJ.throwArgumentError("invalid component count for transaction type: 2","payload",(0,eo.Dv)(O));let $=handleNumber(U[2]),J=handleNumber(U[3]),en={type:2,chainId:handleNumber(U[0]).toNumber(),nonce:handleNumber(U[1]).toNumber(),maxPriorityFeePerGas:$,maxFeePerGas:J,gasPrice:null,gasLimit:handleNumber(U[4]),to:handleAddress(U[5]),value:handleNumber(U[6]),data:U[7],accessList:accessListify(U[8])};return 9===U.length||(en.hash=(0,eu.w)(O),_parseEipSignature(en,U.slice(9),_serializeEip1559)),en}function _parseEip2930(O){let U=ef.J(O.slice(1));8!==U.length&&11!==U.length&&eJ.throwArgumentError("invalid component count for transaction type: 1","payload",(0,eo.Dv)(O));let $={type:1,chainId:handleNumber(U[0]).toNumber(),nonce:handleNumber(U[1]).toNumber(),gasPrice:handleNumber(U[2]),gasLimit:handleNumber(U[3]),to:handleAddress(U[4]),value:handleNumber(U[5]),data:U[6],accessList:accessListify(U[7])};return 8===U.length||($.hash=(0,eu.w)(O),_parseEipSignature($,U.slice(8),_serializeEip2930)),$}function _parse(O){let U=ef.J(O);9!==U.length&&6!==U.length&&eJ.throwArgumentError("invalid raw transaction","rawTransaction",O);let $={nonce:handleNumber(U[0]).toNumber(),gasPrice:handleNumber(U[1]),gasLimit:handleNumber(U[2]),to:handleAddress(U[3]),value:handleNumber(U[4]),data:U[5],chainId:0};if(6===U.length)return $;try{$.v=es.O$.from(U[6]).toNumber()}catch(O){return $}if($.r=(0,eo.$m)(U[7],32),$.s=(0,eo.$m)(U[8],32),es.O$.from($.r).isZero()&&es.O$.from($.s).isZero())$.chainId=$.v,$.v=0;else{$.chainId=Math.floor(($.v-35)/2),$.chainId<0&&($.chainId=0);let J=$.v-27,en=U.slice(0,6);0!==$.chainId&&(en.push((0,eo.Dv)($.chainId)),en.push("0x"),en.push("0x"),J-=2*$.chainId+8);let es=(0,eu.w)(ef.c(en));try{$.from=recoverAddress(es,{r:(0,eo.Dv)($.r),s:(0,eo.Dv)($.s),recoveryParam:J})}catch(O){}$.hash=(0,eu.w)(O)}return $.type=null,$}function parse(O){let U=(0,eo.lE)(O);if(U[0]>127)return _parse(U);switch(U[0]){case 1:return _parseEip2930(U);case 2:return _parseEip1559(U)}return eJ.throwError(`unsupported transaction type: ${U[0]}`,eV.Yd.errors.UNSUPPORTED_OPERATION,{operation:"parseTransaction",transactionType:U[0]})}!function(O){O[O.legacy=0]="legacy",O[O.eip2930=1]="eip2930",O[O.eip1559=2]="eip1559"}(J||(J={}))},2790:function(O){"use strict";function asPromise(O,U){for(var $=Array(arguments.length-1),J=0,en=2,es=!0;en1&&"="===O.charAt(U);)++$;return Math.ceil(3*O.length)/4-$};for(var J=Array(64),en=Array(123),es=0;es<64;)en[J[es]=es<26?es+65:es<52?es+71:es<62?es-4:es-59|43]=es++;$.encode=function(O,U,$){for(var en,es=null,eo=[],ea=0,eu=0;U<$;){var ef=O[U++];switch(eu){case 0:eo[ea++]=J[ef>>2],en=(3&ef)<<4,eu=1;break;case 1:eo[ea++]=J[en|ef>>4],en=(15&ef)<<2,eu=2;break;case 2:eo[ea++]=J[en|ef>>6],eo[ea++]=J[63&ef],eu=0}ea>8191&&((es||(es=[])).push(String.fromCharCode.apply(String,eo)),ea=0)}return(eu&&(eo[ea++]=J[en],eo[ea++]=61,1===eu&&(eo[ea++]=61)),es)?(ea&&es.push(String.fromCharCode.apply(String,eo.slice(0,ea))),es.join("")):String.fromCharCode.apply(String,eo.slice(0,ea))};var eo="invalid encoding";$.decode=function(O,U,$){for(var J,es=$,ea=0,eu=0;eu1)break;if(void 0===(ef=en[ef]))throw Error(eo);switch(ea){case 0:J=ef,ea=1;break;case 1:U[$++]=J<<2|(48&ef)>>4,J=ef,ea=2;break;case 2:U[$++]=(15&J)<<4|(60&ef)>>2,J=ef,ea=3;break;case 3:U[$++]=(3&J)<<6|ef,ea=0}}if(1===ea)throw Error(eo);return $-es},$.test=function(O){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(O)}},8919:function(O){"use strict";function codegen(O,U){"string"==typeof O&&(U=O,O=void 0);var $=[];function Codegen(O){if("string"!=typeof O){var U=toString();if(codegen.verbose&&console.log("codegen: "+U),U="return "+U,O){for(var J=Object.keys(O),en=Array(J.length+1),es=Array(J.length),eo=0;eo0?0:2147483648,$,J);else if(isNaN(U))O(2143289344,$,J);else if(U>34028234663852886e22)O((en<<31|2139095040)>>>0,$,J);else if(U<11754943508222875e-54)O((en<<31|Math.round(U/1401298464324817e-60))>>>0,$,J);else{var es=Math.floor(Math.log(U)/Math.LN2),eo=8388607&Math.round(U*Math.pow(2,-es)*8388608);O((en<<31|es+127<<23|eo)>>>0,$,J)}}function readFloat_ieee754(O,U,$){var J=O(U,$),en=(J>>31)*2+1,es=J>>>23&255,eo=8388607&J;return 255===es?eo?NaN:en*(1/0):0===es?1401298464324817e-60*en*eo:en*Math.pow(2,es-150)*(eo+8388608)}O.writeFloatLE=writeFloat_ieee754.bind(null,writeUintLE),O.writeFloatBE=writeFloat_ieee754.bind(null,writeUintBE),O.readFloatLE=readFloat_ieee754.bind(null,readUintLE),O.readFloatBE=readFloat_ieee754.bind(null,readUintBE)}(),"undefined"!=typeof Float64Array?function(){var U=new Float64Array([-0]),$=new Uint8Array(U.buffer),J=128===$[7];function writeDouble_f64_cpy(O,J,en){U[0]=O,J[en]=$[0],J[en+1]=$[1],J[en+2]=$[2],J[en+3]=$[3],J[en+4]=$[4],J[en+5]=$[5],J[en+6]=$[6],J[en+7]=$[7]}function writeDouble_f64_rev(O,J,en){U[0]=O,J[en]=$[7],J[en+1]=$[6],J[en+2]=$[5],J[en+3]=$[4],J[en+4]=$[3],J[en+5]=$[2],J[en+6]=$[1],J[en+7]=$[0]}function readDouble_f64_cpy(O,J){return $[0]=O[J],$[1]=O[J+1],$[2]=O[J+2],$[3]=O[J+3],$[4]=O[J+4],$[5]=O[J+5],$[6]=O[J+6],$[7]=O[J+7],U[0]}function readDouble_f64_rev(O,J){return $[7]=O[J],$[6]=O[J+1],$[5]=O[J+2],$[4]=O[J+3],$[3]=O[J+4],$[2]=O[J+5],$[1]=O[J+6],$[0]=O[J+7],U[0]}O.writeDoubleLE=J?writeDouble_f64_cpy:writeDouble_f64_rev,O.writeDoubleBE=J?writeDouble_f64_rev:writeDouble_f64_cpy,O.readDoubleLE=J?readDouble_f64_cpy:readDouble_f64_rev,O.readDoubleBE=J?readDouble_f64_rev:readDouble_f64_cpy}():function(){function writeDouble_ieee754(O,U,$,J,en,es){var eo,ea=J<0?1:0;if(ea&&(J=-J),0===J)O(0,en,es+U),O(1/J>0?0:2147483648,en,es+$);else if(isNaN(J))O(0,en,es+U),O(2146959360,en,es+$);else if(J>17976931348623157e292)O(0,en,es+U),O((ea<<31|2146435072)>>>0,en,es+$);else if(J<22250738585072014e-324)O((eo=J/5e-324)>>>0,en,es+U),O((ea<<31|eo/4294967296)>>>0,en,es+$);else{var eu=Math.floor(Math.log(J)/Math.LN2);1024===eu&&(eu=1023),O(4503599627370496*(eo=J*Math.pow(2,-eu))>>>0,en,es+U),O((ea<<31|eu+1023<<20|1048576*eo&1048575)>>>0,en,es+$)}}function readDouble_ieee754(O,U,$,J,en){var es=O(J,en+U),eo=O(J,en+$),ea=(eo>>31)*2+1,eu=eo>>>20&2047,ef=4294967296*(1048575&eo)+es;return 2047===eu?ef?NaN:ea*(1/0):0===eu?5e-324*ea*ef:ea*Math.pow(2,eu-1075)*(ef+4503599627370496)}O.writeDoubleLE=writeDouble_ieee754.bind(null,writeUintLE,0,4),O.writeDoubleBE=writeDouble_ieee754.bind(null,writeUintBE,4,0),O.readDoubleLE=readDouble_ieee754.bind(null,readUintLE,0,4),O.readDoubleBE=readDouble_ieee754.bind(null,readUintBE,4,0)}(),O}function writeUintLE(O,U,$){U[$]=255&O,U[$+1]=O>>>8&255,U[$+2]=O>>>16&255,U[$+3]=O>>>24}function writeUintBE(O,U,$){U[$]=O>>>24,U[$+1]=O>>>16&255,U[$+2]=O>>>8&255,U[$+3]=255&O}function readUintLE(O,U){return(O[U]|O[U+1]<<8|O[U+2]<<16|O[U+3]<<24)>>>0}function readUintBE(O,U){return(O[U]<<24|O[U+1]<<16|O[U+2]<<8|O[U+3])>>>0}O.exports=factory(factory)},4962:function(module){"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},2041:function(O,U){"use strict";var $=U,J=$.isAbsolute=function(O){return/^(?:\/|\w+:)/.test(O)},en=$.normalize=function(O){var U=(O=O.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),$=J(O),en="";$&&(en=U.shift()+"/");for(var es=0;es0&&".."!==U[es-1]?U.splice(--es,2):$?U.splice(es,1):++es:"."===U[es]?U.splice(es,1):++es;return en+U.join("/")};$.resolve=function(O,U,$){return($||(U=en(U)),J(U))?U:($||(O=en(O)),(O=O.replace(/(?:\/|^)[^/]+$/,"")).length?en(O+"/"+U):U)}},3505:function(O){"use strict";function pool(O,U,$){var J=$||8192,en=J>>>1,es=null,eo=J;return function($){if($<1||$>en)return O($);eo+$>J&&(es=O(J),eo=0);var ea=U.call(es,eo,eo+=$);return 7&eo&&(eo=(7|eo)+1),ea}}O.exports=pool},6503:function(O,U){"use strict";var $=U;$.length=function(O){for(var U=0,$=0,J=0;J191&&J<224?es[eo++]=(31&J)<<6|63&O[U++]:J>239&&J<365?(J=((7&J)<<18|(63&O[U++])<<12|(63&O[U++])<<6|63&O[U++])-65536,es[eo++]=55296+(J>>10),es[eo++]=56320+(1023&J)):es[eo++]=(15&J)<<12|(63&O[U++])<<6|63&O[U++],eo>8191&&((en||(en=[])).push(String.fromCharCode.apply(String,es)),eo=0);return en?(eo&&en.push(String.fromCharCode.apply(String,es.slice(0,eo))),en.join("")):String.fromCharCode.apply(String,es.slice(0,eo))},$.write=function(O,U,$){for(var J,en,es=$,eo=0;eo>6|192:((64512&J)==55296&&(64512&(en=O.charCodeAt(eo+1)))==56320?(J=65536+((1023&J)<<10)+(1023&en),++eo,U[$++]=J>>18|240,U[$++]=J>>12&63|128):U[$++]=J>>12|224,U[$++]=J>>6&63|128),U[$++]=63&J|128);return $-es}},9055:function(O,U,$){var J,en=$(2601);!function(){"use strict";var es="input is invalid type",eo="finalize already called",ea="object"==typeof window,eu=ea?window:{};eu.JS_SHA3_NO_WINDOW&&(ea=!1);var ef=!ea&&"object"==typeof self;!eu.JS_SHA3_NO_NODE_JS&&"object"==typeof en&&en.versions&&en.versions.node?eu=$.g:ef&&(eu=self);for(var eg=!eu.JS_SHA3_NO_COMMON_JS&&O.exports,ev=$.amdO,e_=!eu.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,ew="0123456789abcdef".split(""),eE=[31,7936,2031616,520093696],eS=[4,1024,262144,67108864],eA=[1,256,65536,16777216],eI=[6,1536,393216,100663296],eP=[0,8,16,24],ek=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],eT=[224,256,384,512],eR=[128,256],eC=["hex","buffer","arrayBuffer","array","digest"],eB={128:168,256:136},eN=eu.JS_SHA3_NO_NODE_JS||!Array.isArray?function(O){return"[object Array]"===Object.prototype.toString.call(O)}:Array.isArray,eD=e_&&(eu.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)?function(O){return"object"==typeof O&&O.buffer&&O.buffer.constructor===ArrayBuffer}:ArrayBuffer.isView,formatMessage=function(O){var U=typeof O;if("string"===U)return[O,!0];if("object"!==U||null===O)throw Error(es);if(e_&&O.constructor===ArrayBuffer)return[new Uint8Array(O),!1];if(!eN(O)&&!eD(O))throw Error(es);return[O,!1]},empty=function(O){return 0===formatMessage(O)[0].length},createOutputMethod=function(O,U,$){return function(J){return new Keccak(O,U,O).update(J)[$]()}},createShakeOutputMethod=function(O,U,$){return function(J,en){return new Keccak(O,U,en).update(J)[$]()}},createCshakeOutputMethod=function(O,U,$){return function(U,J,en,es){return eO["cshake"+O].update(U,J,en,es)[$]()}},createKmacOutputMethod=function(O,U,$){return function(U,J,en,es){return eO["kmac"+O].update(U,J,en,es)[$]()}},createOutputMethods=function(O,U,$,J){for(var en=0;en>5,this.byteCount=this.blockCount<<2,this.outputBlocks=$>>5,this.extraBytes=(31&$)>>3;for(var J=0;J<50;++J)this.s[J]=0}function Kmac(O,U,$){Keccak.call(this,O,U,$)}Keccak.prototype.update=function(O){if(this.finalized)throw Error(eo);var U=formatMessage(O);O=U[0];for(var $,J,en=U[1],es=this.blocks,ea=this.byteCount,eu=O.length,ef=this.blockCount,eg=0,ev=this.s;eg>2]|=J<>2]|=(192|J>>6)<=57344?es[$>>2]|=(224|J>>12)<>2]|=(240|J>>18)<>2]|=(128|J>>12&63)<>2]|=(128|J>>6&63)<>2]|=(128|63&J)<>2]|=O[eg]<=ea){for(this.start=$-ea,this.block=es[ef],$=0;$>=8,$=255&O;$>0;)en.unshift($),O>>=8,$=255&O,++J;return U?en.push(J):en.unshift(J),this.update(en),en.length},Keccak.prototype.encodeString=function(O){var U=formatMessage(O);O=U[0];var $=U[1],J=0,en=O.length;if($)for(var es=0;es=57344?J+=3:(eo=65536+((1023&eo)<<10|1023&O.charCodeAt(++es)),J+=4)}else J=en;return J+=this.encode(8*J),this.update(O),J},Keccak.prototype.bytepad=function(O,U){for(var $=this.encode(U),J=0;J>2]|=this.padding[3&U],this.lastByteIndex===this.byteCount)for(U=1,O[0]=O[$];U<$+1;++U)O[U]=0;for(O[$-1]|=2147483648,U=0;U<$;++U)J[U]^=O[U];f(J)}},Keccak.prototype.toString=Keccak.prototype.hex=function(){this.finalize();for(var O,U=this.blockCount,$=this.s,J=this.outputBlocks,en=this.extraBytes,es=0,eo=0,ea="";eo>4&15]+ew[15&O]+ew[O>>12&15]+ew[O>>8&15]+ew[O>>20&15]+ew[O>>16&15]+ew[O>>28&15]+ew[O>>24&15];eo%U==0&&(f($),es=0)}return en&&(ea+=ew[(O=$[es])>>4&15]+ew[15&O],en>1&&(ea+=ew[O>>12&15]+ew[O>>8&15]),en>2&&(ea+=ew[O>>20&15]+ew[O>>16&15])),ea},Keccak.prototype.arrayBuffer=function(){this.finalize();var O,U=this.blockCount,$=this.s,J=this.outputBlocks,en=this.extraBytes,es=0,eo=0,ea=this.outputBits>>3;O=new ArrayBuffer(en?J+1<<2:ea);for(var eu=new Uint32Array(O);eo>8&255,eu[O+2]=U>>16&255,eu[O+3]=U>>24&255;ea%$==0&&f(J)}return es&&(O=ea<<2,U=J[eo],eu[O]=255&U,es>1&&(eu[O+1]=U>>8&255),es>2&&(eu[O+2]=U>>16&255)),eu},Kmac.prototype=new Keccak,Kmac.prototype.finalize=function(){return this.encode(this.outputBits,!0),Keccak.prototype.finalize.call(this)};var f=function(O){var U,$,J,en,es,eo,ea,eu,ef,eg,ev,e_,ew,eE,eS,eA,eI,eP,eT,eR,eC,eB,eN,eD,eM,eO,eL,eU,eF,eK,ej,eH,eq,eV,eG,e$,eW,eY,eJ,eQ,eZ,eX,e0,e1,e3,e6,e5,e9,e7,te,tt,tr,ta,tu,th,td,tf,tp,tg,tm,ty,tb,tv;for(J=0;J<48;J+=2)en=O[0]^O[10]^O[20]^O[30]^O[40],es=O[1]^O[11]^O[21]^O[31]^O[41],eo=O[2]^O[12]^O[22]^O[32]^O[42],ea=O[3]^O[13]^O[23]^O[33]^O[43],eu=O[4]^O[14]^O[24]^O[34]^O[44],ef=O[5]^O[15]^O[25]^O[35]^O[45],eg=O[6]^O[16]^O[26]^O[36]^O[46],ev=O[7]^O[17]^O[27]^O[37]^O[47],e_=O[8]^O[18]^O[28]^O[38]^O[48],ew=O[9]^O[19]^O[29]^O[39]^O[49],U=e_^(eo<<1|ea>>>31),$=ew^(ea<<1|eo>>>31),O[0]^=U,O[1]^=$,O[10]^=U,O[11]^=$,O[20]^=U,O[21]^=$,O[30]^=U,O[31]^=$,O[40]^=U,O[41]^=$,U=en^(eu<<1|ef>>>31),$=es^(ef<<1|eu>>>31),O[2]^=U,O[3]^=$,O[12]^=U,O[13]^=$,O[22]^=U,O[23]^=$,O[32]^=U,O[33]^=$,O[42]^=U,O[43]^=$,U=eo^(eg<<1|ev>>>31),$=ea^(ev<<1|eg>>>31),O[4]^=U,O[5]^=$,O[14]^=U,O[15]^=$,O[24]^=U,O[25]^=$,O[34]^=U,O[35]^=$,O[44]^=U,O[45]^=$,U=eu^(e_<<1|ew>>>31),$=ef^(ew<<1|e_>>>31),O[6]^=U,O[7]^=$,O[16]^=U,O[17]^=$,O[26]^=U,O[27]^=$,O[36]^=U,O[37]^=$,O[46]^=U,O[47]^=$,U=eg^(en<<1|es>>>31),$=ev^(es<<1|en>>>31),O[8]^=U,O[9]^=$,O[18]^=U,O[19]^=$,O[28]^=U,O[29]^=$,O[38]^=U,O[39]^=$,O[48]^=U,O[49]^=$,eE=O[0],eS=O[1],e6=O[11]<<4|O[10]>>>28,e5=O[10]<<4|O[11]>>>28,eU=O[20]<<3|O[21]>>>29,eF=O[21]<<3|O[20]>>>29,tm=O[31]<<9|O[30]>>>23,ty=O[30]<<9|O[31]>>>23,eX=O[40]<<18|O[41]>>>14,e0=O[41]<<18|O[40]>>>14,eV=O[2]<<1|O[3]>>>31,eG=O[3]<<1|O[2]>>>31,eA=O[13]<<12|O[12]>>>20,eI=O[12]<<12|O[13]>>>20,e9=O[22]<<10|O[23]>>>22,e7=O[23]<<10|O[22]>>>22,eK=O[33]<<13|O[32]>>>19,ej=O[32]<<13|O[33]>>>19,tb=O[42]<<2|O[43]>>>30,tv=O[43]<<2|O[42]>>>30,tu=O[5]<<30|O[4]>>>2,th=O[4]<<30|O[5]>>>2,e$=O[14]<<6|O[15]>>>26,eW=O[15]<<6|O[14]>>>26,eP=O[25]<<11|O[24]>>>21,eT=O[24]<<11|O[25]>>>21,te=O[34]<<15|O[35]>>>17,tt=O[35]<<15|O[34]>>>17,eH=O[45]<<29|O[44]>>>3,eq=O[44]<<29|O[45]>>>3,eD=O[6]<<28|O[7]>>>4,eM=O[7]<<28|O[6]>>>4,td=O[17]<<23|O[16]>>>9,tf=O[16]<<23|O[17]>>>9,eY=O[26]<<25|O[27]>>>7,eJ=O[27]<<25|O[26]>>>7,eR=O[36]<<21|O[37]>>>11,eC=O[37]<<21|O[36]>>>11,tr=O[47]<<24|O[46]>>>8,ta=O[46]<<24|O[47]>>>8,e1=O[8]<<27|O[9]>>>5,e3=O[9]<<27|O[8]>>>5,eO=O[18]<<20|O[19]>>>12,eL=O[19]<<20|O[18]>>>12,tp=O[29]<<7|O[28]>>>25,tg=O[28]<<7|O[29]>>>25,eQ=O[38]<<8|O[39]>>>24,eZ=O[39]<<8|O[38]>>>24,eB=O[48]<<14|O[49]>>>18,eN=O[49]<<14|O[48]>>>18,O[0]=eE^~eA&eP,O[1]=eS^~eI&eT,O[10]=eD^~eO&eU,O[11]=eM^~eL&eF,O[20]=eV^~e$&eY,O[21]=eG^~eW&eJ,O[30]=e1^~e6&e9,O[31]=e3^~e5&e7,O[40]=tu^~td&tp,O[41]=th^~tf&tg,O[2]=eA^~eP&eR,O[3]=eI^~eT&eC,O[12]=eO^~eU&eK,O[13]=eL^~eF&ej,O[22]=e$^~eY&eQ,O[23]=eW^~eJ&eZ,O[32]=e6^~e9&te,O[33]=e5^~e7&tt,O[42]=td^~tp&tm,O[43]=tf^~tg&ty,O[4]=eP^~eR&eB,O[5]=eT^~eC&eN,O[14]=eU^~eK&eH,O[15]=eF^~ej&eq,O[24]=eY^~eQ&eX,O[25]=eJ^~eZ&e0,O[34]=e9^~te&tr,O[35]=e7^~tt&ta,O[44]=tp^~tm&tb,O[45]=tg^~ty&tv,O[6]=eR^~eB&eE,O[7]=eC^~eN&eS,O[16]=eK^~eH&eD,O[17]=ej^~eq&eM,O[26]=eQ^~eX&eV,O[27]=eZ^~e0&eG,O[36]=te^~tr&e1,O[37]=tt^~ta&e3,O[46]=tm^~tb&tu,O[47]=ty^~tv&th,O[8]=eB^~eE&eA,O[9]=eN^~eS&eI,O[18]=eH^~eD&eO,O[19]=eq^~eM&eL,O[28]=eX^~eV&e$,O[29]=e0^~eG&eW,O[38]=tr^~e1&e6,O[39]=ta^~e3&e5,O[48]=tb^~tu&td,O[49]=tv^~th&tf,O[0]^=ek[J],O[1]^=ek[J+1]};if(eg)O.exports=eO;else{for(eU=0;eU127)break;es[en+eo]=U}if(eo!==J){0!==eo&&(O=O.slice(eo)),en=$(en,J,J=eo+3*O.length);let U=getUint8Memory0().subarray(en+eo,en+J),es=eg(O,U);eo+=es.written}return eu=eo,en}function isLikeNone(O){return null==O}let ev=null;function getInt32Memory0(){return(null===ev||0===ev.byteLength)&&(ev=new Int32Array(J.memory.buffer)),ev}function debugString(O){let U;let $=typeof O;if("number"==$||"boolean"==$||null==O)return`${O}`;if("string"==$)return`"${O}"`;if("symbol"==$){let U=O.description;return null==U?"Symbol":`Symbol(${U})`}if("function"==$){let U=O.name;return"string"==typeof U&&U.length>0?`Function(${U})`:"Function"}if(Array.isArray(O)){let U=O.length,$="[";U>0&&($+=debugString(O[0]));for(let J=1;J1))return toString.call(O);if("Object"==(U=J[1]))try{return"Object("+JSON.stringify(O)+")"}catch(O){return"Object"}return O instanceof Error?`${O.name}: ${O.message} +${O.stack}`:U}function init_panic_hook(){J.init_panic_hook()}function newRLN(O,U,$){try{let eo=J.__wbindgen_add_to_stack_pointer(-16);J.newRLN(eo,O,addHeapObject(U),addHeapObject($));var en=getInt32Memory0()[eo/4+0],es=getInt32Memory0()[eo/4+1];if(getInt32Memory0()[eo/4+2])throw takeObject(es);return en}finally{J.__wbindgen_add_to_stack_pointer(16)}}function getSerializedRLNWitness(O,U){try{let es=J.__wbindgen_add_to_stack_pointer(-16);J.getSerializedRLNWitness(es,O,addHeapObject(U));var $=getInt32Memory0()[es/4+0],en=getInt32Memory0()[es/4+1];if(getInt32Memory0()[es/4+2])throw takeObject(en);return takeObject($)}finally{J.__wbindgen_add_to_stack_pointer(16)}}function insertMember(O,U){try{let en=J.__wbindgen_add_to_stack_pointer(-16);J.insertMember(en,O,addHeapObject(U));var $=getInt32Memory0()[en/4+0];if(getInt32Memory0()[en/4+1])throw takeObject($)}finally{J.__wbindgen_add_to_stack_pointer(16)}}function setLeavesFrom(O,U,$){try{let es=J.__wbindgen_add_to_stack_pointer(-16);J.setLeavesFrom(es,O,U,addHeapObject($));var en=getInt32Memory0()[es/4+0];if(getInt32Memory0()[es/4+1])throw takeObject(en)}finally{J.__wbindgen_add_to_stack_pointer(16)}}function deleteLeaf(O,U){try{let en=J.__wbindgen_add_to_stack_pointer(-16);J.deleteLeaf(en,O,U);var $=getInt32Memory0()[en/4+0];if(getInt32Memory0()[en/4+1])throw takeObject($)}finally{J.__wbindgen_add_to_stack_pointer(16)}}function RLNWitnessToJson(O,U){try{let es=J.__wbindgen_add_to_stack_pointer(-16);J.RLNWitnessToJson(es,O,addHeapObject(U));var $=getInt32Memory0()[es/4+0],en=getInt32Memory0()[es/4+1];if(getInt32Memory0()[es/4+2])throw takeObject(en);return takeObject($)}finally{J.__wbindgen_add_to_stack_pointer(16)}}let e_=null;function getUint32Memory0(){return(null===e_||0===e_.byteLength)&&(e_=new Uint32Array(J.memory.buffer)),e_}function passArrayJsValueToWasm0(O,U){let $=U(4*O.length),J=getUint32Memory0();for(let U=0;U>>0]=takeObject($)},U.wbg.__wbg_toString_91b13ec0b518b06b=function(){return handleError(function(O,U){let $=getObject(O).toString(U);return addHeapObject($)},arguments)},U.wbg.__wbg_call_9495de66fdbe016b=function(){return handleError(function(O,U,$){let J=getObject(O).call(getObject(U),getObject($));return addHeapObject(J)},arguments)},U.wbg.__wbg_set_388c4c6422704173=function(O,U,$){let J=getObject(O).set(getObject(U),getObject($));return addHeapObject(J)},U.wbg.__wbg_fromEntries_47a432d7604fc06a=function(){return handleError(function(O){let U=Object.fromEntries(getObject(O));return addHeapObject(U)},arguments)},U.wbg.__wbg_buffer_cf65c07de34b9a08=function(O){let U=getObject(O).buffer;return addHeapObject(U)},U.wbg.__wbg_newwithbyteoffsetandlength_9fb2f11355ecadf5=function(O,U,$){let J=new Uint8Array(getObject(O),U>>>0,$>>>0);return addHeapObject(J)},U.wbg.__wbg_new_537b7341ce90bb31=function(O){let U=new Uint8Array(getObject(O));return addHeapObject(U)},U.wbg.__wbg_set_17499e8aa4003ebd=function(O,U,$){getObject(O).set(getObject(U),$>>>0)},U.wbg.__wbg_length_27a2afe8ab42b09f=function(O){let U=getObject(O).length;return U},U.wbg.__wbg_newwithlength_b56c882b57805732=function(O){let U=new Uint8Array(O>>>0);return addHeapObject(U)},U.wbg.__wbg_subarray_7526649b91a252a6=function(O,U,$){let J=getObject(O).subarray(U>>>0,$>>>0);return addHeapObject(J)},U.wbg.__wbindgen_debug_string=function(O,U){let $=debugString(getObject(U)),en=passStringToWasm0($,J.__wbindgen_malloc,J.__wbindgen_realloc),es=eu;getInt32Memory0()[O/4+1]=es,getInt32Memory0()[O/4+0]=en},U.wbg.__wbindgen_throw=function(O,U){throw Error(getStringFromWasm0(O,U))},U.wbg.__wbindgen_memory=function(){let O=J.memory;return addHeapObject(O)},U}function finalizeInit(O,U){return J=O.exports,init.__wbindgen_wasm_module=U,ev=null,e_=null,eo=null,J}async function init(O){void 0===O&&(O=new $.U($(632)));let U=getImports();("string"==typeof O||"function"==typeof Request&&O instanceof Request||"function"==typeof URL&&O instanceof URL)&&(O=fetch(O));let{instance:J,module:en}=await load(await O,U);return finalizeInit(J,en)}U.ZP=init},6942:function(O){"use strict";for(var U="qpzry9x8gf2tvdw0s3jn54khce6mua7l",$={},J=0;J>25;return(33554431&O)<<5^996825010&-(U>>0&1)^642813549&-(U>>1&1)^513874426&-(U>>2&1)^1027748829&-(U>>3&1)^705979059&-(U>>4&1)}function prefixChk(O){for(var U=1,$=0;$126)return"Invalid prefix ("+O+")";U=polymodStep(U)^J>>5}for($=0,U=polymodStep(U);$J)throw TypeError("Exceeds length limit");var en=prefixChk(O=O.toLowerCase());if("string"==typeof en)throw Error(en);for(var es=O+"1",eo=0;eo<$.length;++eo){var ea=$[eo];if(ea>>5!=0)throw Error("Non 5-bit word");en=polymodStep(en)^ea,es+=U.charAt(ea)}for(eo=0;eo<6;++eo)en=polymodStep(en);for(en^=1,eo=0;eo<6;++eo){var eu=en>>(5-eo)*5&31;es+=U.charAt(eu)}return es}function __decode(O,U){if(U=U||90,O.length<8)return O+" too short";if(O.length>U)return"Exceeds length limit";var J=O.toLowerCase(),en=O.toUpperCase();if(O!==J&&O!==en)return"Mixed-case string "+O;var es=(O=J).lastIndexOf("1");if(-1===es)return"No separator character for "+O;if(0===es)return"Missing prefix for "+O;var eo=O.slice(0,es),ea=O.slice(es+1);if(ea.length<6)return"Data too short";var eu=prefixChk(eo);if("string"==typeof eu)return eu;for(var ef=[],eg=0;eg=ea.length||ef.push(e_)}return 1!==eu?"Invalid checksum for "+O:{prefix:eo,words:ef}}function decodeUnsafe(){var O=__decode.apply(null,arguments);if("object"==typeof O)return O}function decode(O){var U=__decode.apply(null,arguments);if("object"==typeof U)return U;throw Error(U)}function convert(O,U,$,J){for(var en=0,es=0,eo=(1<<$)-1,ea=[],eu=0;eu=$;)ea.push(en>>(es-=$)&eo);if(J)es>0&&ea.push(en<<$-es&eo);else{if(es>=U)return"Excess padding";if(en<<$-es&eo)return"Non-zero padding"}return ea}function toWordsUnsafe(O){var U=convert(O,8,5,!0);if(Array.isArray(U))return U}function toWords(O){var U=convert(O,8,5,!0);if(Array.isArray(U))return U;throw Error(U)}function fromWordsUnsafe(O){var U=convert(O,5,8,!1);if(Array.isArray(U))return U}function fromWords(O){var U=convert(O,5,8,!1);if(Array.isArray(U))return U;throw Error(U)}O.exports={decodeUnsafe:decodeUnsafe,decode:decode,encode:encode,toWordsUnsafe:toWordsUnsafe,toWords:toWords,fromWordsUnsafe:fromWordsUnsafe,fromWords:fromWords}},6662:function(O,U,$){!function(O,U){"use strict";function assert(O,U){if(!O)throw Error(U||"Assertion failed")}function inherits(O,U){O.super_=U;var TempCtor=function(){};TempCtor.prototype=U.prototype,O.prototype=new TempCtor,O.prototype.constructor=O}function BN(O,U,$){if(BN.isBN(O))return O;this.negative=0,this.words=null,this.length=0,this.red=null,null!==O&&(("le"===U||"be"===U)&&($=U,U=10),this._init(O||0,U||10,$||"be"))}"object"==typeof O?O.exports=BN:U.BN=BN,BN.BN=BN,BN.wordSize=26;try{J="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:$(6601).Buffer}catch(O){}function parseHex4Bits(O,U){var $=O.charCodeAt(U);return $>=48&&$<=57?$-48:$>=65&&$<=70?$-55:$>=97&&$<=102?$-87:void assert(!1,"Invalid character in "+O)}function parseHexByte(O,U,$){var J=parseHex4Bits(O,$);return $-1>=U&&(J|=parseHex4Bits(O,$-1)<<4),J}function parseBase(O,U,$,J){for(var en=0,es=0,eo=Math.min(O.length,$),ea=U;ea=49?eu-49+10:eu>=17?eu-17+10:eu,assert(eu>=0&&es0?O:U},BN.min=function(O,U){return 0>O.cmp(U)?O:U},BN.prototype._init=function(O,U,$){if("number"==typeof O)return this._initNumber(O,U,$);if("object"==typeof O)return this._initArray(O,U,$);"hex"===U&&(U=16),assert(U===(0|U)&&U>=2&&U<=36);var J=0;"-"===(O=O.toString().replace(/\s+/g,""))[0]&&(J++,this.negative=1),J=0;es-=3)en=O[es]|O[es-1]<<8|O[es-2]<<16,this.words[J]|=en<>>26-eo&67108863,(eo+=24)>=26&&(eo-=26,J++);else if("le"===$)for(es=0,J=0;es>>26-eo&67108863,(eo+=24)>=26&&(eo-=26,J++);return this._strip()},BN.prototype._parseHex=function(O,U,$){this.length=Math.ceil((O.length-U)/6),this.words=Array(this.length);for(var J,en=0;en=U;en-=2)J=parseHexByte(O,U,en)<=18?(es-=18,eo+=1,this.words[eo]|=J>>>26):es+=8;else for(en=(O.length-U)%2==0?U+1:U;en=18?(es-=18,eo+=1,this.words[eo]|=J>>>26):es+=8;this._strip()},BN.prototype._parseBase=function(O,U,$){this.words=[0],this.length=1;for(var J=0,en=1;en<=67108863;en*=U)J++;J--,en=en/U|0;for(var es=O.length-$,eo=es%J,ea=Math.min(es,es-eo)+$,eu=0,ef=$;ef1&&0===this.words[this.length-1];)this.length--;return this._normSign()},BN.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{BN.prototype[Symbol.for("nodejs.util.inspect.custom")]=inspect}catch(O){BN.prototype.inspect=inspect}else BN.prototype.inspect=inspect;function inspect(){return(this.red?""}var J,en=["","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"],es=[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],eo=[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];BN.prototype.toString=function(O,U){if(U=0|U||1,16===(O=O||10)||"hex"===O){$="";for(var $,J=0,ea=0,eu=0;eu>>24-J&16777215,(J+=2)>=26&&(J-=26,eu--),$=0!==ea||eu!==this.length-1?en[6-eg.length]+eg+$:eg+$}for(0!==ea&&($=ea.toString(16)+$);$.length%U!=0;)$="0"+$;return 0!==this.negative&&($="-"+$),$}if(O===(0|O)&&O>=2&&O<=36){var ev=es[O],e_=eo[O];$="";var ew=this.clone();for(ew.negative=0;!ew.isZero();){var eE=ew.modrn(e_).toString(O);$=(ew=ew.idivn(e_)).isZero()?eE+$:en[ev-eE.length]+eE+$}for(this.isZero()&&($="0"+$);$.length%U!=0;)$="0"+$;return 0!==this.negative&&($="-"+$),$}assert(!1,"Base should be between 2 and 36")},BN.prototype.toNumber=function(){var O=this.words[0];return 2===this.length?O+=67108864*this.words[1]:3===this.length&&1===this.words[2]?O+=4503599627370496+67108864*this.words[1]:this.length>2&&assert(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-O:O},BN.prototype.toJSON=function(){return this.toString(16,2)},J&&(BN.prototype.toBuffer=function(O,U){return this.toArrayLike(J,O,U)}),BN.prototype.toArray=function(O,U){return this.toArrayLike(Array,O,U)};var allocate=function(O,U){return O.allocUnsafe?O.allocUnsafe(U):new O(U)};function toBitArray(O){for(var U=Array(O.bitLength()),$=0;$>>en&1}return U}function smallMulTo(O,U,$){$.negative=U.negative^O.negative;var J=O.length+U.length|0;$.length=J,J=J-1|0;var en=0|O.words[0],es=0|U.words[0],eo=en*es,ea=67108863&eo,eu=eo/67108864|0;$.words[0]=ea;for(var ef=1;ef>>26,ev=67108863&eu,e_=Math.min(ef,U.length-1),ew=Math.max(0,ef-O.length+1);ew<=e_;ew++){var eE=ef-ew|0;eg+=(eo=(en=0|O.words[eE])*(es=0|U.words[ew])+ev)/67108864|0,ev=67108863&eo}$.words[ef]=0|ev,eu=0|eg}return 0!==eu?$.words[ef]=0|eu:$.length--,$._strip()}BN.prototype.toArrayLike=function(O,U,$){this._strip();var J=this.byteLength(),en=$||Math.max(1,J);assert(J<=en,"byte array longer than desired length"),assert(en>0,"Requested array length <= 0");var es=allocate(O,en);return this["_toArrayLike"+("le"===U?"LE":"BE")](es,J),es},BN.prototype._toArrayLikeLE=function(O,U){for(var $=0,J=0,en=0,es=0;en>8&255),$>16&255),6===es?($>24&255),J=0,es=0):(J=eo>>>24,es+=2)}if($=0&&(O[$--]=eo>>8&255),$>=0&&(O[$--]=eo>>16&255),6===es?($>=0&&(O[$--]=eo>>24&255),J=0,es=0):(J=eo>>>24,es+=2)}if($>=0)for(O[$--]=J;$>=0;)O[$--]=0},Math.clz32?BN.prototype._countBits=function(O){return 32-Math.clz32(O)}:BN.prototype._countBits=function(O){var U=O,$=0;return U>=4096&&($+=13,U>>>=13),U>=64&&($+=7,U>>>=7),U>=8&&($+=4,U>>>=4),U>=2&&($+=2,U>>>=2),$+U},BN.prototype._zeroBits=function(O){if(0===O)return 26;var U=O,$=0;return(8191&U)==0&&($+=13,U>>>=13),(127&U)==0&&($+=7,U>>>=7),(15&U)==0&&($+=4,U>>>=4),(3&U)==0&&($+=2,U>>>=2),(1&U)==0&&$++,$},BN.prototype.bitLength=function(){var O=this.words[this.length-1],U=this._countBits(O);return(this.length-1)*26+U},BN.prototype.zeroBits=function(){if(this.isZero())return 0;for(var O=0,U=0;UO.length?this.clone().ior(O):O.clone().ior(this)},BN.prototype.uor=function(O){return this.length>O.length?this.clone().iuor(O):O.clone().iuor(this)},BN.prototype.iuand=function(O){var U;U=this.length>O.length?O:this;for(var $=0;$O.length?this.clone().iand(O):O.clone().iand(this)},BN.prototype.uand=function(O){return this.length>O.length?this.clone().iuand(O):O.clone().iuand(this)},BN.prototype.iuxor=function(O){this.length>O.length?(U=this,$=O):(U=O,$=this);for(var U,$,J=0;J<$.length;J++)this.words[J]=U.words[J]^$.words[J];if(this!==U)for(;JO.length?this.clone().ixor(O):O.clone().ixor(this)},BN.prototype.uxor=function(O){return this.length>O.length?this.clone().iuxor(O):O.clone().iuxor(this)},BN.prototype.inotn=function(O){assert("number"==typeof O&&O>=0);var U=0|Math.ceil(O/26),$=O%26;this._expand(U),$>0&&U--;for(var J=0;J0&&(this.words[J]=~this.words[J]&67108863>>26-$),this._strip()},BN.prototype.notn=function(O){return this.clone().inotn(O)},BN.prototype.setn=function(O,U){assert("number"==typeof O&&O>=0);var $=O/26|0,J=O%26;return this._expand($+1),U?this.words[$]=this.words[$]|1<O.length?($=this,J=O):($=O,J=this);for(var U,$,J,en=0,es=0;es>>26;for(;0!==en&&es<$.length;es++)U=(0|$.words[es])+en,this.words[es]=67108863&U,en=U>>>26;if(this.length=$.length,0!==en)this.words[this.length]=en,this.length++;else if($!==this)for(;es<$.length;es++)this.words[es]=$.words[es];return this},BN.prototype.add=function(O){var U;return 0!==O.negative&&0===this.negative?(O.negative=0,U=this.sub(O),O.negative^=1,U):0===O.negative&&0!==this.negative?(this.negative=0,U=O.sub(this),this.negative=1,U):this.length>O.length?this.clone().iadd(O):O.clone().iadd(this)},BN.prototype.isub=function(O){if(0!==O.negative){O.negative=0;var U,$,J=this.iadd(O);return O.negative=1,J._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(O),this.negative=1,this._normSign();var en=this.cmp(O);if(0===en)return this.negative=0,this.length=1,this.words[0]=0,this;en>0?(U=this,$=O):(U=O,$=this);for(var es=0,eo=0;eo<$.length;eo++)es=(J=(0|U.words[eo])-(0|$.words[eo])+es)>>26,this.words[eo]=67108863&J;for(;0!==es&&eo>26,this.words[eo]=67108863&J;if(0===es&&eo>>13,ew=0|eo[1],eE=8191&ew,eS=ew>>>13,eA=0|eo[2],eI=8191&eA,eP=eA>>>13,ek=0|eo[3],eT=8191&ek,eR=ek>>>13,eC=0|eo[4],eB=8191&eC,eN=eC>>>13,eD=0|eo[5],eM=8191&eD,eO=eD>>>13,eL=0|eo[6],eU=8191&eL,eF=eL>>>13,eK=0|eo[7],ej=8191&eK,eH=eK>>>13,eq=0|eo[8],eV=8191&eq,eG=eq>>>13,e$=0|eo[9],eW=8191&e$,eY=e$>>>13,eJ=0|ea[0],eQ=8191&eJ,eZ=eJ>>>13,eX=0|ea[1],e0=8191&eX,e1=eX>>>13,e3=0|ea[2],e6=8191&e3,e5=e3>>>13,e9=0|ea[3],e7=8191&e9,te=e9>>>13,tt=0|ea[4],tr=8191&tt,ta=tt>>>13,tu=0|ea[5],th=8191&tu,td=tu>>>13,tf=0|ea[6],tp=8191&tf,tg=tf>>>13,tm=0|ea[7],ty=8191&tm,tb=tm>>>13,tv=0|ea[8],t_=8191&tv,tw=tv>>>13,tE=0|ea[9],tS=8191&tE,tA=tE>>>13;$.negative=O.negative^U.negative,$.length=19;var tI=(ef+(J=Math.imul(ev,eQ))|0)+((8191&(en=(en=Math.imul(ev,eZ))+Math.imul(e_,eQ)|0))<<13)|0;ef=((es=Math.imul(e_,eZ))+(en>>>13)|0)+(tI>>>26)|0,tI&=67108863,J=Math.imul(eE,eQ),en=(en=Math.imul(eE,eZ))+Math.imul(eS,eQ)|0,es=Math.imul(eS,eZ);var tP=(ef+(J=J+Math.imul(ev,e0)|0)|0)+((8191&(en=(en=en+Math.imul(ev,e1)|0)+Math.imul(e_,e0)|0))<<13)|0;ef=((es=es+Math.imul(e_,e1)|0)+(en>>>13)|0)+(tP>>>26)|0,tP&=67108863,J=Math.imul(eI,eQ),en=(en=Math.imul(eI,eZ))+Math.imul(eP,eQ)|0,es=Math.imul(eP,eZ),J=J+Math.imul(eE,e0)|0,en=(en=en+Math.imul(eE,e1)|0)+Math.imul(eS,e0)|0,es=es+Math.imul(eS,e1)|0;var tk=(ef+(J=J+Math.imul(ev,e6)|0)|0)+((8191&(en=(en=en+Math.imul(ev,e5)|0)+Math.imul(e_,e6)|0))<<13)|0;ef=((es=es+Math.imul(e_,e5)|0)+(en>>>13)|0)+(tk>>>26)|0,tk&=67108863,J=Math.imul(eT,eQ),en=(en=Math.imul(eT,eZ))+Math.imul(eR,eQ)|0,es=Math.imul(eR,eZ),J=J+Math.imul(eI,e0)|0,en=(en=en+Math.imul(eI,e1)|0)+Math.imul(eP,e0)|0,es=es+Math.imul(eP,e1)|0,J=J+Math.imul(eE,e6)|0,en=(en=en+Math.imul(eE,e5)|0)+Math.imul(eS,e6)|0,es=es+Math.imul(eS,e5)|0;var tT=(ef+(J=J+Math.imul(ev,e7)|0)|0)+((8191&(en=(en=en+Math.imul(ev,te)|0)+Math.imul(e_,e7)|0))<<13)|0;ef=((es=es+Math.imul(e_,te)|0)+(en>>>13)|0)+(tT>>>26)|0,tT&=67108863,J=Math.imul(eB,eQ),en=(en=Math.imul(eB,eZ))+Math.imul(eN,eQ)|0,es=Math.imul(eN,eZ),J=J+Math.imul(eT,e0)|0,en=(en=en+Math.imul(eT,e1)|0)+Math.imul(eR,e0)|0,es=es+Math.imul(eR,e1)|0,J=J+Math.imul(eI,e6)|0,en=(en=en+Math.imul(eI,e5)|0)+Math.imul(eP,e6)|0,es=es+Math.imul(eP,e5)|0,J=J+Math.imul(eE,e7)|0,en=(en=en+Math.imul(eE,te)|0)+Math.imul(eS,e7)|0,es=es+Math.imul(eS,te)|0;var tR=(ef+(J=J+Math.imul(ev,tr)|0)|0)+((8191&(en=(en=en+Math.imul(ev,ta)|0)+Math.imul(e_,tr)|0))<<13)|0;ef=((es=es+Math.imul(e_,ta)|0)+(en>>>13)|0)+(tR>>>26)|0,tR&=67108863,J=Math.imul(eM,eQ),en=(en=Math.imul(eM,eZ))+Math.imul(eO,eQ)|0,es=Math.imul(eO,eZ),J=J+Math.imul(eB,e0)|0,en=(en=en+Math.imul(eB,e1)|0)+Math.imul(eN,e0)|0,es=es+Math.imul(eN,e1)|0,J=J+Math.imul(eT,e6)|0,en=(en=en+Math.imul(eT,e5)|0)+Math.imul(eR,e6)|0,es=es+Math.imul(eR,e5)|0,J=J+Math.imul(eI,e7)|0,en=(en=en+Math.imul(eI,te)|0)+Math.imul(eP,e7)|0,es=es+Math.imul(eP,te)|0,J=J+Math.imul(eE,tr)|0,en=(en=en+Math.imul(eE,ta)|0)+Math.imul(eS,tr)|0,es=es+Math.imul(eS,ta)|0;var tC=(ef+(J=J+Math.imul(ev,th)|0)|0)+((8191&(en=(en=en+Math.imul(ev,td)|0)+Math.imul(e_,th)|0))<<13)|0;ef=((es=es+Math.imul(e_,td)|0)+(en>>>13)|0)+(tC>>>26)|0,tC&=67108863,J=Math.imul(eU,eQ),en=(en=Math.imul(eU,eZ))+Math.imul(eF,eQ)|0,es=Math.imul(eF,eZ),J=J+Math.imul(eM,e0)|0,en=(en=en+Math.imul(eM,e1)|0)+Math.imul(eO,e0)|0,es=es+Math.imul(eO,e1)|0,J=J+Math.imul(eB,e6)|0,en=(en=en+Math.imul(eB,e5)|0)+Math.imul(eN,e6)|0,es=es+Math.imul(eN,e5)|0,J=J+Math.imul(eT,e7)|0,en=(en=en+Math.imul(eT,te)|0)+Math.imul(eR,e7)|0,es=es+Math.imul(eR,te)|0,J=J+Math.imul(eI,tr)|0,en=(en=en+Math.imul(eI,ta)|0)+Math.imul(eP,tr)|0,es=es+Math.imul(eP,ta)|0,J=J+Math.imul(eE,th)|0,en=(en=en+Math.imul(eE,td)|0)+Math.imul(eS,th)|0,es=es+Math.imul(eS,td)|0;var tB=(ef+(J=J+Math.imul(ev,tp)|0)|0)+((8191&(en=(en=en+Math.imul(ev,tg)|0)+Math.imul(e_,tp)|0))<<13)|0;ef=((es=es+Math.imul(e_,tg)|0)+(en>>>13)|0)+(tB>>>26)|0,tB&=67108863,J=Math.imul(ej,eQ),en=(en=Math.imul(ej,eZ))+Math.imul(eH,eQ)|0,es=Math.imul(eH,eZ),J=J+Math.imul(eU,e0)|0,en=(en=en+Math.imul(eU,e1)|0)+Math.imul(eF,e0)|0,es=es+Math.imul(eF,e1)|0,J=J+Math.imul(eM,e6)|0,en=(en=en+Math.imul(eM,e5)|0)+Math.imul(eO,e6)|0,es=es+Math.imul(eO,e5)|0,J=J+Math.imul(eB,e7)|0,en=(en=en+Math.imul(eB,te)|0)+Math.imul(eN,e7)|0,es=es+Math.imul(eN,te)|0,J=J+Math.imul(eT,tr)|0,en=(en=en+Math.imul(eT,ta)|0)+Math.imul(eR,tr)|0,es=es+Math.imul(eR,ta)|0,J=J+Math.imul(eI,th)|0,en=(en=en+Math.imul(eI,td)|0)+Math.imul(eP,th)|0,es=es+Math.imul(eP,td)|0,J=J+Math.imul(eE,tp)|0,en=(en=en+Math.imul(eE,tg)|0)+Math.imul(eS,tp)|0,es=es+Math.imul(eS,tg)|0;var tN=(ef+(J=J+Math.imul(ev,ty)|0)|0)+((8191&(en=(en=en+Math.imul(ev,tb)|0)+Math.imul(e_,ty)|0))<<13)|0;ef=((es=es+Math.imul(e_,tb)|0)+(en>>>13)|0)+(tN>>>26)|0,tN&=67108863,J=Math.imul(eV,eQ),en=(en=Math.imul(eV,eZ))+Math.imul(eG,eQ)|0,es=Math.imul(eG,eZ),J=J+Math.imul(ej,e0)|0,en=(en=en+Math.imul(ej,e1)|0)+Math.imul(eH,e0)|0,es=es+Math.imul(eH,e1)|0,J=J+Math.imul(eU,e6)|0,en=(en=en+Math.imul(eU,e5)|0)+Math.imul(eF,e6)|0,es=es+Math.imul(eF,e5)|0,J=J+Math.imul(eM,e7)|0,en=(en=en+Math.imul(eM,te)|0)+Math.imul(eO,e7)|0,es=es+Math.imul(eO,te)|0,J=J+Math.imul(eB,tr)|0,en=(en=en+Math.imul(eB,ta)|0)+Math.imul(eN,tr)|0,es=es+Math.imul(eN,ta)|0,J=J+Math.imul(eT,th)|0,en=(en=en+Math.imul(eT,td)|0)+Math.imul(eR,th)|0,es=es+Math.imul(eR,td)|0,J=J+Math.imul(eI,tp)|0,en=(en=en+Math.imul(eI,tg)|0)+Math.imul(eP,tp)|0,es=es+Math.imul(eP,tg)|0,J=J+Math.imul(eE,ty)|0,en=(en=en+Math.imul(eE,tb)|0)+Math.imul(eS,ty)|0,es=es+Math.imul(eS,tb)|0;var tD=(ef+(J=J+Math.imul(ev,t_)|0)|0)+((8191&(en=(en=en+Math.imul(ev,tw)|0)+Math.imul(e_,t_)|0))<<13)|0;ef=((es=es+Math.imul(e_,tw)|0)+(en>>>13)|0)+(tD>>>26)|0,tD&=67108863,J=Math.imul(eW,eQ),en=(en=Math.imul(eW,eZ))+Math.imul(eY,eQ)|0,es=Math.imul(eY,eZ),J=J+Math.imul(eV,e0)|0,en=(en=en+Math.imul(eV,e1)|0)+Math.imul(eG,e0)|0,es=es+Math.imul(eG,e1)|0,J=J+Math.imul(ej,e6)|0,en=(en=en+Math.imul(ej,e5)|0)+Math.imul(eH,e6)|0,es=es+Math.imul(eH,e5)|0,J=J+Math.imul(eU,e7)|0,en=(en=en+Math.imul(eU,te)|0)+Math.imul(eF,e7)|0,es=es+Math.imul(eF,te)|0,J=J+Math.imul(eM,tr)|0,en=(en=en+Math.imul(eM,ta)|0)+Math.imul(eO,tr)|0,es=es+Math.imul(eO,ta)|0,J=J+Math.imul(eB,th)|0,en=(en=en+Math.imul(eB,td)|0)+Math.imul(eN,th)|0,es=es+Math.imul(eN,td)|0,J=J+Math.imul(eT,tp)|0,en=(en=en+Math.imul(eT,tg)|0)+Math.imul(eR,tp)|0,es=es+Math.imul(eR,tg)|0,J=J+Math.imul(eI,ty)|0,en=(en=en+Math.imul(eI,tb)|0)+Math.imul(eP,ty)|0,es=es+Math.imul(eP,tb)|0,J=J+Math.imul(eE,t_)|0,en=(en=en+Math.imul(eE,tw)|0)+Math.imul(eS,t_)|0,es=es+Math.imul(eS,tw)|0;var tM=(ef+(J=J+Math.imul(ev,tS)|0)|0)+((8191&(en=(en=en+Math.imul(ev,tA)|0)+Math.imul(e_,tS)|0))<<13)|0;ef=((es=es+Math.imul(e_,tA)|0)+(en>>>13)|0)+(tM>>>26)|0,tM&=67108863,J=Math.imul(eW,e0),en=(en=Math.imul(eW,e1))+Math.imul(eY,e0)|0,es=Math.imul(eY,e1),J=J+Math.imul(eV,e6)|0,en=(en=en+Math.imul(eV,e5)|0)+Math.imul(eG,e6)|0,es=es+Math.imul(eG,e5)|0,J=J+Math.imul(ej,e7)|0,en=(en=en+Math.imul(ej,te)|0)+Math.imul(eH,e7)|0,es=es+Math.imul(eH,te)|0,J=J+Math.imul(eU,tr)|0,en=(en=en+Math.imul(eU,ta)|0)+Math.imul(eF,tr)|0,es=es+Math.imul(eF,ta)|0,J=J+Math.imul(eM,th)|0,en=(en=en+Math.imul(eM,td)|0)+Math.imul(eO,th)|0,es=es+Math.imul(eO,td)|0,J=J+Math.imul(eB,tp)|0,en=(en=en+Math.imul(eB,tg)|0)+Math.imul(eN,tp)|0,es=es+Math.imul(eN,tg)|0,J=J+Math.imul(eT,ty)|0,en=(en=en+Math.imul(eT,tb)|0)+Math.imul(eR,ty)|0,es=es+Math.imul(eR,tb)|0,J=J+Math.imul(eI,t_)|0,en=(en=en+Math.imul(eI,tw)|0)+Math.imul(eP,t_)|0,es=es+Math.imul(eP,tw)|0;var tO=(ef+(J=J+Math.imul(eE,tS)|0)|0)+((8191&(en=(en=en+Math.imul(eE,tA)|0)+Math.imul(eS,tS)|0))<<13)|0;ef=((es=es+Math.imul(eS,tA)|0)+(en>>>13)|0)+(tO>>>26)|0,tO&=67108863,J=Math.imul(eW,e6),en=(en=Math.imul(eW,e5))+Math.imul(eY,e6)|0,es=Math.imul(eY,e5),J=J+Math.imul(eV,e7)|0,en=(en=en+Math.imul(eV,te)|0)+Math.imul(eG,e7)|0,es=es+Math.imul(eG,te)|0,J=J+Math.imul(ej,tr)|0,en=(en=en+Math.imul(ej,ta)|0)+Math.imul(eH,tr)|0,es=es+Math.imul(eH,ta)|0,J=J+Math.imul(eU,th)|0,en=(en=en+Math.imul(eU,td)|0)+Math.imul(eF,th)|0,es=es+Math.imul(eF,td)|0,J=J+Math.imul(eM,tp)|0,en=(en=en+Math.imul(eM,tg)|0)+Math.imul(eO,tp)|0,es=es+Math.imul(eO,tg)|0,J=J+Math.imul(eB,ty)|0,en=(en=en+Math.imul(eB,tb)|0)+Math.imul(eN,ty)|0,es=es+Math.imul(eN,tb)|0,J=J+Math.imul(eT,t_)|0,en=(en=en+Math.imul(eT,tw)|0)+Math.imul(eR,t_)|0,es=es+Math.imul(eR,tw)|0;var tL=(ef+(J=J+Math.imul(eI,tS)|0)|0)+((8191&(en=(en=en+Math.imul(eI,tA)|0)+Math.imul(eP,tS)|0))<<13)|0;ef=((es=es+Math.imul(eP,tA)|0)+(en>>>13)|0)+(tL>>>26)|0,tL&=67108863,J=Math.imul(eW,e7),en=(en=Math.imul(eW,te))+Math.imul(eY,e7)|0,es=Math.imul(eY,te),J=J+Math.imul(eV,tr)|0,en=(en=en+Math.imul(eV,ta)|0)+Math.imul(eG,tr)|0,es=es+Math.imul(eG,ta)|0,J=J+Math.imul(ej,th)|0,en=(en=en+Math.imul(ej,td)|0)+Math.imul(eH,th)|0,es=es+Math.imul(eH,td)|0,J=J+Math.imul(eU,tp)|0,en=(en=en+Math.imul(eU,tg)|0)+Math.imul(eF,tp)|0,es=es+Math.imul(eF,tg)|0,J=J+Math.imul(eM,ty)|0,en=(en=en+Math.imul(eM,tb)|0)+Math.imul(eO,ty)|0,es=es+Math.imul(eO,tb)|0,J=J+Math.imul(eB,t_)|0,en=(en=en+Math.imul(eB,tw)|0)+Math.imul(eN,t_)|0,es=es+Math.imul(eN,tw)|0;var tU=(ef+(J=J+Math.imul(eT,tS)|0)|0)+((8191&(en=(en=en+Math.imul(eT,tA)|0)+Math.imul(eR,tS)|0))<<13)|0;ef=((es=es+Math.imul(eR,tA)|0)+(en>>>13)|0)+(tU>>>26)|0,tU&=67108863,J=Math.imul(eW,tr),en=(en=Math.imul(eW,ta))+Math.imul(eY,tr)|0,es=Math.imul(eY,ta),J=J+Math.imul(eV,th)|0,en=(en=en+Math.imul(eV,td)|0)+Math.imul(eG,th)|0,es=es+Math.imul(eG,td)|0,J=J+Math.imul(ej,tp)|0,en=(en=en+Math.imul(ej,tg)|0)+Math.imul(eH,tp)|0,es=es+Math.imul(eH,tg)|0,J=J+Math.imul(eU,ty)|0,en=(en=en+Math.imul(eU,tb)|0)+Math.imul(eF,ty)|0,es=es+Math.imul(eF,tb)|0,J=J+Math.imul(eM,t_)|0,en=(en=en+Math.imul(eM,tw)|0)+Math.imul(eO,t_)|0,es=es+Math.imul(eO,tw)|0;var tF=(ef+(J=J+Math.imul(eB,tS)|0)|0)+((8191&(en=(en=en+Math.imul(eB,tA)|0)+Math.imul(eN,tS)|0))<<13)|0;ef=((es=es+Math.imul(eN,tA)|0)+(en>>>13)|0)+(tF>>>26)|0,tF&=67108863,J=Math.imul(eW,th),en=(en=Math.imul(eW,td))+Math.imul(eY,th)|0,es=Math.imul(eY,td),J=J+Math.imul(eV,tp)|0,en=(en=en+Math.imul(eV,tg)|0)+Math.imul(eG,tp)|0,es=es+Math.imul(eG,tg)|0,J=J+Math.imul(ej,ty)|0,en=(en=en+Math.imul(ej,tb)|0)+Math.imul(eH,ty)|0,es=es+Math.imul(eH,tb)|0,J=J+Math.imul(eU,t_)|0,en=(en=en+Math.imul(eU,tw)|0)+Math.imul(eF,t_)|0,es=es+Math.imul(eF,tw)|0;var tK=(ef+(J=J+Math.imul(eM,tS)|0)|0)+((8191&(en=(en=en+Math.imul(eM,tA)|0)+Math.imul(eO,tS)|0))<<13)|0;ef=((es=es+Math.imul(eO,tA)|0)+(en>>>13)|0)+(tK>>>26)|0,tK&=67108863,J=Math.imul(eW,tp),en=(en=Math.imul(eW,tg))+Math.imul(eY,tp)|0,es=Math.imul(eY,tg),J=J+Math.imul(eV,ty)|0,en=(en=en+Math.imul(eV,tb)|0)+Math.imul(eG,ty)|0,es=es+Math.imul(eG,tb)|0,J=J+Math.imul(ej,t_)|0,en=(en=en+Math.imul(ej,tw)|0)+Math.imul(eH,t_)|0,es=es+Math.imul(eH,tw)|0;var tj=(ef+(J=J+Math.imul(eU,tS)|0)|0)+((8191&(en=(en=en+Math.imul(eU,tA)|0)+Math.imul(eF,tS)|0))<<13)|0;ef=((es=es+Math.imul(eF,tA)|0)+(en>>>13)|0)+(tj>>>26)|0,tj&=67108863,J=Math.imul(eW,ty),en=(en=Math.imul(eW,tb))+Math.imul(eY,ty)|0,es=Math.imul(eY,tb),J=J+Math.imul(eV,t_)|0,en=(en=en+Math.imul(eV,tw)|0)+Math.imul(eG,t_)|0,es=es+Math.imul(eG,tw)|0;var tH=(ef+(J=J+Math.imul(ej,tS)|0)|0)+((8191&(en=(en=en+Math.imul(ej,tA)|0)+Math.imul(eH,tS)|0))<<13)|0;ef=((es=es+Math.imul(eH,tA)|0)+(en>>>13)|0)+(tH>>>26)|0,tH&=67108863,J=Math.imul(eW,t_),en=(en=Math.imul(eW,tw))+Math.imul(eY,t_)|0,es=Math.imul(eY,tw);var tq=(ef+(J=J+Math.imul(eV,tS)|0)|0)+((8191&(en=(en=en+Math.imul(eV,tA)|0)+Math.imul(eG,tS)|0))<<13)|0;ef=((es=es+Math.imul(eG,tA)|0)+(en>>>13)|0)+(tq>>>26)|0,tq&=67108863;var tz=(ef+(J=Math.imul(eW,tS))|0)+((8191&(en=(en=Math.imul(eW,tA))+Math.imul(eY,tS)|0))<<13)|0;return ef=((es=Math.imul(eY,tA))+(en>>>13)|0)+(tz>>>26)|0,tz&=67108863,eu[0]=tI,eu[1]=tP,eu[2]=tk,eu[3]=tT,eu[4]=tR,eu[5]=tC,eu[6]=tB,eu[7]=tN,eu[8]=tD,eu[9]=tM,eu[10]=tO,eu[11]=tL,eu[12]=tU,eu[13]=tF,eu[14]=tK,eu[15]=tj,eu[16]=tH,eu[17]=tq,eu[18]=tz,0!==ef&&(eu[19]=ef,$.length++),$};function bigMulTo(O,U,$){$.negative=U.negative^O.negative,$.length=O.length+U.length;for(var J=0,en=0,es=0;es<$.length-1;es++){var eo=en;en=0;for(var ea=67108863&J,eu=Math.min(es,U.length-1),ef=Math.max(0,es-O.length+1);ef<=eu;ef++){var eg=es-ef,ev=(0|O.words[eg])*(0|U.words[ef]),e_=67108863&ev;eo=eo+(ev/67108864|0)|0,ea=67108863&(e_=e_+ea|0),en+=(eo=eo+(e_>>>26)|0)>>>26,eo&=67108863}$.words[es]=ea,J=eo,eo=en}return 0!==J?$.words[es]=J:$.length--,$._strip()}function jumboMulTo(O,U,$){return bigMulTo(O,U,$)}function FFTM(O,U){this.x=O,this.y=U}Math.imul||(comb10MulTo=smallMulTo),BN.prototype.mulTo=function(O,U){var $=this.length+O.length;return 10===this.length&&10===O.length?comb10MulTo(this,O,U):$<63?smallMulTo(this,O,U):$<1024?bigMulTo(this,O,U):jumboMulTo(this,O,U)},FFTM.prototype.makeRBT=function(O){for(var U=Array(O),$=BN.prototype._countBits(O)-1,J=0;J>=1;return J},FFTM.prototype.permute=function(O,U,$,J,en,es){for(var eo=0;eo>>=1)en++;return 1<>>=13,$[2*es+1]=8191&en,en>>>=13;for(es=2*U;es>=26,$+=(en/67108864|0)+(es>>>26),this.words[J]=67108863&es}return 0!==$&&(this.words[J]=$,this.length++),U?this.ineg():this},BN.prototype.muln=function(O){return this.clone().imuln(O)},BN.prototype.sqr=function(){return this.mul(this)},BN.prototype.isqr=function(){return this.imul(this.clone())},BN.prototype.pow=function(O){var U=toBitArray(O);if(0===U.length)return new BN(1);for(var $=this,J=0;J=0);var U,$=O%26,J=(O-$)/26,en=67108863>>>26-$<<26-$;if(0!==$){var es=0;for(U=0;U>>26-$}es&&(this.words[U]=es,this.length++)}if(0!==J){for(U=this.length-1;U>=0;U--)this.words[U+J]=this.words[U];for(U=0;U=0),J=U?(U-U%26)/26:0;var J,en=O%26,es=Math.min((O-en)/26,this.length),eo=67108863^67108863>>>en<es)for(this.length-=es,eu=0;eu=0&&(0!==ef||eu>=J);eu--){var eg=0|this.words[eu];this.words[eu]=ef<<26-en|eg>>>en,ef=eg&eo}return ea&&0!==ef&&(ea.words[ea.length++]=ef),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},BN.prototype.ishrn=function(O,U,$){return assert(0===this.negative),this.iushrn(O,U,$)},BN.prototype.shln=function(O){return this.clone().ishln(O)},BN.prototype.ushln=function(O){return this.clone().iushln(O)},BN.prototype.shrn=function(O){return this.clone().ishrn(O)},BN.prototype.ushrn=function(O){return this.clone().iushrn(O)},BN.prototype.testn=function(O){assert("number"==typeof O&&O>=0);var U=O%26,$=(O-U)/26,J=1<=0);var U=O%26,$=(O-U)/26;if(assert(0===this.negative,"imaskn works only with positive numbers"),this.length<=$)return this;if(0!==U&&$++,this.length=Math.min($,this.length),0!==U){var J=67108863^67108863>>>U<=67108864;U++)this.words[U]-=67108864,U===this.length-1?this.words[U+1]=1:this.words[U+1]++;return this.length=Math.max(this.length,U+1),this},BN.prototype.isubn=function(O){if(assert("number"==typeof O),assert(O<67108864),O<0)return this.iaddn(-O);if(0!==this.negative)return this.negative=0,this.iaddn(O),this.negative=1,this;if(this.words[0]-=O,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var U=0;U>26)-(ea/67108864|0),this.words[J+$]=67108863&en}for(;J>26,this.words[J+$]=67108863&en;if(0===eo)return this._strip();for(assert(-1===eo),eo=0,J=0;J>26,this.words[J]=67108863&en;return this.negative=1,this._strip()},BN.prototype._wordDiv=function(O,U){var $,J=this.length-O.length,en=this.clone(),es=O,eo=0|es.words[es.length-1];0!=(J=26-this._countBits(eo))&&(es=es.ushln(J),en.iushln(J),eo=0|es.words[es.length-1]);var ea=en.length-es.length;if("mod"!==U){($=new BN(null)).length=ea+1,$.words=Array($.length);for(var eu=0;eu<$.length;eu++)$.words[eu]=0}var ef=en.clone()._ishlnsubmul(es,1,ea);0===ef.negative&&(en=ef,$&&($.words[ea]=1));for(var eg=ea-1;eg>=0;eg--){var ev=(0|en.words[es.length+eg])*67108864+(0|en.words[es.length+eg-1]);for(ev=Math.min(ev/eo|0,67108863),en._ishlnsubmul(es,ev,eg);0!==en.negative;)ev--,en.negative=0,en._ishlnsubmul(es,1,eg),en.isZero()||(en.negative^=1);$&&($.words[eg]=ev)}return $&&$._strip(),en._strip(),"div"!==U&&0!==J&&en.iushrn(J),{div:$||null,mod:en}},BN.prototype.divmod=function(O,U,$){var J,en,es;return(assert(!O.isZero()),this.isZero())?{div:new BN(0),mod:new BN(0)}:0!==this.negative&&0===O.negative?(es=this.neg().divmod(O,U),"mod"!==U&&(J=es.div.neg()),"div"!==U&&(en=es.mod.neg(),$&&0!==en.negative&&en.iadd(O)),{div:J,mod:en}):0===this.negative&&0!==O.negative?(es=this.divmod(O.neg(),U),"mod"!==U&&(J=es.div.neg()),{div:J,mod:es.mod}):(this.negative&O.negative)!=0?(es=this.neg().divmod(O.neg(),U),"div"!==U&&(en=es.mod.neg(),$&&0!==en.negative&&en.isub(O)),{div:es.div,mod:en}):O.length>this.length||0>this.cmp(O)?{div:new BN(0),mod:this}:1===O.length?"div"===U?{div:this.divn(O.words[0]),mod:null}:"mod"===U?{div:null,mod:new BN(this.modrn(O.words[0]))}:{div:this.divn(O.words[0]),mod:new BN(this.modrn(O.words[0]))}:this._wordDiv(O,U)},BN.prototype.div=function(O){return this.divmod(O,"div",!1).div},BN.prototype.mod=function(O){return this.divmod(O,"mod",!1).mod},BN.prototype.umod=function(O){return this.divmod(O,"mod",!0).mod},BN.prototype.divRound=function(O){var U=this.divmod(O);if(U.mod.isZero())return U.div;var $=0!==U.div.negative?U.mod.isub(O):U.mod,J=O.ushrn(1),en=O.andln(1),es=$.cmp(J);return es<0||1===en&&0===es?U.div:0!==U.div.negative?U.div.isubn(1):U.div.iaddn(1)},BN.prototype.modrn=function(O){var U=O<0;U&&(O=-O),assert(O<=67108863);for(var $=67108864%O,J=0,en=this.length-1;en>=0;en--)J=($*J+(0|this.words[en]))%O;return U?-J:J},BN.prototype.modn=function(O){return this.modrn(O)},BN.prototype.idivn=function(O){var U=O<0;U&&(O=-O),assert(O<=67108863);for(var $=0,J=this.length-1;J>=0;J--){var en=(0|this.words[J])+67108864*$;this.words[J]=en/O|0,$=en%O}return this._strip(),U?this.ineg():this},BN.prototype.divn=function(O){return this.clone().idivn(O)},BN.prototype.egcd=function(O){assert(0===O.negative),assert(!O.isZero());var U=this,$=O.clone();U=0!==U.negative?U.umod(O):U.clone();for(var J=new BN(1),en=new BN(0),es=new BN(0),eo=new BN(1),ea=0;U.isEven()&&$.isEven();)U.iushrn(1),$.iushrn(1),++ea;for(var eu=$.clone(),ef=U.clone();!U.isZero();){for(var eg=0,ev=1;(U.words[0]&ev)==0&&eg<26;++eg,ev<<=1);if(eg>0)for(U.iushrn(eg);eg-- >0;)(J.isOdd()||en.isOdd())&&(J.iadd(eu),en.isub(ef)),J.iushrn(1),en.iushrn(1);for(var e_=0,ew=1;($.words[0]&ew)==0&&e_<26;++e_,ew<<=1);if(e_>0)for($.iushrn(e_);e_-- >0;)(es.isOdd()||eo.isOdd())&&(es.iadd(eu),eo.isub(ef)),es.iushrn(1),eo.iushrn(1);U.cmp($)>=0?(U.isub($),J.isub(es),en.isub(eo)):($.isub(U),es.isub(J),eo.isub(en))}return{a:es,b:eo,gcd:$.iushln(ea)}},BN.prototype._invmp=function(O){assert(0===O.negative),assert(!O.isZero());var U,$=this,J=O.clone();$=0!==$.negative?$.umod(O):$.clone();for(var en=new BN(1),es=new BN(0),eo=J.clone();$.cmpn(1)>0&&J.cmpn(1)>0;){for(var ea=0,eu=1;($.words[0]&eu)==0&&ea<26;++ea,eu<<=1);if(ea>0)for($.iushrn(ea);ea-- >0;)en.isOdd()&&en.iadd(eo),en.iushrn(1);for(var ef=0,eg=1;(J.words[0]&eg)==0&&ef<26;++ef,eg<<=1);if(ef>0)for(J.iushrn(ef);ef-- >0;)es.isOdd()&&es.iadd(eo),es.iushrn(1);$.cmp(J)>=0?($.isub(J),en.isub(es)):(J.isub($),es.isub(en))}return 0>(U=0===$.cmpn(1)?en:es).cmpn(0)&&U.iadd(O),U},BN.prototype.gcd=function(O){if(this.isZero())return O.abs();if(O.isZero())return this.abs();var U=this.clone(),$=O.clone();U.negative=0,$.negative=0;for(var J=0;U.isEven()&&$.isEven();J++)U.iushrn(1),$.iushrn(1);for(;;){for(;U.isEven();)U.iushrn(1);for(;$.isEven();)$.iushrn(1);var en=U.cmp($);if(en<0){var es=U;U=$,$=es}else if(0===en||0===$.cmpn(1))break;U.isub($)}return $.iushln(J)},BN.prototype.invm=function(O){return this.egcd(O).a.umod(O)},BN.prototype.isEven=function(){return(1&this.words[0])==0},BN.prototype.isOdd=function(){return(1&this.words[0])==1},BN.prototype.andln=function(O){return this.words[0]&O},BN.prototype.bincn=function(O){assert("number"==typeof O);var U=O%26,$=(O-U)/26,J=1<>>26,eo&=67108863,this.words[es]=eo}return 0!==en&&(this.words[es]=en,this.length++),this},BN.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},BN.prototype.cmpn=function(O){var U,$=O<0;if(0!==this.negative&&!$)return -1;if(0===this.negative&&$)return 1;if(this._strip(),this.length>1)U=1;else{$&&(O=-O),assert(O<=67108863,"Number is too big");var J=0|this.words[0];U=J===O?0:JO.length)return 1;if(this.length=0;$--){var J=0|this.words[$],en=0|O.words[$];if(J!==en){Jen&&(U=1);break}}return U},BN.prototype.gtn=function(O){return 1===this.cmpn(O)},BN.prototype.gt=function(O){return 1===this.cmp(O)},BN.prototype.gten=function(O){return this.cmpn(O)>=0},BN.prototype.gte=function(O){return this.cmp(O)>=0},BN.prototype.ltn=function(O){return -1===this.cmpn(O)},BN.prototype.lt=function(O){return -1===this.cmp(O)},BN.prototype.lten=function(O){return 0>=this.cmpn(O)},BN.prototype.lte=function(O){return 0>=this.cmp(O)},BN.prototype.eqn=function(O){return 0===this.cmpn(O)},BN.prototype.eq=function(O){return 0===this.cmp(O)},BN.red=function(O){return new Red(O)},BN.prototype.toRed=function(O){return assert(!this.red,"Already a number in reduction context"),assert(0===this.negative,"red works only with positives"),O.convertTo(this)._forceRed(O)},BN.prototype.fromRed=function(){return assert(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},BN.prototype._forceRed=function(O){return this.red=O,this},BN.prototype.forceRed=function(O){return assert(!this.red,"Already a number in reduction context"),this._forceRed(O)},BN.prototype.redAdd=function(O){return assert(this.red,"redAdd works only with red numbers"),this.red.add(this,O)},BN.prototype.redIAdd=function(O){return assert(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,O)},BN.prototype.redSub=function(O){return assert(this.red,"redSub works only with red numbers"),this.red.sub(this,O)},BN.prototype.redISub=function(O){return assert(this.red,"redISub works only with red numbers"),this.red.isub(this,O)},BN.prototype.redShl=function(O){return assert(this.red,"redShl works only with red numbers"),this.red.shl(this,O)},BN.prototype.redMul=function(O){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,O),this.red.mul(this,O)},BN.prototype.redIMul=function(O){return assert(this.red,"redMul works only with red numbers"),this.red._verify2(this,O),this.red.imul(this,O)},BN.prototype.redSqr=function(){return assert(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},BN.prototype.redISqr=function(){return assert(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},BN.prototype.redSqrt=function(){return assert(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},BN.prototype.redInvm=function(){return assert(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},BN.prototype.redNeg=function(){return assert(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},BN.prototype.redPow=function(O){return assert(this.red&&!O.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,O)};var ea={k256:null,p224:null,p192:null,p25519:null};function MPrime(O,U){this.name=O,this.p=new BN(U,16),this.n=this.p.bitLength(),this.k=new BN(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function K256(){MPrime.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function P224(){MPrime.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function P192(){MPrime.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function P25519(){MPrime.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function Red(O){if("string"==typeof O){var U=BN._prime(O);this.m=U.p,this.prime=U}else assert(O.gtn(1),"modulus must be greater than 1"),this.m=O,this.prime=null}function Mont(O){Red.call(this,O),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new BN(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)}MPrime.prototype._tmp=function(){var O=new BN(null);return O.words=Array(Math.ceil(this.n/13)),O},MPrime.prototype.ireduce=function(O){var U,$=O;do this.split($,this.tmp),U=($=($=this.imulK($)).iadd(this.tmp)).bitLength();while(U>this.n);var J=U0?$.isub(this.p):void 0!==$.strip?$.strip():$._strip(),$},MPrime.prototype.split=function(O,U){O.iushrn(this.n,0,U)},MPrime.prototype.imulK=function(O){return O.imul(this.k)},inherits(K256,MPrime),K256.prototype.split=function(O,U){for(var $=4194303,J=Math.min(O.length,9),en=0;en>>22,es=eo}es>>>=22,O.words[en-10]=es,0===es&&O.length>10?O.length-=10:O.length-=9},K256.prototype.imulK=function(O){O.words[O.length]=0,O.words[O.length+1]=0,O.length+=2;for(var U=0,$=0;$>>=26,O.words[$]=en,U=J}return 0!==U&&(O.words[O.length++]=U),O},BN._prime=function(O){var U;if(ea[O])return ea[O];if("k256"===O)U=new K256;else if("p224"===O)U=new P224;else if("p192"===O)U=new P192;else if("p25519"===O)U=new P25519;else throw Error("Unknown prime "+O);return ea[O]=U,U},Red.prototype._verify1=function(O){assert(0===O.negative,"red works only with positives"),assert(O.red,"red works only with red numbers")},Red.prototype._verify2=function(O,U){assert((O.negative|U.negative)==0,"red works only with positives"),assert(O.red&&O.red===U.red,"red works only with red numbers")},Red.prototype.imod=function(O){return this.prime?this.prime.ireduce(O)._forceRed(this):(move(O,O.umod(this.m)._forceRed(this)),O)},Red.prototype.neg=function(O){return O.isZero()?O.clone():this.m.sub(O)._forceRed(this)},Red.prototype.add=function(O,U){this._verify2(O,U);var $=O.add(U);return $.cmp(this.m)>=0&&$.isub(this.m),$._forceRed(this)},Red.prototype.iadd=function(O,U){this._verify2(O,U);var $=O.iadd(U);return $.cmp(this.m)>=0&&$.isub(this.m),$},Red.prototype.sub=function(O,U){this._verify2(O,U);var $=O.sub(U);return 0>$.cmpn(0)&&$.iadd(this.m),$._forceRed(this)},Red.prototype.isub=function(O,U){this._verify2(O,U);var $=O.isub(U);return 0>$.cmpn(0)&&$.iadd(this.m),$},Red.prototype.shl=function(O,U){return this._verify1(O),this.imod(O.ushln(U))},Red.prototype.imul=function(O,U){return this._verify2(O,U),this.imod(O.imul(U))},Red.prototype.mul=function(O,U){return this._verify2(O,U),this.imod(O.mul(U))},Red.prototype.isqr=function(O){return this.imul(O,O.clone())},Red.prototype.sqr=function(O){return this.mul(O,O)},Red.prototype.sqrt=function(O){if(O.isZero())return O.clone();var U=this.m.andln(3);if(assert(U%2==1),3===U){var $=this.m.add(new BN(1)).iushrn(2);return this.pow(O,$)}for(var J=this.m.subn(1),en=0;!J.isZero()&&0===J.andln(1);)en++,J.iushrn(1);assert(!J.isZero());var es=new BN(1).toRed(this),eo=es.redNeg(),ea=this.m.subn(1).iushrn(1),eu=this.m.bitLength();for(eu=new BN(2*eu*eu).toRed(this);0!==this.pow(eu,ea).cmp(eo);)eu.redIAdd(eo);for(var ef=this.pow(eu,J),eg=this.pow(O,J.addn(1).iushrn(1)),ev=this.pow(O,J),e_=en;0!==ev.cmp(es);){for(var ew=ev,eE=0;0!==ew.cmp(es);eE++)ew=ew.redSqr();assert(eE=0;en--){for(var ef=U.words[en],eg=eu-1;eg>=0;eg--){var ev=ef>>eg&1;if(es!==J[0]&&(es=this.sqr(es)),0===ev&&0===eo){ea=0;continue}eo<<=1,eo|=ev,(++ea===$||0===en&&0===eg)&&(es=this.mul(es,J[eo]),ea=0,eo=0)}eu=26}return es},Red.prototype.convertTo=function(O){var U=O.umod(this.m);return U===O?U.clone():U},Red.prototype.convertFrom=function(O){var U=O.clone();return U.red=null,U},BN.mont=function(O){return new Mont(O)},inherits(Mont,Red),Mont.prototype.convertTo=function(O){return this.imod(O.ushln(this.shift))},Mont.prototype.convertFrom=function(O){var U=this.imod(O.mul(this.rinv));return U.red=null,U},Mont.prototype.imul=function(O,U){if(O.isZero()||U.isZero())return O.words[0]=0,O.length=1,O;var $=O.imul(U),J=$.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),en=$.isub(J).iushrn(this.shift),es=en;return en.cmp(this.m)>=0?es=en.isub(this.m):0>en.cmpn(0)&&(es=en.iadd(this.m)),es._forceRed(this)},Mont.prototype.mul=function(O,U){if(O.isZero()||U.isZero())return new BN(0)._forceRed(this);var $=O.mul(U),J=$.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),en=$.isub(J).iushrn(this.shift),es=en;return en.cmp(this.m)>=0?es=en.isub(this.m):0>en.cmpn(0)&&(es=en.iadd(this.m)),es._forceRed(this)},Mont.prototype.invm=function(O){return this.imod(O._invmp(this.m).mul(this.r2))._forceRed(this)}}(O=$.nmd(O),this)},4461:function(O,U,$){var J=$(2601);function useColors(){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+)/))}function formatArgs(U){if(U[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+U[0]+(this.useColors?"%c ":" ")+"+"+O.exports.humanize(this.diff),!this.useColors)return;let $="color: "+this.color;U.splice(1,0,$,"color: inherit");let J=0,en=0;U[0].replace(/%[a-zA-Z%]/g,O=>{"%%"!==O&&(J++,"%c"===O&&(en=J))}),U.splice(en,0,$)}function save(O){try{O?U.storage.setItem("debug",O):U.storage.removeItem("debug")}catch(O){}}function load(){let O;try{O=U.storage.getItem("debug")}catch(O){}return!O&&void 0!==J&&"env"in J&&(O=J.env.DEBUG),O}function localstorage(){try{return localStorage}catch(O){}}U.formatArgs=formatArgs,U.save=save,U.load=load,U.useColors=useColors,U.storage=localstorage(),U.destroy=(()=>{let O=!1;return()=>{O||(O=!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`."))}})(),U.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"],U.log=console.debug||console.log||(()=>{}),O.exports=$(4239)(U);let{formatters:en}=O.exports;en.j=function(O){try{return JSON.stringify(O)}catch(O){return"[UnexpectedJSONParseError]: "+O.message}}},4239:function(O,U,$){function setup(O){function selectColor(O){let U=0;for(let $=0;${if("%%"===U)return"%";es++;let en=createDebug.formatters[J];if("function"==typeof en){let J=O[es];U=en.call($,J),O.splice(es,1),es--}return U}),createDebug.formatArgs.call($,O);let eo=$.log||createDebug.log;eo.apply($,O)}return debug.namespace=O,debug.useColors=createDebug.useColors(),debug.color=createDebug.selectColor(O),debug.extend=extend,debug.destroy=createDebug.destroy,Object.defineProperty(debug,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==en?en:($!==createDebug.namespaces&&($=createDebug.namespaces,J=createDebug.enabled(O)),J),set:O=>{en=O}}),"function"==typeof createDebug.init&&createDebug.init(debug),debug}function extend(O,U){let $=createDebug(this.namespace+(void 0===U?":":U)+O);return $.log=this.log,$}function enable(O){let U;createDebug.save(O),createDebug.namespaces=O,createDebug.names=[],createDebug.skips=[];let $=("string"==typeof O?O:"").split(/[\s,]+/),J=$.length;for(U=0;U"-"+O)].join(",");return createDebug.enable(""),O}function enabled(O){let U,$;if("*"===O[O.length-1])return!0;for(U=0,$=createDebug.skips.length;U<$;U++)if(createDebug.skips[U].test(O))return!1;for(U=0,$=createDebug.names.length;U<$;U++)if(createDebug.names[U].test(O))return!0;return!1}function toNamespace(O){return O.toString().substring(2,O.toString().length-2).replace(/\.\*\?$/,"*")}function coerce(O){return O instanceof Error?O.stack||O.message:O}function destroy(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return createDebug.debug=createDebug,createDebug.default=createDebug,createDebug.coerce=coerce,createDebug.disable=disable,createDebug.enable=enable,createDebug.enabled=enabled,createDebug.humanize=$(438),createDebug.destroy=destroy,Object.keys(O).forEach(U=>{createDebug[U]=O[U]}),createDebug.names=[],createDebug.skips=[],createDebug.formatters={},createDebug.selectColor=selectColor,createDebug.enable(createDebug.load()),createDebug}O.exports=setup},2185:function(O){"use strict";function Denque(O,U){var U=U||{};this._capacity=U.capacity,this._head=0,this._tail=0,Array.isArray(O)?this._fromArray(O):(this._capacityMask=3,this._list=[,,,,])}Denque.prototype.peekAt=function(O){var U=O;if(U===(0|U)){var $=this.size();if(!(U>=$)&&!(U<-$))return U<0&&(U+=$),U=this._head+U&this._capacityMask,this._list[U]}},Denque.prototype.get=function(O){return this.peekAt(O)},Denque.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},Denque.prototype.peekFront=function(){return this.peek()},Denque.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(Denque.prototype,"length",{get:function(){return this.size()}}),Denque.prototype.size=function(){return this._head===this._tail?0:this._headthis._capacity&&this.pop(),this._head1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),U}},Denque.prototype.push=function(O){if(0==arguments.length)return this.size();var U=this._tail;return(this._list[U]=O,this._tail=U+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head1e4&&O<=U>>>2&&this._shrinkArray(),$}},Denque.prototype.removeOne=function(O){var U,$=O;if($===(0|$)&&this._head!==this._tail){var J=this.size(),en=this._list.length;if(!($>=J)&&!($<-J)){$<0&&($+=J),$=this._head+$&this._capacityMask;var es=this._list[$];if(O0;U--)this._list[$]=this._list[$=$-1+en&this._capacityMask];this._list[$]=void 0,this._head=this._head+1+en&this._capacityMask}else{for(U=J-1-O;U>0;U--)this._list[$]=this._list[$=$+1+en&this._capacityMask];this._list[$]=void 0,this._tail=this._tail-1+en&this._capacityMask}return es}}},Denque.prototype.remove=function(O,U){var $,J,en=O,es=U;if(en===(0|en)&&this._head!==this._tail){var eo=this.size(),ea=this._list.length;if(!(en>=eo)&&!(en<-eo)&&!(U<1)){if(en<0&&(en+=eo),1===U||!U)return($=[,])[0]=this.removeOne(en),$;if(0===en&&en+U>=eo)return $=this.toArray(),this.clear(),$;for(en+U>eo&&(U=eo-en),$=Array(U),J=0;J0;J--)this._list[en=en+1+ea&this._capacityMask]=void 0;return $}if(0===O){for(this._head=this._head+U+ea&this._capacityMask,J=U-1;J>0;J--)this._list[en=en+1+ea&this._capacityMask]=void 0;return $}if(en0;J--)this.unshift(this._list[en=en-1+ea&this._capacityMask]);for(en=this._head-1+ea&this._capacityMask;es>0;)this._list[en=en-1+ea&this._capacityMask]=void 0,es--;O<0&&(this._tail=en)}else{for(this._tail=en,en=en+U+ea&this._capacityMask,J=eo-(U+O);J>0;J--)this.push(this._list[en++]);for(en=this._tail;es>0;)this._list[en=en+1+ea&this._capacityMask]=void 0,es--}return this._head<2&&this._tail>1e4&&this._tail<=ea>>>2&&this._shrinkArray(),$}}},Denque.prototype.splice=function(O,U){var $=O;if($===(0|$)){var J=this.size();if($<0&&($+=J),!($>J)){if(!(arguments.length>2))return this.remove($,U);var en,es,eo,ea=arguments.length,eu=this._list.length,ef=2;if(!J||$0&&(this._head=this._head+$+eu&this._capacityMask)):(eo=this.remove($,U),this._head=this._head+$+eu&this._capacityMask);ea>ef;)this.unshift(arguments[--ea]);for(en=$;en>0;en--)this.unshift(es[en-1])}else{var eg=(es=Array(J-($+U))).length;for(en=0;enthis._tail){for($=this._head;$>>=1,this._capacityMask>>>=1},Denque.prototype._nextPowerOf2=function(O){return Math.max(1<(this.addEventListener(O,$,U),()=>this.removeEventListener(O,$,U)),$)},en.EventIterator},9831:function(O,U){"use strict";Object.defineProperty(U,"__esModule",{value:!0});let EventQueue=class EventQueue{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(O){if(this.isStopped)return;let U={value:O,done:!1};if(this.pullQueue.length){let O=this.pullQueue.shift();O&&O.resolve(U)}else this.pushQueue.push(Promise.resolve(U)),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){for(let O of(this.isStopped=!0,this.remove(),this.pullQueue))O.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(O){if(!this.isStopped){if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(let U of this.pullQueue)U.reject(O);this.pullQueue.length=0}else{let U=Promise.reject(O);U.catch(()=>{}),this.pushQueue.push(U)}}}remove(){Promise.resolve().then(()=>{this.removeCallback&&this.removeCallback()})}[Symbol.asyncIterator](){return{next:O=>{let U=this.pushQueue.shift();return U?(void 0!==this.lowWaterMark&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),U):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise((O,U)=>{this.pullQueue.push({resolve:O,reject:U})})},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}};let EventIterator=class EventIterator{constructor(O,{highWaterMark:U=100,lowWaterMark:$=1}={}){let J=new EventQueue;J.highWaterMark=U,J.lowWaterMark=$,J.removeCallback=O({push:O=>J.push(O),stop:()=>J.stop(),fail:O=>J.fail(O),on:(O,U)=>{J.eventHandlers[O]=U}})||(()=>{}),this[Symbol.asyncIterator]=()=>J[Symbol.asyncIterator](),Object.freeze(this)}};U.EventIterator=EventIterator,U.default=EventIterator},8729:function(O){"use strict";var U=Object.prototype.hasOwnProperty,$="~";function Events(){}function EE(O,U,$){this.fn=O,this.context=U,this.once=$||!1}function addListener(O,U,J,en,es){if("function"!=typeof J)throw TypeError("The listener must be a function");var eo=new EE(J,en||O,es),ea=$?$+U:U;return O._events[ea]?O._events[ea].fn?O._events[ea]=[O._events[ea],eo]:O._events[ea].push(eo):(O._events[ea]=eo,O._eventsCount++),O}function clearEvent(O,U){0==--O._eventsCount?O._events=new Events:delete O._events[U]}function EventEmitter(){this._events=new Events,this._eventsCount=0}Object.create&&(Events.prototype=Object.create(null),new Events().__proto__||($=!1)),EventEmitter.prototype.eventNames=function(){var O,J,en=[];if(0===this._eventsCount)return en;for(J in O=this._events)U.call(O,J)&&en.push($?J.slice(1):J);return Object.getOwnPropertySymbols?en.concat(Object.getOwnPropertySymbols(O)):en},EventEmitter.prototype.listeners=function(O){var U=$?$+O:O,J=this._events[U];if(!J)return[];if(J.fn)return[J.fn];for(var en=0,es=J.length,eo=Array(es);en0&&eo.length>en&&!eo.warned){eo.warned=!0;var en,es,eo,ea=Error("Possible EventEmitter memory leak detected. "+eo.length+" "+String(U)+" listeners added. Use emitter.setMaxListeners() to increase limit");ea.name="MaxListenersExceededWarning",ea.emitter=O,ea.type=U,ea.count=eo.length,ProcessEmitWarning(ea)}return O}function onceWrapper(){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 _onceWrap(O,U,$){var J={fired:!1,wrapFn:void 0,target:O,type:U,listener:$},en=onceWrapper.bind(J);return en.listener=$,J.wrapFn=en,en}function _listeners(O,U,$){var J=O._events;if(void 0===J)return[];var en=J[U];return void 0===en?[]:"function"==typeof en?$?[en.listener||en]:[en]:$?unwrapListeners(en):arrayClone(en,en.length)}function listenerCount(O){var U=this._events;if(void 0!==U){var $=U[O];if("function"==typeof $)return 1;if(void 0!==$)return $.length}return 0}function arrayClone(O,U){for(var $=Array(U),J=0;J0&&(eo=U[0]),eo instanceof Error)throw eo;var eo,ea=Error("Unhandled error."+(eo?" ("+eo.message+")":""));throw ea.context=eo,ea}var eu=es[O];if(void 0===eu)return!1;if("function"==typeof eu)J(eu,this,U);else for(var ef=eu.length,eg=arrayClone(eu,ef),$=0;$=0;es--)if($[es]===U||$[es].listener===U){eo=$[es].listener,en=es;break}if(en<0)return this;0===en?$.shift():spliceOne($,en),1===$.length&&(J[O]=$[0]),void 0!==J.removeListener&&this.emit("removeListener",O,eo||U)}return this},EventEmitter.prototype.off=EventEmitter.prototype.removeListener,EventEmitter.prototype.removeAllListeners=function(O){var U,$,J;if(void 0===($=this._events))return this;if(void 0===$.removeListener)return 0==arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==$[O]&&(0==--this._eventsCount?this._events=Object.create(null):delete $[O]),this;if(0==arguments.length){var en,es=Object.keys($);for(J=0;J=0;J--)this.removeListener(O,U[J]);return this},EventEmitter.prototype.listeners=function(O){return _listeners(this,O,!0)},EventEmitter.prototype.rawListeners=function(O){return _listeners(this,O,!1)},EventEmitter.listenerCount=function(O,U){return"function"==typeof O.listenerCount?O.listenerCount(U):listenerCount.call(O,U)},EventEmitter.prototype.listenerCount=listenerCount,EventEmitter.prototype.eventNames=function(){return this._eventsCount>0?U(this._events):[]}},5336:function(O,U,$){var J=U;J.utils=$(5794),J.common=$(9619),J.sha=$(3610),J.ripemd=$(7721),J.hmac=$(6432),J.sha1=J.sha.sha1,J.sha256=J.sha.sha256,J.sha224=J.sha.sha224,J.sha384=J.sha.sha384,J.sha512=J.sha.sha512,J.ripemd160=J.ripemd.ripemd160},9619:function(O,U,$){"use strict";var J=$(5794),en=$(8786);function BlockHash(){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}U.BlockHash=BlockHash,BlockHash.prototype.update=function(O,U){if(O=J.toArray(O,U),this.pending?this.pending=this.pending.concat(O):this.pending=O,this.pendingTotal+=O.length,this.pending.length>=this._delta8){var $=(O=this.pending).length%this._delta8;this.pending=O.slice(O.length-$,O.length),0===this.pending.length&&(this.pending=null),O=J.join32(O,0,O.length-$,this.endian);for(var en=0;en>>24&255,J[en++]=O>>>16&255,J[en++]=O>>>8&255,J[en++]=255&O}else for(es=8,J[en++]=255&O,J[en++]=O>>>8&255,J[en++]=O>>>16&255,J[en++]=O>>>24&255,J[en++]=0,J[en++]=0,J[en++]=0,J[en++]=0;esthis.blockSize&&(O=new this.Hash().update(O).digest()),en(O.length<=this.blockSize);for(var U=O.length;U>>3}function g1_256(O){return J(O,17)^J(O,19)^O>>>10}U.ft_1=ft_1,U.ch32=ch32,U.maj32=maj32,U.p32=p32,U.s0_256=s0_256,U.s1_256=s1_256,U.g0_256=g0_256,U.g1_256=g1_256},5794:function(O,U,$){"use strict";var J=$(8786),en=$(5335);function isSurrogatePair(O,U){return(64512&O.charCodeAt(U))==55296&&!(U<0)&&!(U+1>=O.length)&&(64512&O.charCodeAt(U+1))==56320}function toArray(O,U){if(Array.isArray(O))return O.slice();if(!O)return[];var $=[];if("string"==typeof O){if(U){if("hex"===U)for((O=O.replace(/[^a-z0-9]+/ig,"")).length%2!=0&&(O="0"+O),en=0;en>6|192:(isSurrogatePair(O,en)?(es=65536+((1023&es)<<10)+(1023&O.charCodeAt(++en)),$[J++]=es>>18|240,$[J++]=es>>12&63|128):$[J++]=es>>12|224,$[J++]=es>>6&63|128),$[J++]=63&es|128)}}else for(en=0;en>>24|O>>>8&65280|O<<8&16711680|(255&O)<<24)>>>0}function toHex32(O,U){for(var $="",J=0;J>>0;return ea}function split32(O,U){for(var $=Array(4*O.length),J=0,en=0;J>>24,$[en+1]=es>>>16&255,$[en+2]=es>>>8&255,$[en+3]=255&es):($[en+3]=es>>>24,$[en+2]=es>>>16&255,$[en+1]=es>>>8&255,$[en]=255&es)}return $}function rotr32(O,U){return O>>>U|O<<32-U}function rotl32(O,U){return O<>>32-U}function sum32(O,U){return O+U>>>0}function sum32_3(O,U,$){return O+U+$>>>0}function sum32_4(O,U,$,J){return O+U+$+J>>>0}function sum32_5(O,U,$,J,en){return O+U+$+J+en>>>0}function sum64(O,U,$,J){var en=O[U],es=J+O[U+1]>>>0,eo=(es>>0,O[U+1]=es}function sum64_hi(O,U,$,J){return(U+J>>>0>>0}function sum64_lo(O,U,$,J){return U+J>>>0}function sum64_4_hi(O,U,$,J,en,es,eo,ea){var eu,ef=U;return O+$+en+eo+(eu=0+((ef=ef+J>>>0)>>0)>>0)>>0}function sum64_4_lo(O,U,$,J,en,es,eo,ea){return U+J+es+ea>>>0}function sum64_5_hi(O,U,$,J,en,es,eo,ea,eu,ef){var eg,ev=U;return O+$+en+eo+eu+(eg=0+((ev=ev+J>>>0)>>0)>>0)>>0)>>0}function sum64_5_lo(O,U,$,J,en,es,eo,ea,eu,ef){return U+J+es+ea+ef>>>0}function rotr64_hi(O,U,$){return(U<<32-$|O>>>$)>>>0}function rotr64_lo(O,U,$){return(O<<32-$|U>>>$)>>>0}function shr64_hi(O,U,$){return O>>>$}function shr64_lo(O,U,$){return(O<<32-$|U>>>$)>>>0}U.inherits=en,U.toArray=toArray,U.toHex=toHex,U.htonl=htonl,U.toHex32=toHex32,U.zero2=zero2,U.zero8=zero8,U.join32=join32,U.split32=split32,U.rotr32=rotr32,U.rotl32=rotl32,U.sum32=sum32,U.sum32_3=sum32_3,U.sum32_4=sum32_4,U.sum32_5=sum32_5,U.sum64=sum64,U.sum64_hi=sum64_hi,U.sum64_lo=sum64_lo,U.sum64_4_hi=sum64_4_hi,U.sum64_4_lo=sum64_4_lo,U.sum64_5_hi=sum64_5_hi,U.sum64_5_lo=sum64_5_lo,U.rotr64_hi=rotr64_hi,U.rotr64_lo=rotr64_lo,U.shr64_hi=shr64_hi,U.shr64_lo=shr64_lo},7935:function(O,U,$){var J,en=$(2601);!function(){"use strict";var U="object"==typeof window?window:{};!U.HI_BASE32_NO_NODE_JS&&"object"==typeof en&&en.versions&&en.versions.node&&(U=$.g);var es=!U.HI_BASE32_NO_COMMON_JS&&O.exports,eo=$.amdO,ea="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".split(""),eu={A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,2:26,3:27,4:28,5:29,6:30,7:31},ef=[0,0,0,0,0,0,0,0],throwInvalidUtf8=function(O,U){U.length>10&&(U="..."+U.substr(-10));var $=Error("Decoded data is not valid UTF-8. Maybe try base32.decode.asBytes()? Partial data after reading "+O+" bytes: "+U+" <-");throw $.position=O,$},toUtf8String=function(O){for(var U,$,J="",en=O.length,es=0,eo=0;es191&&U<=223?($=31&U,eo=1):U<=239?($=15&U,eo=2):U<=247?($=7&U,eo=3):throwInvalidUtf8(es,J);for(var ea=0;ea191)&&throwInvalidUtf8(es,J),$<<=6,$+=63&U;$>=55296&&$<=57343&&throwInvalidUtf8(es,J),$>1114111&&throwInvalidUtf8(es,J),$<=65535?J+=String.fromCharCode($):($-=65536,J+=String.fromCharCode(($>>10)+55296)+String.fromCharCode((1023&$)+56320))}return J},decodeAsBytes=function(O){if(""===O)return[];if(!/^[A-Z2-7=]+$/.test(O))throw Error("Invalid base32 characters");O=O.replace(/=/g,"");for(var U,$,J,en,es,eo,ea,ef,eg=[],ev=0,e_=O.length,ew=0,eE=e_>>3<<3;ew>>2)&255,eg[ev++]=($<<6|J<<1|en>>>4)&255,eg[ev++]=(en<<4|es>>>1)&255,eg[ev++]=(es<<7|eo<<2|ea>>>3)&255,eg[ev++]=(ea<<5|ef)&255;var eS=e_-eE;return 2===eS?(U=eu[O.charAt(ew++)],$=eu[O.charAt(ew++)],eg[ev++]=(U<<3|$>>>2)&255):4===eS?(U=eu[O.charAt(ew++)],$=eu[O.charAt(ew++)],J=eu[O.charAt(ew++)],en=eu[O.charAt(ew++)],eg[ev++]=(U<<3|$>>>2)&255,eg[ev++]=($<<6|J<<1|en>>>4)&255):5===eS?(U=eu[O.charAt(ew++)],$=eu[O.charAt(ew++)],J=eu[O.charAt(ew++)],en=eu[O.charAt(ew++)],es=eu[O.charAt(ew++)],eg[ev++]=(U<<3|$>>>2)&255,eg[ev++]=($<<6|J<<1|en>>>4)&255,eg[ev++]=(en<<4|es>>>1)&255):7===eS&&(U=eu[O.charAt(ew++)],$=eu[O.charAt(ew++)],J=eu[O.charAt(ew++)],en=eu[O.charAt(ew++)],es=eu[O.charAt(ew++)],eo=eu[O.charAt(ew++)],ea=eu[O.charAt(ew++)],eg[ev++]=(U<<3|$>>>2)&255,eg[ev++]=($<<6|J<<1|en>>>4)&255,eg[ev++]=(en<<4|es>>>1)&255,eg[ev++]=(es<<7|eo<<2|ea>>>3)&255),eg},encodeAscii=function(O){for(var U,$,J,en,es,eo="",eu=O.length,ef=0,eg=5*parseInt(eu/5);ef>>3]+ea[(U<<2|$>>>6)&31]+ea[$>>>1&31]+ea[($<<4|J>>>4)&31]+ea[(J<<1|en>>>7)&31]+ea[en>>>2&31]+ea[(en<<3|es>>>5)&31]+ea[31&es];var ev=eu-eg;return 1===ev?eo+=ea[(U=O.charCodeAt(ef))>>>3]+ea[U<<2&31]+"======":2===ev?(U=O.charCodeAt(ef++),$=O.charCodeAt(ef),eo+=ea[U>>>3]+ea[(U<<2|$>>>6)&31]+ea[$>>>1&31]+ea[$<<4&31]+"===="):3===ev?(U=O.charCodeAt(ef++),$=O.charCodeAt(ef++),J=O.charCodeAt(ef),eo+=ea[U>>>3]+ea[(U<<2|$>>>6)&31]+ea[$>>>1&31]+ea[($<<4|J>>>4)&31]+ea[J<<1&31]+"==="):4===ev&&(U=O.charCodeAt(ef++),$=O.charCodeAt(ef++),J=O.charCodeAt(ef++),en=O.charCodeAt(ef),eo+=ea[U>>>3]+ea[(U<<2|$>>>6)&31]+ea[$>>>1&31]+ea[($<<4|J>>>4)&31]+ea[(J<<1|en>>>7)&31]+ea[en>>>2&31]+ea[en<<3&31]+"="),eo},encodeUtf8=function(O){var U,$,J,en,es,eo,eu,eg=!1,ev="",e_=0,ew=0,eE=0,eS=O.length;if(""===O)return ev;do{for(ef[0]=ef[5],ef[1]=ef[6],ef[2]=ef[7],eu=ew;e_>6:(eo<55296||eo>=57344?ef[eu++]=224|eo>>12:(eo=65536+((1023&eo)<<10|1023&O.charCodeAt(++e_)),ef[eu++]=240|eo>>18,ef[eu++]=128|eo>>12&63),ef[eu++]=128|eo>>6&63),ef[eu++]=128|63&eo);eE+=eu-ew,ew=eu-5,e_===eS&&++e_,e_>eS&&eu<6&&(eg=!0),U=ef[0],eu>4?($=ef[1],J=ef[2],en=ef[3],es=ef[4],ev+=ea[U>>>3]+ea[(U<<2|$>>>6)&31]+ea[$>>>1&31]+ea[($<<4|J>>>4)&31]+ea[(J<<1|en>>>7)&31]+ea[en>>>2&31]+ea[(en<<3|es>>>5)&31]+ea[31&es]):1===eu?ev+=ea[U>>>3]+ea[U<<2&31]+"======":2===eu?($=ef[1],ev+=ea[U>>>3]+ea[(U<<2|$>>>6)&31]+ea[$>>>1&31]+ea[$<<4&31]+"===="):3===eu?($=ef[1],J=ef[2],ev+=ea[U>>>3]+ea[(U<<2|$>>>6)&31]+ea[$>>>1&31]+ea[($<<4|J>>>4)&31]+ea[J<<1&31]+"==="):($=ef[1],J=ef[2],en=ef[3],ev+=ea[U>>>3]+ea[(U<<2|$>>>6)&31]+ea[$>>>1&31]+ea[($<<4|J>>>4)&31]+ea[(J<<1|en>>>7)&31]+ea[en>>>2&31]+ea[en<<3&31]+"=")}while(!eg);return ev},encodeBytes=function(O){for(var U,$,J,en,es,eo="",eu=O.length,ef=0,eg=5*parseInt(eu/5);ef>>3]+ea[(U<<2|$>>>6)&31]+ea[$>>>1&31]+ea[($<<4|J>>>4)&31]+ea[(J<<1|en>>>7)&31]+ea[en>>>2&31]+ea[(en<<3|es>>>5)&31]+ea[31&es];var ev=eu-eg;return 1===ev?eo+=ea[(U=O[ef])>>>3]+ea[U<<2&31]+"======":2===ev?(U=O[ef++],$=O[ef],eo+=ea[U>>>3]+ea[(U<<2|$>>>6)&31]+ea[$>>>1&31]+ea[$<<4&31]+"===="):3===ev?(U=O[ef++],$=O[ef++],J=O[ef],eo+=ea[U>>>3]+ea[(U<<2|$>>>6)&31]+ea[$>>>1&31]+ea[($<<4|J>>>4)&31]+ea[J<<1&31]+"==="):4===ev&&(U=O[ef++],$=O[ef++],J=O[ef++],en=O[ef],eo+=ea[U>>>3]+ea[(U<<2|$>>>6)&31]+ea[$>>>1&31]+ea[($<<4|J>>>4)&31]+ea[(J<<1|en>>>7)&31]+ea[en>>>2&31]+ea[en<<3&31]+"="),eo},decode=function(O,U){if(!U)return toUtf8String(decodeAsBytes(O));if(""===O)return"";if(!/^[A-Z2-7=]+$/.test(O))throw Error("Invalid base32 characters");var $,J,en,es,eo,ea,ef,eg,ev="",e_=O.indexOf("=");-1===e_&&(e_=O.length);for(var ew=0,eE=e_>>3<<3;ew>>2)&255)+String.fromCharCode((J<<6|en<<1|es>>>4)&255)+String.fromCharCode((es<<4|eo>>>1)&255)+String.fromCharCode((eo<<7|ea<<2|ef>>>3)&255)+String.fromCharCode((ef<<5|eg)&255);var eS=e_-eE;return 2===eS?ev+=String.fromCharCode((($=eu[O.charAt(ew++)])<<3|(J=eu[O.charAt(ew++)])>>>2)&255):4===eS?($=eu[O.charAt(ew++)],J=eu[O.charAt(ew++)],en=eu[O.charAt(ew++)],es=eu[O.charAt(ew++)],ev+=String.fromCharCode(($<<3|J>>>2)&255)+String.fromCharCode((J<<6|en<<1|es>>>4)&255)):5===eS?($=eu[O.charAt(ew++)],J=eu[O.charAt(ew++)],en=eu[O.charAt(ew++)],es=eu[O.charAt(ew++)],eo=eu[O.charAt(ew++)],ev+=String.fromCharCode(($<<3|J>>>2)&255)+String.fromCharCode((J<<6|en<<1|es>>>4)&255)+String.fromCharCode((es<<4|eo>>>1)&255)):7===eS&&($=eu[O.charAt(ew++)],J=eu[O.charAt(ew++)],en=eu[O.charAt(ew++)],es=eu[O.charAt(ew++)],eo=eu[O.charAt(ew++)],ea=eu[O.charAt(ew++)],ef=eu[O.charAt(ew++)],ev+=String.fromCharCode(($<<3|J>>>2)&255)+String.fromCharCode((J<<6|en<<1|es>>>4)&255)+String.fromCharCode((es<<4|eo>>>1)&255)+String.fromCharCode((eo<<7|ea<<2|ef>>>3)&255)),ev},eg={encode:function(O,U){var $="string"!=typeof O;return($&&O.constructor===ArrayBuffer&&(O=new Uint8Array(O)),$)?encodeBytes(O):U?encodeAscii(O):encodeUtf8(O)},decode:decode};decode.asBytes=decodeAsBytes,es?O.exports=eg:(U.base32=eg,eo&&void 0!==(J=(function(){return eg}).call(eg,$,eg,O))&&(O.exports=J))}()},5335:function(O){"function"==typeof Object.create?O.exports=function(O,U){U&&(O.super_=U,O.prototype=Object.create(U.prototype,{constructor:{value:O,enumerable:!1,writable:!0,configurable:!0}}))}:O.exports=function(O,U){if(U){O.super_=U;var TempCtor=function(){};TempCtor.prototype=U.prototype,O.prototype=new TempCtor,O.prototype.constructor=O}}},9173:function(O){!function(U){"use strict";let $="(0?\\d+|0x[a-f0-9]+)",J={fourOctet:RegExp(`^${$}\\.${$}\\.${$}\\.${$}$`,"i"),threeOctet:RegExp(`^${$}\\.${$}\\.${$}$`,"i"),twoOctet:RegExp(`^${$}\\.${$}$`,"i"),longValue:RegExp(`^${$}$`,"i")},en=RegExp("^0[0-7]+$","i"),es=RegExp("^0x[a-f0-9]+$","i"),eo="%[0-9a-z]{1,}",ea="(?:[0-9a-f]+::?)+",eu={zoneIndex:RegExp(eo,"i"),native:RegExp(`^(::)?(${ea})?([0-9a-f]+)?(::)?(${eo})?$`,"i"),deprecatedTransitional:RegExp(`^(?:::)(${$}\\.${$}\\.${$}\\.${$}(${eo})?)$`,"i"),transitional:RegExp(`^((?:${ea})|(?:::)(?:${ea})?)${$}\\.${$}\\.${$}\\.${$}(${eo})?$`,"i")};function expandIPv6(O,U){let $,J;if(O.indexOf("::")!==O.lastIndexOf("::"))return null;let en=0,es=-1,eo=(O.match(eu.zoneIndex)||[])[0];for(eo&&(eo=eo.substring(1),O=O.replace(/%.+$/,""));(es=O.indexOf(":",es+1))>=0;)en++;if("::"===O.substr(0,2)&&en--,"::"===O.substr(-2,2)&&en--,en>U)return null;for(J=U-en,$=":";J--;)$+="0:";return":"===(O=O.replace("::",$))[0]&&(O=O.slice(1)),":"===O[O.length-1]&&(O=O.slice(0,-1)),{parts:U=function(){let U=O.split(":"),$=[];for(let O=0;O0;){if((en=$-J)<0&&(en=0),O[es]>>en!=U[es]>>en)return!1;J-=$,es+=1}return!0}function parseIntAuto(O){if(es.test(O))return parseInt(O,16);if("0"===O[0]&&!isNaN(parseInt(O[1],10))){if(en.test(O))return parseInt(O,8);throw Error(`ipaddr: cannot parse ${O} as octal`)}return parseInt(O,10)}function padPart(O,U){for(;O.length=0;O-=1){if(!((U=this.octets[O])in es)||($=es[U],en&&0!==$))return null;8!==$&&(en=!0),J+=$}return 32-J},IPv4.prototype.range=function(){return ef.subnetMatch(this,this.SpecialRanges)},IPv4.prototype.toByteArray=function(){return this.octets.slice(0)},IPv4.prototype.toIPv4MappedAddress=function(){return ef.IPv6.parse(`::ffff:${this.toString()}`)},IPv4.prototype.toNormalizedString=function(){return this.toString()},IPv4.prototype.toString=function(){return this.octets.join(".")},IPv4}(),ef.IPv4.broadcastAddressFromCIDR=function(O){try{let U=this.parseCIDR(O),$=U[0].toByteArray(),J=this.subnetMaskFromPrefixLength(U[1]).toByteArray(),en=[],es=0;for(;es<4;)en.push(parseInt($[es],10)|255^parseInt(J[es],10)),es++;return new this(en)}catch(O){throw Error("ipaddr: the address does not have IPv4 CIDR format")}},ef.IPv4.isIPv4=function(O){return null!==this.parser(O)},ef.IPv4.isValid=function(O){try{return new this(this.parser(O)),!0}catch(O){return!1}},ef.IPv4.isValidFourPartDecimal=function(O){return!!(ef.IPv4.isValid(O)&&O.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},ef.IPv4.networkAddressFromCIDR=function(O){let U,$,J,en,es;try{for(J=(U=this.parseCIDR(O))[0].toByteArray(),es=this.subnetMaskFromPrefixLength(U[1]).toByteArray(),en=[],$=0;$<4;)en.push(parseInt(J[$],10)&parseInt(es[$],10)),$++;return new this(en)}catch(O){throw Error("ipaddr: the address does not have IPv4 CIDR format")}},ef.IPv4.parse=function(O){let U=this.parser(O);if(null===U)throw Error("ipaddr: string is not formatted like an IPv4 Address");return new this(U)},ef.IPv4.parseCIDR=function(O){let U;if(U=O.match(/^(.+)\/(\d+)$/)){let O=parseInt(U[2]);if(O>=0&&O<=32){let $=[this.parse(U[1]),O];return Object.defineProperty($,"toString",{value:function(){return this.join("/")}}),$}}throw Error("ipaddr: string is not formatted like an IPv4 CIDR range")},ef.IPv4.parser=function(O){let U,$;if(U=O.match(J.fourOctet))return function(){let O=U.slice(1,6),$=[];for(let U=0;U4294967295||$<0)throw Error("ipaddr: address outside defined range");return(function(){let O;let U=[];for(O=0;O<=24;O+=8)U.push($>>O&255);return U})().reverse()}return(U=O.match(J.twoOctet))?function(){let O=U.slice(1,4),J=[];if(($=parseIntAuto(O[1]))>16777215||$<0)throw Error("ipaddr: address outside defined range");return J.push(parseIntAuto(O[0])),J.push($>>16&255),J.push($>>8&255),J.push(255&$),J}():(U=O.match(J.threeOctet))?function(){let O=U.slice(1,5),J=[];if(($=parseIntAuto(O[2]))>65535||$<0)throw Error("ipaddr: address outside defined range");return J.push(parseIntAuto(O[0])),J.push(parseIntAuto(O[1])),J.push($>>8&255),J.push(255&$),J}():null},ef.IPv4.subnetMaskFromPrefixLength=function(O){if((O=parseInt(O))<0||O>32)throw Error("ipaddr: invalid IPv4 prefix length");let U=[0,0,0,0],$=0,J=Math.floor(O/8);for(;$=0;es-=1){if(!((O=this.parts[es])in en)||(U=en[O],J&&0!==U))return null;16!==U&&(J=!0),$+=U}return 128-$},IPv6.prototype.range=function(){return ef.subnetMatch(this,this.SpecialRanges)},IPv6.prototype.toByteArray=function(){let O;let U=[],$=this.parts;for(let J=0;J<$.length;J++)U.push((O=$[J])>>8),U.push(255&O);return U},IPv6.prototype.toFixedLengthString=function(){let O=(function(){let O=[];for(let U=0;U>8,255&U,$>>8,255&$])},IPv6.prototype.toNormalizedString=function(){let O=(function(){let O=[];for(let U=0;Uen&&(J=O.index,en=O[0].length);return en<0?$:`${$.substring(0,J)}::${$.substring(J+en)}`},IPv6.prototype.toString=function(){return this.toRFC5952String()},IPv6}(),ef.IPv6.broadcastAddressFromCIDR=function(O){try{let U=this.parseCIDR(O),$=U[0].toByteArray(),J=this.subnetMaskFromPrefixLength(U[1]).toByteArray(),en=[],es=0;for(;es<16;)en.push(parseInt($[es],10)|255^parseInt(J[es],10)),es++;return new this(en)}catch(O){throw Error(`ipaddr: the address does not have IPv6 CIDR format (${O})`)}},ef.IPv6.isIPv6=function(O){return null!==this.parser(O)},ef.IPv6.isValid=function(O){if("string"==typeof O&&-1===O.indexOf(":"))return!1;try{let U=this.parser(O);return new this(U.parts,U.zoneId),!0}catch(O){return!1}},ef.IPv6.networkAddressFromCIDR=function(O){let U,$,J,en,es;try{for(J=(U=this.parseCIDR(O))[0].toByteArray(),es=this.subnetMaskFromPrefixLength(U[1]).toByteArray(),en=[],$=0;$<16;)en.push(parseInt(J[$],10)&parseInt(es[$],10)),$++;return new this(en)}catch(O){throw Error(`ipaddr: the address does not have IPv6 CIDR format (${O})`)}},ef.IPv6.parse=function(O){let U=this.parser(O);if(null===U.parts)throw Error("ipaddr: string is not formatted like an IPv6 Address");return new this(U.parts,U.zoneId)},ef.IPv6.parseCIDR=function(O){let U,$,J;if(($=O.match(/^(.+)\/(\d+)$/))&&(U=parseInt($[2]))>=0&&U<=128)return Object.defineProperty(J=[this.parse($[1]),U],"toString",{value:function(){return this.join("/")}}),J;throw Error("ipaddr: string is not formatted like an IPv6 CIDR range")},ef.IPv6.parser=function(O){let U,$,J,en,es,eo;if(J=O.match(eu.deprecatedTransitional))return this.parser(`::ffff:${J[1]}`);if(eu.native.test(O))return expandIPv6(O,8);if((J=O.match(eu.transitional))&&(eo=J[6]||"",(U=expandIPv6(J[1].slice(0,-1)+eo,6)).parts)){for($=0,es=[parseInt(J[2]),parseInt(J[3]),parseInt(J[4]),parseInt(J[5])];$128)throw Error("ipaddr: invalid IPv6 prefix length");let U=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],$=0,J=Math.floor(O/8);for(;$=0)}O.exports=isElectron},361:function(O){"use strict";O.exports=O=>{if("[object Object]"!==Object.prototype.toString.call(O))return!1;let U=Object.getPrototypeOf(O);return null===U||U===Object.prototype}},2543:function(O,U,$){"use strict";let{URLWithLegacySupport:J,format:en,URLSearchParams:es,defaultBase:eo}=$(8608),ea=$(6926);O.exports={URL:J,URLSearchParams:es,format:en,relative:ea,defaultBase:eo}},6926:function(O,U,$){"use strict";let{URLWithLegacySupport:J,format:en}=$(8608);O.exports=(O,U={},$={},es)=>{let eo,ea=U.protocol?U.protocol.replace(":",""):"http";ea=($[ea]||es||ea)+":";try{eo=new J(O)}catch(O){eo={}}let eu=Object.assign({},U,{protocol:ea||eo.protocol,host:U.host||eo.host});return new J(O,en(eu)).toString()}},8608:function(O){"use strict";let U="undefined"!=typeof navigator&&"ReactNative"===navigator.product;function getDefaultBase(){return U?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}let $=self.URL,J=getDefaultBase();let URLWithLegacySupport=class URLWithLegacySupport{constructor(O="",U=J){this.super=new $(O,U),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(O){this.super.hash=O}set host(O){this.super.host=O}set hostname(O){this.super.hostname=O}set href(O){this.super.href=O}set password(O){this.super.password=O}set pathname(O){this.super.pathname=O}set port(O){this.super.port=O}set protocol(O){this.super.protocol=O}set search(O){this.super.search=O}set username(O){this.super.username=O}static createObjectURL(O){return $.createObjectURL(O)}static revokeObjectURL(O){$.revokeObjectURL(O)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function format(O){if("string"==typeof O){let U=new $(O);return U.toString()}if(!(O instanceof $)){let U=O.username&&O.password?`${O.username}:${O.password}@`:"",$=O.auth?O.auth+"@":"",J=O.port?":"+O.port:"",en=O.protocol?O.protocol+"//":"",es=O.host||"",eo=O.hostname||"",ea=O.search||(O.query?"?"+O.query:""),eu=O.hash||"",ef=O.pathname||"",eg=O.path||ef+ea;return`${en}${U||$}${es||eo+J}${eg}${eu}`}}O.exports={URLWithLegacySupport,URLSearchParams:self.URLSearchParams,defaultBase:J,format}},6398:function(O,U,$){var J,en=$(2601);!function(){"use strict";var es="input is invalid type",eo="finalize already called",ea="object"==typeof window,eu=ea?window:{};eu.JS_SHA3_NO_WINDOW&&(ea=!1);var ef=!ea&&"object"==typeof self;!eu.JS_SHA3_NO_NODE_JS&&"object"==typeof en&&en.versions&&en.versions.node?eu=$.g:ef&&(eu=self);var eg=!eu.JS_SHA3_NO_COMMON_JS&&O.exports,ev=$.amdO,e_=!eu.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,ew="0123456789abcdef".split(""),eE=[31,7936,2031616,520093696],eS=[4,1024,262144,67108864],eA=[1,256,65536,16777216],eI=[6,1536,393216,100663296],eP=[0,8,16,24],ek=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],eT=[224,256,384,512],eR=[128,256],eC=["hex","buffer","arrayBuffer","array","digest"],eB={128:168,256:136};(eu.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(O){return"[object Array]"===Object.prototype.toString.call(O)}),e_&&(eu.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(O){return"object"==typeof O&&O.buffer&&O.buffer.constructor===ArrayBuffer});for(var createOutputMethod=function(O,U,$){return function(J){return new Keccak(O,U,O).update(J)[$]()}},createShakeOutputMethod=function(O,U,$){return function(J,en){return new Keccak(O,U,en).update(J)[$]()}},createCshakeOutputMethod=function(O,U,$){return function(U,J,en,es){return eD["cshake"+O].update(U,J,en,es)[$]()}},createKmacOutputMethod=function(O,U,$){return function(U,J,en,es){return eD["kmac"+O].update(U,J,en,es)[$]()}},createOutputMethods=function(O,U,$,J){for(var en=0;en>5,this.byteCount=this.blockCount<<2,this.outputBlocks=$>>5,this.extraBytes=(31&$)>>3;for(var J=0;J<50;++J)this.s[J]=0}function Kmac(O,U,$){Keccak.call(this,O,U,$)}Keccak.prototype.update=function(O){if(this.finalized)throw Error(eo);var U,$=typeof O;if("string"!==$){if("object"===$){if(null===O)throw Error(es);if(e_&&O.constructor===ArrayBuffer)O=new Uint8Array(O);else if(!Array.isArray(O)&&(!e_||!ArrayBuffer.isView(O)))throw Error(es)}else throw Error(es);U=!0}for(var J,en,ea=this.blocks,eu=this.byteCount,ef=O.length,eg=this.blockCount,ev=0,ew=this.s;ev>2]|=O[ev]<>2]|=en<>2]|=(192|en>>6)<=57344?ea[J>>2]|=(224|en>>12)<>2]|=(240|en>>18)<>2]|=(128|en>>12&63)<>2]|=(128|en>>6&63)<>2]|=(128|63&en)<=eu){for(this.start=J-eu,this.block=ea[eg],J=0;J>=8,$=255&O;$>0;)en.unshift($),O>>=8,$=255&O,++J;return U?en.push(J):en.unshift(J),this.update(en),en.length},Keccak.prototype.encodeString=function(O){var U,$=typeof O;if("string"!==$){if("object"===$){if(null===O)throw Error(es);if(e_&&O.constructor===ArrayBuffer)O=new Uint8Array(O);else if(!Array.isArray(O)&&(!e_||!ArrayBuffer.isView(O)))throw Error(es)}else throw Error(es);U=!0}var J=0,en=O.length;if(U)J=en;else for(var eo=0;eo=57344?J+=3:(ea=65536+((1023&ea)<<10|1023&O.charCodeAt(++eo)),J+=4)}return J+=this.encode(8*J),this.update(O),J},Keccak.prototype.bytepad=function(O,U){for(var $=this.encode(U),J=0;J>2]|=this.padding[3&U],this.lastByteIndex===this.byteCount)for(U=1,O[0]=O[$];U<$+1;++U)O[U]=0;for(O[$-1]|=2147483648,U=0;U<$;++U)J[U]^=O[U];f(J)}},Keccak.prototype.toString=Keccak.prototype.hex=function(){this.finalize();for(var O,U=this.blockCount,$=this.s,J=this.outputBlocks,en=this.extraBytes,es=0,eo=0,ea="";eo>4&15]+ew[15&O]+ew[O>>12&15]+ew[O>>8&15]+ew[O>>20&15]+ew[O>>16&15]+ew[O>>28&15]+ew[O>>24&15];eo%U==0&&(f($),es=0)}return en&&(ea+=ew[(O=$[es])>>4&15]+ew[15&O],en>1&&(ea+=ew[O>>12&15]+ew[O>>8&15]),en>2&&(ea+=ew[O>>20&15]+ew[O>>16&15])),ea},Keccak.prototype.arrayBuffer=function(){this.finalize();var O,U=this.blockCount,$=this.s,J=this.outputBlocks,en=this.extraBytes,es=0,eo=0,ea=this.outputBits>>3;O=new ArrayBuffer(en?J+1<<2:ea);for(var eu=new Uint32Array(O);eo>8&255,eu[O+2]=U>>16&255,eu[O+3]=U>>24&255;ea%$==0&&f(J)}return es&&(O=ea<<2,U=J[eo],eu[O]=255&U,es>1&&(eu[O+1]=U>>8&255),es>2&&(eu[O+2]=U>>16&255)),eu},Kmac.prototype=new Keccak,Kmac.prototype.finalize=function(){return this.encode(this.outputBits,!0),Keccak.prototype.finalize.call(this)};var f=function(O){var U,$,J,en,es,eo,ea,eu,ef,eg,ev,e_,ew,eE,eS,eA,eI,eP,eT,eR,eC,eB,eN,eD,eM,eO,eL,eU,eF,eK,ej,eH,eq,eV,eG,e$,eW,eY,eJ,eQ,eZ,eX,e0,e1,e3,e6,e5,e9,e7,te,tt,tr,ta,tu,th,td,tf,tp,tg,tm,ty,tb,tv;for(J=0;J<48;J+=2)en=O[0]^O[10]^O[20]^O[30]^O[40],es=O[1]^O[11]^O[21]^O[31]^O[41],eo=O[2]^O[12]^O[22]^O[32]^O[42],ea=O[3]^O[13]^O[23]^O[33]^O[43],eu=O[4]^O[14]^O[24]^O[34]^O[44],ef=O[5]^O[15]^O[25]^O[35]^O[45],eg=O[6]^O[16]^O[26]^O[36]^O[46],ev=O[7]^O[17]^O[27]^O[37]^O[47],e_=O[8]^O[18]^O[28]^O[38]^O[48],ew=O[9]^O[19]^O[29]^O[39]^O[49],U=e_^(eo<<1|ea>>>31),$=ew^(ea<<1|eo>>>31),O[0]^=U,O[1]^=$,O[10]^=U,O[11]^=$,O[20]^=U,O[21]^=$,O[30]^=U,O[31]^=$,O[40]^=U,O[41]^=$,U=en^(eu<<1|ef>>>31),$=es^(ef<<1|eu>>>31),O[2]^=U,O[3]^=$,O[12]^=U,O[13]^=$,O[22]^=U,O[23]^=$,O[32]^=U,O[33]^=$,O[42]^=U,O[43]^=$,U=eo^(eg<<1|ev>>>31),$=ea^(ev<<1|eg>>>31),O[4]^=U,O[5]^=$,O[14]^=U,O[15]^=$,O[24]^=U,O[25]^=$,O[34]^=U,O[35]^=$,O[44]^=U,O[45]^=$,U=eu^(e_<<1|ew>>>31),$=ef^(ew<<1|e_>>>31),O[6]^=U,O[7]^=$,O[16]^=U,O[17]^=$,O[26]^=U,O[27]^=$,O[36]^=U,O[37]^=$,O[46]^=U,O[47]^=$,U=eg^(en<<1|es>>>31),$=ev^(es<<1|en>>>31),O[8]^=U,O[9]^=$,O[18]^=U,O[19]^=$,O[28]^=U,O[29]^=$,O[38]^=U,O[39]^=$,O[48]^=U,O[49]^=$,eE=O[0],eS=O[1],e6=O[11]<<4|O[10]>>>28,e5=O[10]<<4|O[11]>>>28,eU=O[20]<<3|O[21]>>>29,eF=O[21]<<3|O[20]>>>29,tm=O[31]<<9|O[30]>>>23,ty=O[30]<<9|O[31]>>>23,eX=O[40]<<18|O[41]>>>14,e0=O[41]<<18|O[40]>>>14,eV=O[2]<<1|O[3]>>>31,eG=O[3]<<1|O[2]>>>31,eA=O[13]<<12|O[12]>>>20,eI=O[12]<<12|O[13]>>>20,e9=O[22]<<10|O[23]>>>22,e7=O[23]<<10|O[22]>>>22,eK=O[33]<<13|O[32]>>>19,ej=O[32]<<13|O[33]>>>19,tb=O[42]<<2|O[43]>>>30,tv=O[43]<<2|O[42]>>>30,tu=O[5]<<30|O[4]>>>2,th=O[4]<<30|O[5]>>>2,e$=O[14]<<6|O[15]>>>26,eW=O[15]<<6|O[14]>>>26,eP=O[25]<<11|O[24]>>>21,eT=O[24]<<11|O[25]>>>21,te=O[34]<<15|O[35]>>>17,tt=O[35]<<15|O[34]>>>17,eH=O[45]<<29|O[44]>>>3,eq=O[44]<<29|O[45]>>>3,eD=O[6]<<28|O[7]>>>4,eM=O[7]<<28|O[6]>>>4,td=O[17]<<23|O[16]>>>9,tf=O[16]<<23|O[17]>>>9,eY=O[26]<<25|O[27]>>>7,eJ=O[27]<<25|O[26]>>>7,eR=O[36]<<21|O[37]>>>11,eC=O[37]<<21|O[36]>>>11,tr=O[47]<<24|O[46]>>>8,ta=O[46]<<24|O[47]>>>8,e1=O[8]<<27|O[9]>>>5,e3=O[9]<<27|O[8]>>>5,eO=O[18]<<20|O[19]>>>12,eL=O[19]<<20|O[18]>>>12,tp=O[29]<<7|O[28]>>>25,tg=O[28]<<7|O[29]>>>25,eQ=O[38]<<8|O[39]>>>24,eZ=O[39]<<8|O[38]>>>24,eB=O[48]<<14|O[49]>>>18,eN=O[49]<<14|O[48]>>>18,O[0]=eE^~eA&eP,O[1]=eS^~eI&eT,O[10]=eD^~eO&eU,O[11]=eM^~eL&eF,O[20]=eV^~e$&eY,O[21]=eG^~eW&eJ,O[30]=e1^~e6&e9,O[31]=e3^~e5&e7,O[40]=tu^~td&tp,O[41]=th^~tf&tg,O[2]=eA^~eP&eR,O[3]=eI^~eT&eC,O[12]=eO^~eU&eK,O[13]=eL^~eF&ej,O[22]=e$^~eY&eQ,O[23]=eW^~eJ&eZ,O[32]=e6^~e9&te,O[33]=e5^~e7&tt,O[42]=td^~tp&tm,O[43]=tf^~tg&ty,O[4]=eP^~eR&eB,O[5]=eT^~eC&eN,O[14]=eU^~eK&eH,O[15]=eF^~ej&eq,O[24]=eY^~eQ&eX,O[25]=eJ^~eZ&e0,O[34]=e9^~te&tr,O[35]=e7^~tt&ta,O[44]=tp^~tm&tb,O[45]=tg^~ty&tv,O[6]=eR^~eB&eE,O[7]=eC^~eN&eS,O[16]=eK^~eH&eD,O[17]=ej^~eq&eM,O[26]=eQ^~eX&eV,O[27]=eZ^~e0&eG,O[36]=te^~tr&e1,O[37]=tt^~ta&e3,O[46]=tm^~tb&tu,O[47]=ty^~tv&th,O[8]=eB^~eE&eA,O[9]=eN^~eS&eI,O[18]=eH^~eD&eO,O[19]=eq^~eM&eL,O[28]=eX^~eV&e$,O[29]=e0^~eG&eW,O[38]=tr^~e1&e6,O[39]=ta^~e3&e5,O[48]=tb^~tu&td,O[49]=tv^~th&tf,O[0]^=ek[J],O[1]^=ek[J+1]};if(eg)O.exports=eD;else{for(eO=0;eOObject.defineProperty(O,U,{value:$,writable:!0,enumerable:!0,configurable:!0}),eo=this,ea={concatArrays:!1,ignoreUndefined:!1},getEnumerableOwnPropertyKeys=O=>{let U=[];for(let $ in O)en.call(O,$)&&U.push($);if(Object.getOwnPropertySymbols){let $=Object.getOwnPropertySymbols(O);for(let J of $)es.call(O,J)&&U.push(J)}return U};function clone(O){return Array.isArray(O)?cloneArray(O):J(O)?cloneOptionObject(O):O}function cloneArray(O){let U=O.slice(0,0);return getEnumerableOwnPropertyKeys(O).forEach($=>{defineProperty(U,$,clone(O[$]))}),U}function cloneOptionObject(O){let U=null===Object.getPrototypeOf(O)?Object.create(null):{};return getEnumerableOwnPropertyKeys(O).forEach($=>{defineProperty(U,$,clone(O[$]))}),U}let mergeKeys=(O,U,$,J)=>($.forEach($=>{void 0===U[$]&&J.ignoreUndefined||($ in O&&O[$]!==Object.getPrototypeOf(O)?defineProperty(O,$,merge(O[$],U[$],J)):defineProperty(O,$,clone(U[$])))}),O),concatArrays=(O,U,$)=>{let J=O.slice(0,0),es=0;return[O,U].forEach(U=>{let eo=[];for(let $=0;$!eo.includes(O)),$)}),J};function merge(O,U,$){return $.concatArrays&&Array.isArray(O)&&Array.isArray(U)?concatArrays(O,U,$):J(U)&&J(O)?mergeKeys(O,U,getEnumerableOwnPropertyKeys(U),$):clone(U)}O.exports=function(...O){let U=merge(clone(ea),this!==eo&&this||{},ea),$={_:{}};for(let en of O)if(void 0!==en){if(!J(en))throw TypeError("`"+en+"` is not an Option Object");$=merge($,{_:en},U)}return $._}},8786:function(O){function assert(O,U){if(!O)throw Error(U||"Assertion failed")}O.exports=assert,assert.equal=function(O,U,$){if(O!=U)throw Error($||"Assertion failed: "+O+" != "+U)}},438:function(O){var U=1e3,$=6e4,J=36e5,en=864e5,es=6048e5,eo=315576e5;function parse(O){if(!((O=String(O)).length>100)){var ea=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(O);if(ea){var eu=parseFloat(ea[1]);switch((ea[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return eu*eo;case"weeks":case"week":case"w":return eu*es;case"days":case"day":case"d":return eu*en;case"hours":case"hour":case"hrs":case"hr":case"h":return eu*J;case"minutes":case"minute":case"mins":case"min":case"m":return eu*$;case"seconds":case"second":case"secs":case"sec":case"s":return eu*U;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return eu;default:return}}}}function fmtShort(O){var es=Math.abs(O);return es>=en?Math.round(O/en)+"d":es>=J?Math.round(O/J)+"h":es>=$?Math.round(O/$)+"m":es>=U?Math.round(O/U)+"s":O+"ms"}function fmtLong(O){var es=Math.abs(O);return es>=en?plural(O,es,en,"day"):es>=J?plural(O,es,J,"hour"):es>=$?plural(O,es,$,"minute"):es>=U?plural(O,es,U,"second"):O+" ms"}function plural(O,U,$,J){var en=U>=1.5*$;return Math.round(O/$)+" "+J+(en?"s":"")}O.exports=function(O,U){U=U||{};var $=typeof O;if("string"===$&&O.length>0)return parse(O);if("number"===$&&isFinite(O))return U.long?fmtLong(O):fmtShort(O);throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(O))}},5194:function(O,U){(function(){var O,$,J,en,es,eo,ea,eu;eu=function(O){return[(-16777216&O)>>>24,(16711680&O)>>>16,(65280&O)>>>8,255&O].join(".")},ea=function(O){var U,J,en,es,eo,ea;for(U=[],en=es=0;es<=3&&0!==O.length;en=++es){if(en>0){if("."!==O[0])throw Error("Invalid IP");O=O.substring(1)}eo=(ea=$(O))[0],J=ea[1],O=O.substring(J),U.push(eo)}if(0!==O.length)throw Error("Invalid IP");switch(U.length){case 1:if(U[0]>4294967295)throw Error("Invalid IP");return U[0]>>>0;case 2:if(U[0]>255||U[1]>16777215)throw Error("Invalid IP");return(U[0]<<24|U[1])>>>0;case 3:if(U[0]>255||U[1]>255||U[2]>65535)throw Error("Invalid IP");return(U[0]<<24|U[1]<<16|U[2])>>>0;case 4:if(U[0]>255||U[1]>255||U[2]>255||U[3]>255)throw Error("Invalid IP");return(U[0]<<24|U[1]<<16|U[2]<<8|U[3])>>>0;default:throw Error("Invalid IP")}},en=(J=function(O){return O.charCodeAt(0)})("0"),eo=J("a"),es=J("A"),$=function(O){var U,$,ea,eu,ef;for(eu=0,U=10,$="9",ea=0,O.length>1&&"0"===O[ea]&&("x"===O[ea+1]||"X"===O[ea+1]?(ea+=2,U=16):"0"<=O[ea+1]&&O[ea+1]<="9"&&(ea++,U=8,$="7")),ef=ea;ea>>0;else if(16===U){if("a"<=O[ea]&&O[ea]<="f")eu=eu*U+(10+J(O[ea])-eo)>>>0;else if("A"<=O[ea]&&O[ea]<="F")eu=eu*U+(10+J(O[ea])-es)>>>0;else break}else break;if(eu>4294967295)throw Error("too large");ea++}if(ea===ef)throw Error("empty octet");return[eu,ea]},O=function(){function Netmask(O,U){var $,J,en;if("string"!=typeof O)throw Error("Missing `net' parameter");if(U||(O=(en=O.split("/",2))[0],U=en[1]),U||(U=32),"string"==typeof U&&U.indexOf(".")>-1){try{this.maskLong=ea(U)}catch(O){throw Error("Invalid mask: "+U)}for($=J=32;J>=0;$=--J)if(this.maskLong===4294967295<<32-$>>>0){this.bitmask=$;break}}else if(U||0===U)this.bitmask=parseInt(U,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw Error("Invalid mask: empty");try{this.netLong=(ea(O)&this.maskLong)>>>0}catch(U){throw Error("Invalid net address: "+O)}if(!(this.bitmask<=32))throw Error("Invalid mask for ip4: "+U);this.size=Math.pow(2,32-this.bitmask),this.base=eu(this.netLong),this.mask=eu(this.maskLong),this.hostmask=eu(~this.maskLong),this.first=this.bitmask<=30?eu(this.netLong+1):this.base,this.last=this.bitmask<=30?eu(this.netLong+this.size-2):eu(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?eu(this.netLong+this.size-1):void 0}return Netmask.prototype.contains=function(O){return("string"==typeof O&&(O.indexOf("/")>0||4!==O.split(".").length)&&(O=new Netmask(O)),O instanceof Netmask)?this.contains(O.base)&&this.contains(O.broadcast||O.last):(ea(O)&this.maskLong)>>>0==(this.netLong&this.maskLong)>>>0},Netmask.prototype.next=function(O){return null==O&&(O=1),new Netmask(eu(this.netLong+this.size*O),this.mask)},Netmask.prototype.forEach=function(O){var U,$,J;for(J=ea(this.first),$=ea(this.last),U=0;J<=$;)O(eu(J),J,U),U++,J++},Netmask.prototype.toString=function(){return this.base+"/"+this.bitmask},Netmask}(),U.ip2long=ea,U.long2ip=eu,U.Netmask=O}).call(this)},2601:function(O,U,$){"use strict";var J,en;O.exports=(null==(J=$.g.process)?void 0:J.env)&&"object"==typeof(null==(en=$.g.process)?void 0:en.env)?$.g.process:$(8960)},8960:function(O){var U="/";!function(){var $={229:function(O){var U,$,J,en=O.exports={};function defaultSetTimout(){throw Error("setTimeout has not been defined")}function defaultClearTimeout(){throw Error("clearTimeout has not been defined")}function runTimeout(O){if(U===setTimeout)return setTimeout(O,0);if((U===defaultSetTimout||!U)&&setTimeout)return U=setTimeout,setTimeout(O,0);try{return U(O,0)}catch($){try{return U.call(null,O,0)}catch($){return U.call(this,O,0)}}}function runClearTimeout(O){if($===clearTimeout)return clearTimeout(O);if(($===defaultClearTimeout||!$)&&clearTimeout)return $=clearTimeout,clearTimeout(O);try{return $(O)}catch(U){try{return $.call(null,O)}catch(U){return $.call(this,O)}}}!function(){try{U="function"==typeof setTimeout?setTimeout:defaultSetTimout}catch(O){U=defaultSetTimout}try{$="function"==typeof clearTimeout?clearTimeout:defaultClearTimeout}catch(O){$=defaultClearTimeout}}();var es=[],eo=!1,ea=-1;function cleanUpNextTick(){eo&&J&&(eo=!1,J.length?es=J.concat(es):ea=-1,es.length&&drainQueue())}function drainQueue(){if(!eo){var O=runTimeout(cleanUpNextTick);eo=!0;for(var U=es.length;U;){for(J=es,es=[];++ea1)for(var $=1;$>>=2;for(var J=0;J>8^255&ev^99,J[eS]=ev,en[ev]=eS,e_=O[ev],$=O[eS],eu=O[$],eg=O[eu],ew=e_<<24^ev<<16^ev<<8^(ev^e_),eE=($^eu^eg)<<24^(eS^eg)<<16^(eS^eu^eg)<<8^(eS^$^eg);for(var eI=0;eI<4;++eI)eo[eI][eS]=ew,ea[eI][ev]=eE,ew=ew<<24|ew>>>8,eE=eE<<24|eE>>>8;0===eS?eS=eA=1:(eS=$^O[O[O[$^eg]]],eA^=O[O[eA]])}}function _expandKey(O,U){for(var $,en=O.slice(0),eo=1,eu=en.length,ef=eg*(eu+6+1),ev=eu;ev>>16&255]<<24^J[$>>>8&255]<<16^J[255&$]<<8^J[$>>>24]^es[eo]<<24,eo++):eu>6&&ev%eu==4&&($=J[$>>>24]<<24^J[$>>>16&255]<<16^J[$>>>8&255]<<8^J[255&$]),en[ev]=en[ev-eu]^$;if(U){var e_,ew=ea[0],eE=ea[1],eS=ea[2],eA=ea[3],eI=en.slice(0);ef=en.length;for(var ev=0,eP=ef-eg;ev>>24]]^eE[J[e_>>>16&255]]^eS[J[e_>>>8&255]]^eA[J[255&e_]];en=eI}return en}function _updateBlock(O,U,$,es){var eu,ef,eg,ev,e_,ew,eE,eS,eA,eI,eP,ek,eT=O.length/4-1;es?(eu=ea[0],ef=ea[1],eg=ea[2],ev=ea[3],e_=en):(eu=eo[0],ef=eo[1],eg=eo[2],ev=eo[3],e_=J),ew=U[0]^O[0],eE=U[es?3:1]^O[1],eS=U[2]^O[2],eA=U[es?1:3]^O[3];for(var eR=3,eC=1;eC>>24]^ef[eE>>>16&255]^eg[eS>>>8&255]^ev[255&eA]^O[++eR],eP=eu[eE>>>24]^ef[eS>>>16&255]^eg[eA>>>8&255]^ev[255&ew]^O[++eR],ek=eu[eS>>>24]^ef[eA>>>16&255]^eg[ew>>>8&255]^ev[255&eE]^O[++eR],eA=eu[eA>>>24]^ef[ew>>>16&255]^eg[eE>>>8&255]^ev[255&eS]^O[++eR],ew=eI,eE=eP,eS=ek;$[0]=e_[ew>>>24]<<24^e_[eE>>>16&255]<<16^e_[eS>>>8&255]<<8^e_[255&eA]^O[++eR],$[es?3:1]=e_[eE>>>24]<<24^e_[eS>>>16&255]<<16^e_[eA>>>8&255]<<8^e_[255&ew]^O[++eR],$[2]=e_[eS>>>24]<<24^e_[eA>>>16&255]<<16^e_[ew>>>8&255]<<8^e_[255&eE]^O[++eR],$[es?1:3]=e_[eA>>>24]<<24^e_[ew>>>16&255]<<16^e_[eE>>>8&255]<<8^e_[255&eS]^O[++eR]}function _createCipher(O){var U,$="AES-"+((O=O||{}).mode||"CBC").toUpperCase(),J=(U=O.decrypt?eu.cipher.createDecipher($,O.key):eu.cipher.createCipher($,O.key)).start;return U.start=function(O,$){var en=null;$ instanceof eu.util.ByteBuffer&&(en=$,$={}),($=$||{}).output=en,$.iv=O,J.call(U,$)},U}},9642:function(O,U,$){var J=$(2595);$(2366),$(552);var en=O.exports=J.asn1=J.asn1||{};function _checkBufferLength(O,U,$){if($>U){var J=Error("Too few bytes to parse DER.");throw J.available=O.length(),J.remaining=U,J.requested=$,J}}en.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},en.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},en.create=function(O,U,$,es,eo){if(J.util.isArray(es)){for(var ea=[],eu=0;euU){if(J.strict){var e_=Error("Too few bytes to read ASN.1 value.");throw e_.available=O.length(),e_.remaining=U,e_.requested=ev,e_}ev=U}var ew=(32&eu)==32;if(ew){if(eo=[],void 0===ev)for(;;){if(_checkBufferLength(O,U,2),O.bytes(2)===String.fromCharCode(0,0)){O.getBytes(2),U-=2;break}es=O.length(),eo.push(_fromDer(O,U,$+1,J)),U-=es-O.length()}else for(;ev>0;)es=O.length(),eo.push(_fromDer(O,ev,$+1,J)),U-=es-O.length(),ev-=es-O.length()}if(void 0===eo&&ef===en.Class.UNIVERSAL&&eg===en.Type.BITSTRING&&(ea=O.bytes(ev)),void 0===eo&&J.decodeBitStrings&&ef===en.Class.UNIVERSAL&&eg===en.Type.BITSTRING&&ev>1){var eE=O.read,eS=U,eA=0;if(eg===en.Type.BITSTRING&&(_checkBufferLength(O,U,1),eA=O.getByte(),U--),0===eA)try{es=O.length();var eI={strict:!0,decodeBitStrings:!0},eP=_fromDer(O,U,$+1,eI),ek=es-O.length();U-=ek,eg==en.Type.BITSTRING&&ek++;var eT=eP.tagClass;ek===ev&&(eT===en.Class.UNIVERSAL||eT===en.Class.CONTEXT_SPECIFIC)&&(eo=[eP])}catch(O){}void 0===eo&&(O.read=eE,U=eS)}if(void 0===eo){if(void 0===ev){if(J.strict)throw Error("Non-constructed ASN.1 object of indefinite length.");ev=U}if(eg===en.Type.BMPSTRING)for(eo="";ev>0;ev-=2)_checkBufferLength(O,U,2),eo+=String.fromCharCode(O.getInt16()),U-=2;else eo=O.getBytes(ev),U-=ev}var eR=void 0===ea?null:{bitStringContents:ea};return en.create(ef,eg,ew,eo,eR)}en.fromDer=function(O,U){void 0===U&&(U={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),"boolean"==typeof U&&(U={strict:U,parseAllBytes:!0,decodeBitStrings:!0}),"strict"in U||(U.strict=!0),"parseAllBytes"in U||(U.parseAllBytes=!0),"decodeBitStrings"in U||(U.decodeBitStrings=!0),"string"==typeof O&&(O=J.util.createBuffer(O));var $=O.length(),en=_fromDer(O,O.length(),0,U);if(U.parseAllBytes&&0!==O.length()){var es=Error("Unparsed DER bytes remain after ASN.1 parsing.");throw es.byteCount=$,es.remaining=O.length(),es}return en},en.toDer=function(O){var U=J.util.createBuffer(),$=O.tagClass|O.type,es=J.util.createBuffer(),eo=!1;if("bitStringContents"in O&&(eo=!0,O.original&&(eo=en.equals(O,O.original))),eo)es.putBytes(O.bitStringContents);else if(O.composed){O.constructed?$|=32:es.putByte(0);for(var ea=0;ea1&&(0===O.value.charCodeAt(0)&&(128&O.value.charCodeAt(1))==0||255===O.value.charCodeAt(0)&&(128&O.value.charCodeAt(1))==128)?es.putBytes(O.value.substr(1)):es.putBytes(O.value);if(U.putByte($),127>=es.length())U.putByte(127&es.length());else{var eu=es.length(),ef="";do ef+=String.fromCharCode(255&eu),eu>>>=8;while(eu>0);U.putByte(128|ef.length);for(var ea=ef.length-1;ea>=0;--ea)U.putByte(ef.charCodeAt(ea))}return U.putBuffer(es),U},en.oidToDer=function(O){var U,$,en,es,eo=O.split("."),ea=J.util.createBuffer();ea.putByte(40*parseInt(eo[0],10)+parseInt(eo[1],10));for(var eu=2;eu>>=7,U||(es|=128),$.push(es),U=!1;while(en>0);for(var ef=$.length-1;ef>=0;--ef)ea.putByte($[ef])}return ea},en.derToOid=function(O){"string"==typeof O&&(O=J.util.createBuffer(O));var U,$=O.getByte();U=Math.floor($/40)+"."+$%40;for(var en=0;O.length()>0;)$=O.getByte(),en<<=7,128&$?en+=127&$:(U+="."+(en+$),en=0);return U},en.utcTimeToDate=function(O){var U=new Date,$=parseInt(O.substr(0,2),10);$=$>=50?1900+$:2e3+$;var J=parseInt(O.substr(2,2),10)-1,en=parseInt(O.substr(4,2),10),es=parseInt(O.substr(6,2),10),eo=parseInt(O.substr(8,2),10),ea=0;if(O.length>11){var eu=O.charAt(10),ef=10;"+"!==eu&&"-"!==eu&&(ea=parseInt(O.substr(10,2),10),ef+=2)}if(U.setUTCFullYear($,J,en),U.setUTCHours(es,eo,ea,0),ef&&("+"===(eu=O.charAt(ef))||"-"===eu)){var eg=60*parseInt(O.substr(ef+1,2),10)+parseInt(O.substr(ef+4,2),10);eg*=6e4,"+"===eu?U.setTime(+U-eg):U.setTime(+U+eg)}return U},en.generalizedTimeToDate=function(O){var U=new Date,$=parseInt(O.substr(0,4),10),J=parseInt(O.substr(4,2),10)-1,en=parseInt(O.substr(6,2),10),es=parseInt(O.substr(8,2),10),eo=parseInt(O.substr(10,2),10),ea=parseInt(O.substr(12,2),10),eu=0,ef=0,eg=!1;"Z"===O.charAt(O.length-1)&&(eg=!0);var ev=O.length-5,e_=O.charAt(ev);return("+"===e_||"-"===e_)&&(ef=(60*parseInt(O.substr(ev+1,2),10)+parseInt(O.substr(ev+4,2),10))*6e4,"+"===e_&&(ef*=-1),eg=!0),"."===O.charAt(14)&&(eu=1e3*parseFloat(O.substr(14),10)),eg?(U.setUTCFullYear($,J,en),U.setUTCHours(es,eo,ea,eu),U.setTime(+U+ef)):(U.setFullYear($,J,en),U.setHours(es,eo,ea,eu)),U},en.dateToUtcTime=function(O){if("string"==typeof O)return O;var U="",$=[];$.push((""+O.getUTCFullYear()).substr(2)),$.push(""+(O.getUTCMonth()+1)),$.push(""+O.getUTCDate()),$.push(""+O.getUTCHours()),$.push(""+O.getUTCMinutes()),$.push(""+O.getUTCSeconds());for(var J=0;J<$.length;++J)$[J].length<2&&(U+="0"),U+=$[J];return U+"Z"},en.dateToGeneralizedTime=function(O){if("string"==typeof O)return O;var U="",$=[];$.push(""+O.getUTCFullYear()),$.push(""+(O.getUTCMonth()+1)),$.push(""+O.getUTCDate()),$.push(""+O.getUTCHours()),$.push(""+O.getUTCMinutes()),$.push(""+O.getUTCSeconds());for(var J=0;J<$.length;++J)$[J].length<2&&(U+="0"),U+=$[J];return U+"Z"},en.integerToDer=function(O){var U=J.util.createBuffer();if(O>=-128&&O<128)return U.putSignedInt(O,8);if(O>=-32768&&O<32768)return U.putSignedInt(O,16);if(O>=-8388608&&O<8388608)return U.putSignedInt(O,24);if(O>=-2147483648&&O<2147483648)return U.putSignedInt(O,32);var $=Error("Integer too large; max is 32-bits.");throw $.integer=O,$},en.derToInteger=function(O){"string"==typeof O&&(O=J.util.createBuffer(O));var U=8*O.length();if(U>32)throw Error("Integer too large; max is 32-bits.");return O.getSignedInt(U)},en.validate=function(O,U,$,es){var eo=!1;if((O.tagClass===U.tagClass||void 0===U.tagClass)&&(O.type===U.type||void 0===U.type)){if(O.constructed===U.constructed||void 0===U.constructed){if(eo=!0,U.value&&J.util.isArray(U.value))for(var ea=0,eu=0;eo&&eu0&&(eo+="\n");for(var ea="",eu=0;eu1?eo+="0x"+J.util.bytesToHex(O.value.slice(1)):eo+="(none)",O.value.length>0){var e_=O.value.charCodeAt(0);1==e_?eo+=" (1 unused bit shown)":e_>1&&(eo+=" ("+e_+" unused bits shown)")}}else if(O.type===en.Type.OCTETSTRING)es.test(O.value)||(eo+="("+O.value+") "),eo+="0x"+J.util.bytesToHex(O.value);else if(O.type===en.Type.UTF8)try{eo+=J.util.decodeUtf8(O.value)}catch(U){if("URI malformed"===U.message)eo+="0x"+J.util.bytesToHex(O.value)+" (malformed UTF8)";else throw U}else O.type===en.Type.PRINTABLESTRING||O.type===en.Type.IA5String?eo+=O.value:es.test(O.value)?eo+="0x"+J.util.bytesToHex(O.value):0===O.value.length?eo+="[null]":eo+=O.value}return eo}},4446:function(O,U,$){var J=$(2678).Buffer,en={};O.exports=en;var es={};function _encodeWithByteBuffer(O,U){var $=0,J=U.length,en=U.charAt(0),es=[0];for($=0;$0;)es.push(ea%J),ea=ea/J|0}var eu="";for($=0;0===O.at($)&&$=0;--$)eu+=U[es[$]];return eu}en.encode=function(O,U,$){if("string"!=typeof U)throw TypeError('"alphabet" must be a string.');if(void 0!==$&&"number"!=typeof $)throw TypeError('"maxline" must be a number.');var J="";if(O instanceof Uint8Array){var en=0,es=U.length,eo=U.charAt(0),ea=[0];for(en=0;en0;)ea.push(ef%es),ef=ef/es|0}for(en=0;0===O[en]&&en=0;--en)J+=U[ea[en]]}else J=_encodeWithByteBuffer(O,U);if($){var eg=RegExp(".{1,"+$+"}","g");J=J.match(eg).join("\r\n")}return J},en.decode=function(O,U){if("string"!=typeof O)throw TypeError('"input" must be a string.');if("string"!=typeof U)throw TypeError('"alphabet" must be a string.');var $=es[U];if(!$){$=es[U]=[];for(var en=0;en>=8;for(;ev>0;)eu.push(255&ev),ev>>=8}for(var e_=0;O[e_]===ea&&e_4){var $=O;O=J.util.createBuffer();for(var en=0;en<$.length;++en)O.putByte($[en])}if(O.length()0))return!0;for(var J=0;J0))return!0;for(var J=0;J0)return!1;var $=O.length(),J=O.at($-1);return!(J>this.blockSize<<2)&&(O.truncate(J),!0)},en.cbc=function(O){O=O||{},this.name="CBC",this.cipher=O.cipher,this.blockSize=O.blockSize||16,this._ints=this.blockSize/4,this._inBlock=Array(this._ints),this._outBlock=Array(this._ints)},en.cbc.prototype.start=function(O){if(null===O.iv){if(!this._prev)throw Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in O)this._iv=transformIV(O.iv,this.blockSize),this._prev=this._iv.slice(0);else throw Error("Invalid IV parameter.")},en.cbc.prototype.encrypt=function(O,U,$){if(O.length()0))return!0;for(var J=0;J0))return!0;for(var J=0;J0)return!1;var $=O.length(),J=O.at($-1);return!(J>this.blockSize<<2)&&(O.truncate(J),!0)},en.cfb=function(O){O=O||{},this.name="CFB",this.cipher=O.cipher,this.blockSize=O.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=Array(this._ints),this._partialBlock=Array(this._ints),this._partialOutput=J.util.createBuffer(),this._partialBytes=0},en.cfb.prototype.start=function(O){if(!("iv"in O))throw Error("Invalid IV parameter.");this._iv=transformIV(O.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},en.cfb.prototype.encrypt=function(O,U,$){var J=O.length();if(0===J)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&J>=this.blockSize){for(var en=0;en0&&(es=this.blockSize-es),this._partialOutput.clear();for(var en=0;en0)O.read-=this.blockSize;else for(var en=0;en0&&this._partialOutput.getBytes(this._partialBytes),es>0&&!$)return U.putBytes(this._partialOutput.getBytes(es-this._partialBytes)),this._partialBytes=es,!0;U.putBytes(this._partialOutput.getBytes(J-this._partialBytes)),this._partialBytes=0},en.cfb.prototype.decrypt=function(O,U,$){var J=O.length();if(0===J)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&J>=this.blockSize){for(var en=0;en0&&(es=this.blockSize-es),this._partialOutput.clear();for(var en=0;en0)O.read-=this.blockSize;else for(var en=0;en0&&this._partialOutput.getBytes(this._partialBytes),es>0&&!$)return U.putBytes(this._partialOutput.getBytes(es-this._partialBytes)),this._partialBytes=es,!0;U.putBytes(this._partialOutput.getBytes(J-this._partialBytes)),this._partialBytes=0},en.ofb=function(O){O=O||{},this.name="OFB",this.cipher=O.cipher,this.blockSize=O.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=Array(this._ints),this._partialOutput=J.util.createBuffer(),this._partialBytes=0},en.ofb.prototype.start=function(O){if(!("iv"in O))throw Error("Invalid IV parameter.");this._iv=transformIV(O.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},en.ofb.prototype.encrypt=function(O,U,$){var J=O.length();if(0===O.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&J>=this.blockSize){for(var en=0;en0&&(es=this.blockSize-es),this._partialOutput.clear();for(var en=0;en0)O.read-=this.blockSize;else for(var en=0;en0&&this._partialOutput.getBytes(this._partialBytes),es>0&&!$)return U.putBytes(this._partialOutput.getBytes(es-this._partialBytes)),this._partialBytes=es,!0;U.putBytes(this._partialOutput.getBytes(J-this._partialBytes)),this._partialBytes=0},en.ofb.prototype.decrypt=en.ofb.prototype.encrypt,en.ctr=function(O){O=O||{},this.name="CTR",this.cipher=O.cipher,this.blockSize=O.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=Array(this._ints),this._partialOutput=J.util.createBuffer(),this._partialBytes=0},en.ctr.prototype.start=function(O){if(!("iv"in O))throw Error("Invalid IV parameter.");this._iv=transformIV(O.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},en.ctr.prototype.encrypt=function(O,U,$){var J=O.length();if(0===J)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&J>=this.blockSize)for(var en=0;en0&&(es=this.blockSize-es),this._partialOutput.clear();for(var en=0;en0&&(O.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),es>0&&!$)return U.putBytes(this._partialOutput.getBytes(es-this._partialBytes)),this._partialBytes=es,!0;U.putBytes(this._partialOutput.getBytes(J-this._partialBytes)),this._partialBytes=0}inc32(this._inBlock)},en.ctr.prototype.decrypt=en.ctr.prototype.encrypt,en.gcm=function(O){O=O||{},this.name="GCM",this.cipher=O.cipher,this.blockSize=O.blockSize||16,this._ints=this.blockSize/4,this._inBlock=Array(this._ints),this._outBlock=Array(this._ints),this._partialOutput=J.util.createBuffer(),this._partialBytes=0,this._R=3774873600},en.gcm.prototype.start=function(O){if(!("iv"in O))throw Error("Invalid IV parameter.");var U,$=J.util.createBuffer(O.iv);if(this._cipherLength=0,U="additionalData"in O?J.util.createBuffer(O.additionalData):J.util.createBuffer(),"tagLength"in O?this._tagLength=O.tagLength:this._tagLength=128,this._tag=null,O.decrypt&&(this._tag=J.util.createBuffer(O.tag).getBytes(),this._tag.length!==this._tagLength/8))throw Error("Authentication tag does not match tag length.");this._hashBlock=Array(this._ints),this.tag=null,this._hashSubkey=Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var en=$.length();if(12===en)this._j0=[$.getInt32(),$.getInt32(),$.getInt32(),1];else{for(this._j0=[0,0,0,0];$.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[$.getInt32(),$.getInt32(),$.getInt32(),$.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(from64To32(8*en)))}this._inBlock=this._j0.slice(0),inc32(this._inBlock),this._partialBytes=0,U=J.util.createBuffer(U),this._aDataLength=from64To32(8*U.length());var es=U.length()%this.blockSize;for(es&&U.fillWithByte(0,this.blockSize-es),this._s=[0,0,0,0];U.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[U.getInt32(),U.getInt32(),U.getInt32(),U.getInt32()])},en.gcm.prototype.encrypt=function(O,U,$){var J=O.length();if(0===J)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&J>=this.blockSize){for(var en=0;en0&&(es=this.blockSize-es),this._partialOutput.clear();for(var en=0;en0&&this._partialOutput.getBytes(this._partialBytes),es>0&&!$)return O.read-=this.blockSize,U.putBytes(this._partialOutput.getBytes(es-this._partialBytes)),this._partialBytes=es,!0;U.putBytes(this._partialOutput.getBytes(J-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),inc32(this._inBlock)},en.gcm.prototype.decrypt=function(O,U,$){var J=O.length();if(J0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),inc32(this._inBlock),this._hashBlock[0]=O.getInt32(),this._hashBlock[1]=O.getInt32(),this._hashBlock[2]=O.getInt32(),this._hashBlock[3]=O.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var en=0;en0;--J)U[J]=O[J]>>>1|(1&O[J-1])<<31;U[0]=O[0]>>>1,$&&(U[0]^=this._R)},en.gcm.prototype.tableMultiply=function(O){for(var U=[0,0,0,0],$=0;$<32;++$){var J=O[$/8|0]>>>(7-$%8)*4&15,en=this._m[$][J];U[0]^=en[0],U[1]^=en[1],U[2]^=en[2],U[3]^=en[3]}return U},en.gcm.prototype.ghash=function(O,U,$){return U[0]^=$[0],U[1]^=$[1],U[2]^=$[2],U[3]^=$[3],this.tableMultiply(U)},en.gcm.prototype.generateHashTable=function(O,U){for(var $=8/U,J=4*$,en=16*$,es=Array(en),eo=0;eo>>1,en=Array($);en[J]=O.slice(0);for(var es=J>>>1;es>0;)this.pow(en[2*es],en[es]=[]),es>>=1;for(es=2;es8?3:1,eI=[],eP=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],ek=0,eT=0;eT>>4^eC)&252645135,eC^=U,eR^=U<<4,U=(eC>>>-16^eR)&65535,eR^=U,eC^=U<<-16,U=(eR>>>2^eC)&858993459,eC^=U,eR^=U<<2,U=(eC>>>-16^eR)&65535,eR^=U,eC^=U<<-16,U=(eR>>>1^eC)&1431655765,eC^=U,eR^=U<<1,U=(eC>>>8^eR)&16711935,eR^=U,eC^=U<<8,U=(eR>>>1^eC)&1431655765,eC^=U,eR^=U<<1,U=eR<<8|eC>>>20&240,eR=eC<<24|eC<<8&16711680|eC>>>8&65280|eC>>>24&240,eC=U;for(var eB=0;eB>>26,eC=eC<<2|eC>>>26):(eR=eR<<1|eR>>>27,eC=eC<<1|eC>>>27),eC&=-15;var eN=$[(eR&=-15)>>>28]|J[eR>>>24&15]|en[eR>>>20&15]|es[eR>>>16&15]|eo[eR>>>12&15]|ea[eR>>>8&15]|eu[eR>>>4&15],eD=ef[eC>>>28]|eg[eC>>>24&15]|ev[eC>>>20&15]|e_[eC>>>16&15]|ew[eC>>>12&15]|eE[eC>>>8&15]|eS[eC>>>4&15];U=(eD>>>16^eN)&65535,eI[ek++]=eN^U,eI[ek++]=eD^U<<16}}return eI}function _updateBlock(O,U,$,J){var e_,ew,eE=32===O.length?3:9;e_=3===eE?J?[30,-2,-2]:[0,32,2]:J?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var eS=U[0],eA=U[1];ew=(eS>>>4^eA)&252645135,eA^=ew,eS^=ew<<4,ew=(eS>>>16^eA)&65535,eA^=ew,eS^=ew<<16,ew=(eA>>>2^eS)&858993459,eS^=ew,eA^=ew<<2,ew=(eA>>>8^eS)&16711935,eS^=ew,eA^=ew<<8,ew=(eS>>>1^eA)&1431655765,eA^=ew,eS^=ew<<1,eS=eS<<1|eS>>>31,eA=eA<<1|eA>>>31;for(var eI=0;eI>>4|eA<<28)^O[eT+1];ew=eS,eS=eA,eA=ew^(es[eR>>>24&63]|ea[eR>>>16&63]|ef[eR>>>8&63]|ev[63&eR]|en[eC>>>24&63]|eo[eC>>>16&63]|eu[eC>>>8&63]|eg[63&eC])}ew=eS,eS=eA,eA=ew}ew=((eS=eS>>>1|eS<<31)>>>1^(eA=eA>>>1|eA<<31))&1431655765,eA^=ew,eS^=ew<<1,ew=(eA>>>8^eS)&16711935,eS^=ew,eA^=ew<<8,ew=(eA>>>2^eS)&858993459,eS^=ew,eA^=ew<<2,ew=(eS>>>16^eA)&65535,eA^=ew,eS^=ew<<16,ew=(eS>>>4^eA)&252645135,eA^=ew,eS^=ew<<4,$[0]=eS,$[1]=eA}function _createCipher(O){var U,$="DES-"+((O=O||{}).mode||"CBC").toUpperCase(),en=(U=O.decrypt?J.cipher.createDecipher($,O.key):J.cipher.createCipher($,O.key)).start;return U.start=function(O,$){var es=null;$ instanceof J.util.ByteBuffer&&(es=$,$={}),($=$||{}).output=es,$.iv=O,en.call(U,$)},U}},2595:function(O){O.exports={options:{usePureJavaScript:!1}}},6888:function(O,U,$){var J=$(2595);$(2528),$(2366),(O.exports=J.hmac=J.hmac||{}).create=function(){var O=null,U=null,$=null,en=null,es={};return es.start=function(es,eo){if(null!==es){if("string"==typeof es){if((es=es.toLowerCase())in J.md.algorithms)U=J.md.algorithms[es].create();else throw Error('Unknown hash algorithm "'+es+'"')}else U=es}if(null===eo)eo=O;else{if("string"==typeof eo)eo=J.util.createBuffer(eo);else if(J.util.isArray(eo)){var ea=eo;eo=J.util.createBuffer();for(var eu=0;euU.blockLength&&(U.start(),U.update(eo.bytes()),eo=U.digest()),$=J.util.createBuffer(),en=J.util.createBuffer(),ef=eo.length();for(var eu=0;eu=0;){var eo=U*this.data[O++]+$.data[J]+en;en=Math.floor(eo/67108864),$.data[J++]=67108863&eo}return en}function am2(O,U,$,J,en,es){for(var eo=32767&U,ea=U>>15;--es>=0;){var eu=32767&this.data[O],ef=this.data[O++]>>15,eg=ea*eu+ef*eo;en=((eu=eo*eu+((32767&eg)<<15)+$.data[J]+(1073741823&en))>>>30)+(eg>>>15)+ea*ef+(en>>>30),$.data[J++]=1073741823&eu}return en}function am3(O,U,$,J,en,es){for(var eo=16383&U,ea=U>>14;--es>=0;){var eu=16383&this.data[O],ef=this.data[O++]>>14,eg=ea*eu+ef*eo;en=((eu=eo*eu+((16383&eg)<<14)+$.data[J]+en)>>28)+(eg>>14)+ea*ef,$.data[J++]=268435455&eu}return en}eo.jsbn.BigInteger=BigInteger,"undefined"==typeof navigator?(BigInteger.prototype.am=am3,J=28):ea&&"Microsoft Internet Explorer"==navigator.appName?(BigInteger.prototype.am=am2,J=30):ea&&"Netscape"!=navigator.appName?(BigInteger.prototype.am=am1,J=26):(BigInteger.prototype.am=am3,J=28),BigInteger.prototype.DB=J,BigInteger.prototype.DM=(1<=0;--U)O.data[U]=this.data[U];O.t=this.t,O.s=this.s}function bnpFromInt(O){this.t=1,this.s=O<0?-1:0,O>0?this.data[0]=O:O<-1?this.data[0]=O+this.DV:this.t=0}function nbv(O){var U=nbi();return U.fromInt(O),U}function bnpFromString(O,U){if(16==U)$=4;else if(8==U)$=3;else if(256==U)$=8;else if(2==U)$=1;else if(32==U)$=5;else if(4==U)$=2;else{this.fromRadix(O,U);return}this.t=0,this.s=0;for(var $,J=O.length,en=!1,es=0;--J>=0;){var eo=8==$?255&O[J]:intAt(O,J);if(eo<0){"-"==O.charAt(J)&&(en=!0);continue}en=!1,0==es?this.data[this.t++]=eo:es+$>this.DB?(this.data[this.t-1]|=(eo&(1<>this.DB-es):this.data[this.t-1]|=eo<=this.DB&&(es-=this.DB)}8==$&&(128&O[0])!=0&&(this.s=-1,es>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==O;)--this.t}function bnToString(O){if(this.s<0)return"-"+this.negate().toString(O);if(16==O)U=4;else if(8==O)U=3;else if(2==O)U=1;else if(32==O)U=5;else{if(4!=O)return this.toRadix(O);U=2}var U,$,J=(1<0)for(ea>ea)>0&&(en=!0,es=int2char($));eo>=0;)ea>(ea+=this.DB-U):($=this.data[eo]>>(ea-=U)&J,ea<=0&&(ea+=this.DB,--eo)),$>0&&(en=!0),en&&(es+=int2char($));return en?es:"0"}function bnNegate(){var O=nbi();return BigInteger.ZERO.subTo(this,O),O}function bnAbs(){return this.s<0?this.negate():this}function bnCompareTo(O){var U=this.s-O.s;if(0!=U)return U;var $=this.t;if(0!=(U=$-O.t))return this.s<0?-U:U;for(;--$>=0;)if(0!=(U=this.data[$]-O.data[$]))return U;return 0}function nbits(O){var U,$=1;return 0!=(U=O>>>16)&&(O=U,$+=16),0!=(U=O>>8)&&(O=U,$+=8),0!=(U=O>>4)&&(O=U,$+=4),0!=(U=O>>2)&&(O=U,$+=2),0!=(U=O>>1)&&(O=U,$+=1),$}function bnBitLength(){return this.t<=0?0:this.DB*(this.t-1)+nbits(this.data[this.t-1]^this.s&this.DM)}function bnpDLShiftTo(O,U){var $;for($=this.t-1;$>=0;--$)U.data[$+O]=this.data[$];for($=O-1;$>=0;--$)U.data[$]=0;U.t=this.t+O,U.s=this.s}function bnpDRShiftTo(O,U){for(var $=O;$=0;--$)U.data[$+eo+1]=this.data[$]>>en|ea,ea=(this.data[$]&es)<=0;--$)U.data[$]=0;U.data[eo]=ea,U.t=this.t+eo+1,U.s=this.s,U.clamp()}function bnpRShiftTo(O,U){U.s=this.s;var $=Math.floor(O/this.DB);if($>=this.t){U.t=0;return}var J=O%this.DB,en=this.DB-J,es=(1<>J;for(var eo=$+1;eo>J;J>0&&(U.data[this.t-$-1]|=(this.s&es)<>=this.DB;if(O.t>=this.DB;J+=this.s}else{for(J+=this.s;$>=this.DB;J-=O.s}U.s=J<0?-1:0,J<-1?U.data[$++]=this.DV+J:J>0&&(U.data[$++]=J),U.t=$,U.clamp()}function bnpMultiplyTo(O,U){var $=this.abs(),J=O.abs(),en=$.t;for(U.t=en+J.t;--en>=0;)U.data[en]=0;for(en=0;en=0;)O.data[$]=0;for($=0;$=U.DV&&(O.data[$+U.t]-=U.DV,O.data[$+U.t+1]=1)}O.t>0&&(O.data[O.t-1]+=U.am($,U.data[$],O,2*$,0,1)),O.s=0,O.clamp()}function bnpDivRemTo(O,U,$){var J=O.abs();if(!(J.t<=0)){var en=this.abs();if(en.t0?(J.lShiftTo(eu,es),en.lShiftTo(eu,$)):(J.copyTo(es),en.copyTo($));var ef=es.t,eg=es.data[ef-1];if(0!=eg){var ev=eg*(1<1?es.data[ef-2]>>this.F2:0),e_=this.FV/ev,ew=(1<=0&&($.data[$.t++]=1,$.subTo(eI,$)),BigInteger.ONE.dlShiftTo(ef,eI),eI.subTo(es,es);es.t=0;){var eP=$.data[--eS]==eg?this.DM:Math.floor($.data[eS]*e_+($.data[eS-1]+eE)*ew);if(($.data[eS]+=es.am(0,eP,$,eA,0,ef))0&&$.rShiftTo(eu,$),eo<0&&BigInteger.ZERO.subTo($,$)}}}function bnMod(O){var U=nbi();return this.abs().divRemTo(O,null,U),this.s<0&&U.compareTo(BigInteger.ZERO)>0&&O.subTo(U,U),U}function Classic(O){this.m=O}function cConvert(O){return O.s<0||O.compareTo(this.m)>=0?O.mod(this.m):O}function cRevert(O){return O}function cReduce(O){O.divRemTo(this.m,null,O)}function cMulTo(O,U,$){O.multiplyTo(U,$),this.reduce($)}function cSqrTo(O,U){O.squareTo(U),this.reduce(U)}function bnpInvDigit(){if(this.t<1)return 0;var O=this.data[0];if((1&O)==0)return 0;var U=3&O;return(U=(U=(U=(U=U*(2-(15&O)*U)&15)*(2-(255&O)*U)&255)*(2-((65535&O)*U&65535))&65535)*(2-O*U%this.DV)%this.DV)>0?this.DV-U:-U}function Montgomery(O){this.m=O,this.mp=O.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(U,U),U}function montRevert(O){var U=nbi();return O.copyTo(U),this.reduce(U),U}function montReduce(O){for(;O.t<=this.mt2;)O.data[O.t++]=0;for(var U=0;U>15)*this.mpl&this.um)<<15)&O.DM;for($=U+this.m.t,O.data[$]+=this.m.am(0,J,O,U,0,this.m.t);O.data[$]>=O.DV;)O.data[$]-=O.DV,O.data[++$]++}O.clamp(),O.drShiftTo(this.m.t,O),O.compareTo(this.m)>=0&&O.subTo(this.m,O)}function montSqrTo(O,U){O.squareTo(U),this.reduce(U)}function montMulTo(O,U,$){O.multiplyTo(U,$),this.reduce($)}function bnpIsEven(){return(this.t>0?1&this.data[0]:this.s)==0}function bnpExp(O,U){if(O>4294967295||O<1)return BigInteger.ONE;var $=nbi(),J=nbi(),en=U.convert(this),es=nbits(O)-1;for(en.copyTo($);--es>=0;)if(U.sqrTo($,J),(O&1<0)U.mulTo(J,en,$);else{var eo=$;$=J,J=eo}return U.revert($)}function bnModPowInt(O,U){var $;return $=O<256||U.isEven()?new Classic(U):new Montgomery(U),this.exp(O,$)}function bnClone(){var O=nbi();return this.copyTo(O),O}function bnIntValue(){if(this.s<0){if(1==this.t)return this.data[0]-this.DV;if(0==this.t)return -1}else if(1==this.t)return this.data[0];else if(0==this.t)return 0;return(this.data[1]&(1<<32-this.DB)-1)<>24}function bnShortValue(){return 0==this.t?this.s:this.data[0]<<16>>16}function bnpChunkSize(O){return Math.floor(Math.LN2*this.DB/Math.log(O))}function bnSigNum(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1}function bnpToRadix(O){if(null==O&&(O=10),0==this.signum()||O<2||O>36)return"0";var U=this.chunkSize(O),$=Math.pow(O,U),J=nbv($),en=nbi(),es=nbi(),eo="";for(this.divRemTo(J,en,es);en.signum()>0;)eo=($+es.intValue()).toString(O).substr(1)+eo,en.divRemTo(J,en,es);return es.intValue().toString(O)+eo}function bnpFromRadix(O,U){this.fromInt(0),null==U&&(U=10);for(var $=this.chunkSize(U),J=Math.pow(U,$),en=!1,es=0,eo=0,ea=0;ea=$&&(this.dMultiply(J),this.dAddOffset(eo,0),es=0,eo=0)}es>0&&(this.dMultiply(Math.pow(U,es)),this.dAddOffset(eo,0)),en&&BigInteger.ZERO.subTo(this,this)}function bnpFromNumber(O,U,$){if("number"==typeof U){if(O<2)this.fromInt(1);else for(this.fromNumber(O,$),this.testBit(O-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(O-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(U);)this.dAddOffset(2,0),this.bitLength()>O&&this.subTo(BigInteger.ONE.shiftLeft(O-1),this)}else{var J=[],en=7&O;J.length=(O>>3)+1,U.nextBytes(J),en>0?J[0]&=(1<0)for(J>J)!=(this.s&this.DM)>>J&&(U[en++]=$|this.s<=0;)J<8?$=(this.data[O]&(1<>(J+=this.DB-8):($=this.data[O]>>(J-=8)&255,J<=0&&(J+=this.DB,--O)),(128&$)!=0&&($|=-256),0==en&&(128&this.s)!=(128&$)&&++en,(en>0||$!=this.s)&&(U[en++]=$);return U}function bnEquals(O){return 0==this.compareTo(O)}function bnMin(O){return 0>this.compareTo(O)?this:O}function bnMax(O){return this.compareTo(O)>0?this:O}function bnpBitwiseTo(O,U,$){var J,en,es=Math.min(O.t,this.t);for(J=0;J>=16,U+=16),(255&O)==0&&(O>>=8,U+=8),(15&O)==0&&(O>>=4,U+=4),(3&O)==0&&(O>>=2,U+=2),(1&O)==0&&++U,U}function bnGetLowestSetBit(){for(var O=0;O=this.t?0!=this.s:(this.data[U]&1<>=this.DB;if(O.t>=this.DB;J+=this.s}else{for(J+=this.s;$>=this.DB;J+=O.s}U.s=J<0?-1:0,J>0?U.data[$++]=J:J<-1&&(U.data[$++]=this.DV+J),U.t=$,U.clamp()}function bnAdd(O){var U=nbi();return this.addTo(O,U),U}function bnSubtract(O){var U=nbi();return this.subTo(O,U),U}function bnMultiply(O){var U=nbi();return this.multiplyTo(O,U),U}function bnDivide(O){var U=nbi();return this.divRemTo(O,U,null),U}function bnRemainder(O){var U=nbi();return this.divRemTo(O,null,U),U}function bnDivideAndRemainder(O){var U=nbi(),$=nbi();return this.divRemTo(O,U,$),[U,$]}function bnpDMultiply(O){this.data[this.t]=this.am(0,O-1,this,0,0,this.t),++this.t,this.clamp()}function bnpDAddOffset(O,U){if(0!=O){for(;this.t<=U;)this.data[this.t++]=0;for(this.data[U]+=O;this.data[U]>=this.DV;)this.data[U]-=this.DV,++U>=this.t&&(this.data[this.t++]=0),++this.data[U]}}function NullExp(){}function nNop(O){return O}function nMulTo(O,U,$){O.multiplyTo(U,$)}function nSqrTo(O,U){O.squareTo(U)}function bnPow(O){return this.exp(O,new NullExp)}function bnpMultiplyLowerTo(O,U,$){var J,en=Math.min(this.t+O.t,U);for($.s=0,$.t=en;en>0;)$.data[--en]=0;for(J=$.t-this.t;en=0;)$.data[J]=0;for(J=Math.max(U-this.t,0);J2*this.m.t)return O.mod(this.m);if(0>O.compareTo(this.m))return O;var U=nbi();return O.copyTo(U),this.reduce(U),U}function barrettRevert(O){return O}function barrettReduce(O){for(O.drShiftTo(this.m.t-1,this.r2),O.t>this.m.t+1&&(O.t=this.m.t+1,O.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);0>O.compareTo(this.r2);)O.dAddOffset(1,this.m.t+1);for(O.subTo(this.r2,O);O.compareTo(this.m)>=0;)O.subTo(this.m,O)}function barrettSqrTo(O,U){O.squareTo(U),this.reduce(U)}function barrettMulTo(O,U,$){O.multiplyTo(U,$),this.reduce($)}function bnModPow(O,U){var $,J,en=O.bitLength(),es=nbv(1);if(en<=0)return es;$=en<18?1:en<48?3:en<144?4:en<768?5:6,J=en<8?new Classic(U):U.isEven()?new Barrett(U):new Montgomery(U);var eo=[],ea=3,eu=$-1,ef=(1<<$)-1;if(eo[1]=J.convert(this),$>1){var eg=nbi();for(J.sqrTo(eo[1],eg);ea<=ef;)eo[ea]=nbi(),J.mulTo(eg,eo[ea-2],eo[ea]),ea+=2}var ev,e_,ew=O.t-1,eE=!0,eS=nbi();for(en=nbits(O.data[ew])-1;ew>=0;){for(en>=eu?ev=O.data[ew]>>en-eu&ef:(ev=(O.data[ew]&(1<0&&(ev|=O.data[ew-1]>>this.DB+en-eu)),ea=$;(1&ev)==0;)ev>>=1,--ea;if((en-=ea)<0&&(en+=this.DB,--ew),eE)eo[ev].copyTo(es),eE=!1;else{for(;ea>1;)J.sqrTo(es,eS),J.sqrTo(eS,es),ea-=2;ea>0?J.sqrTo(es,eS):(e_=es,es=eS,eS=e_),J.mulTo(eS,eo[ev],es)}for(;ew>=0&&(O.data[ew]&1<U.compareTo($)){var J=U;U=$,$=J}var en=U.getLowestSetBit(),es=$.getLowestSetBit();if(es<0)return U;for(en0&&(U.rShiftTo(es,U),$.rShiftTo(es,$));U.signum()>0;)(en=U.getLowestSetBit())>0&&U.rShiftTo(en,U),(en=$.getLowestSetBit())>0&&$.rShiftTo(en,$),U.compareTo($)>=0?(U.subTo($,U),U.rShiftTo(1,U)):($.subTo(U,$),$.rShiftTo(1,$));return es>0&&$.lShiftTo(es,$),$}function bnpModInt(O){if(O<=0)return 0;var U=this.DV%O,$=this.s<0?O-1:0;if(this.t>0){if(0==U)$=this.data[0]%O;else for(var J=this.t-1;J>=0;--J)$=(U*$+this.data[J])%O}return $}function bnModInverse(O){var U=O.isEven();if(this.isEven()&&U||0==O.signum())return BigInteger.ZERO;for(var $=O.clone(),J=this.clone(),en=nbv(1),es=nbv(0),eo=nbv(0),ea=nbv(1);0!=$.signum();){for(;$.isEven();)$.rShiftTo(1,$),U?(en.isEven()&&es.isEven()||(en.addTo(this,en),es.subTo(O,es)),en.rShiftTo(1,en)):es.isEven()||es.subTo(O,es),es.rShiftTo(1,es);for(;J.isEven();)J.rShiftTo(1,J),U?(eo.isEven()&&ea.isEven()||(eo.addTo(this,eo),ea.subTo(O,ea)),eo.rShiftTo(1,eo)):ea.isEven()||ea.subTo(O,ea),ea.rShiftTo(1,ea);$.compareTo(J)>=0?($.subTo(J,$),U&&en.subTo(eo,en),es.subTo(ea,es)):(J.subTo($,J),U&&eo.subTo(en,eo),ea.subTo(es,ea))}return 0!=J.compareTo(BigInteger.ONE)?BigInteger.ZERO:ea.compareTo(O)>=0?ea.subtract(O):0>ea.signum()&&(ea.addTo(O,ea),0>ea.signum())?ea.add(O):ea}Classic.prototype.convert=cConvert,Classic.prototype.revert=cRevert,Classic.prototype.reduce=cReduce,Classic.prototype.mulTo=cMulTo,Classic.prototype.sqrTo=cSqrTo,Montgomery.prototype.convert=montConvert,Montgomery.prototype.revert=montRevert,Montgomery.prototype.reduce=montReduce,Montgomery.prototype.mulTo=montMulTo,Montgomery.prototype.sqrTo=montSqrTo,BigInteger.prototype.copyTo=bnpCopyTo,BigInteger.prototype.fromInt=bnpFromInt,BigInteger.prototype.fromString=bnpFromString,BigInteger.prototype.clamp=bnpClamp,BigInteger.prototype.dlShiftTo=bnpDLShiftTo,BigInteger.prototype.drShiftTo=bnpDRShiftTo,BigInteger.prototype.lShiftTo=bnpLShiftTo,BigInteger.prototype.rShiftTo=bnpRShiftTo,BigInteger.prototype.subTo=bnpSubTo,BigInteger.prototype.multiplyTo=bnpMultiplyTo,BigInteger.prototype.squareTo=bnpSquareTo,BigInteger.prototype.divRemTo=bnpDivRemTo,BigInteger.prototype.invDigit=bnpInvDigit,BigInteger.prototype.isEven=bnpIsEven,BigInteger.prototype.exp=bnpExp,BigInteger.prototype.toString=bnToString,BigInteger.prototype.negate=bnNegate,BigInteger.prototype.abs=bnAbs,BigInteger.prototype.compareTo=bnCompareTo,BigInteger.prototype.bitLength=bnBitLength,BigInteger.prototype.mod=bnMod,BigInteger.prototype.modPowInt=bnModPowInt,BigInteger.ZERO=nbv(0),BigInteger.ONE=nbv(1),NullExp.prototype.convert=nNop,NullExp.prototype.revert=nNop,NullExp.prototype.mulTo=nMulTo,NullExp.prototype.sqrTo=nSqrTo,Barrett.prototype.convert=barrettConvert,Barrett.prototype.revert=barrettRevert,Barrett.prototype.reduce=barrettReduce,Barrett.prototype.mulTo=barrettMulTo,Barrett.prototype.sqrTo=barrettSqrTo;var ev=[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],e_=67108864/ev[ev.length-1];function bnIsProbablePrime(O){var U,$=this.abs();if(1==$.t&&$.data[0]<=ev[ev.length-1]){for(U=0;U=U.compareTo(BigInteger.ONE)||U.compareTo($)>=0);var ea=U.modPow(en,this);if(0!=ea.compareTo(BigInteger.ONE)&&0!=ea.compareTo($)){for(var eu=1;eu++=0;eu--)eU>>=8,eU+=eD.at(eu)+eL.at(eu),eL.setAt(eu,255&eU);eO.putBuffer(eL)}eT=eO,ev.putBuffer(eB)}return ev.truncate(ev.length()-es),ev},eo.pbe.getCipher=function(O,U,$){switch(O){case eo.oids.pkcs5PBES2:return eo.pbe.getCipherForPBES2(O,U,$);case eo.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case eo.oids["pbewithSHAAnd40BitRC2-CBC"]:return eo.pbe.getCipherForPKCS12PBE(O,U,$);default:var J=Error("Cannot read encrypted PBE data block. Unsupported OID.");throw J.oid=O,J.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],J}},eo.pbe.getCipherForPBES2=function(O,U,$){var en,ea,eu={},eg=[];if(!es.validate(U,ef,eu,eg)){var ev=Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw ev.errors=eg,ev}if((O=es.derToOid(eu.kdfOid))!==eo.oids.pkcs5PBKDF2){var ev=Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw ev.oid=O,ev.supportedOids=["pkcs5PBKDF2"],ev}if((O=es.derToOid(eu.encOid))!==eo.oids["aes128-CBC"]&&O!==eo.oids["aes192-CBC"]&&O!==eo.oids["aes256-CBC"]&&O!==eo.oids["des-EDE3-CBC"]&&O!==eo.oids.desCBC){var ev=Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw ev.oid=O,ev.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],ev}var e_=eu.kdfSalt,ew=J.util.createBuffer(eu.kdfIterationCount);switch(ew=ew.getInt(ew.length()<<3),eo.oids[O]){case"aes128-CBC":en=16,ea=J.aes.createDecryptionCipher;break;case"aes192-CBC":en=24,ea=J.aes.createDecryptionCipher;break;case"aes256-CBC":en=32,ea=J.aes.createDecryptionCipher;break;case"des-EDE3-CBC":en=24,ea=J.des.createDecryptionCipher;break;case"desCBC":en=8,ea=J.des.createDecryptionCipher}var eE=prfOidToMessageDigest(eu.prfOid),eS=J.pkcs5.pbkdf2($,e_,ew,en,eE),eA=eu.encIv,eI=ea(eS);return eI.start(eA),eI},eo.pbe.getCipherForPKCS12PBE=function(O,U,$){var en,ea,eu,ef={},ev=[];if(!es.validate(U,eg,ef,ev)){var e_=Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw e_.errors=ev,e_}var ew=J.util.createBuffer(ef.salt),eE=J.util.createBuffer(ef.iterations);switch(eE=eE.getInt(eE.length()<<3),O){case eo.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:en=24,ea=8,eu=J.des.startDecrypting;break;case eo.oids["pbewithSHAAnd40BitRC2-CBC"]:en=5,ea=8,eu=function(O,U){var $=J.rc2.createDecryptionCipher(O,40);return $.start(U,null),$};break;default:var e_=Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw e_.oid=O,e_}var eS=prfOidToMessageDigest(ef.prfOid),eA=eo.pbe.generatePkcs12Key($,ew,1,eE,en,eS);return eS.start(),eu(eA,eo.pbe.generatePkcs12Key($,ew,2,eE,ea,eS))},eo.pbe.opensslDeriveBytes=function(O,U,$,en){if(null==en){if(!("md5"in J.md))throw Error('"md5" hash algorithm unavailable.');en=J.md.md5.create()}null===U&&(U="");for(var es=[hash(en,O+U)],eo=16,ea=1;eo<$;++ea,eo+=16)es.push(hash(en,es[ea-1]+O+U));return es.join("").substr(0,$)}},1953:function(O,U,$){var J,en=$(2678).Buffer,es=$(2595);$(6888),$(2528),$(2366);var eo=es.pkcs5=es.pkcs5||{};es.util.isNodejs&&!es.options.usePureJavaScript&&(J=$(5819)),O.exports=es.pbkdf2=eo.pbkdf2=function(O,U,$,eo,ea,eu){if("function"==typeof ea&&(eu=ea,ea=null),es.util.isNodejs&&!es.options.usePureJavaScript&&J.pbkdf2&&(null===ea||"object"!=typeof ea)&&(J.pbkdf2Sync.length>4||!ea||"sha1"===ea))return("string"!=typeof ea&&(ea="sha1"),O=en.from(O,"binary"),U=en.from(U,"binary"),eu)?4===J.pbkdf2Sync.length?J.pbkdf2(O,U,$,eo,function(O,U){if(O)return eu(O);eu(null,U.toString("binary"))}):J.pbkdf2(O,U,$,eo,ea,function(O,U){if(O)return eu(O);eu(null,U.toString("binary"))}):4===J.pbkdf2Sync.length?J.pbkdf2Sync(O,U,$,eo).toString("binary"):J.pbkdf2Sync(O,U,$,eo,ea).toString("binary");if(null==ea&&(ea="sha1"),"string"==typeof ea){if(!(ea in es.md.algorithms))throw Error("Unknown hash algorithm: "+ea);ea=es.md[ea].create()}var ef=ea.digestLength;if(eo>4294967295*ef){var eg=Error("Derived key is too long.");if(eu)return eu(eg);throw eg}var ev=Math.ceil(eo/ef),e_=eo-(ev-1)*ef,ew=es.hmac.create();ew.start(ea,O);var eE="";if(!eu){for(var eS=1;eS<=ev;++eS){ew.start(null,null),ew.update(U),ew.update(es.util.int32ToBytes(eS)),eI=ek=ew.digest().getBytes();for(var eA=2;eA<=$;++eA)ew.start(null,null),ew.update(ek),eP=ew.digest().getBytes(),eI=es.util.xorBytes(eI,eP,ef),ek=eP;eE+=eSev)return eu(null,eE);ew.start(null,null),ew.update(U),ew.update(es.util.int32ToBytes(eS)),eI=ek=ew.digest().getBytes(),eA=2,inner()}function inner(){if(eA<=$)return ew.start(null,null),ew.update(ek),eP=ew.digest().getBytes(),eI=es.util.xorBytes(eI,eP,ef),ek=eP,++eA,es.util.setImmediate(inner);eE+=eS65&&-1!==es){var eo=U[es];","===eo?(++es,U=U.substr(0,es)+"\r\n "+U.substr(es)):U=U.substr(0,es)+"\r\n"+eo+U.substr(es+1),en=J-es-1,es=-1,++J}else(" "===U[J]||" "===U[J]||","===U[J])&&(es=J);return U}function ltrim(O){return O.replace(/^\s+/,"")}en.encode=function(O,U){U=U||{};var $,en="-----BEGIN "+O.type+"-----\r\n";if(O.procType&&(en+=foldHeader($={name:"Proc-Type",values:[String(O.procType.version),O.procType.type]})),O.contentDomain&&(en+=foldHeader($={name:"Content-Domain",values:[O.contentDomain]})),O.dekInfo&&($={name:"DEK-Info",values:[O.dekInfo.algorithm]},O.dekInfo.parameters&&$.values.push(O.dekInfo.parameters),en+=foldHeader($)),O.headers)for(var es=0;es>24&255,eo>>16&255,eo>>8&255,255&eo);$.start(),$.update(O+ea),en+=$.digest().getBytes()}return en.substring(0,U)}en.encode_rsa_oaep=function(O,U,$){"string"==typeof $?(en=$,es=arguments[3]||void 0,eo=arguments[4]||void 0):$&&(en=$.label||void 0,es=$.seed||void 0,eo=$.md||void 0,$.mgf1&&$.mgf1.md&&(ea=$.mgf1.md)),eo?eo.start():eo=J.md.sha1.create(),ea||(ea=eo);var en,es,eo,ea,eu=Math.ceil(O.n.bitLength()/8),ef=eu-2*eo.digestLength-2;if(U.length>ef){var eg=Error("RSAES-OAEP input message length is too long.");throw eg.length=U.length,eg.maxLength=ef,eg}en||(en=""),eo.update(en,"raw");for(var ev=eo.digest(),e_="",ew=ef-U.length,eE=0;eEU&&(O=generateRandom(U,$)),O.isProbablePrime(eo))return eu(null,O);O.dAddOffset(en[es++%8],0)}while(ea<0||+new Date-efO&&(eo=generateRandom(O,U));var ew=eo.toString(16);en.target.postMessage({hex:ew,workLoad:eu}),eo.dAddOffset(ef,0)}}}generate()}function generateRandom(O,U){var J=new $(O,U),en=O-1;return J.testBit(en)||J.bitwiseTo($.ONE.shiftLeft(en),op_or,J),J.dAddOffset(31-J.mod(es).byteValue(),0),J}function getMillerRabinTests(O){return O<=100?27:O<=150?18:O<=200?15:O<=250?12:O<=300?9:O<=350?8:O<=400?7:O<=500?6:O<=600?5:O<=800?4:O<=1250?3:2}U.generateProbablePrime=function(O,U,$){"function"==typeof U&&($=U,U={});var en=(U=U||{}).algorithm||"PRIMEINC";"string"==typeof en&&(en={name:en}),en.options=en.options||{};var es=U.prng||J.random,eo={nextBytes:function(O){for(var U=es.getBytesSync(O.length),$=0;$=32)return _seed(),O();var $=32-U.pools[0].messageLength<<5;U.seedFile($,function($,J){if($)return O($);U.collect(J),_seed(),O()})}function _reseedSync(){if(U.pools[0].messageLength>=32)return _seed();var O=32-U.pools[0].messageLength<<5;U.collect(U.seedFileSync(O)),_seed()}function _seed(){U.reseeds=4294967295===U.reseeds?0:U.reseeds+1;var O=U.plugin.md.create();O.update(U.keyBytes);for(var $=1,J=0;J<32;++J)U.reseeds%$==0&&(O.update(U.pools[J].digest().getBytes()),U.pools[J].start()),$<<=1;U.keyBytes=O.digest().getBytes(),O.start(),O.update(U.keyBytes);var en=O.digest().getBytes();U.key=U.plugin.formatKey(U.keyBytes),U.seed=U.plugin.formatSeed(en),U.generated=0}function defaultSeedFile(O){var U=null,$=en.util.globalScope,J=$.crypto||$.msCrypto;J&&J.getRandomValues&&(U=function(O){return J.getRandomValues(O)});var es=en.util.createBuffer();if(U)for(;es.length()>16)))<<16)+(ef>>15))))+(eg>>31));for(var eu=0;eu<3;++eu)ev=e_>>>(eu<<3)^Math.floor(256*Math.random()),es.putByte(255&ev)}return es.getBytes(O)}return U.pools=J,U.pool=0,U.generate=function(O,$){if(!$)return U.generateSync(O);var J=U.plugin.cipher,es=U.plugin.increment,eo=U.plugin.formatKey,ea=U.plugin.formatSeed,eu=en.util.createBuffer();function generate(ef){if(ef)return $(ef);if(eu.length()>=O)return $(null,eu.getBytes(O));if(U.generated>1048575&&(U.key=null),null===U.key)return en.util.nextTick(function(){_reseed(generate)});var eg=J(U.key,U.seed);U.generated+=eg.length,eu.putBytes(eg),U.key=eo(J(U.key,es(U.seed))),U.seed=ea(J(U.key,U.seed)),en.util.setImmediate(generate)}U.key=null,generate()},U.generateSync=function(O){var $=U.plugin.cipher,J=U.plugin.increment,es=U.plugin.formatKey,eo=U.plugin.formatSeed;U.key=null;for(var ea=en.util.createBuffer();ea.length()1048575&&(U.key=null),null===U.key&&_reseedSync();var eu=$(U.key,U.seed);U.generated+=eu.length,ea.putBytes(eu),U.key=es($(U.key,J(U.seed))),U.seed=eo($(U.key,U.seed))}return ea.getBytes(O)},es?(U.seedFile=function(O,U){es.randomBytes(O,function(O,$){if(O)return U(O);U(null,$.toString())})},U.seedFileSync=function(O){return es.randomBytes(O).toString()}):(U.seedFile=function(O,U){try{U(null,defaultSeedFile(O))}catch(O){U(O)}},U.seedFileSync=defaultSeedFile),U.collect=function(O){for(var $=O.length,J=0;J<$;++J)U.pools[U.pool].update(O.substr(J,1)),U.pool=31===U.pool?0:U.pool+1},U.collectInt=function(O,$){for(var J="",en=0;en<$;en+=8)J+=String.fromCharCode(O>>en&255);U.collect(J)},U.registerWorker=function(O){if(O===self)U.seedFile=function(O,U){function listener(O){var $=O.data;$.forge&&$.forge.prng&&(self.removeEventListener("message",listener),U($.forge.prng.err,$.forge.prng.bytes))}self.addEventListener("message",listener),self.postMessage({forge:{prng:{needed:O}}})};else{var listener=function($){var J=$.data;J.forge&&J.forge.prng&&U.seedFile(J.forge.prng.needed,function(U,$){O.postMessage({forge:{prng:{err:U,bytes:$}}})})};O.addEventListener("message",listener)}},U}},9249:function(O,U,$){var J=$(2595);$(1250),$(7624),$(2927),$(2366),function(){if(J.random&&J.random.getBytes){O.exports=J.random;return}!function(U){var $={},en=[,,,,],es=J.util.createBuffer();function spawnPrng(){var O=J.prng.create($);return O.getBytes=function(U,$){return O.generate(U,$)},O.getBytesSync=function(U){return O.generate(U)},O}$.formatKey=function(O){var U=J.util.createBuffer(O);return(O=[,,,,])[0]=U.getInt32(),O[1]=U.getInt32(),O[2]=U.getInt32(),O[3]=U.getInt32(),J.aes._expandKey(O,!1)},$.formatSeed=function(O){var U=J.util.createBuffer(O);return(O=[,,,,])[0]=U.getInt32(),O[1]=U.getInt32(),O[2]=U.getInt32(),O[3]=U.getInt32(),O},$.cipher=function(O,U){return J.aes._updateBlock(O,U,en,!1),es.putInt32(en[0]),es.putInt32(en[1]),es.putInt32(en[2]),es.putInt32(en[3]),es.getBytes()},$.increment=function(O){return++O[3],O},$.md=J.md.sha256;var eo=spawnPrng(),ea=null,eu=J.util.globalScope,ef=eu.crypto||eu.msCrypto;if(ef&&ef.getRandomValues&&(ea=function(O){return ef.getRandomValues(O)}),J.options.usePureJavaScript||!J.util.isNodejs&&!ea){if("undefined"==typeof window||window.document,eo.collectInt(+new Date,32),"undefined"!=typeof navigator){var eg="";for(var ev in navigator)try{"string"==typeof navigator[ev]&&(eg+=navigator[ev])}catch(O){}eo.collect(eg),eg=null}U&&(U().mousemove(function(O){eo.collectInt(O.clientX,16),eo.collectInt(O.clientY,16)}),U().keypress(function(O){eo.collectInt(O.charCode,8)}))}if(J.random)for(var ev in eo)J.random[ev]=eo[ev];else J.random=eo;J.random.createInstance=spawnPrng,O.exports=J.random}("undefined"!=typeof jQuery?jQuery:null)}()},3574:function(O,U,$){var J=$(2595);$(2366);var en=[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],es=[1,2,3,5],rol=function(O,U){return O<>16-U},ror=function(O,U){return(65535&O)>>U|O<<16-U&65535};O.exports=J.rc2=J.rc2||{},J.rc2.expandKey=function(O,U){"string"==typeof O&&(O=J.util.createBuffer(O)),U=U||128;var $,es=O,eo=O.length(),ea=U,eu=Math.ceil(ea/8),ef=255>>(7&ea);for($=eo;$<128;$++)es.putByte(en[es.at($-1)+es.at($-eo)&255]);for(es.setAt(128-eu,en[es.at(128-eu)&ef]),$=127-eu;$>=0;$--)es.setAt($,en[es.at($+1)^es.at($+eu)]);return es};var createCipher=function(O,U,$){var en,eo,ea,eu,ef=!1,eg=null,ev=null,e_=null,ew=[];for(ea=0,O=J.rc2.expandKey(O,U);ea<64;ea++)ew.push(O.getInt16Le());$?(en=function(O){for(ea=0;ea<4;ea++)O[ea]+=ew[eu]+(O[(ea+3)%4]&O[(ea+2)%4])+(~O[(ea+3)%4]&O[(ea+1)%4]),O[ea]=rol(O[ea],es[ea]),eu++},eo=function(O){for(ea=0;ea<4;ea++)O[ea]+=ew[63&O[(ea+3)%4]]}):(en=function(O){for(ea=3;ea>=0;ea--)O[ea]=ror(O[ea],es[ea]),O[ea]-=ew[eu]+(O[(ea+3)%4]&O[(ea+2)%4])+(~O[(ea+3)%4]&O[(ea+1)%4]),eu--},eo=function(O){for(ea=3;ea>=0;ea--)O[ea]-=ew[63&O[(ea+3)%4]]});var runPlan=function(O){var U=[];for(ea=0;ea<4;ea++){var J=eg.getInt16Le();null!==e_&&($?J^=e_.getInt16Le():e_.putInt16Le(J)),U.push(65535&J)}eu=$?0:63;for(var en=0;en=8;)runPlan([[5,en],[1,eo],[6,en],[1,eo],[5,en]])},finish:function(O){var U=!0;if($){if(O)U=O(8,eg,!$);else{var J=8===eg.length()?8:8-eg.length();eg.fillWithByte(J,J)}}if(U&&(ef=!0,eE.update()),!$&&(U=0===eg.length())){if(O)U=O(8,ev,!$);else{var en=ev.length(),es=ev.at(en-1);es>en?U=!1:ev.truncate(es)}}return U}}};J.rc2.startEncrypting=function(O,U,$){var en=J.rc2.createEncryptionCipher(O,128);return en.start(U,$),en},J.rc2.createEncryptionCipher=function(O,U){return createCipher(O,U,!0)},J.rc2.startDecrypting=function(O,U,$){var en=J.rc2.createDecryptionCipher(O,128);return en.start(U,$),en},J.rc2.createDecryptionCipher=function(O,U){return createCipher(O,U,!1)}},411:function(O,U,$){var J=$(2595);if($(9642),$(4196),$(552),$(4210),$(7236),$(9249),$(2366),void 0===en)var en=J.jsbn.BigInteger;var es=J.util.isNodejs?$(5819):null,eo=J.asn1,ea=J.util;J.pki=J.pki||{},O.exports=J.pki.rsa=J.rsa=J.rsa||{};var eu=J.pki,ef=[6,4,2,4,2,4,6,2],eg={name:"PrivateKeyInfo",tagClass:eo.Class.UNIVERSAL,type:eo.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:eo.Class.UNIVERSAL,type:eo.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:eo.Class.UNIVERSAL,type:eo.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:eo.Class.UNIVERSAL,type:eo.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:eo.Class.UNIVERSAL,type:eo.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},ev={name:"RSAPrivateKey",tagClass:eo.Class.UNIVERSAL,type:eo.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:eo.Class.UNIVERSAL,type:eo.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:eo.Class.UNIVERSAL,type:eo.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:eo.Class.UNIVERSAL,type:eo.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:eo.Class.UNIVERSAL,type:eo.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:eo.Class.UNIVERSAL,type:eo.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:eo.Class.UNIVERSAL,type:eo.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:eo.Class.UNIVERSAL,type:eo.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:eo.Class.UNIVERSAL,type:eo.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:eo.Class.UNIVERSAL,type:eo.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},e_={name:"RSAPublicKey",tagClass:eo.Class.UNIVERSAL,type:eo.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:eo.Class.UNIVERSAL,type:eo.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:eo.Class.UNIVERSAL,type:eo.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},ew=J.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:eo.Class.UNIVERSAL,type:eo.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:eo.Class.UNIVERSAL,type:eo.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:eo.Class.UNIVERSAL,type:eo.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:eo.Class.UNIVERSAL,type:eo.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:eo.Class.UNIVERSAL,type:eo.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},eE={name:"DigestInfo",tagClass:eo.Class.UNIVERSAL,type:eo.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:eo.Class.UNIVERSAL,type:eo.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:eo.Class.UNIVERSAL,type:eo.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:eo.Class.UNIVERSAL,type:eo.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:eo.Class.UNIVERSAL,type:eo.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},emsaPkcs1v15encode=function(O){if(O.algorithm in eu.oids)U=eu.oids[O.algorithm];else{var U,$=Error("Unknown message digest algorithm.");throw $.algorithm=O.algorithm,$}var J=eo.oidToDer(U).getBytes(),en=eo.create(eo.Class.UNIVERSAL,eo.Type.SEQUENCE,!0,[]),es=eo.create(eo.Class.UNIVERSAL,eo.Type.SEQUENCE,!0,[]);es.value.push(eo.create(eo.Class.UNIVERSAL,eo.Type.OID,!1,J)),es.value.push(eo.create(eo.Class.UNIVERSAL,eo.Type.NULL,!1,""));var ea=eo.create(eo.Class.UNIVERSAL,eo.Type.OCTETSTRING,!1,O.digest().getBytes());return en.value.push(es),en.value.push(ea),eo.toDer(en).getBytes()},_modPow=function(O,U,$){if($)return O.modPow(U.e,U.n);if(!U.p||!U.q)return O.modPow(U.d,U.n);U.dP||(U.dP=U.d.mod(U.p.subtract(en.ONE))),U.dQ||(U.dQ=U.d.mod(U.q.subtract(en.ONE))),U.qInv||(U.qInv=U.q.modInverse(U.p));do es=new en(J.util.bytesToHex(J.random.getBytes(U.n.bitLength()/8)),16);while(es.compareTo(U.n)>=0||!es.gcd(U.n).equals(en.ONE));for(var es,eo=(O=O.multiply(es.modPow(U.e,U.n)).mod(U.n)).mod(U.p).modPow(U.dP,U.p),ea=O.mod(U.q).modPow(U.dQ,U.q);0>eo.compareTo(ea);)eo=eo.add(U.p);return eo.subtract(ea).multiply(U.qInv).mod(U.p).multiply(U.q).add(ea).multiply(es.modInverse(U.n)).mod(U.n)};function _encodePkcs1_v1_5(O,U,$){var en,es=J.util.createBuffer(),eo=Math.ceil(U.n.bitLength()/8);if(O.length>eo-11){var ea=Error("Message is too long for PKCS#1 v1.5 padding.");throw ea.length=O.length,ea.max=eo-11,ea}es.putByte(0),es.putByte($);var eu=eo-3-O.length;if(0===$||1===$){en=0===$?0:255;for(var ef=0;ef0;){for(var eg=0,ev=J.random.getBytes(eu),ef=0;ef1;){if(255!==eo.getByte()){--eo.read;break}++ef}else if(2===eu)for(ef=0;eo.length()>1;){if(0===eo.getByte()){--eo.read;break}++ef}if(0!==eo.getByte()||ef!==es-3-eo.length())throw Error("Encryption block is invalid.");return eo.getBytes()}function _generateKeyPair(O,U,$){"function"==typeof U&&($=U,U={});var es={algorithm:{name:(U=U||{}).algorithm||"PRIMEINC",options:{workers:U.workers||2,workLoad:U.workLoad||100,workerScript:U.workerScript}}};function generate(){getPrime(O.pBits,function(U,J){return U?$(U):(O.p=J,null!==O.q)?finish(U,O.q):void getPrime(O.qBits,finish)})}function getPrime(O,U){J.prime.generateProbablePrime(O,es,U)}function finish(U,J){if(U)return $(U);if(O.q=J,0>O.p.compareTo(O.q)){var es=O.p;O.p=O.q,O.q=es}if(0!==O.p.subtract(en.ONE).gcd(O.e).compareTo(en.ONE)){O.p=null,generate();return}if(0!==O.q.subtract(en.ONE).gcd(O.e).compareTo(en.ONE)){O.q=null,getPrime(O.qBits,finish);return}if(O.p1=O.p.subtract(en.ONE),O.q1=O.q.subtract(en.ONE),O.phi=O.p1.multiply(O.q1),0!==O.phi.gcd(O.e).compareTo(en.ONE)){O.p=O.q=null,generate();return}if(O.n=O.p.multiply(O.q),O.n.bitLength()!==O.bits){O.q=null,getPrime(O.qBits,finish);return}var eo=O.e.modInverse(O.phi);O.keys={privateKey:eu.rsa.setPrivateKey(O.n,O.e,eo,O.p,O.q,eo.mod(O.p1),eo.mod(O.q1),O.q.modInverse(O.p)),publicKey:eu.rsa.setPublicKey(O.n,O.e)},$(null,O.keys)}"prng"in U&&(es.prng=U.prng),generate()}function _bnToBytes(O){var U=O.toString(16);U[0]>="8"&&(U="00"+U);var $=J.util.hexToBytes(U);return $.length>1&&(0===$.charCodeAt(0)&&(128&$.charCodeAt(1))==0||255===$.charCodeAt(0)&&(128&$.charCodeAt(1))==128)?$.substr(1):$}function _getMillerRabinTests(O){return O<=100?27:O<=150?18:O<=200?15:O<=250?12:O<=300?9:O<=350?8:O<=400?7:O<=500?6:O<=600?5:O<=800?4:O<=1250?3:2}function _detectNodeCrypto(O){return J.util.isNodejs&&"function"==typeof es[O]}function _detectSubtleCrypto(O){return void 0!==ea.globalScope&&"object"==typeof ea.globalScope.crypto&&"object"==typeof ea.globalScope.crypto.subtle&&"function"==typeof ea.globalScope.crypto.subtle[O]}function _detectSubtleMsCrypto(O){return void 0!==ea.globalScope&&"object"==typeof ea.globalScope.msCrypto&&"object"==typeof ea.globalScope.msCrypto.subtle&&"function"==typeof ea.globalScope.msCrypto.subtle[O]}function _intToUint8Array(O){for(var U=J.util.hexToBytes(O.toString(16)),$=new Uint8Array(U.length),en=0;en0;)ef.putByte(0),--eg;return ef.putBytes(J.util.hexToBytes(eu)),ef.getBytes()},eu.rsa.decrypt=function(O,U,$,es){var eo=Math.ceil(U.n.bitLength()/8);if(O.length!==eo){var ea=Error("Encrypted message length is invalid.");throw ea.length=O.length,ea.expected=eo,ea}var eu=new en(J.util.createBuffer(O).toHex(),16);if(eu.compareTo(U.n)>=0)throw Error("Encrypted message is invalid.");for(var ef=_modPow(eu,U,$).toString(16),eg=J.util.createBuffer(),ev=eo-Math.ceil(ef.length/2);ev>0;)eg.putByte(0),--ev;return(eg.putBytes(J.util.hexToBytes(ef)),!1!==es)?_decodePkcs1_v1_5(eg.getBytes(),U,$):eg.getBytes()},eu.rsa.createKeyPairGenerationState=function(O,U,$){"string"==typeof O&&(O=parseInt(O,10)),O=O||2048;var es,eo=($=$||{}).prng||J.random,ea={nextBytes:function(O){for(var U=eo.getBytesSync(O.length),$=0;$>1,pBits:O-(O>>1),pqState:0,num:null,keys:null}).e.fromInt(es.eInt);else throw Error("Invalid key generation algorithm: "+eu);return es},eu.rsa.stepKeyPairGenerationState=function(O,U){"algorithm"in O||(O.algorithm="PRIMEINC");var $,J=new en(null);J.fromInt(30);for(var es=0,op_or=function(O,U){return O|U},eo=+new Date,ea=0;null===O.keys&&(U<=0||eaeg?O.pqState=0:O.num.isProbablePrime(_getMillerRabinTests(O.num.bitLength()))?++O.pqState:O.num.dAddOffset(ef[es++%8],0):2===O.pqState?O.pqState=0===O.num.subtract(en.ONE).gcd(O.e).compareTo(en.ONE)?3:0:3===O.pqState&&(O.pqState=0,null===O.p?O.p=O.num:O.q=O.num,null!==O.p&&null!==O.q&&++O.state,O.num=null)}else if(1===O.state)0>O.p.compareTo(O.q)&&(O.num=O.p,O.p=O.q,O.q=O.num),++O.state;else if(2===O.state)O.p1=O.p.subtract(en.ONE),O.q1=O.q.subtract(en.ONE),O.phi=O.p1.multiply(O.q1),++O.state;else if(3===O.state)0===O.phi.gcd(O.e).compareTo(en.ONE)?++O.state:(O.p=null,O.q=null,O.state=0);else if(4===O.state)O.n=O.p.multiply(O.q),O.n.bitLength()===O.bits?++O.state:(O.q=null,O.state=0);else if(5===O.state){var e_=O.e.modInverse(O.phi);O.keys={privateKey:eu.rsa.setPrivateKey(O.n,O.e,e_,O.p,O.q,e_.mod(O.p1),e_.mod(O.q1),O.q.modInverse(O.p)),publicKey:eu.rsa.setPublicKey(O.n,O.e)}}ea+=($=+new Date)-eo,eo=$}return null!==O.keys},eu.rsa.generateKeyPair=function(O,U,$,en){if(1==arguments.length?"object"==typeof O?($=O,O=void 0):"function"==typeof O&&(en=O,O=void 0):2==arguments.length?"number"==typeof O?"function"==typeof U?(en=U,U=void 0):"number"!=typeof U&&($=U,U=void 0):($=O,en=U,O=void 0,U=void 0):3==arguments.length&&("number"==typeof U?"function"==typeof $&&(en=$,$=void 0):(en=$,$=U,U=void 0)),$=$||{},void 0===O&&(O=$.bits||2048),void 0===U&&(U=$.e||65537),!J.options.usePureJavaScript&&!$.prng&&O>=256&&O<=16384&&(65537===U||3===U)){if(en){if(_detectNodeCrypto("generateKeyPair"))return es.generateKeyPair("rsa",{modulusLength:O,publicExponent:U,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(O,U,$){if(O)return en(O);en(null,{privateKey:eu.privateKeyFromPem($),publicKey:eu.publicKeyFromPem(U)})});if(_detectSubtleCrypto("generateKey")&&_detectSubtleCrypto("exportKey"))return ea.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:O,publicExponent:_intToUint8Array(U),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(O){return ea.globalScope.crypto.subtle.exportKey("pkcs8",O.privateKey)}).then(void 0,function(O){en(O)}).then(function(O){if(O){var U=eu.privateKeyFromAsn1(eo.fromDer(J.util.createBuffer(O)));en(null,{privateKey:U,publicKey:eu.setRsaPublicKey(U.n,U.e)})}});if(_detectSubtleMsCrypto("generateKey")&&_detectSubtleMsCrypto("exportKey")){var ef=ea.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:O,publicExponent:_intToUint8Array(U),hash:{name:"SHA-256"}},!0,["sign","verify"]);ef.oncomplete=function(O){var U=O.target.result,$=ea.globalScope.msCrypto.subtle.exportKey("pkcs8",U.privateKey);$.oncomplete=function(O){var U=O.target.result,$=eu.privateKeyFromAsn1(eo.fromDer(J.util.createBuffer(U)));en(null,{privateKey:$,publicKey:eu.setRsaPublicKey($.n,$.e)})},$.onerror=function(O){en(O)}},ef.onerror=function(O){en(O)};return}}else if(_detectNodeCrypto("generateKeyPairSync")){var eg=es.generateKeyPairSync("rsa",{modulusLength:O,publicExponent:U,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:eu.privateKeyFromPem(eg.privateKey),publicKey:eu.publicKeyFromPem(eg.publicKey)}}}var ev=eu.rsa.createKeyPairGenerationState(O,U,$);if(!en)return eu.rsa.stepKeyPairGenerationState(ev,0),ev.keys;_generateKeyPair(ev,$,en)},eu.setRsaPublicKey=eu.rsa.setPublicKey=function(O,U){var $={n:O,e:U};return $.encrypt=function(O,U,en){if("string"==typeof U?U=U.toUpperCase():void 0===U&&(U="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===U)U={encode:function(O,U,$){return _encodePkcs1_v1_5(O,U,2).getBytes()}};else if("RSA-OAEP"===U||"RSAES-OAEP"===U)U={encode:function(O,U){return J.pkcs1.encode_rsa_oaep(U,O,en)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(U))U={encode:function(O){return O}};else if("string"==typeof U)throw Error('Unsupported encryption scheme: "'+U+'".');var es=U.encode(O,$,!0);return eu.rsa.encrypt(es,$,!0)},$.verify=function(O,U,en,es){"string"==typeof en?en=en.toUpperCase():void 0===en&&(en="RSASSA-PKCS1-V1_5"),void 0===es&&(es={_parseAllDigestBytes:!0}),"_parseAllDigestBytes"in es||(es._parseAllDigestBytes=!0),"RSASSA-PKCS1-V1_5"===en?en={verify:function(O,U){U=_decodePkcs1_v1_5(U,$,!0);var en=eo.fromDer(U,{parseAllBytes:es._parseAllDigestBytes}),ea={},eu=[];if(!eo.validate(en,eE,ea,eu)){var ef=Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw ef.errors=eu,ef}var eg=eo.derToOid(ea.algorithmIdentifier);if(!(eg===J.oids.md2||eg===J.oids.md5||eg===J.oids.sha1||eg===J.oids.sha224||eg===J.oids.sha256||eg===J.oids.sha384||eg===J.oids.sha512||eg===J.oids["sha512-224"]||eg===J.oids["sha512-256"])){var ef=Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw ef.oid=eg,ef}if((eg===J.oids.md2||eg===J.oids.md5)&&!("parameters"in ea))throw Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return O===ea.digest}}:("NONE"===en||"NULL"===en||null===en)&&(en={verify:function(O,U){return O===(U=_decodePkcs1_v1_5(U,$,!0))}});var ea=eu.rsa.decrypt(U,$,!0,!1);return en.verify(O,ea,$.n.bitLength())},$},eu.setRsaPrivateKey=eu.rsa.setPrivateKey=function(O,U,$,en,es,eo,ea,ef){var eg={n:O,e:U,d:$,p:en,q:es,dP:eo,dQ:ea,qInv:ef};return eg.decrypt=function(O,U,$){"string"==typeof U?U=U.toUpperCase():void 0===U&&(U="RSAES-PKCS1-V1_5");var en=eu.rsa.decrypt(O,eg,!1,!1);if("RSAES-PKCS1-V1_5"===U)U={decode:_decodePkcs1_v1_5};else if("RSA-OAEP"===U||"RSAES-OAEP"===U)U={decode:function(O,U){return J.pkcs1.decode_rsa_oaep(U,O,$)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(U))U={decode:function(O){return O}};else throw Error('Unsupported encryption scheme: "'+U+'".');return U.decode(en,eg,!1)},eg.sign=function(O,U){var $=!1;"string"==typeof U&&(U=U.toUpperCase()),void 0===U||"RSASSA-PKCS1-V1_5"===U?(U={encode:emsaPkcs1v15encode},$=1):("NONE"===U||"NULL"===U||null===U)&&(U={encode:function(){return O}},$=1);var J=U.encode(O,eg.n.bitLength());return eu.rsa.encrypt(J,eg,$)},eg},eu.wrapRsaPrivateKey=function(O){return eo.create(eo.Class.UNIVERSAL,eo.Type.SEQUENCE,!0,[eo.create(eo.Class.UNIVERSAL,eo.Type.INTEGER,!1,eo.integerToDer(0).getBytes()),eo.create(eo.Class.UNIVERSAL,eo.Type.SEQUENCE,!0,[eo.create(eo.Class.UNIVERSAL,eo.Type.OID,!1,eo.oidToDer(eu.oids.rsaEncryption).getBytes()),eo.create(eo.Class.UNIVERSAL,eo.Type.NULL,!1,"")]),eo.create(eo.Class.UNIVERSAL,eo.Type.OCTETSTRING,!1,eo.toDer(O).getBytes())])},eu.privateKeyFromAsn1=function(O){var U,$,es,ea,ef,e_,ew,eE,eS={},eA=[];if(eo.validate(O,eg,eS,eA)&&(O=eo.fromDer(J.util.createBuffer(eS.privateKey))),eS={},eA=[],!eo.validate(O,ev,eS,eA)){var eI=Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw eI.errors=eA,eI}return U=J.util.createBuffer(eS.privateKeyModulus).toHex(),$=J.util.createBuffer(eS.privateKeyPublicExponent).toHex(),es=J.util.createBuffer(eS.privateKeyPrivateExponent).toHex(),ea=J.util.createBuffer(eS.privateKeyPrime1).toHex(),ef=J.util.createBuffer(eS.privateKeyPrime2).toHex(),e_=J.util.createBuffer(eS.privateKeyExponent1).toHex(),ew=J.util.createBuffer(eS.privateKeyExponent2).toHex(),eE=J.util.createBuffer(eS.privateKeyCoefficient).toHex(),eu.setRsaPrivateKey(new en(U,16),new en($,16),new en(es,16),new en(ea,16),new en(ef,16),new en(e_,16),new en(ew,16),new en(eE,16))},eu.privateKeyToAsn1=eu.privateKeyToRSAPrivateKey=function(O){return eo.create(eo.Class.UNIVERSAL,eo.Type.SEQUENCE,!0,[eo.create(eo.Class.UNIVERSAL,eo.Type.INTEGER,!1,eo.integerToDer(0).getBytes()),eo.create(eo.Class.UNIVERSAL,eo.Type.INTEGER,!1,_bnToBytes(O.n)),eo.create(eo.Class.UNIVERSAL,eo.Type.INTEGER,!1,_bnToBytes(O.e)),eo.create(eo.Class.UNIVERSAL,eo.Type.INTEGER,!1,_bnToBytes(O.d)),eo.create(eo.Class.UNIVERSAL,eo.Type.INTEGER,!1,_bnToBytes(O.p)),eo.create(eo.Class.UNIVERSAL,eo.Type.INTEGER,!1,_bnToBytes(O.q)),eo.create(eo.Class.UNIVERSAL,eo.Type.INTEGER,!1,_bnToBytes(O.dP)),eo.create(eo.Class.UNIVERSAL,eo.Type.INTEGER,!1,_bnToBytes(O.dQ)),eo.create(eo.Class.UNIVERSAL,eo.Type.INTEGER,!1,_bnToBytes(O.qInv))])},eu.publicKeyFromAsn1=function(O){var U={},$=[];if(eo.validate(O,ew,U,$)){var es=eo.derToOid(U.publicKeyOid);if(es!==eu.oids.rsaEncryption){var ea=Error("Cannot read public key. Unknown OID.");throw ea.oid=es,ea}O=U.rsaPublicKey}if($=[],!eo.validate(O,e_,U,$)){var ea=Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw ea.errors=$,ea}var ef=J.util.createBuffer(U.publicKeyModulus).toHex(),eg=J.util.createBuffer(U.publicKeyExponent).toHex();return eu.setRsaPublicKey(new en(ef,16),new en(eg,16))},eu.publicKeyToAsn1=eu.publicKeyToSubjectPublicKeyInfo=function(O){return eo.create(eo.Class.UNIVERSAL,eo.Type.SEQUENCE,!0,[eo.create(eo.Class.UNIVERSAL,eo.Type.SEQUENCE,!0,[eo.create(eo.Class.UNIVERSAL,eo.Type.OID,!1,eo.oidToDer(eu.oids.rsaEncryption).getBytes()),eo.create(eo.Class.UNIVERSAL,eo.Type.NULL,!1,"")]),eo.create(eo.Class.UNIVERSAL,eo.Type.BITSTRING,!1,[eu.publicKeyToRSAPublicKey(O)])])},eu.publicKeyToRSAPublicKey=function(O){return eo.create(eo.Class.UNIVERSAL,eo.Type.SEQUENCE,!0,[eo.create(eo.Class.UNIVERSAL,eo.Type.INTEGER,!1,_bnToBytes(O.n)),eo.create(eo.Class.UNIVERSAL,eo.Type.INTEGER,!1,_bnToBytes(O.e))])}},8295:function(O,U,$){var J=$(2595);$(2528),$(2366);var en=O.exports=J.sha1=J.sha1||{};J.md.sha1=J.md.algorithms.sha1=en,en.create=function(){eo||_init();var O=null,U=J.util.createBuffer(),$=Array(80),en={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return en.start=function(){en.messageLength=0,en.fullMessageLength=en.messageLength64=[];for(var $=en.messageLengthSize/4,es=0;es<$;++es)en.fullMessageLength.push(0);return U=J.util.createBuffer(),O={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},en},en.start(),en.update=function(es,eo){"utf8"===eo&&(es=J.util.encodeUtf8(es));var ea=es.length;en.messageLength+=ea,ea=[ea/4294967296>>>0,ea>>>0];for(var eu=en.fullMessageLength.length-1;eu>=0;--eu)en.fullMessageLength[eu]+=ea[1],ea[1]=ea[0]+(en.fullMessageLength[eu]/4294967296>>>0),en.fullMessageLength[eu]=en.fullMessageLength[eu]>>>0,ea[0]=ea[1]/4294967296>>>0;return U.putBytes(es),_update(O,$,U),(U.read>2048||0===U.length())&&U.compact(),en},en.digest=function(){var eo,ea=J.util.createBuffer();ea.putBytes(U.bytes());var eu=en.fullMessageLength[en.fullMessageLength.length-1]+en.messageLengthSize&en.blockLength-1;ea.putBytes(es.substr(0,en.blockLength-eu));for(var ef=8*en.fullMessageLength[0],eg=0;eg>>0,ea.putInt32(ef>>>0),ef=eo>>>0;ea.putInt32(ef);var ev={h0:O.h0,h1:O.h1,h2:O.h2,h3:O.h3,h4:O.h4};_update(ev,$,ea);var e_=J.util.createBuffer();return e_.putInt32(ev.h0),e_.putInt32(ev.h1),e_.putInt32(ev.h2),e_.putInt32(ev.h3),e_.putInt32(ev.h4),e_},en};var es=null,eo=!1;function _init(){es=String.fromCharCode(128)+J.util.fillString("\x00",64),eo=!0}function _update(O,U,$){for(var J,en,es,eo,ea,eu,ef,eg,ev=$.length();ev>=64;){for(eg=0,en=O.h0,es=O.h1,eo=O.h2,ea=O.h3,eu=O.h4;eg<16;++eg)J=$.getInt32(),U[eg]=J,J=(en<<5|en>>>27)+(ef=ea^es&(eo^ea))+eu+1518500249+J,eu=ea,ea=eo,eo=(es<<30|es>>>2)>>>0,es=en,en=J;for(;eg<20;++eg)J=(J=U[eg-3]^U[eg-8]^U[eg-14]^U[eg-16])<<1|J>>>31,U[eg]=J,J=(en<<5|en>>>27)+(ef=ea^es&(eo^ea))+eu+1518500249+J,eu=ea,ea=eo,eo=(es<<30|es>>>2)>>>0,es=en,en=J;for(;eg<32;++eg)J=(J=U[eg-3]^U[eg-8]^U[eg-14]^U[eg-16])<<1|J>>>31,U[eg]=J,J=(en<<5|en>>>27)+(ef=es^eo^ea)+eu+1859775393+J,eu=ea,ea=eo,eo=(es<<30|es>>>2)>>>0,es=en,en=J;for(;eg<40;++eg)J=(J=U[eg-6]^U[eg-16]^U[eg-28]^U[eg-32])<<2|J>>>30,U[eg]=J,J=(en<<5|en>>>27)+(ef=es^eo^ea)+eu+1859775393+J,eu=ea,ea=eo,eo=(es<<30|es>>>2)>>>0,es=en,en=J;for(;eg<60;++eg)J=(J=U[eg-6]^U[eg-16]^U[eg-28]^U[eg-32])<<2|J>>>30,U[eg]=J,J=(en<<5|en>>>27)+(ef=es&eo|ea&(es^eo))+eu+2400959708+J,eu=ea,ea=eo,eo=(es<<30|es>>>2)>>>0,es=en,en=J;for(;eg<80;++eg)J=(J=U[eg-6]^U[eg-16]^U[eg-28]^U[eg-32])<<2|J>>>30,U[eg]=J,J=(en<<5|en>>>27)+(ef=es^eo^ea)+eu+3395469782+J,eu=ea,ea=eo,eo=(es<<30|es>>>2)>>>0,es=en,en=J;O.h0=O.h0+en|0,O.h1=O.h1+es|0,O.h2=O.h2+eo|0,O.h3=O.h3+ea|0,O.h4=O.h4+eu|0,ev-=64}}},7624:function(O,U,$){var J=$(2595);$(2528),$(2366);var en=O.exports=J.sha256=J.sha256||{};J.md.sha256=J.md.algorithms.sha256=en,en.create=function(){eo||_init();var O=null,U=J.util.createBuffer(),$=Array(64),en={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return en.start=function(){en.messageLength=0,en.fullMessageLength=en.messageLength64=[];for(var $=en.messageLengthSize/4,es=0;es<$;++es)en.fullMessageLength.push(0);return U=J.util.createBuffer(),O={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},en},en.start(),en.update=function(es,eo){"utf8"===eo&&(es=J.util.encodeUtf8(es));var ea=es.length;en.messageLength+=ea,ea=[ea/4294967296>>>0,ea>>>0];for(var eu=en.fullMessageLength.length-1;eu>=0;--eu)en.fullMessageLength[eu]+=ea[1],ea[1]=ea[0]+(en.fullMessageLength[eu]/4294967296>>>0),en.fullMessageLength[eu]=en.fullMessageLength[eu]>>>0,ea[0]=ea[1]/4294967296>>>0;return U.putBytes(es),_update(O,$,U),(U.read>2048||0===U.length())&&U.compact(),en},en.digest=function(){var eo,ea=J.util.createBuffer();ea.putBytes(U.bytes());var eu=en.fullMessageLength[en.fullMessageLength.length-1]+en.messageLengthSize&en.blockLength-1;ea.putBytes(es.substr(0,en.blockLength-eu));for(var ef=8*en.fullMessageLength[0],eg=0;eg>>0,ea.putInt32(ef>>>0),ef=eo>>>0;ea.putInt32(ef);var ev={h0:O.h0,h1:O.h1,h2:O.h2,h3:O.h3,h4:O.h4,h5:O.h5,h6:O.h6,h7:O.h7};_update(ev,$,ea);var e_=J.util.createBuffer();return e_.putInt32(ev.h0),e_.putInt32(ev.h1),e_.putInt32(ev.h2),e_.putInt32(ev.h3),e_.putInt32(ev.h4),e_.putInt32(ev.h5),e_.putInt32(ev.h6),e_.putInt32(ev.h7),e_},en};var es=null,eo=!1,ea=null;function _init(){es=String.fromCharCode(128)+J.util.fillString("\x00",64),ea=[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],eo=!0}function _update(O,U,$){for(var J,en,es,eo,eu,ef,eg,ev,e_,ew,eE,eS,eA,eI,eP,ek=$.length();ek>=64;){for(eg=0;eg<16;++eg)U[eg]=$.getInt32();for(;eg<64;++eg)J=((J=U[eg-2])>>>17|J<<15)^(J>>>19|J<<13)^J>>>10,en=((en=U[eg-15])>>>7|en<<25)^(en>>>18|en<<14)^en>>>3,U[eg]=J+U[eg-7]+en+U[eg-16]|0;for(eg=0,ev=O.h0,e_=O.h1,ew=O.h2,eE=O.h3,eS=O.h4,eA=O.h5,eI=O.h6,eP=O.h7;eg<64;++eg)eo=(eS>>>6|eS<<26)^(eS>>>11|eS<<21)^(eS>>>25|eS<<7),eu=eI^eS&(eA^eI),es=(ev>>>2|ev<<30)^(ev>>>13|ev<<19)^(ev>>>22|ev<<10),ef=ev&e_|ew&(ev^e_),J=eP+eo+eu+ea[eg]+U[eg],en=es+ef,eP=eI,eI=eA,eA=eS,eS=eE+J>>>0,eE=ew,ew=e_,e_=ev,ev=J+en>>>0;O.h0=O.h0+ev|0,O.h1=O.h1+e_|0,O.h2=O.h2+ew|0,O.h3=O.h3+eE|0,O.h4=O.h4+eS|0,O.h5=O.h5+eA|0,O.h6=O.h6+eI|0,O.h7=O.h7+eP|0,ek-=64}}},8439:function(O,U,$){var J=$(2595);$(2528),$(2366);var en=O.exports=J.sha512=J.sha512||{};J.md.sha512=J.md.algorithms.sha512=en;var es=J.sha384=J.sha512.sha384=J.sha512.sha384||{};es.create=function(){return en.create("SHA-384")},J.md.sha384=J.md.algorithms.sha384=es,J.sha512.sha256=J.sha512.sha256||{create:function(){return en.create("SHA-512/256")}},J.md["sha512/256"]=J.md.algorithms["sha512/256"]=J.sha512.sha256,J.sha512.sha224=J.sha512.sha224||{create:function(){return en.create("SHA-512/224")}},J.md["sha512/224"]=J.md.algorithms["sha512/224"]=J.sha512.sha224,en.create=function(O){if(ea||_init(),void 0===O&&(O="SHA-512"),!(O in ef))throw Error("Invalid SHA-512 algorithm: "+O);for(var U=ef[O],$=null,en=J.util.createBuffer(),es=Array(80),eu=0;eu<80;++eu)es[eu]=[,,];var eg=64;switch(O){case"SHA-384":eg=48;break;case"SHA-512/256":eg=32;break;case"SHA-512/224":eg=28}var ev={algorithm:O.replace("-","").toLowerCase(),blockLength:128,digestLength:eg,messageLength:0,fullMessageLength:null,messageLengthSize:16};return ev.start=function(){ev.messageLength=0,ev.fullMessageLength=ev.messageLength128=[];for(var O=ev.messageLengthSize/4,es=0;es>>0,eo>>>0];for(var ea=ev.fullMessageLength.length-1;ea>=0;--ea)ev.fullMessageLength[ea]+=eo[1],eo[1]=eo[0]+(ev.fullMessageLength[ea]/4294967296>>>0),ev.fullMessageLength[ea]=ev.fullMessageLength[ea]>>>0,eo[0]=eo[1]/4294967296>>>0;return en.putBytes(O),_update($,es,en),(en.read>2048||0===en.length())&&en.compact(),ev},ev.digest=function(){var U,ea,eu=J.util.createBuffer();eu.putBytes(en.bytes());var ef=ev.fullMessageLength[ev.fullMessageLength.length-1]+ev.messageLengthSize&ev.blockLength-1;eu.putBytes(eo.substr(0,ev.blockLength-ef));for(var eg=8*ev.fullMessageLength[0],e_=0;e_>>0,eu.putInt32(eg>>>0),eg=U>>>0;eu.putInt32(eg);for(var ew=Array($.length),e_=0;e_<$.length;++e_)ew[e_]=$[e_].slice(0);_update(ew,es,eu);var eE=J.util.createBuffer();ea="SHA-512"===O?ew.length:"SHA-384"===O?ew.length-2:ew.length-4;for(var e_=0;e_=128;){for(ej=0;ej<16;++ej)U[ej][0]=$.getInt32()>>>0,U[ej][1]=$.getInt32()>>>0;for(;ej<80;++ej)J=(((eH=(eV=U[ej-2])[0])>>>19|(eq=eV[1])<<13)^(eq>>>29|eH<<3)^eH>>>6)>>>0,en=((eH<<13|eq>>>19)^(eq<<3|eH>>>29)^(eH<<26|eq>>>6))>>>0,es=(((eH=(e$=U[ej-15])[0])>>>1|(eq=e$[1])<<31)^(eH>>>8|eq<<24)^eH>>>7)>>>0,eo=((eH<<31|eq>>>1)^(eH<<24|eq>>>8)^(eH<<25|eq>>>7))>>>0,eG=U[ej-7],eW=U[ej-16],eq=en+eG[1]+eo+eW[1],U[ej][0]=J+eG[0]+es+eW[0]+(eq/4294967296>>>0)>>>0,U[ej][1]=eq>>>0;for(ej=0,eA=O[0][0],eI=O[0][1],eP=O[1][0],ek=O[1][1],eT=O[2][0],eR=O[2][1],eC=O[3][0],eB=O[3][1],eN=O[4][0],eD=O[4][1],eM=O[5][0],eO=O[5][1],eL=O[6][0],eU=O[6][1],eF=O[7][0],eK=O[7][1];ej<80;++ej)eg=((eN>>>14|eD<<18)^(eN>>>18|eD<<14)^(eD>>>9|eN<<23))>>>0,ev=((eN<<18|eD>>>14)^(eN<<14|eD>>>18)^(eD<<23|eN>>>9))>>>0,e_=(eL^eN&(eM^eL))>>>0,ew=(eU^eD&(eO^eU))>>>0,ea=((eA>>>28|eI<<4)^(eI>>>2|eA<<30)^(eI>>>7|eA<<25))>>>0,ef=((eA<<4|eI>>>28)^(eI<<30|eA>>>2)^(eI<<25|eA>>>7))>>>0,eE=(eA&eP|eT&(eA^eP))>>>0,eS=(eI&ek|eR&(eI^ek))>>>0,eq=eK+ev+ew+eu[ej][1]+U[ej][1],J=eF+eg+e_+eu[ej][0]+U[ej][0]+(eq/4294967296>>>0)>>>0,en=eq>>>0,es=ea+eE+((eq=ef+eS)/4294967296>>>0)>>>0,eo=eq>>>0,eF=eL,eK=eU,eL=eM,eU=eO,eM=eN,eO=eD,eN=eC+J+((eq=eB+en)/4294967296>>>0)>>>0,eD=eq>>>0,eC=eT,eB=eR,eT=eP,eR=ek,eP=eA,ek=eI,eA=J+es+((eq=en+eo)/4294967296>>>0)>>>0,eI=eq>>>0;eq=O[0][1]+eI,O[0][0]=O[0][0]+eA+(eq/4294967296>>>0)>>>0,O[0][1]=eq>>>0,eq=O[1][1]+ek,O[1][0]=O[1][0]+eP+(eq/4294967296>>>0)>>>0,O[1][1]=eq>>>0,eq=O[2][1]+eR,O[2][0]=O[2][0]+eT+(eq/4294967296>>>0)>>>0,O[2][1]=eq>>>0,eq=O[3][1]+eB,O[3][0]=O[3][0]+eC+(eq/4294967296>>>0)>>>0,O[3][1]=eq>>>0,eq=O[4][1]+eD,O[4][0]=O[4][0]+eN+(eq/4294967296>>>0)>>>0,O[4][1]=eq>>>0,eq=O[5][1]+eO,O[5][0]=O[5][0]+eM+(eq/4294967296>>>0)>>>0,O[5][1]=eq>>>0,eq=O[6][1]+eU,O[6][0]=O[6][0]+eL+(eq/4294967296>>>0)>>>0,O[6][1]=eq>>>0,eq=O[7][1]+eK,O[7][0]=O[7][0]+eF+(eq/4294967296>>>0)>>>0,O[7][1]=eq>>>0,eY-=128}}},2366:function(O,U,$){var J=$(4112),en=$(2678).Buffer,es=$(2595),eo=$(4446),ea=O.exports=es.util=es.util||{};function _checkBitsParam(O){if(!(8===O||16===O||24===O||32===O))throw Error("Only 8, 16, 24, or 32 bits supported: "+O)}function ByteStringBuffer(O){if(this.data="",this.read=0,"string"==typeof O)this.data=O;else if(ea.isArrayBuffer(O)||ea.isArrayBufferView(O)){if(void 0!==en&&O instanceof en)this.data=O.toString("binary");else{var U=new Uint8Array(O);try{this.data=String.fromCharCode.apply(null,U)}catch(O){for(var $=0;$15?($=Date.now(),eo(O)):(U.push(O),1===U.length&&es.setAttribute("a",en=!en))}}ea.nextTick=ea.setImmediate}(),ea.isNodejs=void 0!==J&&J.versions&&J.versions.node,ea.globalScope=function(){return ea.isNodejs?$.g:"undefined"==typeof self?window:self}(),ea.isArray=Array.isArray||function(O){return"[object Array]"===Object.prototype.toString.call(O)},ea.isArrayBuffer=function(O){return"undefined"!=typeof ArrayBuffer&&O instanceof ArrayBuffer},ea.isArrayBufferView=function(O){return O&&ea.isArrayBuffer(O.buffer)&&void 0!==O.byteLength},ea.ByteBuffer=ByteStringBuffer,ea.ByteStringBuffer=ByteStringBuffer;var eu=4096;function DataBuffer(O,U){U=U||{},this.read=U.readOffset||0,this.growSize=U.growSize||1024;var $=ea.isArrayBuffer(O),J=ea.isArrayBufferView(O);if($||J){$?this.data=new DataView(O):this.data=new DataView(O.buffer,O.byteOffset,O.byteLength),this.write="writeOffset"in U?U.writeOffset:this.data.byteLength;return}this.data=new DataView(new ArrayBuffer(0)),this.write=0,null!=O&&this.putBytes(O),"writeOffset"in U&&(this.write=U.writeOffset)}ea.ByteStringBuffer.prototype._optimizeConstructedString=function(O){this._constructedStringLength+=O,this._constructedStringLength>eu&&(this.data.substr(0,1),this._constructedStringLength=0)},ea.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},ea.ByteStringBuffer.prototype.isEmpty=function(){return 0>=this.length()},ea.ByteStringBuffer.prototype.putByte=function(O){return this.putBytes(String.fromCharCode(O))},ea.ByteStringBuffer.prototype.fillWithByte=function(O,U){O=String.fromCharCode(O);for(var $=this.data;U>0;)1&U&&($+=O),(U>>>=1)>0&&(O+=O);return this.data=$,this._optimizeConstructedString(U),this},ea.ByteStringBuffer.prototype.putBytes=function(O){return this.data+=O,this._optimizeConstructedString(O.length),this},ea.ByteStringBuffer.prototype.putString=function(O){return this.putBytes(ea.encodeUtf8(O))},ea.ByteStringBuffer.prototype.putInt16=function(O){return this.putBytes(String.fromCharCode(O>>8&255)+String.fromCharCode(255&O))},ea.ByteStringBuffer.prototype.putInt24=function(O){return this.putBytes(String.fromCharCode(O>>16&255)+String.fromCharCode(O>>8&255)+String.fromCharCode(255&O))},ea.ByteStringBuffer.prototype.putInt32=function(O){return this.putBytes(String.fromCharCode(O>>24&255)+String.fromCharCode(O>>16&255)+String.fromCharCode(O>>8&255)+String.fromCharCode(255&O))},ea.ByteStringBuffer.prototype.putInt16Le=function(O){return this.putBytes(String.fromCharCode(255&O)+String.fromCharCode(O>>8&255))},ea.ByteStringBuffer.prototype.putInt24Le=function(O){return this.putBytes(String.fromCharCode(255&O)+String.fromCharCode(O>>8&255)+String.fromCharCode(O>>16&255))},ea.ByteStringBuffer.prototype.putInt32Le=function(O){return this.putBytes(String.fromCharCode(255&O)+String.fromCharCode(O>>8&255)+String.fromCharCode(O>>16&255)+String.fromCharCode(O>>24&255))},ea.ByteStringBuffer.prototype.putInt=function(O,U){_checkBitsParam(U);var $="";do U-=8,$+=String.fromCharCode(O>>U&255);while(U>0);return this.putBytes($)},ea.ByteStringBuffer.prototype.putSignedInt=function(O,U){return O<0&&(O+=2<0);return U},ea.ByteStringBuffer.prototype.getSignedInt=function(O){var U=this.getInt(O),$=2<=$&&(U-=$<<1),U},ea.ByteStringBuffer.prototype.getBytes=function(O){var U;return O?(O=Math.min(this.length(),O),U=this.data.slice(this.read,this.read+O),this.read+=O):0===O?U="":(U=0===this.read?this.data:this.data.slice(this.read),this.clear()),U},ea.ByteStringBuffer.prototype.bytes=function(O){return void 0===O?this.data.slice(this.read):this.data.slice(this.read,this.read+O)},ea.ByteStringBuffer.prototype.at=function(O){return this.data.charCodeAt(this.read+O)},ea.ByteStringBuffer.prototype.setAt=function(O,U){return this.data=this.data.substr(0,this.read+O)+String.fromCharCode(U)+this.data.substr(this.read+O+1),this},ea.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},ea.ByteStringBuffer.prototype.copy=function(){var O=ea.createBuffer(this.data);return O.read=this.read,O},ea.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},ea.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},ea.ByteStringBuffer.prototype.truncate=function(O){var U=Math.max(0,this.length()-O);return this.data=this.data.substr(this.read,U),this.read=0,this},ea.ByteStringBuffer.prototype.toHex=function(){for(var O="",U=this.read;U=this.length()},ea.DataBuffer.prototype.accommodate=function(O,U){if(this.length()>=O)return this;U=Math.max(U||this.growSize,O);var $=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),J=new Uint8Array(this.length()+U);return J.set($),this.data=new DataView(J.buffer),this},ea.DataBuffer.prototype.putByte=function(O){return this.accommodate(1),this.data.setUint8(this.write++,O),this},ea.DataBuffer.prototype.fillWithByte=function(O,U){this.accommodate(U);for(var $=0;$>8&65535),this.data.setInt8(this.write,O>>16&255),this.write+=3,this},ea.DataBuffer.prototype.putInt32=function(O){return this.accommodate(4),this.data.setInt32(this.write,O),this.write+=4,this},ea.DataBuffer.prototype.putInt16Le=function(O){return this.accommodate(2),this.data.setInt16(this.write,O,!0),this.write+=2,this},ea.DataBuffer.prototype.putInt24Le=function(O){return this.accommodate(3),this.data.setInt8(this.write,O>>16&255),this.data.setInt16(this.write,O>>8&65535,!0),this.write+=3,this},ea.DataBuffer.prototype.putInt32Le=function(O){return this.accommodate(4),this.data.setInt32(this.write,O,!0),this.write+=4,this},ea.DataBuffer.prototype.putInt=function(O,U){_checkBitsParam(U),this.accommodate(U/8);do U-=8,this.data.setInt8(this.write++,O>>U&255);while(U>0);return this},ea.DataBuffer.prototype.putSignedInt=function(O,U){return _checkBitsParam(U),this.accommodate(U/8),O<0&&(O+=2<0);return U},ea.DataBuffer.prototype.getSignedInt=function(O){var U=this.getInt(O),$=2<=$&&(U-=$<<1),U},ea.DataBuffer.prototype.getBytes=function(O){var U;return O?(O=Math.min(this.length(),O),U=this.data.slice(this.read,this.read+O),this.read+=O):0===O?U="":(U=0===this.read?this.data:this.data.slice(this.read),this.clear()),U},ea.DataBuffer.prototype.bytes=function(O){return void 0===O?this.data.slice(this.read):this.data.slice(this.read,this.read+O)},ea.DataBuffer.prototype.at=function(O){return this.data.getUint8(this.read+O)},ea.DataBuffer.prototype.setAt=function(O,U){return this.data.setUint8(O,U),this},ea.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},ea.DataBuffer.prototype.copy=function(){return new ea.DataBuffer(this)},ea.DataBuffer.prototype.compact=function(){if(this.read>0){var O=new Uint8Array(this.data.buffer,this.read),U=new Uint8Array(O.byteLength);U.set(O),this.data=new DataView(U),this.write-=this.read,this.read=0}return this},ea.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},ea.DataBuffer.prototype.truncate=function(O){return this.write=Math.max(0,this.length()-O),this.read=Math.min(this.read,this.write),this},ea.DataBuffer.prototype.toHex=function(){for(var O="",U=this.read;U0;)1&U&&($+=O),(U>>>=1)>0&&(O+=O);return $},ea.xorBytes=function(O,U,$){for(var J="",en="",es="",eo=0,ea=0;$>0;--$,++eo)en=O.charCodeAt(eo)^U.charCodeAt(eo),ea>=10&&(J+=es,es="",ea=0),es+=String.fromCharCode(en),++ea;return J+es},ea.hexToBytes=function(O){var U="",$=0;for(!0&O.length&&($=1,U+=String.fromCharCode(parseInt(O[0],16)));$>24&255)+String.fromCharCode(O>>16&255)+String.fromCharCode(O>>8&255)+String.fromCharCode(255&O)};var ef="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",eg=[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],ev="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";ea.encode64=function(O,U){for(var $,J,en,es="",eo="",ea=0;ea>2)+ef.charAt((3&$)<<4|J>>4),isNaN(J)?es+="==":es+=ef.charAt((15&J)<<2|en>>6)+(isNaN(en)?"=":ef.charAt(63&en)),U&&es.length>U&&(eo+=es.substr(0,U)+"\r\n",es=es.substr(U));return eo+es},ea.decode64=function(O){O=O.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var U,$,J,en,es="",eo=0;eo>4),64!==J&&(es+=String.fromCharCode((15&$)<<4|J>>2),64!==en&&(es+=String.fromCharCode((3&J)<<6|en)));return es},ea.encodeUtf8=function(O){return unescape(encodeURIComponent(O))},ea.decodeUtf8=function(O){return decodeURIComponent(escape(O))},ea.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:eo.encode,decode:eo.decode}},ea.binary.raw.encode=function(O){return String.fromCharCode.apply(null,O)},ea.binary.raw.decode=function(O,U,$){var J=U;J||(J=new Uint8Array(O.length));for(var en=$=$||0,es=0;es>2)+ef.charAt((3&$)<<4|J>>4),isNaN(J)?es+="==":es+=ef.charAt((15&J)<<2|en>>6)+(isNaN(en)?"=":ef.charAt(63&en)),U&&es.length>U&&(eo+=es.substr(0,U)+"\r\n",es=es.substr(U));return eo+es},ea.binary.base64.decode=function(O,U,$){var J,en,es,eo,ea=U;ea||(ea=new Uint8Array(3*Math.ceil(O.length/4))),O=O.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var eu=0,ef=$=$||0;eu>4,64!==es&&(ea[ef++]=(15&en)<<4|es>>2,64!==eo&&(ea[ef++]=(3&es)<<6|eo));return U?ef-$:ea.subarray(0,ef)},ea.binary.base58.encode=function(O,U){return ea.binary.baseN.encode(O,ev,U)},ea.binary.base58.decode=function(O,U){return ea.binary.baseN.decode(O,ev,U)},ea.text={utf8:{},utf16:{}},ea.text.utf8.encode=function(O,U,$){O=ea.encodeUtf8(O);var J=U;J||(J=new Uint8Array(O.length));for(var en=$=$||0,es=0;es0&&es.push($),eo=J.lastIndex;var ea=U[0][1];switch(ea){case"s":case"o":en");break;case"%":es.push("%");break;default:es.push("<%"+ea+"?>")}}return es.push(O.substring(eo)),es.join("")},ea.formatNumber=function(O,U,$,J){var en=O,es=isNaN(U=Math.abs(U))?2:U,eo=void 0===$?",":$,ea=void 0===J?".":J,eu=en<0?"-":"",ef=parseInt(en=Math.abs(+en||0).toFixed(es),10)+"",eg=ef.length>3?ef.length%3:0;return eu+(eg?ef.substr(0,eg)+ea:"")+ef.substr(eg).replace(/(\d{3})(?=\d)/g,"$1"+ea)+(es?eo+Math.abs(en-ef).toFixed(es).slice(2):"")},ea.formatSize=function(O){return O=O>=1073741824?ea.formatNumber(O/1073741824,2,".","")+" GiB":O>=1048576?ea.formatNumber(O/1048576,2,".","")+" MiB":O>=1024?ea.formatNumber(O/1024,0)+" KiB":ea.formatNumber(O,0)+" bytes"},ea.bytesFromIP=function(O){return -1!==O.indexOf(".")?ea.bytesFromIPv4(O):-1!==O.indexOf(":")?ea.bytesFromIPv6(O):null},ea.bytesFromIPv4=function(O){if(4!==(O=O.split(".")).length)return null;for(var U=ea.createBuffer(),$=0;$$[J].end-$[J].start&&(J=$.length-1)):$.push({start:eu,end:eu})}U.push(es)}if($.length>0){var ef=$[J];ef.end-ef.start>0&&(U.splice(ef.start,ef.end-ef.start+1,""),0===ef.start&&U.unshift(""),7===ef.end&&U.push(""))}return U.join(":")},ea.estimateCores=function(O,U){if("function"==typeof O&&(U=O,O={}),O=O||{},"cores"in ea&&!O.update)return U(null,ea.cores);if("undefined"!=typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return ea.cores=navigator.hardwareConcurrency,U(null,ea.cores);if("undefined"==typeof Worker)return ea.cores=1,U(null,ea.cores);if("undefined"==typeof Blob)return ea.cores=2,U(null,ea.cores);var $=URL.createObjectURL(new Blob(["(",(function(){self.addEventListener("message",function(O){for(var U=Date.now(),$=U+4;Date.now()<$;);self.postMessage({st:U,et:$})})}).toString(),")()"],{type:"application/javascript"}));function sample(O,J,en){if(0===J){var es=Math.floor(O.reduce(function(O,U){return O+U},0)/O.length);return ea.cores=Math.max(1,es),URL.revokeObjectURL($),U(null,ea.cores)}map(en,function(U,$){O.push(reduce(en,$)),sample(O,J-1,en)})}function map(O,U){for(var J=[],en=[],es=0;esea.st&&en.sten.st&&ea.st>>0",J,J);break;case"int32":case"sint32":case"sfixed32":O("m%s=d%s|0",J,J);break;case"uint64":ef=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":O("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",J,J,ef)('else if(typeof d%s==="string")',J)("m%s=parseInt(d%s,10)",J,J)('else if(typeof d%s==="number")',J)("m%s=d%s",J,J)('else if(typeof d%s==="object")',J)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",J,J,J,ef?"true":"");break;case"bytes":O('if(typeof d%s==="string")',J)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",J,J,J)("else if(d%s.length >= 0)",J)("m%s=d%s",J,J);break;case"string":O("m%s=String(d%s)",J,J);break;case"bool":O("m%s=Boolean(d%s)",J,J)}}return O}function genValuePartial_toObject(O,U,$,J){if(U.resolvedType)U.resolvedType instanceof en?O("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",J,$,J,J,$,J,J):O("d%s=types[%i].toObject(m%s,o)",J,$,J);else{var es=!1;switch(U.type){case"double":case"float":O("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",J,J,J,J);break;case"uint64":es=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":O('if(typeof m%s==="number")',J)("d%s=o.longs===String?String(m%s):m%s",J,J,J)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",J,J,J,J,es?"true":"",J);break;case"bytes":O("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",J,J,J,J,J);break;default:O("d%s=m%s",J,J)}}return O}J.fromObject=function(O){var U=O.fieldsArray,$=es.codegen(["d"],O.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!U.length)return $("return new this.ctor");$("var m=new this.ctor");for(var J=0;J>>3){");for(var $=0;$>>3){")("case 1: k=r.%s(); break",eo.keyType)("case 2:"),void 0===en.basic[ea]?U("value=types[%i].decode(r,r.uint32())",$):U("value=r.%s()",ea),U("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),U(void 0!==en.long[eo.keyType]?'%s[typeof k==="object"?util.longToHash(k):k]=value':"%s[k]=value",eu)):eo.repeated?(U("if(!(%s&&%s.length))",eu,eu)("%s=[]",eu),void 0!==en.packed[ea]&&U("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos>>0,(U.id<<3|4)>>>0):O("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",$,J,(U.id<<3|2)>>>0)}function encoder(O){for(var U,$,eo=es.codegen(["m","w"],O.name+"$encode")("if(!w)")("w=Writer.create()"),ea=O.fieldsArray.slice().sort(es.compareFieldsById),U=0;U>>0,8|en.mapKey[eu.keyType],eu.keyType),void 0===ev?eo("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",ef,$):eo(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|ev,eg,$),eo("}")("}")):eu.repeated?(eo("if(%s!=null&&%s.length){",$,$),eu.packed&&void 0!==en.packed[eg]?eo("w.uint32(%i).fork()",(eu.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",$)("w.%s(%s[i])",eg,$)("w.ldelim()"):(eo("for(var i=0;i<%s.length;++i)",$),void 0===ev?genTypePartial(eo,eu,ef,$+"[i]"):eo("w.uint32(%i).%s(%s[i])",(eu.id<<3|ev)>>>0,eg,$)),eo("}")):(eu.optional&&eo("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",$,eu.name),void 0===ev?genTypePartial(eo,eu,ef,$):eo("w.uint32(%i).%s(%s)",(eu.id<<3|ev)>>>0,eg,$))}return eo("return w")}},7763:function(O,U,$){"use strict";O.exports=Enum;var J=$(965);((Enum.prototype=Object.create(J.prototype)).constructor=Enum).className="Enum";var en=$(9485),es=$(8970);function Enum(O,U,$,en,es,eo){if(J.call(this,O,$),U&&"object"!=typeof U)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=en,this.comments=es||{},this.valuesOptions=eo,this.reserved=void 0,U)for(var ea=Object.keys(U),eu=0;euU)return!0}return!1},Namespace.isReservedName=function(O,U){if(O){for(var $=0;$0;){var J=O.shift();if($.nested&&$.nested[J]){if(!(($=$.nested[J])instanceof Namespace))throw Error("path conflicts with non-namespace objects")}else $.add($=new Namespace(J))}return U&&$.addJSON(U),$},Namespace.prototype.resolveAll=function(){for(var O=this.nestedArray,U=0;U-1)return J}else if(J instanceof Namespace&&(J=J.lookup(O.slice(1),U,!0)))return J}else for(var en=0;en-1&&this.oneof.splice(U,1),O.partOf=null,this},OneOf.prototype.onAdd=function(O){J.prototype.onAdd.call(this,O);for(var U=this,$=0;$");var J=eK();if(!eR.test(J))throw illegal(J,"name");eq("=");var en=new ea(eY(J),parseId(eK()),U,$);ifBlock(en,function(O){if("option"===O)parseOption(en,O),eq(";");else throw illegal(O)},function(){parseInlineOptions(en)}),O.add(en)}function parseOneOf(O,U){if(!eR.test(U=eK()))throw illegal(U,"name");var $=new eu(eY(U));ifBlock($,function(O){"option"===O?(parseOption($,O),eq(";")):(ej(O),parseField($,"optional"))}),O.add($)}function parseEnum(O,U){if(!eR.test(U=eK()))throw illegal(U,"name");var $=new ef(U);ifBlock($,function(O){switch(O){case"option":parseOption($,O),eq(";");break;case"reserved":readRanges($.reserved||($.reserved=[]),!0);break;default:parseEnumValue($,O)}}),O.add($)}function parseEnumValue(O,U){if(!eR.test(U))throw illegal(U,"name");eq("=");var $=parseId(eK(),!0),J={options:void 0};J.setOption=function(O,U){void 0===this.options&&(this.options={}),this.options[O]=U},ifBlock(J,function(O){if("option"===O)parseOption(J,O),eq(";");else throw illegal(O)},function(){parseInlineOptions(J)}),O.add(U,$,J.comment,J.options)}function parseOption(O,U){var $,J=eq("(",!0);if(!eC.test(U=eK()))throw illegal(U,"name");var en=U,es=en;J&&(eq(")"),es=en="("+en+")",U=eH(),eB.test(U)&&($=U.slice(1),en+=U,eK())),eq("=");var eo=parseOptionValue(O,en);setParsedOption(O,es,eo,$)}function parseOptionValue(O,U){if(eq("{",!0)){for(var $={};!eq("}",!0);){if(!eR.test(eN=eK()))throw illegal(eN,"name");if(null===eN)throw illegal(eN,"end of input");var J,en,es=eN;if(eq(":",!0),"{"===eH())J=parseOptionValue(O,U+"."+eN);else if("["===eH()){if(J=[],eq("[",!0)){do en=readValue(!0),J.push(en);while(eq(",",!0));eq("]"),void 0!==en&&setOption(O,U+"."+eN,en)}}else J=readValue(!0),setOption(O,U+"."+eN,J);var eo=$[es];eo&&(J=[].concat(eo).concat(J)),$[es]=J,eq(",",!0),eq(";",!0)}return $}var ea=readValue(!0);return setOption(O,U,ea),ea}function setOption(O,U,$){O.setOption&&O.setOption(U,$)}function setParsedOption(O,U,$,J){O.setParsedOption&&O.setParsedOption(U,$,J)}function parseInlineOptions(O){if(eq("[",!0)){do parseOption(O,"option");while(eq(",",!0));eq("]")}return O}function parseService(O,U){if(!eR.test(U=eK()))throw illegal(U,"service name");var $=new eg(U);ifBlock($,function(O){if(!parseCommon($,O)){if("rpc"===O)parseMethod($,O);else throw illegal(O)}}),O.add($)}function parseMethod(O,U){var $=eV(),J=U;if(!eR.test(U=eK()))throw illegal(U,"name");var en,es,eo,ea,eu=U;if(eq("("),eq("stream",!0)&&(es=!0),!eC.test(U=eK())||(en=U,eq(")"),eq("returns"),eq("("),eq("stream",!0)&&(ea=!0),!eC.test(U=eK())))throw illegal(U);eo=U,eq(")");var ef=new ev(eu,J,en,eo,es,ea);ef.comment=$,ifBlock(ef,function(O){if("option"===O)parseOption(ef,O),eq(";");else throw illegal(O)}),O.add(ef)}function parseExtension(O,U){if(!eC.test(U=eK()))throw illegal(U,"reference");var $=U;ifBlock(null,function(U){switch(U){case"required":case"repeated":parseField(O,U,$);break;case"optional":e$?parseField(O,"proto3_optional",$):parseField(O,"optional",$);break;default:if(!e$||!eC.test(U))throw illegal(U);ej(U),parseField(O,"optional",$)}})}for(;null!==(eN=eK());)switch(eN){case"package":if(!eG)throw illegal(eN);parsePackage();break;case"import":if(!eG)throw illegal(eN);parseImport();break;case"syntax":if(!eG)throw illegal(eN);parseSyntax();break;case"option":parseOption(eW,eN),eq(";");break;default:if(parseCommon(eW,eN)){eG=!1;continue}throw illegal(eN)}return parse.filename=null,{package:eD,imports:eM,weakImports:eO,syntax:eL,root:U}}},911:function(O,U,$){"use strict";O.exports=Reader;var J,en=$(6642),es=en.LongBits,eo=en.utf8;function indexOutOfRange(O,U){return RangeError("index out of range: "+O.pos+" + "+(U||1)+" > "+O.len)}function Reader(O){this.buf=O,this.pos=0,this.len=O.length}var ea="undefined"!=typeof Uint8Array?function(O){if(O instanceof Uint8Array||Array.isArray(O))return new Reader(O);throw Error("illegal buffer")}:function(O){if(Array.isArray(O))return new Reader(O);throw Error("illegal buffer")},create=function(){return en.Buffer?function(O){return(Reader.create=function(O){return en.Buffer.isBuffer(O)?new J(O):ea(O)})(O)}:ea};function readLongVarint(){var O=new es(0,0),U=0;if(this.len-this.pos>4){for(;U<4;++U)if(O.lo=(O.lo|(127&this.buf[this.pos])<<7*U)>>>0,this.buf[this.pos++]<128)return O;if(O.lo=(O.lo|(127&this.buf[this.pos])<<28)>>>0,O.hi=(O.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return O;U=0}else{for(;U<3;++U){if(this.pos>=this.len)throw indexOutOfRange(this);if(O.lo=(O.lo|(127&this.buf[this.pos])<<7*U)>>>0,this.buf[this.pos++]<128)return O}return O.lo=(O.lo|(127&this.buf[this.pos++])<<7*U)>>>0,O}if(this.len-this.pos>4){for(;U<5;++U)if(O.hi=(O.hi|(127&this.buf[this.pos])<<7*U+3)>>>0,this.buf[this.pos++]<128)return O}else for(;U<5;++U){if(this.pos>=this.len)throw indexOutOfRange(this);if(O.hi=(O.hi|(127&this.buf[this.pos])<<7*U+3)>>>0,this.buf[this.pos++]<128)return O}throw Error("invalid varint encoding")}function readFixed32_end(O,U){return(O[U-4]|O[U-3]<<8|O[U-2]<<16|O[U-1]<<24)>>>0}function readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange(this,8);return new es(readFixed32_end(this.buf,this.pos+=4),readFixed32_end(this.buf,this.pos+=4))}Reader.create=create(),Reader.prototype._slice=en.Array.prototype.subarray||en.Array.prototype.slice,Reader.prototype.uint32=function(){var O=4294967295;return function(){if(O=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(O=(O|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(O=(O|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(O=(O|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(O=(O|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return O;if((this.pos+=5)>this.len)throw this.pos=this.len,indexOutOfRange(this,10);return O}}(),Reader.prototype.int32=function(){return 0|this.uint32()},Reader.prototype.sint32=function(){var O=this.uint32();return O>>>1^-(1&O)|0},Reader.prototype.bool=function(){return 0!==this.uint32()},Reader.prototype.fixed32=function(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)},Reader.prototype.sfixed32=function(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return 0|readFixed32_end(this.buf,this.pos+=4)},Reader.prototype.float=function(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);var O=en.float.readFloatLE(this.buf,this.pos);return this.pos+=4,O},Reader.prototype.double=function(){if(this.pos+8>this.len)throw indexOutOfRange(this,4);var O=en.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,O},Reader.prototype.bytes=function(){var O=this.uint32(),U=this.pos,$=this.pos+O;if($>this.len)throw indexOutOfRange(this,O);if(this.pos+=O,Array.isArray(this.buf))return this.buf.slice(U,$);if(U===$){var J=en.Buffer;return J?J.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,U,$)},Reader.prototype.string=function(){var O=this.bytes();return eo.read(O,0,O.length)},Reader.prototype.skip=function(O){if("number"==typeof O){if(this.pos+O>this.len)throw indexOutOfRange(this,O);this.pos+=O}else do if(this.pos>=this.len)throw indexOutOfRange(this);while(128&this.buf[this.pos++]);return this},Reader.prototype.skipType=function(O){switch(O){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(O=7&this.uint32());)this.skipType(O);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+O+" at offset "+this.pos)}return this},Reader._configure=function(O){J=O,Reader.create=create(),J._configure();var U=en.Long?"toLong":"toNumber";en.merge(Reader.prototype,{int64:function(){return readLongVarint.call(this)[U](!1)},uint64:function(){return readLongVarint.call(this)[U](!0)},sint64:function(){return readLongVarint.call(this).zzDecode()[U](!1)},fixed64:function(){return readFixed64.call(this)[U](!0)},sfixed64:function(){return readFixed64.call(this)[U](!1)}})}},5957:function(O,U,$){"use strict";O.exports=BufferReader;var J=$(911);(BufferReader.prototype=Object.create(J.prototype)).constructor=BufferReader;var en=$(6642);function BufferReader(O){J.call(this,O)}BufferReader._configure=function(){en.Buffer&&(BufferReader.prototype._slice=en.Buffer.prototype.slice)},BufferReader.prototype.string=function(){var O=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+O,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+O,this.len))},BufferReader._configure()},7785:function(O,U,$){"use strict";O.exports=Root;var J,en,es,eo=$(9485);((Root.prototype=Object.create(eo.prototype)).constructor=Root).className="Root";var ea=$(8878),eu=$(7763),ef=$(5417),eg=$(8970);function Root(O){eo.call(this,"",O),this.deferred=[],this.files=[]}function SYNC(){}Root.fromJSON=function(O,U){return U||(U=new Root),O.options&&U.setOptions(O.options),U.addJSON(O.nested)},Root.prototype.resolvePath=eg.path.resolve,Root.prototype.fetch=eg.fetch,Root.prototype.load=function load(O,U,$){"function"==typeof U&&($=U,U=void 0);var J=this;if(!$)return eg.asPromise(load,J,O,U);var eo=$===SYNC;function finish(O,U){if($){var J=$;if($=null,eo)throw O;J(O,U)}}function getBundledFileName(O){var U=O.lastIndexOf("google/protobuf/");if(U>-1){var $=O.substring(U);if($ in es)return $}return null}function process(O,$){try{if(eg.isString($)&&"{"===$.charAt(0)&&($=JSON.parse($)),eg.isString($)){en.filename=O;var es,eu=en($,J,U),ef=0;if(eu.imports)for(;ef-1)){if(J.files.push(O),O in es){eo?process(O,es[O]):(++ea,setTimeout(function(){--ea,process(O,es[O])}));return}if(eo){var en;try{en=eg.fs.readFileSync(O).toString("utf8")}catch(O){U||finish(O);return}process(O,en)}else++ea,J.fetch(O,function(en,es){if(--ea,$){if(en){U?ea||finish(null,J):finish(en);return}process(O,es)}})}}var ea=0;eg.isString(O)&&(O=[O]);for(var eu,ef=0;ef-1&&this.deferred.splice(U,1)}}}else if(O instanceof eu)ev.test(O.name)&&delete O.parent[O.name];else if(O instanceof eo){for(var $=0;$]/g,$=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,J=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,en=/^ *[*/]+ */,es=/^\s*\*?\/*/,eo=/\n/g,ea=/\s/,eu=/\\(.?)/g,ef={0:"\x00",r:"\r",n:"\n",t:" "};function unescape(O){return O.replace(eu,function(O,U){switch(U){case"\\":case"":return U;default:return ef[U]||""}})}function tokenize(O,eu){O=O.toString();var ef=0,eg=O.length,ev=1,e_=0,ew={},eE=[],eS=null;function illegal(O){return Error("illegal "+O+" (line "+ev+")")}function readString(){var U="'"===eS?J:$;U.lastIndex=ef-1;var en=U.exec(O);if(!en)throw illegal("string");return ef=U.lastIndex,push(eS),eS=null,unescape(en[1])}function charAt(U){return O.charAt(U)}function setComment(U,$,J){var ea,ef,eg={type:O.charAt(U++),lineEmpty:!1,leading:J},eE=U-(ea=eu?2:3);do if(--eE<0||"\n"===(ef=O.charAt(eE))){eg.lineEmpty=!0;break}while(" "===ef||" "===ef);for(var eS=O.substring(U,$).split(eo),eA=0;eA0)return eE.shift();if(eS)return readString();var $,J,en,es,eo,e_=0===ef;do{if(ef===eg)return null;for($=!1;ea.test(en=charAt(ef));)if("\n"===en&&(e_=!0,++ev),++ef===eg)return null;if("/"===charAt(ef)){if(++ef===eg)throw illegal("comment");if("/"===charAt(ef)){if(eu){if(es=ef,eo=!1,isDoubleSlashCommentLine(ef-1)){eo=!0;do if((ef=findEndOfLine(ef))===eg||(ef++,!e_))break;while(isDoubleSlashCommentLine(ef))}else ef=Math.min(eg,findEndOfLine(ef)+1);eo&&(setComment(es,ef,e_),e_=!0),ev++,$=!0}else{for(eo="/"===charAt(es=ef+1);"\n"!==charAt(++ef);)if(ef===eg)return null;++ef,eo&&(setComment(es,ef-1,e_),e_=!0),++ev,$=!0}}else{if("*"!==(en=charAt(ef)))return"/";es=ef+1,eo=eu||"*"===charAt(es);do{if("\n"===en&&++ev,++ef===eg)throw illegal("comment");J=en,en=charAt(ef)}while("*"!==J||"/"!==en);++ef,eo&&(setComment(es,ef-2,e_),e_=!0),$=!0}}}while($);var ew=ef;if(U.lastIndex=0,!U.test(charAt(ew++)))for(;ew0)O[J]=setProp(O[J]||{},U,$);else{var en=O[J];en&&($=[].concat(en).concat($)),O[J]=$}return O}if("object"!=typeof O)throw TypeError("dst must be an object");if(!U)throw TypeError("path must be specified");return setProp(O,U=U.split("."),$)},Object.defineProperty(es,"decorateRoot",{get:function(){return eo.decorated||(eo.decorated=new($(7785)))}})},6341:function(O,U,$){"use strict";O.exports=LongBits;var J=$(6642);function LongBits(O,U){this.lo=O>>>0,this.hi=U>>>0}var en=LongBits.zero=new LongBits(0,0);en.toNumber=function(){return 0},en.zzEncode=en.zzDecode=function(){return this},en.length=function(){return 1};var es=LongBits.zeroHash="\x00\x00\x00\x00\x00\x00\x00\x00";LongBits.fromNumber=function(O){if(0===O)return en;var U=O<0;U&&(O=-O);var $=O>>>0,J=(O-$)/4294967296>>>0;return U&&(J=~J>>>0,$=~$>>>0,++$>4294967295&&($=0,++J>4294967295&&(J=0))),new LongBits($,J)},LongBits.from=function(O){if("number"==typeof O)return LongBits.fromNumber(O);if(J.isString(O)){if(!J.Long)return LongBits.fromNumber(parseInt(O,10));O=J.Long.fromString(O)}return O.low||O.high?new LongBits(O.low>>>0,O.high>>>0):en},LongBits.prototype.toNumber=function(O){if(!O&&this.hi>>>31){var U=~this.lo+1>>>0,$=~this.hi>>>0;return U||($=$+1>>>0),-(U+4294967296*$)}return this.lo+4294967296*this.hi},LongBits.prototype.toLong=function(O){return J.Long?new J.Long(0|this.lo,0|this.hi,!!O):{low:0|this.lo,high:0|this.hi,unsigned:!!O}};var eo=String.prototype.charCodeAt;LongBits.fromHash=function(O){return O===es?en:new LongBits((eo.call(O,0)|eo.call(O,1)<<8|eo.call(O,2)<<16|eo.call(O,3)<<24)>>>0,(eo.call(O,4)|eo.call(O,5)<<8|eo.call(O,6)<<16|eo.call(O,7)<<24)>>>0)},LongBits.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)},LongBits.prototype.zzEncode=function(){var O=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^O)>>>0,this.lo=(this.lo<<1^O)>>>0,this},LongBits.prototype.zzDecode=function(){var O=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^O)>>>0,this.hi=(this.hi>>>1^O)>>>0,this},LongBits.prototype.length=function(){var O=this.lo,U=(this.lo>>>28|this.hi<<4)>>>0,$=this.hi>>>24;return 0===$?0===U?O<16384?O<128?1:2:O<2097152?3:4:U<16384?U<128?5:6:U<2097152?7:8:$<128?9:10}},6642:function(O,U,$){"use strict";var J=U;function merge(O,U,$){for(var J=Object.keys(U),en=0;en0)},J.Buffer=function(){try{var O=J.inquire("buffer").Buffer;return O.prototype.utf8Write?O:null}catch(O){return null}}(),J._Buffer_from=null,J._Buffer_allocUnsafe=null,J.newBuffer=function(O){return"number"==typeof O?J.Buffer?J._Buffer_allocUnsafe(O):new J.Array(O):J.Buffer?J._Buffer_from(O):"undefined"==typeof Uint8Array?O:new Uint8Array(O)},J.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,J.Long=J.global.dcodeIO&&J.global.dcodeIO.Long||J.global.Long||J.inquire("long"),J.key2Re=/^true|false|0|1$/,J.key32Re=/^-?(?:0|[1-9][0-9]*)$/,J.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,J.longToHash=function(O){return O?J.LongBits.from(O).toHash():J.LongBits.zeroHash},J.longFromHash=function(O,U){var $=J.LongBits.fromHash(O);return J.Long?J.Long.fromBits($.lo,$.hi,U):$.toNumber(!!U)},J.merge=merge,J.lcFirst=function(O){return O.charAt(0).toLowerCase()+O.substring(1)},J.newError=newError,J.ProtocolError=newError("ProtocolError"),J.oneOfGetter=function(O){for(var U={},$=0;$-1;--$)if(1===U[O[$]]&&void 0!==this[O[$]]&&null!==this[O[$]])return O[$]}},J.oneOfSetter=function(O){return function(U){for(var $=0;$127;)U[$++]=127&O|128,O>>>=7;U[$]=O}function VarintOp(O,U){this.len=O,this.next=void 0,this.val=U}function writeVarint64(O,U,$){for(;O.hi;)U[$++]=127&O.lo|128,O.lo=(O.lo>>>7|O.hi<<25)>>>0,O.hi>>>=7;for(;O.lo>127;)U[$++]=127&O.lo|128,O.lo=O.lo>>>7;U[$++]=O.lo}function writeFixed32(O,U,$){U[$]=255&O,U[$+1]=O>>>8&255,U[$+2]=O>>>16&255,U[$+3]=O>>>24}Writer.create=create(),Writer.alloc=function(O){return new en.Array(O)},en.Array!==Array&&(Writer.alloc=en.pool(Writer.alloc,en.Array.prototype.subarray)),Writer.prototype._push=function(O,U,$){return this.tail=this.tail.next=new Op(O,U,$),this.len+=U,this},VarintOp.prototype=Object.create(Op.prototype),VarintOp.prototype.fn=writeVarint32,Writer.prototype.uint32=function(O){return this.len+=(this.tail=this.tail.next=new VarintOp((O>>>=0)<128?1:O<16384?2:O<2097152?3:O<268435456?4:5,O)).len,this},Writer.prototype.int32=function(O){return O<0?this._push(writeVarint64,10,es.fromNumber(O)):this.uint32(O)},Writer.prototype.sint32=function(O){return this.uint32((O<<1^O>>31)>>>0)},Writer.prototype.uint64=function(O){var U=es.from(O);return this._push(writeVarint64,U.length(),U)},Writer.prototype.int64=Writer.prototype.uint64,Writer.prototype.sint64=function(O){var U=es.from(O).zzEncode();return this._push(writeVarint64,U.length(),U)},Writer.prototype.bool=function(O){return this._push(writeByte,1,O?1:0)},Writer.prototype.fixed32=function(O){return this._push(writeFixed32,4,O>>>0)},Writer.prototype.sfixed32=Writer.prototype.fixed32,Writer.prototype.fixed64=function(O){var U=es.from(O);return this._push(writeFixed32,4,U.lo)._push(writeFixed32,4,U.hi)},Writer.prototype.sfixed64=Writer.prototype.fixed64,Writer.prototype.float=function(O){return this._push(en.float.writeFloatLE,4,O)},Writer.prototype.double=function(O){return this._push(en.float.writeDoubleLE,8,O)};var eu=en.Array.prototype.set?function(O,U,$){U.set(O,$)}:function(O,U,$){for(var J=0;J>>0;if(!U)return this._push(writeByte,1,0);if(en.isString(O)){var $=Writer.alloc(U=eo.length(O));eo.decode(O,$,0),O=$}return this.uint32(U)._push(eu,U,O)},Writer.prototype.string=function(O){var U=ea.length(O);return U?this.uint32(U)._push(ea.write,U,O):this._push(writeByte,1,0)},Writer.prototype.fork=function(){return this.states=new State(this),this.head=this.tail=new Op(noop,0,0),this.len=0,this},Writer.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 Op(noop,0,0),this.len=0),this},Writer.prototype.ldelim=function(){var O=this.head,U=this.tail,$=this.len;return this.reset().uint32($),$&&(this.tail.next=O.next,this.tail=U,this.len+=$),this},Writer.prototype.finish=function(){for(var O=this.head.next,U=this.constructor.alloc(this.len),$=0;O;)O.fn(O.val,U,$),$+=O.len,O=O.next;return U},Writer._configure=function(O){J=O,Writer.create=create(),J._configure()}},3654:function(O,U,$){"use strict";O.exports=BufferWriter;var J=$(8045);(BufferWriter.prototype=Object.create(J.prototype)).constructor=BufferWriter;var en=$(6642);function BufferWriter(){J.call(this)}function writeStringBuffer(O,U,$){O.length<40?en.utf8.write(O,U,$):U.utf8Write?U.utf8Write(O,$):U.write(O,$)}BufferWriter._configure=function(){BufferWriter.alloc=en._Buffer_allocUnsafe,BufferWriter.writeBytesBuffer=en.Buffer&&en.Buffer.prototype instanceof Uint8Array&&"set"===en.Buffer.prototype.set.name?function(O,U,$){U.set(O,$)}:function(O,U,$){if(O.copy)O.copy(U,$,0,O.length);else for(var J=0;J>>0;return this.uint32(U),U&&this._push(BufferWriter.writeBytesBuffer,U,O),this},BufferWriter.prototype.string=function(O){var U=en.Buffer.byteLength(O);return this.uint32(U),U&&this._push(writeStringBuffer,U,O),this},BufferWriter._configure()},5719:function(O,U,$){let J=$(4254),en=$(2492),es=$(6192),eo=$(9770),{RateLimiterClusterMaster:ea,RateLimiterClusterMasterPM2:eu,RateLimiterCluster:ef}=$(4413),eg=$(2311),ev=$(1626),e_=$(3205),ew=$(4005),eE=$(4845),eS=$(9623),eA=$(367);O.exports={RateLimiterRedis:J,RateLimiterMongo:en,RateLimiterMySQL:es,RateLimiterPostgres:eo,RateLimiterMemory:eg,RateLimiterMemcache:ev,RateLimiterClusterMaster:ea,RateLimiterClusterMasterPM2:eu,RateLimiterCluster:ef,RLWrapperBlackAndWhite:e_,RateLimiterUnion:ew,RateLimiterQueue:eE,BurstyRateLimiter:eS,RateLimiterRes:eA}},9623:function(O,U,$){let J=$(367);O.exports=class{constructor(O,U){this._rateLimiter=O,this._burstLimiter=U}_combineRes(O,U){return O?new J(O.remainingPoints,Math.min(O.msBeforeNext,U?U.msBeforeNext:0),O.consumedPoints,O.isFirstInDuration):null}consume(O,U=1,$={}){return this._rateLimiter.consume(O,U,$).catch(en=>en instanceof J?this._burstLimiter.consume(O,U,$).then(O=>Promise.resolve(this._combineRes(en,O))).catch(O=>O instanceof J?Promise.reject(this._combineRes(en,O)):Promise.reject(O)):Promise.reject(en))}get(O){return Promise.all([this._rateLimiter.get(O),this._burstLimiter.get(O)]).then(([O,U])=>this._combineRes(O,U))}get points(){return this._rateLimiter.points}}},3205:function(O,U,$){let J=$(367);O.exports=class{constructor(O={}){this.limiter=O.limiter,this.blackList=O.blackList,this.whiteList=O.whiteList,this.isBlackListed=O.isBlackListed,this.isWhiteListed=O.isWhiteListed,this.runActionAnyway=O.runActionAnyway}get limiter(){return this._limiter}set limiter(O){if(void 0===O)throw Error("limiter is not set");this._limiter=O}get runActionAnyway(){return this._runActionAnyway}set runActionAnyway(O){this._runActionAnyway=void 0!==O&&O}get blackList(){return this._blackList}set blackList(O){this._blackList=Array.isArray(O)?O:[]}get isBlackListed(){return this._isBlackListed}set isBlackListed(O){if(void 0===O&&(O=()=>!1),"function"!=typeof O)throw Error("isBlackListed must be function");this._isBlackListed=O}get whiteList(){return this._whiteList}set whiteList(O){this._whiteList=Array.isArray(O)?O:[]}get isWhiteListed(){return this._isWhiteListed}set isWhiteListed(O){if(void 0===O&&(O=()=>!1),"function"!=typeof O)throw Error("isWhiteListed must be function");this._isWhiteListed=O}isBlackListedSomewhere(O){return this.blackList.indexOf(O)>=0||this.isBlackListed(O)}isWhiteListedSomewhere(O){return this.whiteList.indexOf(O)>=0||this.isWhiteListed(O)}getBlackRes(){return new J(0,Number.MAX_SAFE_INTEGER,0,!1)}getWhiteRes(){return new J(Number.MAX_SAFE_INTEGER,0,0,!1)}rejectBlack(){return Promise.reject(this.getBlackRes())}resolveBlack(){return Promise.resolve(this.getBlackRes())}resolveWhite(){return Promise.resolve(this.getWhiteRes())}consume(O,U=1){let $;return(this.isWhiteListedSomewhere(O)?$=this.resolveWhite():this.isBlackListedSomewhere(O)&&($=this.rejectBlack()),void 0===$)?this.limiter.consume(O,U):(this.runActionAnyway&&this.limiter.consume(O,U).catch(()=>{}),$)}block(O,U){let $;return(this.isWhiteListedSomewhere(O)?$=this.resolveWhite():this.isBlackListedSomewhere(O)&&($=this.resolveBlack()),void 0===$)?this.limiter.block(O,U):(this.runActionAnyway&&this.limiter.block(O,U).catch(()=>{}),$)}penalty(O,U){let $;return(this.isWhiteListedSomewhere(O)?$=this.resolveWhite():this.isBlackListedSomewhere(O)&&($=this.resolveBlack()),void 0===$)?this.limiter.penalty(O,U):(this.runActionAnyway&&this.limiter.penalty(O,U).catch(()=>{}),$)}reward(O,U){let $;return(this.isWhiteListedSomewhere(O)?$=this.resolveWhite():this.isBlackListedSomewhere(O)&&($=this.resolveBlack()),void 0===$)?this.limiter.reward(O,U):(this.runActionAnyway&&this.limiter.reward(O,U).catch(()=>{}),$)}get(O){let U;return(this.isWhiteListedSomewhere(O)?U=this.resolveWhite():this.isBlackListedSomewhere(O)&&(U=this.resolveBlack()),void 0===U||this.runActionAnyway)?this.limiter.get(O):U}delete(O){return this.limiter.delete(O)}}},1725:function(O){O.exports=class{constructor(O={}){this.points=O.points,this.duration=O.duration,this.blockDuration=O.blockDuration,this.execEvenly=O.execEvenly,this.execEvenlyMinDelayMs=O.execEvenlyMinDelayMs,this.keyPrefix=O.keyPrefix}get points(){return this._points}set points(O){this._points=O>=0?O:4}get duration(){return this._duration}set duration(O){this._duration=void 0===O?1:O}get msDuration(){return 1e3*this.duration}get blockDuration(){return this._blockDuration}set blockDuration(O){this._blockDuration=void 0===O?0:O}get msBlockDuration(){return 1e3*this.blockDuration}get execEvenly(){return this._execEvenly}set execEvenly(O){this._execEvenly=void 0!==O&&!!O}get execEvenlyMinDelayMs(){return this._execEvenlyMinDelayMs}set execEvenlyMinDelayMs(O){this._execEvenlyMinDelayMs=void 0===O?Math.ceil(this.msDuration/this.points):O}get keyPrefix(){return this._keyPrefix}set keyPrefix(O){if(void 0===O&&(O="rlflx"),"string"!=typeof O)throw Error("keyPrefix must be string");this._keyPrefix=O}_getKeySecDuration(O={}){return O&&O.customDuration>=0?O.customDuration:this.duration}getKey(O){return this.keyPrefix.length>0?`${this.keyPrefix}:${O}`:O}parseKey(O){return O.substring(this.keyPrefix.length)}consume(){throw Error("You have to implement the method 'consume'!")}penalty(){throw Error("You have to implement the method 'penalty'!")}reward(){throw Error("You have to implement the method 'reward'!")}get(){throw Error("You have to implement the method 'get'!")}set(){throw Error("You have to implement the method 'set'!")}block(){throw Error("You have to implement the method 'block'!")}delete(){throw Error("You have to implement the method 'delete'!")}}},4413:function(O,U,$){var J=$(2601);let en=$(1265),es=$(5539),eo=$(1725),ea=$(2311),eu=$(367),ef="rate_limiter_flexible",eg=null,masterSendToWorker=function(O,U,$,J){let en;en=null===J||!0===J||!1===J?J:{remainingPoints:J.remainingPoints,msBeforeNext:J.msBeforeNext,consumedPoints:J.consumedPoints,isFirstInDuration:J.isFirstInDuration},O.send({channel:ef,keyPrefix:U.keyPrefix,promiseId:U.promiseId,type:$,data:en})},workerWaitInit=function(O){setTimeout(()=>{this._initiated?J.send(O):void 0!==this._promises[O.promiseId]&&workerWaitInit.call(this,O)},30)},workerSendToMaster=function(O,U,$,en,es){let eo={channel:ef,keyPrefix:this.keyPrefix,func:O,promiseId:U,data:{key:$,arg:en,opts:es}};this._initiated?J.send(eo):workerWaitInit.call(this,eo)},masterProcessMsg=function(O,U){let $;if(!U||U.channel!==ef||void 0===this._rateLimiters[U.keyPrefix])return!1;switch(U.func){case"consume":$=this._rateLimiters[U.keyPrefix].consume(U.data.key,U.data.arg,U.data.opts);break;case"penalty":$=this._rateLimiters[U.keyPrefix].penalty(U.data.key,U.data.arg,U.data.opts);break;case"reward":$=this._rateLimiters[U.keyPrefix].reward(U.data.key,U.data.arg,U.data.opts);break;case"block":$=this._rateLimiters[U.keyPrefix].block(U.data.key,U.data.arg,U.data.opts);break;case"get":$=this._rateLimiters[U.keyPrefix].get(U.data.key,U.data.opts);break;case"delete":$=this._rateLimiters[U.keyPrefix].delete(U.data.key,U.data.opts);break;default:return!1}$&&$.then($=>{masterSendToWorker(O,U,"resolve",$)}).catch($=>{masterSendToWorker(O,U,"reject",$)})},workerProcessMsg=function(O){if(!O||O.channel!==ef||O.keyPrefix!==this.keyPrefix)return!1;if(this._promises[O.promiseId]){let U;switch(clearTimeout(this._promises[O.promiseId].timeoutId),U=null===O.data||!0===O.data||!1===O.data?O.data:new eu(O.data.remainingPoints,O.data.msBeforeNext,O.data.consumedPoints,O.data.isFirstInDuration),O.type){case"resolve":this._promises[O.promiseId].resolve(U);break;case"reject":this._promises[O.promiseId].reject(U);break;default:throw Error(`RateLimiterCluster: no such message type '${O.type}'`)}delete this._promises[O.promiseId]}},getOpts=function(){return{points:this.points,duration:this.duration,blockDuration:this.blockDuration,execEvenly:this.execEvenly,execEvenlyMinDelayMs:this.execEvenlyMinDelayMs,keyPrefix:this.keyPrefix}},savePromise=function(O,U){let $=J.hrtime(),en=$[0].toString()+$[1].toString();return void 0!==this._promises[en]&&(en+=es.randomBytes(12).toString("base64")),this._promises[en]={resolve:O,reject:U,timeoutId:setTimeout(()=>{delete this._promises[en],U(Error("RateLimiterCluster timeout: no answer from master in time"))},this.timeoutMs)},en};let RateLimiterClusterMaster=class RateLimiterClusterMaster{constructor(){if(eg)return eg;this._rateLimiters={},en.setMaxListeners(0),en.on("message",(O,U)=>{U&&U.channel===ef&&"init"===U.type?(void 0===this._rateLimiters[U.opts.keyPrefix]&&(this._rateLimiters[U.opts.keyPrefix]=new ea(U.opts)),O.send({channel:ef,type:"init",keyPrefix:U.opts.keyPrefix})):masterProcessMsg.call(this,O,U)}),eg=this}};let RateLimiterClusterMasterPM2=class RateLimiterClusterMasterPM2{constructor(O){if(eg)return eg;this._rateLimiters={},O.launchBus((U,$)=>{$.on("process:msg",U=>{let $=U.raw;if($&&$.channel===ef&&"init"===$.type)void 0===this._rateLimiters[$.opts.keyPrefix]&&(this._rateLimiters[$.opts.keyPrefix]=new ea($.opts)),O.sendDataToProcessId(U.process.pm_id,{data:{},topic:ef,channel:ef,type:"init",keyPrefix:$.opts.keyPrefix},(O,U)=>{O&&console.log(O,U)});else{let J={send:$=>{let J=$;J.topic=ef,void 0===J.data&&(J.data={}),O.sendDataToProcessId(U.process.pm_id,J,(O,U)=>{O&&console.log(O,U)})}};masterProcessMsg.call(this,J,$)}})}),eg=this}};let RateLimiterClusterWorker=class RateLimiterClusterWorker extends eo{get timeoutMs(){return this._timeoutMs}set timeoutMs(O){this._timeoutMs=void 0===O?5e3:Math.abs(parseInt(O))}constructor(O={}){super(O),J.setMaxListeners(0),this.timeoutMs=O.timeoutMs,this._initiated=!1,J.on("message",O=>{O&&O.channel===ef&&"init"===O.type&&O.keyPrefix===this.keyPrefix?this._initiated=!0:workerProcessMsg.call(this,O)}),J.send({channel:ef,type:"init",opts:getOpts.call(this)}),this._promises={}}consume(O,U=1,$={}){return new Promise((J,en)=>{let es=savePromise.call(this,J,en);workerSendToMaster.call(this,"consume",es,O,U,$)})}penalty(O,U=1,$={}){return new Promise((J,en)=>{let es=savePromise.call(this,J,en);workerSendToMaster.call(this,"penalty",es,O,U,$)})}reward(O,U=1,$={}){return new Promise((J,en)=>{let es=savePromise.call(this,J,en);workerSendToMaster.call(this,"reward",es,O,U,$)})}block(O,U,$={}){return new Promise((J,en)=>{let es=savePromise.call(this,J,en);workerSendToMaster.call(this,"block",es,O,U,$)})}get(O,U={}){return new Promise(($,J)=>{let en=savePromise.call(this,$,J);workerSendToMaster.call(this,"get",en,O,U)})}delete(O,U={}){return new Promise(($,J)=>{let en=savePromise.call(this,$,J);workerSendToMaster.call(this,"delete",en,O,U)})}};O.exports={RateLimiterClusterMaster,RateLimiterClusterMasterPM2,RateLimiterCluster:RateLimiterClusterWorker}},1626:function(O,U,$){let J=$(928),en=$(367);let RateLimiterMemcache=class RateLimiterMemcache extends J{constructor(O){super(O),this.client=O.storeClient}_getRateLimiterRes(O,U,$){let J=new en;return J.consumedPoints=parseInt($.consumedPoints),J.isFirstInDuration=$.consumedPoints===U,J.remainingPoints=Math.max(this.points-J.consumedPoints,0),J.msBeforeNext=$.msBeforeNext,J}_upsert(O,U,$,J=!1,en={}){return new Promise((es,eo)=>{let ea=Date.now(),eu=Math.floor($/1e3);J?this.client.set(O,U,eu,$=>{$?eo($):this.client.set(`${O}_expire`,eu>0?ea+1e3*eu:-1,eu,()=>{let O={consumedPoints:U,msBeforeNext:eu>0?1e3*eu:-1};es(O)})}):this.client.incr(O,U,(ef,eg)=>{ef||!1===eg?this.client.add(O,U,eu,(ef,eg)=>{if(ef||!eg){if(void 0===en.attemptNumber||en.attemptNumber<3){let ea=Object.assign({},en);ea.attemptNumber=ea.attemptNumber?ea.attemptNumber+1:1,this._upsert(O,U,$,J,ea).then(O=>es(O)).catch(O=>eo(O))}else eo(Error("Can not add key"))}else this.client.add(`${O}_expire`,eu>0?ea+1e3*eu:-1,eu,()=>{let O={consumedPoints:U,msBeforeNext:eu>0?1e3*eu:-1};es(O)})}):this.client.get(`${O}_expire`,(O,U)=>{if(O)eo(O);else{let O=!1===U?0:U,$={consumedPoints:eg,msBeforeNext:O>=0?Math.max(O-ea,0):-1};es($)}})})})}_get(O){return new Promise((U,$)=>{let J=Date.now();this.client.get(O,(en,es)=>{es?this.client.get(`${O}_expire`,(O,en)=>{if(O)$(O);else{let O=!1===en?0:en,$={consumedPoints:es,msBeforeNext:O>=0?Math.max(O-J,0):-1};U($)}}):U(null)})})}_delete(O){return new Promise((U,$)=>{this.client.del(O,(J,en)=>{J?$(J):!1===en?U(en):this.client.del(`${O}_expire`,O=>{O?$(O):U(en)})})})}};O.exports=RateLimiterMemcache},2311:function(O,U,$){let J=$(1725),en=$(4603),es=$(367);let RateLimiterMemory=class RateLimiterMemory extends J{constructor(O={}){super(O),this._memoryStorage=new en}consume(O,U=1,$={}){return new Promise((J,en)=>{let es=this.getKey(O),eo=this._getKeySecDuration($),ea=this._memoryStorage.incrby(es,U,eo);if(ea.remainingPoints=Math.max(this.points-ea.consumedPoints,0),ea.consumedPoints>this.points)this.blockDuration>0&&ea.consumedPoints<=this.points+U&&(ea=this._memoryStorage.set(es,ea.consumedPoints,this.blockDuration)),en(ea);else if(this.execEvenly&&ea.msBeforeNext>0&&!ea.isFirstInDuration){let O=Math.ceil(ea.msBeforeNext/(ea.remainingPoints+2));O{let en=this._getKeySecDuration($),es=this._memoryStorage.incrby(J,U,en);es.remainingPoints=Math.max(this.points-es.consumedPoints,0),O(es)})}reward(O,U=1,$={}){let J=this.getKey(O);return new Promise(O=>{let en=this._getKeySecDuration($),es=this._memoryStorage.incrby(J,-U,en);es.remainingPoints=Math.max(this.points-es.consumedPoints,0),O(es)})}block(O,U){let $=1e3*U,J=this.points+1;return this._memoryStorage.set(this.getKey(O),J,U),Promise.resolve(new es(0,0===$?-1:$,J))}set(O,U,$){let J=($>=0?$:this.duration)*1e3;return this._memoryStorage.set(this.getKey(O),U,$),Promise.resolve(new es(0,0===J?-1:J,U))}get(O){let U=this._memoryStorage.get(this.getKey(O));return null!==U&&(U.remainingPoints=Math.max(this.points-U.consumedPoints,0)),Promise.resolve(U)}delete(O){return Promise.resolve(this._memoryStorage.delete(this.getKey(O)))}};O.exports=RateLimiterMemory},2492:function(O,U,$){let J=$(928),en=$(367);function getDriverVersion(O){try{let U=O.client?O.client:O,{version:$}=U.topology.s.options.metadata.driver,J=$.split(".").map(O=>parseInt(O));return{major:J[0],feature:J[1],patch:J[2]}}catch(O){return{major:0,feature:0,patch:0}}}let RateLimiterMongo=class RateLimiterMongo extends J{constructor(O){super(O),this.dbName=O.dbName,this.tableName=O.tableName,this.indexKeyPrefix=O.indexKeyPrefix,O.mongo?this.client=O.mongo:this.client=O.storeClient,"function"==typeof this.client.then?this.client.then(O=>{this.client=O,this._initCollection(),this._driverVersion=getDriverVersion(this.client)}):(this._initCollection(),this._driverVersion=getDriverVersion(this.client))}get dbName(){return this._dbName}set dbName(O){this._dbName=void 0===O?RateLimiterMongo.getDbName():O}static getDbName(){return"node-rate-limiter-flexible"}get tableName(){return this._tableName}set tableName(O){this._tableName=void 0===O?this.keyPrefix:O}get client(){return this._client}set client(O){if(void 0===O)throw Error("mongo is not set");this._client=O}get indexKeyPrefix(){return this._indexKeyPrefix}set indexKeyPrefix(O){this._indexKeyPrefix=O||{}}_initCollection(){let O="function"==typeof this.client.db?this.client.db(this.dbName):this.client,U=O.collection(this.tableName);U.createIndex({expire:-1},{expireAfterSeconds:0}),U.createIndex(Object.assign({},this.indexKeyPrefix,{key:1}),{unique:!0}),this._collection=U}_getRateLimiterRes(O,U,$){let J;let es=new en;return J=void 0===$.value?$:$.value,es.isFirstInDuration=J.points===U,es.consumedPoints=J.points,es.remainingPoints=Math.max(this.points-es.consumedPoints,0),es.msBeforeNext=null!==J.expire?Math.max(new Date(J.expire).getTime()-Date.now(),0):-1,es}_upsert(O,U,$,J=!1,en={}){let es,eo;if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));let ea=en.attrs||{};J?(es=Object.assign(es={key:O},ea),(eo={$set:{key:O,points:U,expire:$>0?new Date(Date.now()+$):null}}).$set=Object.assign(eo.$set,ea)):(es=Object.assign(es={$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}],key:O},ea),(eo={$setOnInsert:{key:O,expire:$>0?new Date(Date.now()+$):null},$inc:{points:U}}).$setOnInsert=Object.assign(eo.$setOnInsert,ea));let eu={upsert:!0};return this._driverVersion.major>=4||3===this._driverVersion.major&&this._driverVersion.feature>=7||this._driverVersion.feature>=6&&this._driverVersion.patch>=7?eu.returnDocument="after":eu.returnOriginal=!1,new Promise((en,ef)=>{this._collection.findOneAndUpdate(es,eo,eu).then(O=>{en(O)}).catch(es=>{if(es&&11e3===es.code){let es=Object.assign({$or:[{expire:{$lte:new Date}},{expire:{$eq:null}}],key:O},ea),eo={$set:Object.assign({key:O,points:U,expire:$>0?new Date(Date.now()+$):null},ea)};this._collection.findOneAndUpdate(es,eo,eu).then(O=>{en(O)}).catch(es=>{es&&11e3===es.code?this._upsert(O,U,$,J).then(O=>en(O)).catch(O=>ef(O)):ef(es)})}else ef(es)})})}_get(O,U={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));let $=U.attrs||{},J=Object.assign({key:O,$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}]},$);return this._collection.findOne(J)}_delete(O,U={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));let $=U.attrs||{},J=Object.assign({key:O},$);return this._collection.deleteOne(J).then(O=>O.deletedCount>0)}};O.exports=RateLimiterMongo},6192:function(O,U,$){let J=$(928),en=$(367);let RateLimiterMySQL=class RateLimiterMySQL extends J{constructor(O,U=null){super(O),this.client=O.storeClient,this.clientType=O.storeType,this.dbName=O.dbName,this.tableName=O.tableName,this.clearExpiredByTimeout=O.clearExpiredByTimeout,this.tableCreated=O.tableCreated,this.tableCreated?(this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"==typeof U&&U()):this._createDbAndTable().then(()=>{this.tableCreated=!0,this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"==typeof U&&U()}).catch(O=>{if("function"==typeof U)U(O);else throw O})}clearExpired(O){return new Promise(U=>{this._getConnection().then($=>{$.query("DELETE FROM ??.?? WHERE expire < ?",[this.dbName,this.tableName,O],()=>{this._releaseConnection($),U()})}).catch(()=>{U()})})}_clearExpiredHourAgo(){this._clearExpiredTimeoutId&&clearTimeout(this._clearExpiredTimeoutId),this._clearExpiredTimeoutId=setTimeout(()=>{this.clearExpired(Date.now()-36e5).then(()=>{this._clearExpiredHourAgo()})},3e5),this._clearExpiredTimeoutId.unref()}_getConnection(){switch(this.clientType){case"pool":return new Promise((O,U)=>{this.client.getConnection(($,J)=>{if($)return U($);O(J)})});case"sequelize":return this.client.connectionManager.getConnection();case"knex":return this.client.client.acquireConnection();default:return Promise.resolve(this.client)}}_releaseConnection(O){switch(this.clientType){case"pool":return O.release();case"sequelize":return this.client.connectionManager.releaseConnection(O);case"knex":return this.client.client.releaseConnection(O);default:return!0}}_createDbAndTable(){return new Promise((O,U)=>{this._getConnection().then($=>{$.query(`CREATE DATABASE IF NOT EXISTS \`${this.dbName}\`;`,J=>{if(J)return this._releaseConnection($),U(J);$.query(this._getCreateTableStmt(),J=>{if(J)return this._releaseConnection($),U(J);this._releaseConnection($),O()})})}).catch(O=>{U(O)})})}_getCreateTableStmt(){return`CREATE TABLE IF NOT EXISTS \`${this.dbName}\`.\`${this.tableName}\` (\`key\` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\`points\` INT(9) NOT NULL default 0,\`expire\` BIGINT UNSIGNED,PRIMARY KEY (\`key\`)) ENGINE = INNODB;`}get clientType(){return this._clientType}set clientType(O){if(void 0===O){if("Connection"===this.client.constructor.name)O="connection";else if("Pool"===this.client.constructor.name)O="pool";else if("Sequelize"===this.client.constructor.name)O="sequelize";else throw Error("storeType is not defined")}this._clientType=O.toLowerCase()}get dbName(){return this._dbName}set dbName(O){this._dbName=void 0===O?"rtlmtrflx":O}get tableName(){return this._tableName}set tableName(O){this._tableName=void 0===O?this.keyPrefix:O}get tableCreated(){return this._tableCreated}set tableCreated(O){this._tableCreated=void 0!==O&&!!O}get clearExpiredByTimeout(){return this._clearExpiredByTimeout}set clearExpiredByTimeout(O){this._clearExpiredByTimeout=void 0===O||!!O}_getRateLimiterRes(O,U,$){let J=new en,[es]=$;return J.isFirstInDuration=U===es.points,J.consumedPoints=J.isFirstInDuration?U:es.points,J.remainingPoints=Math.max(this.points-J.consumedPoints,0),J.msBeforeNext=es.expire?Math.max(es.expire-Date.now(),0):-1,J}_upsertTransaction(O,U,$,J,en){return new Promise((es,eo)=>{O.query("BEGIN",ea=>{let eu,ef;if(ea)return O.rollback(),eo(ea);let eg=Date.now(),ev=J>0?eg+J:null;en?(eu=`INSERT INTO ??.?? VALUES (?, ?, ?) + ON DUPLICATE KEY UPDATE + points = ?, + expire = ?;`,ef=[this.dbName,this.tableName,U,$,ev,$,ev]):(eu=`INSERT INTO ??.?? VALUES (?, ?, ?) + ON DUPLICATE KEY UPDATE + points = IF(expire <= ?, ?, points + (?)), + expire = IF(expire <= ?, ?, expire);`,ef=[this.dbName,this.tableName,U,$,ev,eg,$,$,eg,ev]),O.query(eu,ef,$=>{if($)return O.rollback(),eo($);O.query("SELECT points, expire FROM ??.?? WHERE `key` = ?;",[this.dbName,this.tableName,U],(U,$)=>{if(U)return O.rollback(),eo(U);O.query("COMMIT",U=>{if(U)return O.rollback(),eo(U);es($)})})})})})}_upsert(O,U,$,J=!1){return this.tableCreated?new Promise((en,es)=>{this._getConnection().then(eo=>{this._upsertTransaction(eo,O,U,$,J).then(O=>{en(O),this._releaseConnection(eo)}).catch(O=>{es(O),this._releaseConnection(eo)})}).catch(O=>{es(O)})}):Promise.reject(Error("Table is not created yet"))}_get(O){return this.tableCreated?new Promise((U,$)=>{this._getConnection().then(J=>{J.query("SELECT points, expire FROM ??.?? WHERE `key` = ? AND (`expire` > ? OR `expire` IS NULL)",[this.dbName,this.tableName,O,Date.now()],(O,en)=>{O?$(O):0===en.length?U(null):U(en),this._releaseConnection(J)})}).catch(O=>{$(O)})}):Promise.reject(Error("Table is not created yet"))}_delete(O){return this.tableCreated?new Promise((U,$)=>{this._getConnection().then(J=>{J.query("DELETE FROM ??.?? WHERE `key` = ?",[this.dbName,this.tableName,O],(O,en)=>{O?$(O):U(en.affectedRows>0),this._releaseConnection(J)})}).catch(O=>{$(O)})}):Promise.reject(Error("Table is not created yet"))}};O.exports=RateLimiterMySQL},9770:function(O,U,$){let J=$(928),en=$(367);let RateLimiterPostgres=class RateLimiterPostgres extends J{constructor(O,U=null){super(O),this.client=O.storeClient,this.clientType=O.storeType,this.tableName=O.tableName,this.schemaName=O.schemaName,this.clearExpiredByTimeout=O.clearExpiredByTimeout,this.tableCreated=O.tableCreated,this.tableCreated?"function"==typeof U&&U():this._createTable().then(()=>{this.tableCreated=!0,this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"==typeof U&&U()}).catch(O=>{if("function"==typeof U)U(O);else throw O})}_getTableIdentifier(){return this.schemaName?`"${this.schemaName}"."${this.tableName}"`:`"${this.tableName}"`}clearExpired(O){return new Promise(U=>{let $={name:"rlflx-clear-expired",text:`DELETE FROM ${this._getTableIdentifier()} WHERE expire < $1`,values:[O]};this._query($).then(()=>{U()}).catch(()=>{U()})})}_clearExpiredHourAgo(){this._clearExpiredTimeoutId&&clearTimeout(this._clearExpiredTimeoutId),this._clearExpiredTimeoutId=setTimeout(()=>{this.clearExpired(Date.now()-36e5).then(()=>{this._clearExpiredHourAgo()})},3e5),this._clearExpiredTimeoutId.unref()}_getConnection(){switch(this.clientType){case"pool":default:return Promise.resolve(this.client);case"sequelize":return this.client.connectionManager.getConnection();case"knex":return this.client.client.acquireConnection();case"typeorm":return Promise.resolve(this.client.driver.master)}}_releaseConnection(O){switch(this.clientType){case"pool":case"typeorm":default:return!0;case"sequelize":return this.client.connectionManager.releaseConnection(O);case"knex":return this.client.client.releaseConnection(O)}}_createTable(){return new Promise((O,U)=>{this._query({text:this._getCreateTableStmt()}).then(()=>{O()}).catch($=>{"23505"===$.code?O():U($)})})}_getCreateTableStmt(){return`CREATE TABLE IF NOT EXISTS ${this._getTableIdentifier()} ( + key varchar(255) PRIMARY KEY, + points integer NOT NULL DEFAULT 0, + expire bigint + );`}get clientType(){return this._clientType}set clientType(O){let U=this.client.constructor.name;if(void 0===O){if("Client"===U)O="client";else if("Pool"===U||"BoundPool"===U)O="pool";else if("Sequelize"===U)O="sequelize";else throw Error("storeType is not defined")}this._clientType=O.toLowerCase()}get tableName(){return this._tableName}set tableName(O){this._tableName=void 0===O?this.keyPrefix:O}get schemaName(){return this._schemaName}set schemaName(O){this._schemaName=O}get tableCreated(){return this._tableCreated}set tableCreated(O){this._tableCreated=void 0!==O&&!!O}get clearExpiredByTimeout(){return this._clearExpiredByTimeout}set clearExpiredByTimeout(O){this._clearExpiredByTimeout=void 0===O||!!O}_getRateLimiterRes(O,U,$){let J=new en,es=$.rows[0];return J.isFirstInDuration=U===es.points,J.consumedPoints=J.isFirstInDuration?U:es.points,J.remainingPoints=Math.max(this.points-J.consumedPoints,0),J.msBeforeNext=es.expire?Math.max(es.expire-Date.now(),0):-1,J}_query(O){let U=this.tableName.toLowerCase(),$={name:`${U}:${O.name}`,text:O.text,values:O.values};return new Promise((O,U)=>{this._getConnection().then(J=>{J.query($).then(U=>{O(U),this._releaseConnection(J)}).catch(O=>{U(O),this._releaseConnection(J)})}).catch(O=>{U(O)})})}_upsert(O,U,$,J=!1){if(!this.tableCreated)return Promise.reject(Error("Table is not created yet"));let en=$>0?Date.now()+$:null,es=J?" $3 ":` CASE + WHEN ${this._getTableIdentifier()}.expire <= $4 THEN $3 + ELSE ${this._getTableIdentifier()}.expire + END `;return this._query({name:J?"rlflx-upsert-force":"rlflx-upsert",text:` + INSERT INTO ${this._getTableIdentifier()} VALUES ($1, $2, $3) + ON CONFLICT(key) DO UPDATE SET + points = CASE + WHEN (${this._getTableIdentifier()}.expire <= $4 OR 1=${J?1:0}) THEN $2 + ELSE ${this._getTableIdentifier()}.points + ($2) + END, + expire = ${es} + RETURNING points, expire;`,values:[O,U,en,Date.now()]})}_get(O){return this.tableCreated?new Promise((U,$)=>{this._query({name:"rlflx-get",text:` + SELECT points, expire FROM ${this._getTableIdentifier()} WHERE key = $1 AND (expire > $2 OR expire IS NULL);`,values:[O,Date.now()]}).then(O=>{0===O.rowCount&&(O=null),U(O)}).catch(O=>{$(O)})}):Promise.reject(Error("Table is not created yet"))}_delete(O){return this.tableCreated?this._query({name:"rlflx-delete",text:`DELETE FROM ${this._getTableIdentifier()} WHERE key = $1`,values:[O]}).then(O=>O.rowCount>0):Promise.reject(Error("Table is not created yet"))}};O.exports=RateLimiterPostgres},4845:function(O,U,$){let J=$(8990),en=4294967295,es="limiter";O.exports=class{constructor(O,U={maxQueueSize:en}){this._queueLimiters={KEY_DEFAULT:new RateLimiterQueueInternal(O,U)},this._limiterFlexible=O,this._maxQueueSize=U.maxQueueSize}getTokensRemaining(O=es){return this._queueLimiters[O]?this._queueLimiters[O].getTokensRemaining():Promise.resolve(this._limiterFlexible.points)}removeTokens(O,U=es){return this._queueLimiters[U]||(this._queueLimiters[U]=new RateLimiterQueueInternal(this._limiterFlexible,{key:U,maxQueueSize:this._maxQueueSize})),this._queueLimiters[U].removeTokens(O)}};let RateLimiterQueueInternal=class RateLimiterQueueInternal{constructor(O,U={maxQueueSize:en,key:es}){this._key=U.key,this._waitTimeout=null,this._queue=[],this._limiterFlexible=O,this._maxQueueSize=U.maxQueueSize}getTokensRemaining(){return this._limiterFlexible.get(this._key).then(O=>null!==O?O.remainingPoints:this._limiterFlexible.points)}removeTokens(O){let U=this;return new Promise(($,en)=>{if(O>U._limiterFlexible.points){en(new J(`Requested tokens ${O} exceeds maximum ${U._limiterFlexible.points} tokens per interval`));return}U._queue.length>0?U._queueRequest.call(U,$,en,O):U._limiterFlexible.consume(U._key,O).then(O=>{$(O.remainingPoints)}).catch(J=>{J instanceof Error?en(J):(U._queueRequest.call(U,$,en,O),null===U._waitTimeout&&(U._waitTimeout=setTimeout(U._processFIFO.bind(U),J.msBeforeNext)))})})}_queueRequest(O,U,$){let en=this;en._queue.length{U.resolve($.remainingPoints),O._processFIFO.call(O)}).catch($=>{$ instanceof Error?(U.reject($),O._processFIFO.call(O)):(O._queue.unshift(U),null===O._waitTimeout&&(O._waitTimeout=setTimeout(O._processFIFO.bind(O),$.msBeforeNext)))})}}},4254:function(O,U,$){let J=$(928),en=$(367),es=`redis.call('set', KEYS[1], 0, 'EX', ARGV[2], 'NX') \ +local consumed = redis.call('incrby', KEYS[1], ARGV[1]) \ +local ttl = redis.call('pttl', KEYS[1]) \ +if ttl == -1 then \ + redis.call('expire', KEYS[1], ARGV[2]) \ + ttl = 1000 * ARGV[2] \ +end \ +return {consumed, ttl} \ +`;let RateLimiterRedis=class RateLimiterRedis extends J{constructor(O){super(O),this.client=O.storeClient,this._rejectIfRedisNotReady=!!O.rejectIfRedisNotReady,this.useRedisPackage=O.useRedisPackage,this.useRedis3AndLowerPackage=O.useRedis3AndLowerPackage,"function"==typeof this.client.defineCommand&&this.client.defineCommand("rlflxIncr",{numberOfKeys:1,lua:es})}_isRedisReady(){return!this._rejectIfRedisNotReady||(!this.client.status||"ready"===this.client.status)&&("function"!=typeof this.client.isReady||!!this.client.isReady())}_getRateLimiterRes(O,U,$){let[J,es]=$;Array.isArray(J)&&([,J]=J,[,es]=es);let eo=new en;return eo.consumedPoints=parseInt(J),eo.isFirstInDuration=eo.consumedPoints===U,eo.remainingPoints=Math.max(this.points-eo.consumedPoints,0),eo.msBeforeNext=es,eo}async _upsert(O,U,$,J=!1){if(!this._isRedisReady())throw Error("Redis connection is not ready");let en=Math.floor($/1e3),eo=this.client.multi();return J?(en>0?this.useRedisPackage||this.useRedis3AndLowerPackage?eo.set(O,U,{EX:en}):eo.set(O,U,"EX",en):eo.set(O,U),this.useRedisPackage||this.useRedis3AndLowerPackage)?eo.pTTL(O).exec(!0):eo.pttl(O).exec(!0):en>0?this.useRedisPackage||this.useRedis3AndLowerPackage?this.useRedis3AndLowerPackage?new Promise(($,J)=>{let incrCallback=function(O,U){return O?J(O):$(U)};"function"==typeof this.client.rlflxIncr?this.client.rlflxIncr(O,U,en,incrCallback):this.client.eval(es,1,O,U,en,incrCallback)}):this.client.eval(es,{keys:[O],arguments:[String(U),String(en)]}):this.client.rlflxIncr([O].concat([String(U),String(en)])):this.useRedisPackage||this.useRedis3AndLowerPackage?eo.incrBy(O,U).pTTL(O).exec(!0):eo.incrby(O,U).pttl(O).exec(!0)}async _get(O){if(!this._isRedisReady())throw Error("Redis connection is not ready");return this.useRedisPackage||this.useRedis3AndLowerPackage?this.client.multi().get(O).pTTL(O).exec(!0).then(O=>{let[U]=O;return null===U?null:O}):this.client.multi().get(O).pttl(O).exec().then(O=>{let[[,U]]=O;return null===U?null:O})}_delete(O){return this.client.del(O).then(O=>O>0)}};O.exports=RateLimiterRedis},367:function(O){O.exports=class{constructor(O,U,$,J){this.remainingPoints=void 0===O?0:O,this.msBeforeNext=void 0===U?0:U,this.consumedPoints=void 0===$?0:$,this.isFirstInDuration=void 0!==J&&J}get msBeforeNext(){return this._msBeforeNext}set msBeforeNext(O){return this._msBeforeNext=O,this}get remainingPoints(){return this._remainingPoints}set remainingPoints(O){return this._remainingPoints=O,this}get consumedPoints(){return this._consumedPoints}set consumedPoints(O){return this._consumedPoints=O,this}get isFirstInDuration(){return this._isFirstInDuration}set isFirstInDuration(O){this._isFirstInDuration=!!O}_getDecoratedProperties(){return{remainingPoints:this.remainingPoints,msBeforeNext:this.msBeforeNext,consumedPoints:this.consumedPoints,isFirstInDuration:this.isFirstInDuration}}[Symbol.for("nodejs.util.inspect.custom")](){return this._getDecoratedProperties()}toString(){return JSON.stringify(this._getDecoratedProperties())}toJSON(){return this._getDecoratedProperties()}}},928:function(O,U,$){let J=$(1725),en=$(9861),es=$(367);O.exports=class extends J{constructor(O={}){super(O),this.inMemoryBlockOnConsumed=O.inMemoryBlockOnConsumed,this.inMemoryBlockDuration=O.inMemoryBlockDuration,this.insuranceLimiter=O.insuranceLimiter,this._inMemoryBlockedKeys=new en}get client(){return this._client}set client(O){if(void 0===O)throw Error("storeClient is not set");this._client=O}_afterConsume(O,U,$,J,en,es={}){let eo=this._getRateLimiterRes($,J,en);if(this.inMemoryBlockOnConsumed>0&&!(this.inMemoryBlockDuration>0)&&eo.consumedPoints>=this.inMemoryBlockOnConsumed)return(this._inMemoryBlockedKeys.addMs($,eo.msBeforeNext),eo.consumedPoints>this.points)?U(eo):O(eo);if(eo.consumedPoints>this.points){let O=Promise.resolve();this.blockDuration>0&&eo.consumedPoints<=this.points+J&&(eo.msBeforeNext=this.msBlockDuration,O=this._block($,eo.consumedPoints,this.msBlockDuration,es)),this.inMemoryBlockOnConsumed>0&&eo.consumedPoints>=this.inMemoryBlockOnConsumed&&(this._inMemoryBlockedKeys.add($,this.inMemoryBlockDuration),eo.msBeforeNext=this.msInMemoryBlockDuration),O.then(()=>{U(eo)}).catch(O=>{U(O)})}else if(this.execEvenly&&eo.msBeforeNext>0&&!eo.isFirstInDuration){let U=Math.ceil(eo.msBeforeNext/(eo.remainingPoints+2));U{$(O)}).catch(O=>{en(O)}):en(O)}getInMemoryBlockMsBeforeExpire(O){return this.inMemoryBlockOnConsumed>0?this._inMemoryBlockedKeys.msBeforeExpire(O):0}get inMemoryBlockOnConsumed(){return this._inMemoryBlockOnConsumed}set inMemoryBlockOnConsumed(O){if(this._inMemoryBlockOnConsumed=O?parseInt(O):0,this.inMemoryBlockOnConsumed>0&&this.points>this.inMemoryBlockOnConsumed)throw Error('inMemoryBlockOnConsumed option must be greater or equal "points" option')}get inMemoryBlockDuration(){return this._inMemoryBlockDuration}set inMemoryBlockDuration(O){if(this._inMemoryBlockDuration=O?parseInt(O):0,this.inMemoryBlockDuration>0&&0===this.inMemoryBlockOnConsumed)throw Error("inMemoryBlockOnConsumed option must be set up")}get msInMemoryBlockDuration(){return 1e3*this._inMemoryBlockDuration}get insuranceLimiter(){return this._insuranceLimiter}set insuranceLimiter(O){if(void 0!==O&&!(O instanceof J))throw Error("insuranceLimiter must be instance of RateLimiterAbstract");this._insuranceLimiter=O,this._insuranceLimiter&&(this._insuranceLimiter.blockDuration=this.blockDuration,this._insuranceLimiter.execEvenly=this.execEvenly)}block(O,U,$={}){let J=1e3*U;return this._block(this.getKey(O),this.points+1,J,$)}set(O,U,$,J={}){let en=($>=0?$:this.duration)*1e3;return this._block(this.getKey(O),U,en,J)}consume(O,U=1,$={}){return new Promise((J,en)=>{let eo=this.getKey(O),ea=this.getInMemoryBlockMsBeforeExpire(eo);if(ea>0)return en(new es(0,ea));this._upsert(eo,U,1e3*this._getKeySecDuration($),!1,$).then(O=>{this._afterConsume(J,en,eo,U,O)}).catch(es=>{this._handleError(es,"consume",J,en,O,U,$)})})}penalty(O,U=1,$={}){let J=this.getKey(O);return new Promise((en,es)=>{this._upsert(J,U,1e3*this._getKeySecDuration($),!1,$).then(O=>{en(this._getRateLimiterRes(J,U,O))}).catch(J=>{this._handleError(J,"penalty",en,es,O,U,$)})})}reward(O,U=1,$={}){let J=this.getKey(O);return new Promise((en,es)=>{this._upsert(J,-U,1e3*this._getKeySecDuration($),!1,$).then(O=>{en(this._getRateLimiterRes(J,-U,O))}).catch(J=>{this._handleError(J,"reward",en,es,O,U,$)})})}get(O,U={}){let $=this.getKey(O);return new Promise((J,en)=>{this._get($,U).then(O=>{null==O?J(null):J(this._getRateLimiterRes($,0,O))}).catch($=>{this._handleError($,"get",J,en,O,U)})})}delete(O,U={}){let $=this.getKey(O);return new Promise((J,en)=>{this._delete($,U).then(O=>{this._inMemoryBlockedKeys.delete($),J(O)}).catch($=>{this._handleError($,"delete",J,en,O,U)})})}deleteInMemoryBlockedAll(){this._inMemoryBlockedKeys.delete()}_getRateLimiterRes(O,U,$){throw Error("You have to implement the method '_getRateLimiterRes'!")}_block(O,U,$,J={}){return new Promise((en,eo)=>{this._upsert(O,U,$,!0,J).then(()=>{en(new es(0,$>0?$:-1,U))}).catch(U=>{this._handleError(U,"block",en,eo,this.parseKey(O),$/1e3,J)})})}_get(O,U={}){throw Error("You have to implement the method '_get'!")}_delete(O,U={}){throw Error("You have to implement the method '_delete'!")}_upsert(O,U,$,J=!1,en={}){throw Error("You have to implement the method '_upsert'!")}}},4005:function(O,U,$){let J=$(1725);O.exports=class{constructor(...O){if(O.length<1)throw Error("RateLimiterUnion: at least one limiter have to be passed");O.forEach(O=>{if(!(O instanceof J))throw Error("RateLimiterUnion: all limiters have to be instance of RateLimiterAbstract")}),this._limiters=O}consume(O,U=1){return new Promise(($,J)=>{let en=[];this._limiters.forEach($=>{en.push($.consume(O,U).catch(O=>({rejected:!0,rej:O})))}),Promise.all(en).then(O=>{let U={},en=!1;O.forEach(O=>{!0===O.rejected&&(en=!0)});for(let $=0;${this._keys[U]<=O&&delete this._keys[U]}),this._addedKeysAmount=Object.keys(this._keys).length}add(O,U){this.addMs(O,1e3*U)}addMs(O,U){this._keys[O]=Date.now()+U,this._addedKeysAmount++,this._addedKeysAmount>999&&this.collectExpired()}msBeforeExpire(O){let U=this._keys[O];if(U&&U>=Date.now()){this.collectExpired();let O=Date.now();return U>=O?U-O:0}return 0}delete(O){O?delete this._keys[O]:Object.keys(this._keys).forEach(O=>{delete this._keys[O]})}}},9861:function(O,U,$){let J=$(6459);O.exports=J},4603:function(O,U,$){let J=$(1381),en=$(367);O.exports=class{constructor(){this._storage={}}incrby(O,U,$){if(this._storage[O]){let $=this._storage[O].expiresAt?this._storage[O].expiresAt.getTime()-new Date().getTime():-1;if(0!==$)return this._storage[O].value=this._storage[O].value+U,new en(0,$,this._storage[O].value,!1)}return this.set(O,U,$)}set(O,U,$){let es=1e3*$;return this._storage[O]&&this._storage[O].timeoutId&&clearTimeout(this._storage[O].timeoutId),this._storage[O]=new J(U,es>0?new Date(Date.now()+es):null),es>0&&(this._storage[O].timeoutId=setTimeout(()=>{delete this._storage[O]},es),this._storage[O].timeoutId.unref&&this._storage[O].timeoutId.unref()),new en(0,0===es?-1:es,this._storage[O].value,!0)}get(O){if(this._storage[O]){let U=this._storage[O].expiresAt?this._storage[O].expiresAt.getTime()-new Date().getTime():-1;return new en(0,U,this._storage[O].value,!1)}return null}delete(O){return!!this._storage[O]&&(this._storage[O].timeoutId&&clearTimeout(this._storage[O].timeoutId),delete this._storage[O],!0)}}},1381:function(O){O.exports=class{constructor(O,U,$=null){this.value=O,this.expiresAt=U,this.timeoutId=$}get value(){return this._value}set value(O){this._value=parseInt(O)}get expiresAt(){return this._expiresAt}set expiresAt(O){!(O instanceof Date)&&Number.isInteger(O)&&(O=new Date(O)),this._expiresAt=O}get timeoutId(){return this._timeoutId}set timeoutId(O){this._timeoutId=O}}},8990:function(O){O.exports=class extends Error{constructor(O,U){super(),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="CustomError",this.message=O,U&&(this.extra=U)}}},6696:function(O,U,$){"use strict";O.exports=Receptacle;var J=$(438),en=Receptacle.prototype,es=new Date%1e9;function getUID(){return(1e9*Math.random()>>>0)+es++}function Receptacle(O){O=O||{},this.id=O.id||getUID(),this.max=O.max||1/0,this.items=O.items||[],this._lookup={},this.size=this.items.length,this.lastModified=new Date(O.lastModified||new Date);for(var U,$,J=this.items.length;J--;)U=this.items[J],$=new Date(U.expires)-new Date,this._lookup[U.key]=U,$>0?this.expire(U.key,$):$<=0&&this.delete(U.key)}en.has=function(O){return O in this._lookup},en.get=function(O){if(!this.has(O))return null;var U=this._lookup[O];return U.refresh&&this.expire(O,U.refresh),this.items.splice(this.items.indexOf(U),1),this.items.push(U),U.value},en.meta=function(O){if(!this.has(O))return null;var U=this._lookup[O];return"meta"in U?U.meta:null},en.set=function(O,U,$){var J=this._lookup[O],en=this._lookup[O]={key:O,value:U};return this.lastModified=new Date,J?(clearTimeout(J.timeout),this.items.splice(this.items.indexOf(J),1,en)):(this.size>=this.max&&this.delete(this.items[0].key),this.items.push(en),this.size++),$&&("ttl"in $&&this.expire(O,$.ttl),"meta"in $&&(en.meta=$.meta),$.refresh&&(en.refresh=$.ttl)),this},en.delete=function(O){var U=this._lookup[O];return!!U&&(this.lastModified=new Date,this.items.splice(this.items.indexOf(U),1),clearTimeout(U.timeout),delete this._lookup[O],this.size--,this)},en.expire=function(O,U){var $=U||0,en=this._lookup[O];if(!en)return this;if("string"==typeof $&&($=J(U)),"number"!=typeof $)throw TypeError("Expiration time must be a string or number.");return clearTimeout(en.timeout),en.timeout=setTimeout(this.delete.bind(this,en.key),$),en.expires=Number(new Date)+$,this},en.clear=function(){for(var O=this.items.length;O--;)this.delete(this.items[O].key);return this},en.toJSON=function(){for(var O,U=Array(this.items.length),$=U.length;$--;)O=this.items[$],U[$]={key:O.key,meta:O.meta,value:O.value,expires:O.expires,refresh:O.refresh};return{id:this.id,max:isFinite(this.max)?this.max:void 0,lastModified:this.lastModified,items:U}}},2508:function(O,U,$){"use strict";var J=$(5230),en=/[\/\?<>\\:\*\|"]/g,es=/[\x00-\x1f\x80-\x9f]/g,eo=/^\.+$/,ea=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,eu=/[\. ]+$/;function sanitize(O,U){if("string"!=typeof O)throw Error("Input must be string");return J(O.replace(en,U).replace(es,U).replace(eo,U).replace(ea,U).replace(eu,U),255)}O.exports=function(O,U){var $=U&&U.replacement||"",J=sanitize(O,$);return""===$?J:sanitize(J,"")}},5230:function(O,U,$){"use strict";var J=$(5858),en=$(4910);O.exports=J.bind(null,en)},5858:function(O){"use strict";function isHighSurrogate(O){return O>=55296&&O<=56319}function isLowSurrogate(O){return O>=56320&&O<=57343}O.exports=function(O,U,$){if("string"!=typeof U)throw Error("Input must be string");for(var J,en,es=U.length,eo=0,ea=0;ea$)return U.slice(0,ea-en.length+1)}return U}},1853:function(O,U,$){"use strict";/** + * @license React + * use-sync-external-store-shim.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var J=$(2265);function h(O,U){return O===U&&(0!==O||1/O==1/U)||O!=O&&U!=U}var en="function"==typeof Object.is?Object.is:h,es=J.useState,eo=J.useEffect,ea=J.useLayoutEffect,eu=J.useDebugValue;function q(O,U){var $=U(),J=es({inst:{value:$,getSnapshot:U}}),en=J[0].inst,ef=J[1];return ea(function(){en.value=$,en.getSnapshot=U,r(en)&&ef({inst:en})},[O,$,U]),eo(function(){return r(en)&&ef({inst:en}),O(function(){r(en)&&ef({inst:en})})},[O]),eu($),$}function r(O){var U=O.getSnapshot;O=O.value;try{var $=U();return!en(O,$)}catch(O){return!0}}function t(O,U){return U()}var ef="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?t:q;U.useSyncExternalStore=void 0!==J.useSyncExternalStore?J.useSyncExternalStore:ef},8704:function(O,U,$){"use strict";/** + * @license React + * use-sync-external-store-shim/with-selector.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var J=$(2265),en=$(6272);function p(O,U){return O===U&&(0!==O||1/O==1/U)||O!=O&&U!=U}var es="function"==typeof Object.is?Object.is:p,eo=en.useSyncExternalStore,ea=J.useRef,eu=J.useEffect,ef=J.useMemo,eg=J.useDebugValue;U.useSyncExternalStoreWithSelector=function(O,U,$,J,en){var ev=ea(null);if(null===ev.current){var e_={hasValue:!1,value:null};ev.current=e_}else e_=ev.current;var ew=eo(O,(ev=ef(function(){function a(U){if(!ea){if(ea=!0,O=U,U=J(U),void 0!==en&&e_.hasValue){var $=e_.value;if(en($,U))return eo=$}return eo=U}if($=eo,es(O,U))return $;var eu=J(U);return void 0!==en&&en($,eu)?$:(O=U,eo=eu)}var O,eo,ea=!1,eu=void 0===$?null:$;return[function(){return a(U())},null===eu?void 0:function(){return a(eu())}]},[U,$,J,en]))[0],ev[1]);return eu(function(){e_.hasValue=!0,e_.value=ew},[ew]),eg(ew),ew}},6272:function(O,U,$){"use strict";O.exports=$(1853)},5401:function(O,U,$){"use strict";O.exports=$(8704)},4910:function(O){"use strict";function isHighSurrogate(O){return O>=55296&&O<=56319}function isLowSurrogate(O){return O>=56320&&O<=57343}O.exports=function(O){if("string"!=typeof O)throw Error("Input must be string");for(var U=O.length,$=0,J=null,en=null,es=0;es=128&&J<=2047?$+=2:J>=2048&&J<=65535&&($+=3),en=J;return $}},1872:function(O,U,$){"use strict";let J;$.d(U,{Z:function(){return esm_browser_v4}});let en="undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);var es={randomUUID:en};let eo=new Uint8Array(16);function rng(){if(!J&&!(J="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return J(eo)}let ea=[];for(let O=0;O<256;++O)ea.push((O+256).toString(16).slice(1));function unsafeStringify(O,U=0){return ea[O[U+0]]+ea[O[U+1]]+ea[O[U+2]]+ea[O[U+3]]+"-"+ea[O[U+4]]+ea[O[U+5]]+"-"+ea[O[U+6]]+ea[O[U+7]]+"-"+ea[O[U+8]]+ea[O[U+9]]+"-"+ea[O[U+10]]+ea[O[U+11]]+ea[O[U+12]]+ea[O[U+13]]+ea[O[U+14]]+ea[O[U+15]]}var esm_browser_v4=function(O,U,$){if(es.randomUUID&&!U&&!O)return es.randomUUID();O=O||{};let J=O.random||(O.rng||rng)();if(J[6]=15&J[6]|64,J[8]=63&J[8]|128,U){$=$||0;for(let O=0;O<16;++O)U[$+O]=J[O];return U}return unsafeStringify(J)}},372:function(O,U,$){var J,en,es;!function(eo,ea){en=[$(4481)],void 0!==(es="function"==typeof(J=ea)?J.apply(U,en):J)&&(O.exports=es)}(0,function(O){"use strict";var U=O.Reader,$=O.Writer,J=O.util,en=O.roots.default||(O.roots.default={});return en.RPC=function(){var es;function RPC(O){if(this.subscriptions=[],this.messages=[],O)for(var U=Object.keys(O),$=0;$>>3){case 1:es.subscriptions&&es.subscriptions.length||(es.subscriptions=[]),es.subscriptions.push(en.RPC.SubOpts.decode(O,O.uint32()));break;case 2:es.messages&&es.messages.length||(es.messages=[]),es.messages.push(en.RPC.Message.decode(O,O.uint32()));break;case 3:es.control=en.RPC.ControlMessage.decode(O,O.uint32());break;default:O.skipType(7&eo)}}return es},RPC.fromObject=function(O){if(O instanceof en.RPC)return O;var U=new en.RPC;if(O.subscriptions){if(!Array.isArray(O.subscriptions))throw TypeError(".RPC.subscriptions: array expected");U.subscriptions=[];for(var $=0;$>>3){case 1:es.subscribe=O.bool();break;case 2:es.topic=O.string();break;default:O.skipType(7&eo)}}return es},SubOpts.fromObject=function(O){if(O instanceof en.RPC.SubOpts)return O;var U=new en.RPC.SubOpts;return null!=O.subscribe&&(U.subscribe=!!O.subscribe),null!=O.topic&&(U.topic=String(O.topic)),U},SubOpts.toObject=function(O,U){U||(U={});var $={};return null!=O.subscribe&&O.hasOwnProperty("subscribe")&&($.subscribe=O.subscribe,U.oneofs&&($._subscribe="subscribe")),null!=O.topic&&O.hasOwnProperty("topic")&&($.topic=O.topic,U.oneofs&&($._topic="topic")),$},SubOpts.prototype.toJSON=function(){return this.constructor.toObject(this,O.util.toJSONOptions)},SubOpts}(),RPC.Message=function(){var es;function Message(O){if(O)for(var U=Object.keys(O),$=0;$>>3){case 1:eo.from=O.bytes();break;case 2:eo.data=O.bytes();break;case 3:eo.seqno=O.bytes();break;case 4:eo.topic=O.string();break;case 5:eo.signature=O.bytes();break;case 6:eo.key=O.bytes();break;default:O.skipType(7&ea)}}if(!eo.hasOwnProperty("topic"))throw J.ProtocolError("missing required 'topic'",{instance:eo});return eo},Message.fromObject=function(O){if(O instanceof en.RPC.Message)return O;var U=new en.RPC.Message;return null!=O.from&&("string"==typeof O.from?J.base64.decode(O.from,U.from=J.newBuffer(J.base64.length(O.from)),0):O.from.length&&(U.from=O.from)),null!=O.data&&("string"==typeof O.data?J.base64.decode(O.data,U.data=J.newBuffer(J.base64.length(O.data)),0):O.data.length&&(U.data=O.data)),null!=O.seqno&&("string"==typeof O.seqno?J.base64.decode(O.seqno,U.seqno=J.newBuffer(J.base64.length(O.seqno)),0):O.seqno.length&&(U.seqno=O.seqno)),null!=O.topic&&(U.topic=String(O.topic)),null!=O.signature&&("string"==typeof O.signature?J.base64.decode(O.signature,U.signature=J.newBuffer(J.base64.length(O.signature)),0):O.signature.length&&(U.signature=O.signature)),null!=O.key&&("string"==typeof O.key?J.base64.decode(O.key,U.key=J.newBuffer(J.base64.length(O.key)),0):O.key.length&&(U.key=O.key)),U},Message.toObject=function(O,U){U||(U={});var $={};return U.defaults&&($.topic=""),null!=O.from&&O.hasOwnProperty("from")&&($.from=U.bytes===String?J.base64.encode(O.from,0,O.from.length):U.bytes===Array?Array.prototype.slice.call(O.from):O.from,U.oneofs&&($._from="from")),null!=O.data&&O.hasOwnProperty("data")&&($.data=U.bytes===String?J.base64.encode(O.data,0,O.data.length):U.bytes===Array?Array.prototype.slice.call(O.data):O.data,U.oneofs&&($._data="data")),null!=O.seqno&&O.hasOwnProperty("seqno")&&($.seqno=U.bytes===String?J.base64.encode(O.seqno,0,O.seqno.length):U.bytes===Array?Array.prototype.slice.call(O.seqno):O.seqno,U.oneofs&&($._seqno="seqno")),null!=O.topic&&O.hasOwnProperty("topic")&&($.topic=O.topic),null!=O.signature&&O.hasOwnProperty("signature")&&($.signature=U.bytes===String?J.base64.encode(O.signature,0,O.signature.length):U.bytes===Array?Array.prototype.slice.call(O.signature):O.signature,U.oneofs&&($._signature="signature")),null!=O.key&&O.hasOwnProperty("key")&&($.key=U.bytes===String?J.base64.encode(O.key,0,O.key.length):U.bytes===Array?Array.prototype.slice.call(O.key):O.key,U.oneofs&&($._key="key")),$},Message.prototype.toJSON=function(){return this.constructor.toObject(this,O.util.toJSONOptions)},Message}(),RPC.ControlMessage=function(){function ControlMessage(O){if(this.ihave=[],this.iwant=[],this.graft=[],this.prune=[],O)for(var U=Object.keys(O),$=0;$>>3){case 1:es.ihave&&es.ihave.length||(es.ihave=[]),es.ihave.push(en.RPC.ControlIHave.decode(O,O.uint32()));break;case 2:es.iwant&&es.iwant.length||(es.iwant=[]),es.iwant.push(en.RPC.ControlIWant.decode(O,O.uint32()));break;case 3:es.graft&&es.graft.length||(es.graft=[]),es.graft.push(en.RPC.ControlGraft.decode(O,O.uint32()));break;case 4:es.prune&&es.prune.length||(es.prune=[]),es.prune.push(en.RPC.ControlPrune.decode(O,O.uint32()));break;default:O.skipType(7&eo)}}return es},ControlMessage.fromObject=function(O){if(O instanceof en.RPC.ControlMessage)return O;var U=new en.RPC.ControlMessage;if(O.ihave){if(!Array.isArray(O.ihave))throw TypeError(".RPC.ControlMessage.ihave: array expected");U.ihave=[];for(var $=0;$>>3){case 1:es.topicID=O.string();break;case 2:es.messageIDs&&es.messageIDs.length||(es.messageIDs=[]),es.messageIDs.push(O.bytes());break;default:O.skipType(7&eo)}}return es},ControlIHave.fromObject=function(O){if(O instanceof en.RPC.ControlIHave)return O;var U=new en.RPC.ControlIHave;if(null!=O.topicID&&(U.topicID=String(O.topicID)),O.messageIDs){if(!Array.isArray(O.messageIDs))throw TypeError(".RPC.ControlIHave.messageIDs: array expected");U.messageIDs=[];for(var $=0;$>>3==1?(es.messageIDs&&es.messageIDs.length||(es.messageIDs=[]),es.messageIDs.push(O.bytes())):O.skipType(7&eo)}return es},ControlIWant.fromObject=function(O){if(O instanceof en.RPC.ControlIWant)return O;var U=new en.RPC.ControlIWant;if(O.messageIDs){if(!Array.isArray(O.messageIDs))throw TypeError(".RPC.ControlIWant.messageIDs: array expected");U.messageIDs=[];for(var $=0;$>>3==1?es.topicID=O.string():O.skipType(7&eo)}return es},ControlGraft.fromObject=function(O){if(O instanceof en.RPC.ControlGraft)return O;var U=new en.RPC.ControlGraft;return null!=O.topicID&&(U.topicID=String(O.topicID)),U},ControlGraft.toObject=function(O,U){U||(U={});var $={};return null!=O.topicID&&O.hasOwnProperty("topicID")&&($.topicID=O.topicID,U.oneofs&&($._topicID="topicID")),$},ControlGraft.prototype.toJSON=function(){return this.constructor.toObject(this,O.util.toJSONOptions)},ControlGraft}(),RPC.ControlPrune=function(){var es;function ControlPrune(O){if(this.peers=[],O)for(var U=Object.keys(O),$=0;$>>3){case 1:es.topicID=O.string();break;case 2:es.peers&&es.peers.length||(es.peers=[]),es.peers.push(en.RPC.PeerInfo.decode(O,O.uint32()));break;case 3:es.backoff=O.uint64();break;default:O.skipType(7&eo)}}return es},ControlPrune.fromObject=function(O){if(O instanceof en.RPC.ControlPrune)return O;var U=new en.RPC.ControlPrune;if(null!=O.topicID&&(U.topicID=String(O.topicID)),O.peers){if(!Array.isArray(O.peers))throw TypeError(".RPC.ControlPrune.peers: array expected");U.peers=[];for(var $=0;$>>0,O.backoff.high>>>0).toNumber(!0))),U},ControlPrune.toObject=function(O,U){U||(U={});var $={};if((U.arrays||U.defaults)&&($.peers=[]),null!=O.topicID&&O.hasOwnProperty("topicID")&&($.topicID=O.topicID,U.oneofs&&($._topicID="topicID")),O.peers&&O.peers.length){$.peers=[];for(var es=0;es>>0,O.backoff.high>>>0).toNumber(!0):O.backoff,U.oneofs&&($._backoff="backoff")),$},ControlPrune.prototype.toJSON=function(){return this.constructor.toObject(this,O.util.toJSONOptions)},ControlPrune}(),RPC.PeerInfo=function(){var es;function PeerInfo(O){if(O)for(var U=Object.keys(O),$=0;$>>3){case 1:es.peerID=O.bytes();break;case 2:es.signedPeerRecord=O.bytes();break;default:O.skipType(7&eo)}}return es},PeerInfo.fromObject=function(O){if(O instanceof en.RPC.PeerInfo)return O;var U=new en.RPC.PeerInfo;return null!=O.peerID&&("string"==typeof O.peerID?J.base64.decode(O.peerID,U.peerID=J.newBuffer(J.base64.length(O.peerID)),0):O.peerID.length&&(U.peerID=O.peerID)),null!=O.signedPeerRecord&&("string"==typeof O.signedPeerRecord?J.base64.decode(O.signedPeerRecord,U.signedPeerRecord=J.newBuffer(J.base64.length(O.signedPeerRecord)),0):O.signedPeerRecord.length&&(U.signedPeerRecord=O.signedPeerRecord)),U},PeerInfo.toObject=function(O,U){U||(U={});var $={};return null!=O.peerID&&O.hasOwnProperty("peerID")&&($.peerID=U.bytes===String?J.base64.encode(O.peerID,0,O.peerID.length):U.bytes===Array?Array.prototype.slice.call(O.peerID):O.peerID,U.oneofs&&($._peerID="peerID")),null!=O.signedPeerRecord&&O.hasOwnProperty("signedPeerRecord")&&($.signedPeerRecord=U.bytes===String?J.base64.encode(O.signedPeerRecord,0,O.signedPeerRecord.length):U.bytes===Array?Array.prototype.slice.call(O.signedPeerRecord):O.signedPeerRecord,U.oneofs&&($._signedPeerRecord="signedPeerRecord")),$},PeerInfo.prototype.toJSON=function(){return this.constructor.toObject(this,O.util.toJSONOptions)},PeerInfo}(),RPC}(),en})},5493:function(O,U,$){"use strict";function number(O){if(!Number.isSafeInteger(O)||O<0)throw Error(`Wrong positive integer: ${O}`)}function bool(O){if("boolean"!=typeof O)throw Error(`Expected boolean, not ${O}`)}function bytes(O,...U){if(!(O instanceof Uint8Array))throw Error("Expected Uint8Array");if(U.length>0&&!U.includes(O.length))throw Error(`Expected Uint8Array of length ${U}, not of length=${O.length}`)}function hash(O){if("function"!=typeof O||"function"!=typeof O.create)throw Error("Hash should be wrapped by utils.wrapConstructor");number(O.outputLen),number(O.blockLen)}function exists(O,U=!0){if(O.destroyed)throw Error("Hash instance has been destroyed");if(U&&O.finished)throw Error("Hash#digest() has already been called")}function output(O,U){bytes(O);let $=U.outputLen;if(O.length<$)throw Error(`digestInto() expects output buffer of length at least ${$}`)}let J={number,bool,bytes,hash,exists,output};U.ZP=J},4727:function(O,U,$){"use strict";$.d(U,{N:function(){return SHA2}});var J=$(5493),en=$(2305);function setBigUint64(O,U,$,J){if("function"==typeof O.setBigUint64)return O.setBigUint64(U,$,J);let en=BigInt(32),es=BigInt(4294967295),eo=Number($>>en&es),ea=Number($&es),eu=J?4:0,ef=J?0:4;O.setUint32(U+eu,eo,J),O.setUint32(U+ef,ea,J)}let SHA2=class SHA2 extends en.kb{constructor(O,U,$,J){super(),this.blockLen=O,this.outputLen=U,this.padOffset=$,this.isLE=J,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(O),this.view=(0,en.GL)(this.buffer)}update(O){J.ZP.exists(this);let{view:U,buffer:$,blockLen:es}=this;O=(0,en.O0)(O);let eo=O.length;for(let J=0;Jes-ea&&(this.process($,0),ea=0);for(let O=ea;Oev.length)throw Error("_sha2: outputLen bigger than state");for(let O=0;O>en&J)}:{h:0|Number(O>>en&J),l:0|Number(O&J)}}function split(O,U=!1){let $=new Uint32Array(O.length),J=new Uint32Array(O.length);for(let en=0;enBigInt(O>>>0)<>>0),shrSH=(O,U,$)=>O>>>$,shrSL=(O,U,$)=>O<<32-$|U>>>$,rotrSH=(O,U,$)=>O>>>$|U<<32-$,rotrSL=(O,U,$)=>O<<32-$|U>>>$,rotrBH=(O,U,$)=>O<<64-$|U>>>$-32,rotrBL=(O,U,$)=>O>>>$-32|U<<64-$,rotr32H=(O,U)=>U,rotr32L=(O,U)=>O,rotlSH=(O,U,$)=>O<<$|U>>>32-$,rotlSL=(O,U,$)=>U<<$|O>>>32-$,rotlBH=(O,U,$)=>U<<$-32|O>>>64-$,rotlBL=(O,U,$)=>O<<$-32|U>>>64-$;function add(O,U,$,J){let en=(U>>>0)+(J>>>0);return{h:O+$+(en/4294967296|0)|0,l:0|en}}let add3L=(O,U,$)=>(O>>>0)+(U>>>0)+($>>>0),add3H=(O,U,$,J)=>U+$+J+(O/4294967296|0)|0,add4L=(O,U,$,J)=>(O>>>0)+(U>>>0)+($>>>0)+(J>>>0),add4H=(O,U,$,J,en)=>U+$+J+en+(O/4294967296|0)|0,add5L=(O,U,$,J,en)=>(O>>>0)+(U>>>0)+($>>>0)+(J>>>0)+(en>>>0),add5H=(O,U,$,J,en,es)=>U+$+J+en+es+(O/4294967296|0)|0,es={fromBig,split,toBig,shrSH,shrSL,rotrSH,rotrSL,rotrBH,rotrBL,rotr32H,rotr32L,rotlSH,rotlSL,rotlBH,rotlBL,add,add3L,add3H,add4L,add4H,add5H,add5L};U.ZP=es},9802:function(O,U,$){"use strict";$.d(U,{J:function(){return eu}});var J=$(4727),en=$(2305);let Chi=(O,U,$)=>O&U^~O&$,Maj=(O,U,$)=>O&U^O&$^U&$,es=new Uint32Array([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]),eo=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ea=new Uint32Array(64);let SHA256=class SHA256 extends J.N{constructor(){super(64,32,8,!1),this.A=0|eo[0],this.B=0|eo[1],this.C=0|eo[2],this.D=0|eo[3],this.E=0|eo[4],this.F=0|eo[5],this.G=0|eo[6],this.H=0|eo[7]}get(){let{A:O,B:U,C:$,D:J,E:en,F:es,G:eo,H:ea}=this;return[O,U,$,J,en,es,eo,ea]}set(O,U,$,J,en,es,eo,ea){this.A=0|O,this.B=0|U,this.C=0|$,this.D=0|J,this.E=0|en,this.F=0|es,this.G=0|eo,this.H=0|ea}process(O,U){for(let $=0;$<16;$++,U+=4)ea[$]=O.getUint32(U,!1);for(let O=16;O<64;O++){let U=ea[O-15],$=ea[O-2],J=(0,en.np)(U,7)^(0,en.np)(U,18)^U>>>3,es=(0,en.np)($,17)^(0,en.np)($,19)^$>>>10;ea[O]=es+ea[O-7]+J+ea[O-16]|0}let{A:$,B:J,C:eo,D:eu,E:ef,F:eg,G:ev,H:e_}=this;for(let O=0;O<64;O++){let U=(0,en.np)(ef,6)^(0,en.np)(ef,11)^(0,en.np)(ef,25),ew=e_+U+Chi(ef,eg,ev)+es[O]+ea[O]|0,eE=(0,en.np)($,2)^(0,en.np)($,13)^(0,en.np)($,22),eS=eE+Maj($,J,eo)|0;e_=ev,ev=eg,eg=ef,ef=eu+ew|0,eu=eo,eo=J,J=$,$=ew+eS|0}$=$+this.A|0,J=J+this.B|0,eo=eo+this.C|0,eu=eu+this.D|0,ef=ef+this.E|0,eg=eg+this.F|0,ev=ev+this.G|0,e_=e_+this.H|0,this.set($,J,eo,eu,ef,eg,ev,e_)}roundClean(){ea.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};let SHA224=class SHA224 extends SHA256{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}};let eu=(0,en.hE)(()=>new SHA256);(0,en.hE)(()=>new SHA224)},2305:function(O,U,$){"use strict";$.d(U,{kb:function(){return Hash},ci:function(){return bytesToHex},eV:function(){return concatBytes},GL:function(){return createView},nr:function(){return hexToBytes},O6:function(){return randomBytes},np:function(){return rotr},O0:function(){return toBytes},Jq:function(){return u32},iY:function(){return utf8ToBytes},hE:function(){return wrapConstructor},gz:function(){return wrapXOFConstructorWithOpts}});let J="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,u8a=O=>O instanceof Uint8Array,u32=O=>new Uint32Array(O.buffer,O.byteOffset,Math.floor(O.byteLength/4)),createView=O=>new DataView(O.buffer,O.byteOffset,O.byteLength),rotr=(O,U)=>O<<32-U|O>>>U,en=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];if(!en)throw Error("Non little-endian hardware is not supported");let es=Array.from({length:256},(O,U)=>U.toString(16).padStart(2,"0"));function bytesToHex(O){if(!u8a(O))throw Error("Uint8Array expected");let U="";for(let $=0;$O+U.length,0)),$=0;return O.forEach(O=>{if(!u8a(O))throw Error("Uint8Array expected");U.set(O,$),$+=O.length}),U}let Hash=class Hash{clone(){return this._cloneInto()}};function wrapConstructor(O){let hashC=U=>O().update(toBytes(U)).digest(),U=O();return hashC.outputLen=U.outputLen,hashC.blockLen=U.blockLen,hashC.create=()=>O(),hashC}function wrapXOFConstructorWithOpts(O){let hashC=(U,$)=>O($).update(toBytes(U)).digest(),U=O({});return hashC.outputLen=U.outputLen,hashC.blockLen=U.blockLen,hashC.create=U=>O(U),hashC}function randomBytes(O=32){if(J&&"function"==typeof J.getRandomValues)return J.getRandomValues(new Uint8Array(O));throw Error("crypto.getRandomValues must be defined")}},3909:function(O,U,$){"use strict";function checkInt(O,U,$,J,en,es){if(U>en||UO.length)throw RangeError("Index out of range")}function writeUIntLE(O,U,$,J,en){if(U=+U,$>>>=0,J>>>=0,!en){let en=Math.pow(2,8*J)-1;checkInt(O,U,$,J,en,0)}let es=1,eo=0;for(O[$]=255&U;++eo(e_.ZP.bytes(U),O(U))}e_.ZP.bool,e_.ZP.bytes,(()=>{let O="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,U="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);return U&&!O?U("crypto"):void 0})();let eE=wrapHash(ev.J);var eS=$(2890),eA=$(1872),eI=$(3909),eP=$(4589),ek=$(9686),eT=$(6357),eR=$(606);let[eC,eB,eN]=[[],[],[]],eD=BigInt(0),eM=BigInt(1),eO=BigInt(2),eL=BigInt(7),eU=BigInt(256),eF=BigInt(113);for(let O=0,U=eM,$=1,J=0;O<24;O++){[$,J]=[J,(2*$+3*J)%5],eC.push(2*(5*J+$)),eB.push((O+1)*(O+2)/2%64);let en=eD;for(let O=0;O<7;O++)(U=(U<>eL)*eF)%eU)&eO&&(en^=eM<<(eM<$>32?eR.ZP.rotlBH(O,U,$):eR.ZP.rotlSH(O,U,$),rotlL=(O,U,$)=>$>32?eR.ZP.rotlBL(O,U,$):eR.ZP.rotlSL(O,U,$);function keccakP(O,U=24){let $=new Uint32Array(10);for(let J=24-U;J<24;J++){for(let U=0;U<10;U++)$[U]=O[U]^O[U+10]^O[U+20]^O[U+30]^O[U+40];for(let U=0;U<10;U+=2){let J=(U+8)%10,en=(U+2)%10,es=$[en],eo=$[en+1],ea=rotlH(es,eo,1)^$[J],eu=rotlL(es,eo,1)^$[J+1];for(let $=0;$<50;$+=10)O[U+$]^=ea,O[U+$+1]^=eu}let U=O[2],en=O[3];for(let $=0;$<24;$++){let J=eB[$],es=rotlH(U,en,J),eo=rotlL(U,en,J),ea=eC[$];U=O[ea],en=O[ea+1],O[ea]=es,O[ea+1]=eo}for(let U=0;U<50;U+=10){for(let J=0;J<10;J++)$[J]=O[U+J];for(let J=0;J<10;J++)O[U+J]^=~$[(J+2)%10]&$[(J+4)%10]}O[0]^=eK[J],O[1]^=ej[J]}$.fill(0)}let Keccak=class Keccak extends ew.kb{constructor(O,U,$,J=!1,en=24){if(super(),this.blockLen=O,this.suffix=U,this.outputLen=$,this.enableXOF=J,this.rounds=en,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,e_.ZP.number($),0>=this.blockLen||this.blockLen>=200)throw Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=(0,ew.Jq)(this.state)}keccak(){keccakP(this.state32,this.rounds),this.posOut=0,this.pos=0}update(O){e_.ZP.exists(this);let{blockLen:U,state:$}=this;O=(0,ew.O0)(O);let J=O.length;for(let en=0;en=$&&this.keccak();let es=Math.min($-this.posOut,en-J);O.set(U.subarray(this.posOut,this.posOut+es),J),this.posOut+=es,J+=es}return O}xofInto(O){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(O)}xof(O){return e_.ZP.number(O),this.xofInto(new Uint8Array(O))}digestInto(O){if(e_.ZP.output(O,this),this.finished)throw Error("digest() was already called");return this.writeInto(O),this.destroy(),O}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(O){let{blockLen:U,suffix:$,outputLen:J,rounds:en,enableXOF:es}=this;return O||(O=new Keccak(U,$,J,es,en)),O.state32.set(this.state32),O.pos=this.pos,O.posOut=this.posOut,O.finished=this.finished,O.rounds=en,O.suffix=$,O.outputLen=J,O.enableXOF=es,O.destroyed=this.destroyed,O}};let gen=(O,U,$)=>(0,ew.hE)(()=>new Keccak(U,O,$));gen(6,144,28),gen(6,136,32),gen(6,104,48),gen(6,72,64);let eH=gen(1,144,28),eq=gen(1,136,32),eV=gen(1,104,48),eG=gen(1,72,64),genShake=(O,U,$)=>(0,ew.gz)((J={})=>new Keccak(U,O,void 0===J.dkLen?$:J.dkLen,!0));genShake(31,168,16),genShake(31,136,32),wrapHash(eH);let e$=(()=>{let O=wrapHash(eq);return O.create=eq.create,O})();wrapHash(eV),wrapHash(eG);let validateChecksum=async(O,U)=>{let $=await keccak256Checksum(O,U);return $===U.crypto.checksum.message},decryptEipKeystore=async(O,U)=>{let $=await (0,ek.kdf)(U.crypto.kdf,(0,eT.normalizePassword)(O)),J=await validateChecksum(O,U);if(!J)throw Error("Password is invalid.");return(0,eP.cipherDecrypt)(U.crypto.cipher,$.slice(0,16))},keccak256Checksum=async(O,U)=>{let $=await (0,ek.kdf)(U.crypto.kdf,(0,eT.normalizePassword)(O)),J=(0,ew.eV)($.slice(16),hexToBytes(U.crypto.cipher.message)),en=e$(J);return(0,ew.ci)(en)},eW=validate11;function validate11(O,{instancePath:U="",parentData:$,parentDataProperty:J,rootData:en=O}={}){let es=null,eo=0;if(!O||"object"!=typeof O||Array.isArray(O))return validate11.errors=[{instancePath:U,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;{let $;if(void 0===O.crypto&&($="crypto"))return validate11.errors=[{instancePath:U,schemaPath:"#/required",keyword:"required",params:{missingProperty:$},message:"must have required property '"+$+"'"}],!1;if(void 0!==O.crypto){let $=O.crypto,J=eo;if(eo===J){if(!$||"object"!=typeof $||Array.isArray($))return validate11.errors=[{instancePath:U+"/crypto",schemaPath:"#/properties/crypto/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;{let O;if(void 0===$.cipher&&(O="cipher")||void 0===$.cipherparams&&(O="cipherparams")||void 0===$.ciphertext&&(O="ciphertext")||void 0===$.kdf&&(O="kdf")||void 0===$.kdfparams&&(O="kdfparams")||void 0===$.mac&&(O="mac"))return validate11.errors=[{instancePath:U+"/crypto",schemaPath:"#/properties/crypto/required",keyword:"required",params:{missingProperty:O},message:"must have required property '"+O+"'"}],!1;if(void 0!==$.cipher){let O=eo;if("string"!=typeof $.cipher)return validate11.errors=[{instancePath:U+"/crypto/cipher",schemaPath:"#/properties/crypto/properties/cipher/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var ea=O===eo}else var ea=!0;if(ea){if(void 0!==$.cipherparams){let O=$.cipherparams,J=eo;if(!(O&&"object"==typeof O&&!Array.isArray(O)))return validate11.errors=[{instancePath:U+"/crypto/cipherparams",schemaPath:"#/properties/crypto/properties/cipherparams/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var ea=J===eo}else var ea=!0;if(ea){if(void 0!==$.ciphertext){let O=eo;if("string"!=typeof $.ciphertext)return validate11.errors=[{instancePath:U+"/crypto/ciphertext",schemaPath:"#/properties/crypto/properties/ciphertext/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var ea=O===eo}else var ea=!0;if(ea){if(void 0!==$.kdf){let O=eo;if("string"!=typeof $.kdf)return validate11.errors=[{instancePath:U+"/crypto/kdf",schemaPath:"#/properties/crypto/properties/kdf/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var ea=O===eo}else var ea=!0;if(ea){if(void 0!==$.kdfparams){let O=$.kdfparams,J=eo;if(!(O&&"object"==typeof O&&!Array.isArray(O)))return validate11.errors=[{instancePath:U+"/crypto/kdfparams",schemaPath:"#/properties/crypto/properties/kdfparams/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var ea=J===eo}else var ea=!0;if(ea){if(void 0!==$.mac){let O=eo;if("string"!=typeof $.mac)return validate11.errors=[{instancePath:U+"/crypto/mac",schemaPath:"#/properties/crypto/properties/mac/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var ea=O===eo}else var ea=!0}}}}}}}}}return validate11.errors=es,0===eo}let eY=keystore_validation_generated_validate11;function keystore_validation_generated_validate11(O,{instancePath:U="",parentData:$,parentDataProperty:J,rootData:en=O}={}){let es=null,eo=0;if(!O||"object"!=typeof O||Array.isArray(O))return keystore_validation_generated_validate11.errors=[{instancePath:U,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;{let $;if(void 0===O.application&&($="application")||void 0===O.appIdentifier&&($="appIdentifier")||void 0===O.credentials&&($="credentials")||void 0===O.version&&($="version"))return keystore_validation_generated_validate11.errors=[{instancePath:U,schemaPath:"#/required",keyword:"required",params:{missingProperty:$},message:"must have required property '"+$+"'"}],!1;if(void 0!==O.credentials){let $=O.credentials,J=eo;if(!($&&"object"==typeof $&&!Array.isArray($)))return keystore_validation_generated_validate11.errors=[{instancePath:U+"/credentials",schemaPath:"#/properties/credentials/type",keyword:"type",params:{type:"object"},message:"must be object"}],!1;var ea=J===eo}else var ea=!0;if(ea){if(void 0!==O.appIdentifier){let $=eo;if("string"!=typeof O.appIdentifier)return keystore_validation_generated_validate11.errors=[{instancePath:U+"/appIdentifier",schemaPath:"#/properties/appIdentifier/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var ea=$===eo}else var ea=!0;if(ea){if(void 0!==O.version){let $=eo;if("string"!=typeof O.version)return keystore_validation_generated_validate11.errors=[{instancePath:U+"/version",schemaPath:"#/properties/version/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var ea=$===eo}else var ea=!0;if(ea){if(void 0!==O.application){let $=eo;if("string"!=typeof O.application)return keystore_validation_generated_validate11.errors=[{instancePath:U+"/application",schemaPath:"#/properties/application/type",keyword:"type",params:{type:"string"},message:"must be string"}],!1;var ea=$===eo}else var ea=!0}}}}return keystore_validation_generated_validate11.errors=es,0===eo}let eJ=eY,eQ=eW;function schemaValidationErrors(O,U){let $=O(U);return $?null:O.errors}function isKeystoreValid(O){return!schemaValidationErrors(eJ,O)}function isCredentialValid(O){return!schemaValidationErrors(eQ,O)}let keystore_Keystore=class keystore_Keystore{constructor(O){this.data=Object.assign({application:"waku-rln-relay",appIdentifier:"01234567890abcdef",version:"0.2",credentials:{}},O)}static create(O={}){return new keystore_Keystore(O)}static fromString(O){try{let U=JSON.parse(O);if(!keystore_Keystore.isValidNwakuStore(U))throw Error("Invalid string, does not match Nwaku Keystore format.");return new keystore_Keystore(U)}catch(O){return console.error("Cannot create Keystore from string:",O),null}}static fromObject(O){if(!keystore_Keystore.isValidNwakuStore(O))throw Error("Invalid object, does not match Nwaku Keystore format.");return new keystore_Keystore(O)}async addCredential(O,U){let $=keystore_Keystore.computeMembershipHash(O.membership);if(this.data.credentials[$])throw Error("Credential already exists in the store.");let J="/stub/path",en=new Uint8Array([0]),es=keystore_Keystore.fromIdentityToBytes(O),eo=await (0,eg.create)(U,es,en,J),ea=await keccak256Checksum(U,eo),eu=keystore_Keystore.fromEipToCredential(eo,ea);return this.data.credentials[$]=eu,$}async readCredential(O,U){let $=this.data.credentials[O];if(!$)return null;let J=keystore_Keystore.fromCredentialToEip($),en=await decryptEipKeystore(U,J);return keystore_Keystore.fromBytesToIdentity(en)}removeCredential(O){this.data.credentials[O]&&delete this.data.credentials[O]}toString(){return JSON.stringify(this.data)}toObject(){return this.data}static isValidNwakuStore(O){if(!isKeystoreValid(O))return!1;let U=Object.values(eS.get(O,"credentials",{})).map(O=>isCredentialValid(O)).every(O=>O);return U}static fromCredentialToEip(O){let U=O.crypto,$={kdf:{function:U.kdf,params:U.kdfparams,message:""},cipher:{function:U.cipher,params:U.cipherparams,message:U.ciphertext},checksum:{function:"sha256",params:{},message:U.mac}};return{version:4,uuid:(0,eA.Z)(),description:void 0,path:"safe to ignore, not important for decrypt",pubkey:"safe to ignore, not important for decrypt",crypto:$}}static fromEipToCredential(O,U){let $=O.crypto,J=$.kdf;return{crypto:{cipher:$.cipher.function,cipherparams:$.cipher.params,ciphertext:$.cipher.message,kdf:J.function,kdfparams:J.params,mac:U}}}static fromBytesToIdentity(O){try{let U=bytesToUtf8(O),$=JSON.parse(U);return{identity:{IDCommitment:keystore_Keystore.fromArraylikeToBytes(eS.get($,"identityCredential.idCommitment",[])),IDTrapdoor:keystore_Keystore.fromArraylikeToBytes(eS.get($,"identityCredential.idTrapdoor",[])),IDNullifier:keystore_Keystore.fromArraylikeToBytes(eS.get($,"identityCredential.idNullifier",[])),IDCommitmentBigInt:(0,eI.T)(keystore_Keystore.fromArraylikeToBytes(eS.get($,"identityCredential.idCommitment",[]))),IDSecretHash:keystore_Keystore.fromArraylikeToBytes(eS.get($,"identityCredential.idSecretHash",[]))},membership:{treeIndex:eS.get($,"treeIndex"),chainId:eS.get($,"membershipContract.chainId"),address:eS.get($,"membershipContract.address")}}}catch(O){return console.error("Cannot parse bytes to Nwaku Credentials:",O),null}}static fromArraylikeToBytes(O){let U=[],$=0,J=O[0];for(;void 0!==J;)U.push(J),$+=1,J=O[$];return new Uint8Array(U)}static computeMembershipHash(O){return(0,ew.ci)(eE((0,ew.iY)(`${O.chainId}${O.address}${O.treeIndex}`))).toUpperCase()}static fromIdentityToBytes(O){return(0,ew.iY)(JSON.stringify({treeIndex:O.membership.treeIndex,identityCredential:{idCommitment:O.identity.IDCommitment,idNullifier:O.identity.IDNullifier,idSecretHash:O.identity.IDSecretHash,idTrapdoor:O.identity.IDTrapdoor},membershipContract:{chainId:O.membership.chainId,address:O.membership.address}}))}};$(5549);var eZ=$(7273),eX=$(2278),e0=$(7213),e1=$(6288);let e3="abi/5.7.0",e6=new e1.Yd(e3);function checkResultErrors(O){let U=[],checkErrors=function(O,$){if(Array.isArray($))for(let J in $){let en=O.slice();en.push(J);try{checkErrors(en,$[J])}catch(O){U.push({path:en,error:O})}}};return checkErrors([],O),U}let Coder=class Coder{constructor(O,U,$,J){this.name=O,this.type=U,this.localName=$,this.dynamic=J}_throwError(O,U){e6.throwArgumentError(O,this.localName,U)}};let Writer=class Writer{constructor(O){(0,e0.zG)(this,"wordSize",O||32),this._data=[],this._dataLength=0,this._padding=new Uint8Array(O)}get data(){return(0,eZ.xs)(this._data)}get length(){return this._dataLength}_writeData(O){return this._data.push(O),this._dataLength+=O.length,O.length}appendWriter(O){return this._writeData((0,eZ.zo)(O._data))}writeBytes(O){let U=(0,eZ.lE)(O),$=U.length%this.wordSize;return $&&(U=(0,eZ.zo)([U,this._padding.slice($)])),this._writeData(U)}_getValue(O){let U=(0,eZ.lE)(eX.O$.from(O));return U.length>this.wordSize&&e6.throwError("value out-of-bounds",e1.Yd.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:U.length}),U.length%this.wordSize&&(U=(0,eZ.zo)([this._padding.slice(U.length%this.wordSize),U])),U}writeValue(O){return this._writeData(this._getValue(O))}writeUpdatableValue(){let O=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,U=>{this._data[O]=this._getValue(U)}}};let Reader=class Reader{constructor(O,U,$,J){(0,e0.zG)(this,"_data",(0,eZ.lE)(O)),(0,e0.zG)(this,"wordSize",U||32),(0,e0.zG)(this,"_coerceFunc",$),(0,e0.zG)(this,"allowLoose",J),this._offset=0}get data(){return(0,eZ.Dv)(this._data)}get consumed(){return this._offset}static coerce(O,U){let $=O.match("^u?int([0-9]+)$");return $&&48>=parseInt($[1])&&(U=U.toNumber()),U}coerce(O,U){return this._coerceFunc?this._coerceFunc(O,U):Reader.coerce(O,U)}_peekBytes(O,U,$){let J=Math.ceil(U/this.wordSize)*this.wordSize;return this._offset+J>this._data.length&&(this.allowLoose&&$&&this._offset+U<=this._data.length?J=U:e6.throwError("data out-of-bounds",e1.Yd.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+J})),this._data.slice(this._offset,this._offset+J)}subReader(O){return new Reader(this._data.slice(this._offset+O),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(O,U){let $=this._peekBytes(0,O,!!U);return this._offset+=$.length,$.slice(0,O)}readValue(){return eX.O$.from(this.readBytes(this.wordSize))}};var e5=$(8994),e9=$(6339),e7=$(4184);let AddressCoder=class AddressCoder extends Coder{constructor(O){super("address","address",O,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(O,U){try{U=(0,e5.Kn)(U)}catch(O){this._throwError(O.message,U)}return O.writeValue(U)}decode(O){return(0,e5.Kn)((0,eZ.$m)(O.readValue().toHexString(),20))}};let AnonymousCoder=class AnonymousCoder extends Coder{constructor(O){super(O.name,O.type,void 0,O.dynamic),this.coder=O}defaultValue(){return this.coder.defaultValue()}encode(O,U){return this.coder.encode(O,U)}decode(O){return this.coder.decode(O)}};let te=new e1.Yd(e3);function pack(O,U,$){let J=null;if(Array.isArray($))J=$;else if($&&"object"==typeof $){let O={};J=U.map(U=>{let J=U.localName;return J||te.throwError("cannot encode object for signature with missing names",e1.Yd.errors.INVALID_ARGUMENT,{argument:"values",coder:U,value:$}),O[J]&&te.throwError("cannot encode object for signature with duplicate names",e1.Yd.errors.INVALID_ARGUMENT,{argument:"values",coder:U,value:$}),O[J]=!0,$[J]})}else te.throwArgumentError("invalid tuple value","tuple",$);U.length!==J.length&&te.throwArgumentError("types/value length mismatch","tuple",$);let en=new Writer(O.wordSize),es=new Writer(O.wordSize),eo=[];return U.forEach((O,U)=>{let $=J[U];if(O.dynamic){let U=es.length;O.encode(es,$);let J=en.writeUpdatableValue();eo.push(O=>{J(O+U)})}else O.encode(en,$)}),eo.forEach(O=>{O(en.length)}),O.appendWriter(en)+O.appendWriter(es)}function unpack(O,U){let $=[],J=O.subReader(0);U.forEach(U=>{let en=null;if(U.dynamic){let $=O.readValue(),es=J.subReader($.toNumber());try{en=U.decode(es)}catch(O){if(O.code===e1.Yd.errors.BUFFER_OVERRUN)throw O;(en=O).baseType=U.name,en.name=U.localName,en.type=U.type}}else try{en=U.decode(O)}catch(O){if(O.code===e1.Yd.errors.BUFFER_OVERRUN)throw O;(en=O).baseType=U.name,en.name=U.localName,en.type=U.type}void 0!=en&&$.push(en)});let en=U.reduce((O,U)=>{let $=U.localName;return $&&(O[$]||(O[$]=0),O[$]++),O},{});U.forEach((O,U)=>{let J=O.localName;if(!J||1!==en[J]||("length"===J&&(J="_length"),null!=$[J]))return;let es=$[U];es instanceof Error?Object.defineProperty($,J,{enumerable:!0,get:()=>{throw es}}):$[J]=es});for(let O=0;O<$.length;O++){let U=$[O];U instanceof Error&&Object.defineProperty($,O,{enumerable:!0,get:()=>{throw U}})}return Object.freeze($)}let ArrayCoder=class ArrayCoder extends Coder{constructor(O,U,$){let J=O.type+"["+(U>=0?U:"")+"]",en=-1===U||O.dynamic;super("array",J,$,en),this.coder=O,this.length=U}defaultValue(){let O=this.coder.defaultValue(),U=[];for(let $=0;$O._data.length&&te.throwError("insufficient data length",e1.Yd.errors.BUFFER_OVERRUN,{length:O._data.length,count:U});let $=[];for(let O=0;O{O.dynamic&&($=!0),J.push(O.type)});let en="tuple("+J.join(",")+")";super("tuple",en,U,$),this.coders=O}defaultValue(){let O=[];this.coders.forEach(U=>{O.push(U.defaultValue())});let U=this.coders.reduce((O,U)=>{let $=U.localName;return $&&(O[$]||(O[$]=0),O[$]++),O},{});return this.coders.forEach(($,J)=>{let en=$.localName;en&&1===U[en]&&("length"===en&&(en="_length"),null==O[en]&&(O[en]=O[J]))}),Object.freeze(O)}encode(O,U){return pack(O,this.coders,U)}decode(O){return O.coerce(this.name,unpack(O,this.coders))}};let ta=new e1.Yd(e3),tu={},th={calldata:!0,memory:!0,storage:!0},td={calldata:!0,memory:!0};function checkModifier(O,U){if("bytes"===O||"string"===O){if(th[U])return!0}else if("address"===O){if("payable"===U)return!0}else if((O.indexOf("[")>=0||"tuple"===O)&&td[U])return!0;return(th[U]||"payable"===U)&&ta.throwArgumentError("invalid modifier","name",U),!1}function parseParamType(O,U){let $=O;function throwError(U){ta.throwArgumentError(`unexpected character at position ${U}`,"param",O)}function newNode(O){let $={type:"",name:"",parent:O,state:{allowType:!0}};return U&&($.indexed=!1),$}O=O.replace(/\s/g," ");let J={type:"",name:"",state:{allowType:!0}},en=J;for(let $=0;$JSON.parse(U.format(O)))),JSON.stringify(U)}let U="";return"array"===this.baseType?U+=this.arrayChildren.format(O)+"["+(this.arrayLength<0?"":String(this.arrayLength))+"]":"tuple"===this.baseType?(O!==tf.sighash&&(U+=this.type),U+="("+this.components.map(U=>U.format(O)).join(O===tf.full?", ":",")+")"):U+=this.type,O!==tf.sighash&&(!0===this.indexed&&(U+=" indexed"),O===tf.full&&this.name&&(U+=" "+this.name)),U}static from(O,U){return"string"==typeof O?ParamType.fromString(O,U):ParamType.fromObject(O)}static fromObject(O){return ParamType.isParamType(O)?O:new ParamType(tu,{name:O.name||null,type:verifyType(O.type),indexed:null==O.indexed?null:!!O.indexed,components:O.components?O.components.map(ParamType.fromObject):null})}static fromString(O,U){return function(O){return ParamType.fromObject({name:O.name,type:O.type,indexed:O.indexed,components:O.components})}(parseParamType(O,!!U))}static isParamType(O){return!!(null!=O&&O._isParamType)}};function parseParams(O,U){return splitNesting(O).map(O=>ParamType.fromString(O,U))}let Fragment=class Fragment{constructor(O,U){O!==tu&&ta.throwError("use a static from method",e1.Yd.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),populate(this,U),this._isFragment=!0,Object.freeze(this)}static from(O){return Fragment.isFragment(O)?O:"string"==typeof O?Fragment.fromString(O):Fragment.fromObject(O)}static fromObject(O){if(Fragment.isFragment(O))return O;switch(O.type){case"function":return FunctionFragment.fromObject(O);case"event":return EventFragment.fromObject(O);case"constructor":return ConstructorFragment.fromObject(O);case"error":return ErrorFragment.fromObject(O);case"fallback":case"receive":return null}return ta.throwArgumentError("invalid fragment object","value",O)}static fromString(O){return"event"===(O=(O=(O=O.replace(/\s/g," ")).replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ")).trim()).split(" ")[0]?EventFragment.fromString(O.substring(5).trim()):"function"===O.split(" ")[0]?FunctionFragment.fromString(O.substring(8).trim()):"constructor"===O.split("(")[0].trim()?ConstructorFragment.fromString(O.trim()):"error"===O.split(" ")[0]?ErrorFragment.fromString(O.substring(5).trim()):ta.throwArgumentError("unsupported fragment","value",O)}static isFragment(O){return!!(O&&O._isFragment)}};let EventFragment=class EventFragment extends Fragment{format(O){if(O||(O=tf.sighash),tf[O]||ta.throwArgumentError("invalid format type","format",O),O===tf.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(U=>JSON.parse(U.format(O)))});let U="";return O!==tf.sighash&&(U+="event "),U+=this.name+"("+this.inputs.map(U=>U.format(O)).join(O===tf.full?", ":",")+") ",O!==tf.sighash&&this.anonymous&&(U+="anonymous "),U.trim()}static from(O){return"string"==typeof O?EventFragment.fromString(O):EventFragment.fromObject(O)}static fromObject(O){if(EventFragment.isEventFragment(O))return O;"event"!==O.type&&ta.throwArgumentError("invalid event object","value",O);let U={name:verifyIdentifier(O.name),anonymous:O.anonymous,inputs:O.inputs?O.inputs.map(ParamType.fromObject):[],type:"event"};return new EventFragment(tu,U)}static fromString(O){let U=O.match(tm);U||ta.throwArgumentError("invalid event string","value",O);let $=!1;return U[3].split(" ").forEach(O=>{switch(O.trim()){case"anonymous":$=!0;break;case"":break;default:ta.warn("unknown modifier: "+O)}}),EventFragment.fromObject({name:U[1].trim(),anonymous:$,inputs:parseParams(U[2],!0),type:"event"})}static isEventFragment(O){return O&&O._isFragment&&"event"===O.type}};function parseGas(O,U){U.gas=null;let $=O.split("@");return 1!==$.length?($.length>2&&ta.throwArgumentError("invalid human-readable ABI signature","value",O),$[1].match(/^[0-9]+$/)||ta.throwArgumentError("invalid human-readable ABI signature gas","value",O),U.gas=eX.O$.from($[1]),$[0]):O}function parseModifiers(O,U){U.constant=!1,U.payable=!1,U.stateMutability="nonpayable",O.split(" ").forEach(O=>{switch(O.trim()){case"constant":U.constant=!0;break;case"payable":U.payable=!0,U.stateMutability="payable";break;case"nonpayable":U.payable=!1,U.stateMutability="nonpayable";break;case"pure":U.constant=!0,U.stateMutability="pure";break;case"view":U.constant=!0,U.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+O)}})}function verifyState(O){let U={constant:!1,payable:!0,stateMutability:"payable"};return null!=O.stateMutability?(U.stateMutability=O.stateMutability,U.constant="view"===U.stateMutability||"pure"===U.stateMutability,null!=O.constant&&!!O.constant!==U.constant&&ta.throwArgumentError("cannot have constant function with mutability "+U.stateMutability,"value",O),U.payable="payable"===U.stateMutability,null!=O.payable&&!!O.payable!==U.payable&&ta.throwArgumentError("cannot have payable function with mutability "+U.stateMutability,"value",O)):null!=O.payable?(U.payable=!!O.payable,null!=O.constant||U.payable||"constructor"===O.type||ta.throwArgumentError("unable to determine stateMutability","value",O),U.constant=!!O.constant,U.constant?U.stateMutability="view":U.stateMutability=U.payable?"payable":"nonpayable",U.payable&&U.constant&&ta.throwArgumentError("cannot have constant payable function","value",O)):null!=O.constant?(U.constant=!!O.constant,U.payable=!U.constant,U.stateMutability=U.constant?"view":"payable"):"constructor"!==O.type&&ta.throwArgumentError("unable to determine stateMutability","value",O),U}let ConstructorFragment=class ConstructorFragment extends Fragment{format(O){if(O||(O=tf.sighash),tf[O]||ta.throwArgumentError("invalid format type","format",O),O===tf.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(U=>JSON.parse(U.format(O)))});O===tf.sighash&&ta.throwError("cannot format a constructor for sighash",e1.Yd.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let U="constructor("+this.inputs.map(U=>U.format(O)).join(O===tf.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(U+=this.stateMutability+" "),U.trim()}static from(O){return"string"==typeof O?ConstructorFragment.fromString(O):ConstructorFragment.fromObject(O)}static fromObject(O){if(ConstructorFragment.isConstructorFragment(O))return O;"constructor"!==O.type&&ta.throwArgumentError("invalid constructor object","value",O);let U=verifyState(O);U.constant&&ta.throwArgumentError("constructor cannot be constant","value",O);let $={name:null,type:O.type,inputs:O.inputs?O.inputs.map(ParamType.fromObject):[],payable:U.payable,stateMutability:U.stateMutability,gas:O.gas?eX.O$.from(O.gas):null};return new ConstructorFragment(tu,$)}static fromString(O){let U={type:"constructor"},$=(O=parseGas(O,U)).match(tm);return $&&"constructor"===$[1].trim()||ta.throwArgumentError("invalid constructor string","value",O),U.inputs=parseParams($[2].trim(),!1),parseModifiers($[3].trim(),U),ConstructorFragment.fromObject(U)}static isConstructorFragment(O){return O&&O._isFragment&&"constructor"===O.type}};let FunctionFragment=class FunctionFragment extends ConstructorFragment{format(O){if(O||(O=tf.sighash),tf[O]||ta.throwArgumentError("invalid format type","format",O),O===tf.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(U=>JSON.parse(U.format(O))),outputs:this.outputs.map(U=>JSON.parse(U.format(O)))});let U="";return O!==tf.sighash&&(U+="function "),U+=this.name+"("+this.inputs.map(U=>U.format(O)).join(O===tf.full?", ":",")+") ",O!==tf.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(U+=this.stateMutability+" "):this.constant&&(U+="view "),this.outputs&&this.outputs.length&&(U+="returns ("+this.outputs.map(U=>U.format(O)).join(", ")+") "),null!=this.gas&&(U+="@"+this.gas.toString()+" ")),U.trim()}static from(O){return"string"==typeof O?FunctionFragment.fromString(O):FunctionFragment.fromObject(O)}static fromObject(O){if(FunctionFragment.isFunctionFragment(O))return O;"function"!==O.type&&ta.throwArgumentError("invalid function object","value",O);let U=verifyState(O),$={type:O.type,name:verifyIdentifier(O.name),constant:U.constant,inputs:O.inputs?O.inputs.map(ParamType.fromObject):[],outputs:O.outputs?O.outputs.map(ParamType.fromObject):[],payable:U.payable,stateMutability:U.stateMutability,gas:O.gas?eX.O$.from(O.gas):null};return new FunctionFragment(tu,$)}static fromString(O){let U={type:"function"},$=(O=parseGas(O,U)).split(" returns ");$.length>2&&ta.throwArgumentError("invalid function string","value",O);let J=$[0].match(tm);if(J||ta.throwArgumentError("invalid function signature","value",O),U.name=J[1].trim(),U.name&&verifyIdentifier(U.name),U.inputs=parseParams(J[2],!1),parseModifiers(J[3].trim(),U),$.length>1){let J=$[1].match(tm);(""!=J[1].trim()||""!=J[3].trim())&&ta.throwArgumentError("unexpected tokens","value",O),U.outputs=parseParams(J[2],!1)}else U.outputs=[];return FunctionFragment.fromObject(U)}static isFunctionFragment(O){return O&&O._isFragment&&"function"===O.type}};function checkForbidden(O){let U=O.format();return("Error(string)"===U||"Panic(uint256)"===U)&&ta.throwArgumentError(`cannot specify user defined ${U} error`,"fragment",O),O}let ErrorFragment=class ErrorFragment extends Fragment{format(O){if(O||(O=tf.sighash),tf[O]||ta.throwArgumentError("invalid format type","format",O),O===tf.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(U=>JSON.parse(U.format(O)))});let U="";return O!==tf.sighash&&(U+="error "),(U+=this.name+"("+this.inputs.map(U=>U.format(O)).join(O===tf.full?", ":",")+") ").trim()}static from(O){return"string"==typeof O?ErrorFragment.fromString(O):ErrorFragment.fromObject(O)}static fromObject(O){if(ErrorFragment.isErrorFragment(O))return O;"error"!==O.type&&ta.throwArgumentError("invalid error object","value",O);let U={type:O.type,name:verifyIdentifier(O.name),inputs:O.inputs?O.inputs.map(ParamType.fromObject):[]};return checkForbidden(new ErrorFragment(tu,U))}static fromString(O){let U={type:"error"},$=O.match(tm);return $||ta.throwArgumentError("invalid error signature","value",O),U.name=$[1].trim(),U.name&&verifyIdentifier(U.name),U.inputs=parseParams($[2],!1),checkForbidden(ErrorFragment.fromObject(U))}static isErrorFragment(O){return O&&O._isFragment&&"error"===O.type}};function verifyType(O){return O.match(/^uint($|[^1-9])/)?O="uint256"+O.substring(4):O.match(/^int($|[^1-9])/)&&(O="int256"+O.substring(3)),O}let tg=RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function verifyIdentifier(O){return O&&O.match(tg)||ta.throwArgumentError(`invalid identifier "${O}"`,"value",O),O}let tm=RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");function splitNesting(O){O=O.trim();let U=[],$="",J=0;for(let en=0;enthis._getCoder(O)),O.name);case"":return new NullCoder(O.name)}let U=O.type.match(tv);if(U){let $=parseInt(U[2]||"256");return(0===$||$>256||$%8!=0)&&ty.throwArgumentError("invalid "+U[1]+" bit length","param",O),new NumberCoder($/8,"int"===U[1],O.name)}if(U=O.type.match(tb)){let $=parseInt(U[1]);return(0===$||$>32)&&ty.throwArgumentError("invalid bytes length","param",O),new FixedBytesCoder($,O.name)}return ty.throwArgumentError("invalid type","type",O.type)}_getWordSize(){return 32}_getReader(O,U){return new Reader(O,this._getWordSize(),this.coerceFunc,U)}_getWriter(){return new Writer(this._getWordSize())}getDefaultValue(O){let U=O.map(O=>this._getCoder(ParamType.from(O))),$=new TupleCoder(U,"_");return $.defaultValue()}encode(O,U){O.length!==U.length&&ty.throwError("types/values length mismatch",e1.Yd.errors.INVALID_ARGUMENT,{count:{types:O.length,values:U.length},value:{types:O,values:U}});let $=O.map(O=>this._getCoder(ParamType.from(O))),J=new TupleCoder($,"_"),en=this._getWriter();return J.encode(en,U),en.data}decode(O,U,$){let J=O.map(O=>this._getCoder(ParamType.from(O))),en=new TupleCoder(J,"_");return en.decode(this._getReader((0,eZ.lE)(U),$))}};let t_=new AbiCoder,tw=new e1.Yd(e3);let LogDescription=class LogDescription extends e0.dk{};let TransactionDescription=class TransactionDescription extends e0.dk{};let ErrorDescription=class ErrorDescription extends e0.dk{};let Indexed=class Indexed extends e0.dk{static isIndexed(O){return!!(O&&O._isIndexed)}};let tE={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function wrapAccessError(O,U){let $=Error(`deferred error during ABI decoding triggered accessing ${O}`);return $.error=U,$}let Interface=class Interface{constructor(O){let U=[];U="string"==typeof O?JSON.parse(O):O,(0,e0.zG)(this,"fragments",U.map(O=>Fragment.from(O)).filter(O=>null!=O)),(0,e0.zG)(this,"_abiCoder",(0,e0.tu)(new.target,"getAbiCoder")()),(0,e0.zG)(this,"functions",{}),(0,e0.zG)(this,"errors",{}),(0,e0.zG)(this,"events",{}),(0,e0.zG)(this,"structs",{}),this.fragments.forEach(O=>{let U=null;switch(O.type){case"constructor":if(this.deploy){tw.warn("duplicate definition - constructor");return}(0,e0.zG)(this,"deploy",O);return;case"function":U=this.functions;break;case"event":U=this.events;break;case"error":U=this.errors;break;default:return}let $=O.format();if(U[$]){tw.warn("duplicate definition - "+$);return}U[$]=O}),this.deploy||(0,e0.zG)(this,"deploy",ConstructorFragment.from({payable:!1,type:"constructor"})),(0,e0.zG)(this,"_isInterface",!0)}format(O){O||(O=tf.full),O===tf.sighash&&tw.throwArgumentError("interface does not support formatting sighash","format",O);let U=this.fragments.map(U=>U.format(O));return O===tf.json?JSON.stringify(U.map(O=>JSON.parse(O))):U}static getAbiCoder(){return t_}static getAddress(O){return(0,e5.Kn)(O)}static getSighash(O){return(0,eZ.p3)((0,e9.id)(O.format()),0,4)}static getEventTopic(O){return(0,e9.id)(O.format())}getFunction(O){if((0,eZ.A7)(O)){for(let U in this.functions)if(O===this.getSighash(U))return this.functions[U];tw.throwArgumentError("no matching function","sighash",O)}if(-1===O.indexOf("(")){let U=O.trim(),$=Object.keys(this.functions).filter(O=>O.split("(")[0]===U);return 0===$.length?tw.throwArgumentError("no matching function","name",U):$.length>1&&tw.throwArgumentError("multiple matching functions","name",U),this.functions[$[0]]}let U=this.functions[FunctionFragment.fromString(O).format()];return U||tw.throwArgumentError("no matching function","signature",O),U}getEvent(O){if((0,eZ.A7)(O)){let U=O.toLowerCase();for(let O in this.events)if(U===this.getEventTopic(O))return this.events[O];tw.throwArgumentError("no matching event","topichash",U)}if(-1===O.indexOf("(")){let U=O.trim(),$=Object.keys(this.events).filter(O=>O.split("(")[0]===U);return 0===$.length?tw.throwArgumentError("no matching event","name",U):$.length>1&&tw.throwArgumentError("multiple matching events","name",U),this.events[$[0]]}let U=this.events[EventFragment.fromString(O).format()];return U||tw.throwArgumentError("no matching event","signature",O),U}getError(O){if((0,eZ.A7)(O)){let U=(0,e0.tu)(this.constructor,"getSighash");for(let $ in this.errors){let J=this.errors[$];if(O===U(J))return this.errors[$]}tw.throwArgumentError("no matching error","sighash",O)}if(-1===O.indexOf("(")){let U=O.trim(),$=Object.keys(this.errors).filter(O=>O.split("(")[0]===U);return 0===$.length?tw.throwArgumentError("no matching error","name",U):$.length>1&&tw.throwArgumentError("multiple matching errors","name",U),this.errors[$[0]]}let U=this.errors[FunctionFragment.fromString(O).format()];return U||tw.throwArgumentError("no matching error","signature",O),U}getSighash(O){if("string"==typeof O)try{O=this.getFunction(O)}catch(U){try{O=this.getError(O)}catch(O){throw U}}return(0,e0.tu)(this.constructor,"getSighash")(O)}getEventTopic(O){return"string"==typeof O&&(O=this.getEvent(O)),(0,e0.tu)(this.constructor,"getEventTopic")(O)}_decodeParams(O,U){return this._abiCoder.decode(O,U)}_encodeParams(O,U){return this._abiCoder.encode(O,U)}encodeDeploy(O){return this._encodeParams(this.deploy.inputs,O||[])}decodeErrorResult(O,U){"string"==typeof O&&(O=this.getError(O));let $=(0,eZ.lE)(U);return(0,eZ.Dv)($.slice(0,4))!==this.getSighash(O)&&tw.throwArgumentError(`data signature does not match error ${O.name}.`,"data",(0,eZ.Dv)($)),this._decodeParams(O.inputs,$.slice(4))}encodeErrorResult(O,U){return"string"==typeof O&&(O=this.getError(O)),(0,eZ.Dv)((0,eZ.zo)([this.getSighash(O),this._encodeParams(O.inputs,U||[])]))}decodeFunctionData(O,U){"string"==typeof O&&(O=this.getFunction(O));let $=(0,eZ.lE)(U);return(0,eZ.Dv)($.slice(0,4))!==this.getSighash(O)&&tw.throwArgumentError(`data signature does not match function ${O.name}.`,"data",(0,eZ.Dv)($)),this._decodeParams(O.inputs,$.slice(4))}encodeFunctionData(O,U){return"string"==typeof O&&(O=this.getFunction(O)),(0,eZ.Dv)((0,eZ.zo)([this.getSighash(O),this._encodeParams(O.inputs,U||[])]))}decodeFunctionResult(O,U){"string"==typeof O&&(O=this.getFunction(O));let $=(0,eZ.lE)(U),J=null,en="",es=null,eo=null,ea=null;switch($.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(O.outputs,$)}catch(O){}break;case 4:{let O=(0,eZ.Dv)($.slice(0,4)),U=tE[O];if(U)es=this._abiCoder.decode(U.inputs,$.slice(4)),eo=U.name,ea=U.signature,U.reason&&(J=es[0]),"Error"===eo?en=`; VM Exception while processing transaction: reverted with reason string ${JSON.stringify(es[0])}`:"Panic"===eo&&(en=`; VM Exception while processing transaction: reverted with panic code ${es[0]}`);else try{let U=this.getError(O);es=this._abiCoder.decode(U.inputs,$.slice(4)),eo=U.name,ea=U.format()}catch(O){}}}return tw.throwError("call revert exception"+en,e1.Yd.errors.CALL_EXCEPTION,{method:O.format(),data:(0,eZ.Dv)(U),errorArgs:es,errorName:eo,errorSignature:ea,reason:J})}encodeFunctionResult(O,U){return"string"==typeof O&&(O=this.getFunction(O)),(0,eZ.Dv)(this._abiCoder.encode(O.outputs,U||[]))}encodeFilterTopics(O,U){"string"==typeof O&&(O=this.getEvent(O)),U.length>O.inputs.length&&tw.throwError("too many arguments for "+O.format(),e1.Yd.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:U});let $=[];O.anonymous||$.push(this.getEventTopic(O));let encodeTopic=(O,U)=>"string"===O.type?(0,e9.id)(U):"bytes"===O.type?(0,e7.w)((0,eZ.Dv)(U)):("bool"===O.type&&"boolean"==typeof U&&(U=U?"0x01":"0x00"),O.type.match(/^u?int/)&&(U=eX.O$.from(U).toHexString()),"address"===O.type&&this._abiCoder.encode(["address"],[U]),(0,eZ.$m)((0,eZ.Dv)(U),32));for(U.forEach((U,J)=>{let en=O.inputs[J];if(!en.indexed){null!=U&&tw.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+en.name,U);return}null==U?$.push(null):"array"===en.baseType||"tuple"===en.baseType?tw.throwArgumentError("filtering with tuples or arrays not supported","contract."+en.name,U):Array.isArray(U)?$.push(U.map(O=>encodeTopic(en,O))):$.push(encodeTopic(en,U))});$.length&&null===$[$.length-1];)$.pop();return $}encodeEventLog(O,U){"string"==typeof O&&(O=this.getEvent(O));let $=[],J=[],en=[];return O.anonymous||$.push(this.getEventTopic(O)),U.length!==O.inputs.length&&tw.throwArgumentError("event arguments/values mismatch","values",U),O.inputs.forEach((O,es)=>{let eo=U[es];if(O.indexed){if("string"===O.type)$.push((0,e9.id)(eo));else if("bytes"===O.type)$.push((0,e7.w)(eo));else if("tuple"===O.baseType||"array"===O.baseType)throw Error("not implemented");else $.push(this._abiCoder.encode([O.type],[eo]))}else J.push(O),en.push(eo)}),{data:this._abiCoder.encode(J,en),topics:$}}decodeEventLog(O,U,$){if("string"==typeof O&&(O=this.getEvent(O)),null!=$&&!O.anonymous){let U=this.getEventTopic(O);(0,eZ.A7)($[0],32)&&$[0].toLowerCase()===U||tw.throwError("fragment/topic mismatch",e1.Yd.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:U,value:$[0]}),$=$.slice(1)}let J=[],en=[],es=[];O.inputs.forEach((O,U)=>{O.indexed?"string"===O.type||"bytes"===O.type||"tuple"===O.baseType||"array"===O.baseType?(J.push(ParamType.fromObject({type:"bytes32",name:O.name})),es.push(!0)):(J.push(O),es.push(!1)):(en.push(O),es.push(!1))});let eo=null!=$?this._abiCoder.decode(J,(0,eZ.zo)($)):null,ea=this._abiCoder.decode(en,U,!0),eu=[],ef=0,eg=0;O.inputs.forEach((O,U)=>{if(O.indexed){if(null==eo)eu[U]=new Indexed({_isIndexed:!0,hash:null});else if(es[U])eu[U]=new Indexed({_isIndexed:!0,hash:eo[eg++]});else try{eu[U]=eo[eg++]}catch(O){eu[U]=O}}else try{eu[U]=ea[ef++]}catch(O){eu[U]=O}if(O.name&&null==eu[O.name]){let $=eu[U];$ instanceof Error?Object.defineProperty(eu,O.name,{enumerable:!0,get:()=>{throw wrapAccessError(`property ${JSON.stringify(O.name)}`,$)}}):eu[O.name]=$}});for(let O=0;O{throw wrapAccessError(`index ${O}`,U)}})}return Object.freeze(eu)}parseTransaction(O){let U=this.getFunction(O.data.substring(0,10).toLowerCase());return U?new TransactionDescription({args:this._abiCoder.decode(U.inputs,"0x"+O.data.substring(10)),functionFragment:U,name:U.name,signature:U.format(),sighash:this.getSighash(U),value:eX.O$.from(O.value||"0")}):null}parseLog(O){let U=this.getEvent(O.topics[0]);return!U||U.anonymous?null:new LogDescription({eventFragment:U,name:U.name,signature:U.format(),topic:this.getEventTopic(U),args:this.decodeEventLog(U,O.data,O.topics)})}parseError(O){let U=(0,eZ.Dv)(O),$=this.getError(U.substring(0,10).toLowerCase());return $?new ErrorDescription({args:this._abiCoder.decode($.inputs,"0x"+U.substring(10)),errorFragment:$,name:$.name,signature:$.format(),sighash:this.getSighash($)}):null}static isInterface(O){return!!(O&&O._isInterface)}};var tS=$(4999),tA=$(4941),tI=$(2501);let tP="contracts/5.7.0";var __awaiter=function(O,U,$,J){function adopt(O){return O instanceof $?O:new $(function(U){U(O)})}return new($||($=Promise))(function($,en){function fulfilled(O){try{step(J.next(O))}catch(O){en(O)}}function rejected(O){try{step(J.throw(O))}catch(O){en(O)}}function step(O){O.done?$(O.value):adopt(O.value).then(fulfilled,rejected)}step((J=J.apply(O,U||[])).next())})};let tk=new e1.Yd(tP);function resolveName(O,U){return __awaiter(this,void 0,void 0,function*(){let $=yield U;"string"!=typeof $&&tk.throwArgumentError("invalid address or ENS name","name",$);try{return(0,e5.Kn)($)}catch(O){}O||tk.throwError("a provider or signer is needed to resolve ENS names",e1.Yd.errors.UNSUPPORTED_OPERATION,{operation:"resolveName"});let J=yield O.resolveName($);return null==J&&tk.throwArgumentError("resolver or addr is not configured for ENS name","name",$),J})}function resolveAddresses(O,U,$){return __awaiter(this,void 0,void 0,function*(){return Array.isArray($)?yield Promise.all($.map(($,J)=>resolveAddresses(O,Array.isArray(U)?U[J]:U[$.name],$))):"address"===$.type?yield resolveName(O,U):"tuple"===$.type?yield resolveAddresses(O,U,$.components):"array"===$.baseType?Array.isArray(U)?yield Promise.all(U.map(U=>resolveAddresses(O,U,$.arrayChildren))):Promise.reject(tk.makeError("invalid value for array",e1.Yd.errors.INVALID_ARGUMENT,{argument:"value",value:U})):U})}function populateTransaction(O,U,$){return __awaiter(this,void 0,void 0,function*(){let J={};$.length===U.inputs.length+1&&"object"==typeof $[$.length-1]&&(J=(0,e0.DC)($.pop())),tk.checkArgumentCount($.length,U.inputs.length,"passed to contract"),O.signer?J.from?J.from=(0,e0.mE)({override:resolveName(O.signer,J.from),signer:O.signer.getAddress()}).then(O=>__awaiter(this,void 0,void 0,function*(){return(0,e5.Kn)(O.signer)!==O.override&&tk.throwError("Contract with a Signer cannot override from",e1.Yd.errors.UNSUPPORTED_OPERATION,{operation:"overrides.from"}),O.override})):J.from=O.signer.getAddress():J.from&&(J.from=resolveName(O.provider,J.from));let en=yield(0,e0.mE)({args:resolveAddresses(O.signer||O.provider,$,U.inputs),address:O.resolvedAddress,overrides:(0,e0.mE)(J)||{}}),es=O.interface.encodeFunctionData(U,en.args),eo={data:es,to:en.address},ea=en.overrides;if(null!=ea.nonce&&(eo.nonce=eX.O$.from(ea.nonce).toNumber()),null!=ea.gasLimit&&(eo.gasLimit=eX.O$.from(ea.gasLimit)),null!=ea.gasPrice&&(eo.gasPrice=eX.O$.from(ea.gasPrice)),null!=ea.maxFeePerGas&&(eo.maxFeePerGas=eX.O$.from(ea.maxFeePerGas)),null!=ea.maxPriorityFeePerGas&&(eo.maxPriorityFeePerGas=eX.O$.from(ea.maxPriorityFeePerGas)),null!=ea.from&&(eo.from=ea.from),null!=ea.type&&(eo.type=ea.type),null!=ea.accessList&&(eo.accessList=(0,tI.z7)(ea.accessList)),null==eo.gasLimit&&null!=U.gas){let O=21e3,$=(0,eZ.lE)(es);for(let U=0;U<$.length;U++)O+=4,$[U]&&(O+=64);eo.gasLimit=eX.O$.from(U.gas).add(O)}if(ea.value){let O=eX.O$.from(ea.value);O.isZero()||U.payable||tk.throwError("non-payable method cannot override value",e1.Yd.errors.UNSUPPORTED_OPERATION,{operation:"overrides.value",value:J.value}),eo.value=O}ea.customData&&(eo.customData=(0,e0.DC)(ea.customData)),ea.ccipReadEnabled&&(eo.ccipReadEnabled=!!ea.ccipReadEnabled),delete J.nonce,delete J.gasLimit,delete J.gasPrice,delete J.from,delete J.value,delete J.type,delete J.accessList,delete J.maxFeePerGas,delete J.maxPriorityFeePerGas,delete J.customData,delete J.ccipReadEnabled;let eu=Object.keys(J).filter(O=>null!=J[O]);return eu.length&&tk.throwError(`cannot override ${eu.map(O=>JSON.stringify(O)).join(",")}`,e1.Yd.errors.UNSUPPORTED_OPERATION,{operation:"overrides",overrides:eu}),eo})}function buildPopulate(O,U){return function(...$){return populateTransaction(O,U,$)}}function buildEstimate(O,U){let $=O.signer||O.provider;return function(...J){return __awaiter(this,void 0,void 0,function*(){$||tk.throwError("estimate require a provider or signer",e1.Yd.errors.UNSUPPORTED_OPERATION,{operation:"estimateGas"});let en=yield populateTransaction(O,U,J);return yield $.estimateGas(en)})}}function addContractWait(O,U){let $=U.wait.bind(U);U.wait=U=>$(U).then(U=>(U.events=U.logs.map($=>{let J=(0,e0.p$)($),en=null;try{en=O.interface.parseLog($)}catch(O){}return en&&(J.args=en.args,J.decode=(U,$)=>O.interface.decodeEventLog(en.eventFragment,U,$),J.event=en.name,J.eventSignature=en.signature),J.removeListener=()=>O.provider,J.getBlock=()=>O.provider.getBlock(U.blockHash),J.getTransaction=()=>O.provider.getTransaction(U.transactionHash),J.getTransactionReceipt=()=>Promise.resolve(U),J}),U))}function buildCall(O,U,$){let J=O.signer||O.provider;return function(...en){return __awaiter(this,void 0,void 0,function*(){let es;if(en.length===U.inputs.length+1&&"object"==typeof en[en.length-1]){let O=(0,e0.DC)(en.pop());null!=O.blockTag&&(es=yield O.blockTag),delete O.blockTag,en.push(O)}null!=O.deployTransaction&&(yield O._deployed(es));let eo=yield populateTransaction(O,U,en),ea=yield J.call(eo,es);try{let J=O.interface.decodeFunctionResult(U,ea);return $&&1===U.outputs.length&&(J=J[0]),J}catch(U){throw U.code===e1.Yd.errors.CALL_EXCEPTION&&(U.address=O.address,U.args=en,U.transaction=eo),U}})}}function buildSend(O,U){return function(...$){return __awaiter(this,void 0,void 0,function*(){O.signer||tk.throwError("sending a transaction requires a signer",e1.Yd.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction"}),null!=O.deployTransaction&&(yield O._deployed());let J=yield populateTransaction(O,U,$),en=yield O.signer.sendTransaction(J);return addContractWait(O,en),en})}}function buildDefault(O,U,$){return U.constant?buildCall(O,U,$):buildSend(O,U)}function getEventTag(O){return O.address&&(null==O.topics||0===O.topics.length)?"*":(O.address||"*")+"@"+(O.topics?O.topics.map(O=>Array.isArray(O)?O.join("|"):O).join(":"):"")}let RunningEvent=class RunningEvent{constructor(O,U){(0,e0.zG)(this,"tag",O),(0,e0.zG)(this,"filter",U),this._listeners=[]}addListener(O,U){this._listeners.push({listener:O,once:U})}removeListener(O){let U=!1;this._listeners=this._listeners.filter($=>!!U||$.listener!==O||(U=!0,!1))}removeAllListeners(){this._listeners=[]}listeners(){return this._listeners.map(O=>O.listener)}listenerCount(){return this._listeners.length}run(O){let U=this.listenerCount();return this._listeners=this._listeners.filter(U=>{let $=O.slice();return setTimeout(()=>{U.listener.apply(this,$)},0),!U.once}),U}prepareEvent(O){}getEmit(O){return[O]}};let ErrorRunningEvent=class ErrorRunningEvent extends RunningEvent{constructor(){super("error",null)}};let FragmentRunningEvent=class FragmentRunningEvent extends RunningEvent{constructor(O,U,$,J){let en={address:O},es=U.getEventTopic($);J?(es!==J[0]&&tk.throwArgumentError("topic mismatch","topics",J),en.topics=J.slice()):en.topics=[es],super(getEventTag(en),en),(0,e0.zG)(this,"address",O),(0,e0.zG)(this,"interface",U),(0,e0.zG)(this,"fragment",$)}prepareEvent(O){super.prepareEvent(O),O.event=this.fragment.name,O.eventSignature=this.fragment.format(),O.decode=(O,U)=>this.interface.decodeEventLog(this.fragment,O,U);try{O.args=this.interface.decodeEventLog(this.fragment,O.data,O.topics)}catch(U){O.args=null,O.decodeError=U}}getEmit(O){let U=checkResultErrors(O.args);if(U.length)throw U[0].error;let $=(O.args||[]).slice();return $.push(O),$}};let WildcardRunningEvent=class WildcardRunningEvent extends RunningEvent{constructor(O,U){super("*",{address:O}),(0,e0.zG)(this,"address",O),(0,e0.zG)(this,"interface",U)}prepareEvent(O){super.prepareEvent(O);try{let U=this.interface.parseLog(O);O.event=U.name,O.eventSignature=U.signature,O.decode=(O,$)=>this.interface.decodeEventLog(U.eventFragment,O,$),O.args=U.args}catch(O){}}};let BaseContract=class BaseContract{constructor(O,U,$){(0,e0.zG)(this,"interface",(0,e0.tu)(new.target,"getInterface")(U)),null==$?((0,e0.zG)(this,"provider",null),(0,e0.zG)(this,"signer",null)):tA.E.isSigner($)?((0,e0.zG)(this,"provider",$.provider||null),(0,e0.zG)(this,"signer",$)):tS.zt.isProvider($)?((0,e0.zG)(this,"provider",$),(0,e0.zG)(this,"signer",null)):tk.throwArgumentError("invalid signer or provider","signerOrProvider",$),(0,e0.zG)(this,"callStatic",{}),(0,e0.zG)(this,"estimateGas",{}),(0,e0.zG)(this,"functions",{}),(0,e0.zG)(this,"populateTransaction",{}),(0,e0.zG)(this,"filters",{});{let O={};Object.keys(this.interface.events).forEach(U=>{let $=this.interface.events[U];(0,e0.zG)(this.filters,U,(...O)=>({address:this.address,topics:this.interface.encodeFilterTopics($,O)})),O[$.name]||(O[$.name]=[]),O[$.name].push(U)}),Object.keys(O).forEach(U=>{let $=O[U];1===$.length?(0,e0.zG)(this.filters,U,this.filters[$[0]]):tk.warn(`Duplicate definition of ${U} (${$.join(", ")})`)})}if((0,e0.zG)(this,"_runningEvents",{}),(0,e0.zG)(this,"_wrappedEmits",{}),null==O&&tk.throwArgumentError("invalid contract address or ENS name","addressOrName",O),(0,e0.zG)(this,"address",O),this.provider)(0,e0.zG)(this,"resolvedAddress",resolveName(this.provider,O));else try{(0,e0.zG)(this,"resolvedAddress",Promise.resolve((0,e5.Kn)(O)))}catch(O){tk.throwError("provider is required to use ENS name as contract address",e1.Yd.errors.UNSUPPORTED_OPERATION,{operation:"new Contract"})}this.resolvedAddress.catch(O=>{});let J={},en={};Object.keys(this.interface.functions).forEach(O=>{let U=this.interface.functions[O];if(en[O]){tk.warn(`Duplicate ABI entry for ${JSON.stringify(O)}`);return}en[O]=!0;{let $=U.name;J[`%${$}`]||(J[`%${$}`]=[]),J[`%${$}`].push(O)}null==this[O]&&(0,e0.zG)(this,O,buildDefault(this,U,!0)),null==this.functions[O]&&(0,e0.zG)(this.functions,O,buildDefault(this,U,!1)),null==this.callStatic[O]&&(0,e0.zG)(this.callStatic,O,buildCall(this,U,!0)),null==this.populateTransaction[O]&&(0,e0.zG)(this.populateTransaction,O,buildPopulate(this,U)),null==this.estimateGas[O]&&(0,e0.zG)(this.estimateGas,O,buildEstimate(this,U))}),Object.keys(J).forEach(O=>{let U=J[O];if(U.length>1)return;O=O.substring(1);let $=U[0];try{null==this[O]&&(0,e0.zG)(this,O,this[$])}catch(O){}null==this.functions[O]&&(0,e0.zG)(this.functions,O,this.functions[$]),null==this.callStatic[O]&&(0,e0.zG)(this.callStatic,O,this.callStatic[$]),null==this.populateTransaction[O]&&(0,e0.zG)(this.populateTransaction,O,this.populateTransaction[$]),null==this.estimateGas[O]&&(0,e0.zG)(this.estimateGas,O,this.estimateGas[$])})}static getContractAddress(O){return(0,e5.CR)(O)}static getInterface(O){return Interface.isInterface(O)?O:new Interface(O)}deployed(){return this._deployed()}_deployed(O){return this._deployedPromise||(this.deployTransaction?this._deployedPromise=this.deployTransaction.wait().then(()=>this):this._deployedPromise=this.provider.getCode(this.address,O).then(O=>("0x"===O&&tk.throwError("contract not deployed",e1.Yd.errors.UNSUPPORTED_OPERATION,{contractAddress:this.address,operation:"getDeployed"}),this))),this._deployedPromise}fallback(O){this.signer||tk.throwError("sending a transactions require a signer",e1.Yd.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});let U=(0,e0.DC)(O||{});return["from","to"].forEach(function(O){null!=U[O]&&tk.throwError("cannot override "+O,e1.Yd.errors.UNSUPPORTED_OPERATION,{operation:O})}),U.to=this.resolvedAddress,this.deployed().then(()=>this.signer.sendTransaction(U))}connect(O){"string"==typeof O&&(O=new tA.b(O,this.provider));let U=new this.constructor(this.address,this.interface,O);return this.deployTransaction&&(0,e0.zG)(U,"deployTransaction",this.deployTransaction),U}attach(O){return new this.constructor(O,this.interface,this.signer||this.provider)}static isIndexed(O){return Indexed.isIndexed(O)}_normalizeRunningEvent(O){return this._runningEvents[O.tag]?this._runningEvents[O.tag]:O}_getRunningEvent(O){if("string"==typeof O){if("error"===O)return this._normalizeRunningEvent(new ErrorRunningEvent);if("event"===O)return this._normalizeRunningEvent(new RunningEvent("event",null));if("*"===O)return this._normalizeRunningEvent(new WildcardRunningEvent(this.address,this.interface));let U=this.interface.getEvent(O);return this._normalizeRunningEvent(new FragmentRunningEvent(this.address,this.interface,U))}if(O.topics&&O.topics.length>0){try{let U=O.topics[0];if("string"!=typeof U)throw Error("invalid topic");let $=this.interface.getEvent(U);return this._normalizeRunningEvent(new FragmentRunningEvent(this.address,this.interface,$,O.topics))}catch(O){}let U={address:this.address,topics:O.topics};return this._normalizeRunningEvent(new RunningEvent(getEventTag(U),U))}return this._normalizeRunningEvent(new WildcardRunningEvent(this.address,this.interface))}_checkRunningEvents(O){if(0===O.listenerCount()){delete this._runningEvents[O.tag];let U=this._wrappedEmits[O.tag];U&&O.filter&&(this.provider.off(O.filter,U),delete this._wrappedEmits[O.tag])}}_wrapEvent(O,U,$){let J=(0,e0.p$)(U);return J.removeListener=()=>{$&&(O.removeListener($),this._checkRunningEvents(O))},J.getBlock=()=>this.provider.getBlock(U.blockHash),J.getTransaction=()=>this.provider.getTransaction(U.transactionHash),J.getTransactionReceipt=()=>this.provider.getTransactionReceipt(U.transactionHash),O.prepareEvent(J),J}_addEventListener(O,U,$){if(this.provider||tk.throwError("events require a provider or a signer with a provider",e1.Yd.errors.UNSUPPORTED_OPERATION,{operation:"once"}),O.addListener(U,$),this._runningEvents[O.tag]=O,!this._wrappedEmits[O.tag]){let wrappedEmit=$=>{let J=this._wrapEvent(O,$,U);if(null==J.decodeError)try{let U=O.getEmit(J);this.emit(O.filter,...U)}catch(O){J.decodeError=O.error}null!=O.filter&&this.emit("event",J),null!=J.decodeError&&this.emit("error",J.decodeError,J)};this._wrappedEmits[O.tag]=wrappedEmit,null!=O.filter&&this.provider.on(O.filter,wrappedEmit)}}queryFilter(O,U,$){let J=this._getRunningEvent(O),en=(0,e0.DC)(J.filter);return"string"==typeof U&&(0,eZ.A7)(U,32)?(null!=$&&tk.throwArgumentError("cannot specify toBlock with blockhash","toBlock",$),en.blockHash=U):(en.fromBlock=null!=U?U:0,en.toBlock=null!=$?$:"latest"),this.provider.getLogs(en).then(O=>O.map(O=>this._wrapEvent(J,O,null)))}on(O,U){return this._addEventListener(this._getRunningEvent(O),U,!1),this}once(O,U){return this._addEventListener(this._getRunningEvent(O),U,!0),this}emit(O,...U){if(!this.provider)return!1;let $=this._getRunningEvent(O),J=$.run(U)>0;return this._checkRunningEvents($),J}listenerCount(O){return this.provider?null==O?Object.keys(this._runningEvents).reduce((O,U)=>O+this._runningEvents[U].listenerCount(),0):this._getRunningEvent(O).listenerCount():0}listeners(O){if(!this.provider)return[];if(null==O){let O=[];for(let U in this._runningEvents)this._runningEvents[U].listeners().forEach(U=>{O.push(U)});return O}return this._getRunningEvent(O).listeners()}removeAllListeners(O){if(!this.provider)return this;if(null==O){for(let O in this._runningEvents){let U=this._runningEvents[O];U.removeAllListeners(),this._checkRunningEvents(U)}return this}let U=this._getRunningEvent(O);return U.removeAllListeners(),this._checkRunningEvents(U),this}off(O,U){if(!this.provider)return this;let $=this._getRunningEvent(O);return $.removeListener(U),this._checkRunningEvents($),this}removeListener(O,U){return this.off(O,U)}};let Contract=class Contract extends BaseContract{};var tT=$(5572);let RootPerBlock=class RootPerBlock{constructor(O,U){this.root=O,this.blockNumber=U}};let tR=20;let MerkleRootTracker=class MerkleRootTracker{constructor(O,U){this.acceptableRootWindowSize=O,this.validMerkleRoots=[],this.merkleRootBuffer=[],this.pushRoot(0,U)}backFill(O){if(0==this.validMerkleRoots.length)return;let U=0;for(let $=this.validMerkleRoots.length-1;$>=0;$--)this.validMerkleRoots[$].blockNumber>=O&&U++;if(0==U)return;let $=OU.blockNumber==O);U>-1&&(this.merkleRootBuffer=this.merkleRootBuffer.slice(0,U))}let en=this.acceptableRootWindowSize-this.validMerkleRoots.length;this.merkleRootBuffer.lengththis.acceptableRootWindowSize){let O=this.validMerkleRoots.shift();O&&this.merkleRootBuffer.push(O)}this.merkleRootBuffer.length>tR&&this.merkleRootBuffer.shift()}roots(){return this.validMerkleRoots.map(O=>O.root)}buffer(){return this.merkleRootBuffer.map(O=>O.root)}};let RLNContract=class RLNContract{static async init(O,U){let $=new RLNContract(O,U);return await $.initStorageContract(U.provider),await $.fetchMembers(O),$.subscribeToMembers(O),$}constructor(O,{registryAddress:U,provider:$}){this._members=new Map;let J=O.getMerkleRoot();this.registryContract=new Contract(U,ea,$),this.merkleRootTracker=new MerkleRootTracker(5,J)}async initStorageContract(O,U={}){let $=U?.storageIndex?U.storageIndex:await this.registryContract.usingStorageIndex(),J=await this.registryContract.storages($);if(!J||J===tT.d)throw Error("No RLN Storage initialized on registry contract.");this.storageIndex=$,this.storageContract=new Contract(J,eu,O),this._membersFilter=this.storageContract.filters.MemberRegistered(),this.deployBlock=await this.storageContract.deployedBlockNumber()}get contract(){if(!this.storageContract)throw Error("Storage contract was not initialized");return this.storageContract}get members(){let O=Array.from(this._members.values()).sort((O,U)=>O.index.toNumber()-U.index.toNumber());return O}get membersFilter(){if(!this._membersFilter)throw Error("Members filter was not initialized.");return this._membersFilter}async fetchMembers(O,U={}){let $=await queryFilter(this.contract,{fromBlock:this.deployBlock,...U,membersFilter:this.membersFilter});this.processEvents(O,$)}processEvents(O,U){let $=new Map,J=new Map;U.forEach(U=>{if(U.args){if(U.removed){let O=U.args.index,J=$.get(U.blockNumber);void 0!=J?(J.push(O.toNumber()),$.set(U.blockNumber,J)):$.set(U.blockNumber,[O.toNumber()])}else{let O=J.get(U.blockNumber);void 0==O&&(O=[]),O.push(U),J.set(U.blockNumber,O)}this.removeMembers(O,$),this.insertMembers(O,J)}})}insertMembers(O,U){U.forEach((U,$)=>{U.forEach(U=>{let $=U?.args?.idCommitment,J=U?.args?.index;if(!$||!J)return;let en=eZ.Bu(eZ.lE($),32);O.insertMember(en),this._members.set(J.toNumber(),{index:J,idCommitment:$?._hex||eZ.Dv(en)})});let J=O.getMerkleRoot();this.merkleRootTracker.pushRoot($,J)})}removeMembers(O,U){let $=new Map([...U].sort().reverse());$.forEach((U,$)=>{U.forEach(U=>{this._members.has(U)&&this._members.delete(U),O.deleteMember(U)}),this.merkleRootTracker.backFill($)})}subscribeToMembers(O){this.contract.on(this.membersFilter,(U,$,J)=>this.processEvents(O,[J]))}async registerWithSignature(O,U){let $=await O.generateSeededIdentityCredential(U);return this.registerWithKey($)}async registerWithKey(O){if(void 0===this.storageIndex)throw Error("Cannot register credential, no storage contract index found.");let U=await this.registryContract["register(uint16,uint256)"](this.storageIndex,O.IDCommitmentBigInt,{gasLimit:1e5}),$=await U.wait(),J=$?.events?.[0];if(!J)return;let en=this.contract.interface.decodeEventLog("MemberRegistered",J.data);return{idCommitment:en.idCommitment,index:en.index}}roots(){return this.merkleRootTracker.roots()}};let tC=5,tB=3e3;async function queryFilter(O,U){let{fromBlock:$,membersFilter:J,fetchRange:en=tB,fetchChunks:es=tC}=U;if(!$)return O.queryFilter(J);if(!O.signer.provider)throw Error("No provider found on the contract's signer.");let eo=await O.signer.provider.getBlockNumber();if(eo-$ignoreErrors(O.queryFilter(J,U,$),[])),en=await Promise.all($);ea.push(en.flatMap(O=>O))}return ea.flatMap(O=>O)}function splitToChunks(O,U,$){let J=[],en=O;for(;en(console.error(`Ignoring an error during query: ${O?.message}`),U))}async function create(){let O=await Promise.resolve().then($.bind($,5549));return await O.create()}},5549:function(O,U,$){"use strict";$.r(U),$.d(U,{IdentityCredential:function(){return IdentityCredential},Proof:function(){return Proof},ProofMetadata:function(){return ProofMetadata},RLNInstance:function(){return RLNInstance},create:function(){return create},poseidonHash:function(){return poseidonHash},proofToBytes:function(){return proofToBytes},sha256:function(){return sha256}});var J=$(3194),en=$(3909),es=$(8385);let eo={protocol:"groth16",curve:"bn128",nPublic:6,vk_alpha_1:["20124996762962216725442980738609010303800849578410091356605067053491763969391","9118593021526896828671519912099489027245924097793322973632351264852174143923","1"],vk_beta_2:[["4693952934005375501364248788849686435240706020501681709396105298107971354382","14346958885444710485362620645446987998958218205939139994511461437152241966681"],["16851772916911573982706166384196538392731905827088356034885868448550849804972","823612331030938060799959717749043047845343400798220427319188951998582076532"],["1","0"]],vk_gamma_2:[["10857046999023057135944570762232829481370756359578518086990519993285655852781","11559732032986387107991004021392285783925812861821192530917403151452391805634"],["8495653923123431417604973247489272438418190587263600148770280649306958101930","4082367875863433681332203403145435568316851327593401208105741076214120093531"],["1","0"]],vk_delta_2:[["8353516066399360694538747105302262515182301251524941126222712285088022964076","9329524012539638256356482961742014315122377605267454801030953882967973561832"],["16805391589556134376869247619848130874761233086443465978238468412168162326401","10111259694977636294287802909665108497237922060047080343914303287629927847739"],["1","0"]],vk_alphabeta_12:[[["12608968655665301215455851857466367636344427685631271961542642719683786103711","9849575605876329747382930567422916152871921500826003490242628251047652318086"],["6322029441245076030714726551623552073612922718416871603535535085523083939021","8700115492541474338049149013125102281865518624059015445617546140629435818912"],["10674973475340072635573101639867487770811074181475255667220644196793546640210","2926286967251299230490668407790788696102889214647256022788211245826267484824"]],[["9660441540778523475944706619139394922744328902833875392144658911530830074820","19548113127774514328631808547691096362144426239827206966690021428110281506546"],["1870837942477655969123169532603615788122896469891695773961478956740992497097","12536105729661705698805725105036536744930776470051238187456307227425796690780"],["21811903352654147452884857281720047789720483752548991551595462057142824037334","19021616763967199151052893283384285352200445499680068407023236283004353578353"]]],IC:[["11992897507809711711025355300535923222599547639134311050809253678876341466909","17181525095924075896332561978747020491074338784673526378866503154966799128110","1"],["17018665030246167677911144513385572506766200776123272044534328594850561667818","18601114175490465275436712413925513066546725461375425769709566180981674884464","1"],["18799470100699658367834559797874857804183288553462108031963980039244731716542","13064227487174191981628537974951887429496059857753101852163607049188825592007","1"],["17432501889058124609368103715904104425610382063762621017593209214189134571156","13406815149699834788256141097399354592751313348962590382887503595131085938635","1"],["10320964835612716439094703312987075811498239445882526576970512041988148264481","9024164961646353611176283204118089412001502110138072989569118393359029324867","1"],["718355081067365548229685160476620267257521491773976402837645005858953849298","14635482993933988261008156660773180150752190597753512086153001683711587601974","1"],["11777720285956632126519898515392071627539405001940313098390150593689568177535","8483603647274280691250972408211651407952870456587066148445913156086740744515","1"]]};var ea=eo;async function builder(O,U){let $;U=U||{};try{$=await WebAssembly.compile(O)}catch(O){throw console.log(O),console.log("\nTry to run circom --c in order to generate c++ code instead\n"),Error(O)}let J="",en="",es=await WebAssembly.instantiate($,{runtime:{exceptionHandler:function(O){let U;throw Error((U=1==O?"Signal not found.\n":2==O?"Too many signals set.\n":3==O?"Signal already set.\n":4==O?"Assert Failed.\n":5==O?"Not enough memory.\n":6==O?"Input signal array access exceeds the size.\n":"Unknown error.\n")+J)},printErrorMessage:function(){J+=getMessage()+"\n"},writeBufferMessage:function(){let O=getMessage();"\n"===O?(console.log(en),en=""):(""!==en&&(en+=" "),en+=O)},showSharedRWMemory:function(){printSharedRWMemory()}}}),eo=U;return new WitnessCalculator(es,eo);function getMessage(){for(var O="",U=es.exports.getMessageChar();0!=U;)O+=String.fromCharCode(U),U=es.exports.getMessageChar();return O}function printSharedRWMemory(){let O=es.exports.getFieldNumLen32(),U=new Uint32Array(O);for(let $=0;${let $=fnvHash(U),en=parseInt($.slice(0,8),16),es=parseInt($.slice(8,16),16),eo=flatArray(O[U]),ea=this.instance.exports.getInputSignalSize(en,es);if(ea<0)throw Error(`Signal ${U} not found +`);if(eo.lengthea)throw Error(`Too many values for input signal ${U} +`);for(let O=0;O0;)$.unshift(0),en--;return $}function fromArray32(O){var U=BigInt(0);let $=BigInt(4294967296);for(let J=0;J= 0";let eo=this.serializeMessage(O,U,$,en),ea=J.ur(this.zkRLN,eo),eu=J.T8(this.zkRLN,ea),ef=await this.witnessCalculator.calculateWitness(eu,!1),eg=J.RP(this.zkRLN,ef,ea);return new Proof(eg)}verifyRLNProof(O,U){let $;$=O instanceof Uint8Array?O:proofToBytes(O);let es=(0,en.n)(new Uint8Array(8),U.length,0,8);return J.iD(this.zkRLN,concatenate($,es,U))}verifyWithRoots(O,U,...$){let es;es=O instanceof Uint8Array?O:proofToBytes(O);let eo=(0,en.n)(new Uint8Array(8),U.length,0,8),ea=concatenate(...$);return J.vs(this.zkRLN,concatenate(es,eo,U),ea)}verifyWithNoRoot(O,U){let $;$=O instanceof Uint8Array?O:proofToBytes(O);let es=(0,en.n)(new Uint8Array(8),U.length,0,8);return J.vs(this.zkRLN,concatenate($,es,U),new Uint8Array)}}},2355:function(O,U,$){"use strict";let J,en,es,eo,ea;$.d(U,{UF:function(){return createDecoder},Mf:function(){return createEncoder},pq:function(){return createLightNode},gT:function(){return waitForRemotePeer}});var eu,ef,eg,ev,e_,ew,eE,eS,eA,eI,eP,ek,eT,eR,eC,eB,eN,eD,eM,eO,eL,eU,eF,eK,ej,eH,eq,eV,eG,e$,eW,eY,eJ,eQ,eZ,eX,e0,e1,e3,e6,e5,e9,e7,te,tt,tr,ta,tu,th,td,tf,tp,tg,tm,ty,tb,tv,t_,tw,tE,tS,tA,tI,tP,tk,tT,tR,tC,tB,tN,tD,tM,tO,tL,tU,tF,tK,tj,tH,tq,tz,tV,tG,t$,tW,tY,tJ,tQ,tZ,tX,t8,t9,rn,ri,rc,ru,rd,rf,rp,rg,rm,ry,rv,r_,rw={};$.r(rw),$.d(rw,{Ed25519PrivateKey:function(){return Ed25519PrivateKey},Ed25519PublicKey:function(){return Ed25519PublicKey},generateKeyPair:function(){return ed25519_class_generateKeyPair},generateKeyPairFromSeed:function(){return generateKeyPairFromSeed},unmarshalEd25519PrivateKey:function(){return unmarshalEd25519PrivateKey},unmarshalEd25519PublicKey:function(){return unmarshalEd25519PublicKey}});var rE={};$.r(rE),$.d(rE,{RsaPrivateKey:function(){return RsaPrivateKey},RsaPublicKey:function(){return RsaPublicKey},fromJwk:function(){return fromJwk},generateKeyPair:function(){return rsa_class_generateKeyPair},unmarshalRsaPrivateKey:function(){return unmarshalRsaPrivateKey},unmarshalRsaPublicKey:function(){return unmarshalRsaPublicKey}});var rS={};$.r(rS),$.d(rS,{Secp256k1PrivateKey:function(){return Secp256k1PrivateKey},Secp256k1PublicKey:function(){return Secp256k1PublicKey},generateKeyPair:function(){return secp256k1_class_generateKeyPair},unmarshalSecp256k1PrivateKey:function(){return unmarshalSecp256k1PrivateKey},unmarshalSecp256k1PublicKey:function(){return unmarshalSecp256k1PublicKey}});var rA={};$.r(rA),$.d(rA,{dQ:function(){return bitMask},ci:function(){return abstract_utils_bytesToHex},bytesToNumberBE:function(){return abstract_utils_bytesToNumberBE},ty:function(){return utils_bytesToNumberLE},eV:function(){return abstract_utils_concatBytes},n$:function(){return createHmacDrbg},ql:function(){return abstract_utils_ensureBytes},hexToBytes:function(){return abstract_utils_hexToBytes},tL:function(){return abstract_utils_numberToBytesBE},S5:function(){return utils_numberToBytesLE},FF:function(){return utils_validateObject}});var rI={};$.r(rI),$.d(rI,{Ed25519PrivateKey:function(){return ed25519_class_Ed25519PrivateKey},Ed25519PublicKey:function(){return ed25519_class_Ed25519PublicKey},generateKeyPair:function(){return keys_ed25519_class_generateKeyPair},generateKeyPairFromSeed:function(){return ed25519_class_generateKeyPairFromSeed},unmarshalEd25519PrivateKey:function(){return ed25519_class_unmarshalEd25519PrivateKey},unmarshalEd25519PublicKey:function(){return ed25519_class_unmarshalEd25519PublicKey}});var rP={};$.r(rP),$.d(rP,{MAX_KEY_SIZE:function(){return am},RsaPrivateKey:function(){return rsa_class_RsaPrivateKey},RsaPublicKey:function(){return rsa_class_RsaPublicKey},fromJwk:function(){return rsa_class_fromJwk},generateKeyPair:function(){return keys_rsa_class_generateKeyPair},unmarshalRsaPrivateKey:function(){return rsa_class_unmarshalRsaPrivateKey},unmarshalRsaPublicKey:function(){return rsa_class_unmarshalRsaPublicKey}});var rk={};$.r(rk),$.d(rk,{Secp256k1PrivateKey:function(){return secp256k1_class_Secp256k1PrivateKey},Secp256k1PublicKey:function(){return secp256k1_class_Secp256k1PublicKey},generateKeyPair:function(){return keys_secp256k1_class_generateKeyPair},unmarshalSecp256k1PrivateKey:function(){return secp256k1_class_unmarshalSecp256k1PrivateKey},unmarshalSecp256k1PublicKey:function(){return secp256k1_class_unmarshalSecp256k1PublicKey}});let rT=Symbol.for("@libp2p/peer-id");function isPeerId(O){return null!=O&&!!O[rT]}let AbortError=class AbortError extends Error{code;type;constructor(O="The operation was aborted"){super(O),this.code=AbortError.code,this.type=AbortError.type}static code="ABORT_ERR";static type="aborted"};let errors_CodeError=class errors_CodeError extends Error{code;props;constructor(O,U,$){super(O),this.code=U,this.name=$?.name??"CodeError",this.props=$??{}}};let UnexpectedPeerError=class UnexpectedPeerError extends Error{code;constructor(O="Unexpected Peer"){super(O),this.code=UnexpectedPeerError.code}static code="ERR_UNEXPECTED_PEER"};let InvalidCryptoExchangeError=class InvalidCryptoExchangeError extends Error{code;constructor(O="Invalid crypto exchange"){super(O),this.code=InvalidCryptoExchangeError.code}static code="ERR_INVALID_CRYPTO_EXCHANGE"};var rR=$(7954),rC=$(5807);function equals(O,U){if(O===U)return!0;if(O.byteLength!==U.byteLength)return!1;for(let $=0;$Number.MAX_SAFE_INTEGER)throw RangeError("Could not encode varint");return 8}function encodeUint8Array(O,U,$=0){switch(encodingLength(O)){case 8:U[$++]=255&O|rj,O/=128;case 7:U[$++]=255&O|rj,O/=128;case 6:U[$++]=255&O|rj,O/=128;case 5:U[$++]=255&O|rj,O/=128;case 4:U[$++]=255&O|rj,O>>>=7;case 3:U[$++]=255&O|rj,O>>>=7;case 2:U[$++]=255&O|rj,O>>>=7;case 1:U[$++]=255&O,O>>>=7;break;default:throw Error("unreachable")}return U}function encodeUint8ArrayList(O,U,$=0){switch(encodingLength(O)){case 8:U.set($++,255&O|rj),O/=128;case 7:U.set($++,255&O|rj),O/=128;case 6:U.set($++,255&O|rj),O/=128;case 5:U.set($++,255&O|rj),O/=128;case 4:U.set($++,255&O|rj),O>>>=7;case 3:U.set($++,255&O|rj),O>>>=7;case 2:U.set($++,255&O|rj),O>>>=7;case 1:U.set($++,255&O),O>>>=7;break;default:throw Error("unreachable")}return U}function decodeUint8Array(O,U){let $,J=O[U];if($=0+(J&rH),JO+U.length,0));let $=(0,rN.E)(U),J=0;for(let U of O)$.set(U,J),J+=U.length;return(0,rq.P)($)}let Parser=class Parser{index=0;input="";new(O){return this.index=0,this.input=O,this}readAtomically(O){let U=this.index,$=O();return void 0===$&&(this.index=U),$}parseWith(O){let U=O();if(this.index===this.input.length)return U}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(O){return this.readAtomically(()=>{let U=this.readChar();if(U===O)return U})}readSeparator(O,U,$){return this.readAtomically(()=>{if(!(U>0)||void 0!==this.readGivenChar(O))return $()})}readNumber(O,U,$,J){return this.readAtomically(()=>{let en=0,es=0,eo=this.peekChar();if(void 0===eo)return;let ea="0"===eo,eu=2**(8*J)-1;for(;;){let $=this.readAtomically(()=>{let U=this.readChar();if(void 0===U)return;let $=Number.parseInt(U,O);if(!Number.isNaN($))return $});if(void 0===$)break;if(en*=O,(en+=$)>eu||(es+=1,void 0!==U&&es>U))return}return 0===es?void 0:!$&&ea&&es>1?void 0:en})}readIPv4Addr(){return this.readAtomically(()=>{let O=new Uint8Array(4);for(let U=0;Uthis.readNumber(10,3,!1,1));if(void 0===$)return;O[U]=$}return O})}readIPv6Addr(){let readGroups=O=>{for(let U=0;Uthis.readIPv4Addr());if(void 0!==J)return O[$]=J[0],O[$+1]=J[1],O[$+2]=J[2],O[$+3]=J[3],[$+4,!0]}let J=this.readSeparator(":",U,()=>this.readNumber(16,4,!0,2));if(void 0===J)return[$,!1];O[$]=J>>8,O[$+1]=255&J}return[O.length,!1]};return this.readAtomically(()=>{let O=new Uint8Array(16),[U,$]=readGroups(O);if(16===U)return O;if($||void 0===this.readGivenChar(":")||void 0===this.readGivenChar(":"))return;let J=new Uint8Array(14),en=16-(U+2),[es]=readGroups(J.subarray(0,en));return O.set(J.subarray(0,es),16-es),O})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};let rz=45,rV=15,rG=new Parser;function parse_parseIPv4(O){if(!(O.length>rV))return rG.new(O).parseWith(()=>rG.readIPv4Addr())}function parse_parseIPv6(O){if(O.includes("%")&&(O=O.split("%")[0]),!(O.length>rz))return rG.new(O).parseWith(()=>rG.readIPv6Addr())}function parse_parseIP(O){if(O.includes("%")&&(O=O.split("%")[0]),!(O.length>rz))return rG.new(O).parseWith(()=>rG.readIPAddr())}parseInt("0xFFFF",16),new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var r$=$(5700),rW=$(9180),rY=$(1453),rJ=$(2223);function isIPv4(O){return!!parse_parseIPv4(O)}function isIPv6(O){return!!parse_parseIPv6(O)}function isIP(O){return!!parse_parseIP(O)}let rQ=isIPv4,rZ=isIPv6,toBytes=function(O){let U=0;if(rQ(O=O.toString().trim())){let $=new Uint8Array(U+4);return O.split(/\./g).forEach(O=>{$[U++]=255&parseInt(O,10)}),$}if(rZ(O)){let $;let J=O.split(":",8);for($=0;$0;$--)O.push("0");J.splice.apply(J,O)}let en=new Uint8Array(U+16);for($=0;$>8&255,en[U++]=255&O}return en}throw Error("invalid ip address")},ip_toString=function(O,U=0,$){U=~~U,$=$??O.length-U;let J=new DataView(O.buffer);if(4===$){let J=[];for(let en=0;en<$;en++)J.push(O[U+en]);return J.join(".")}if(16===$){let O=[];for(let en=0;en<$;en+=2)O.push(J.getUint16(U+en).toString(16));return O.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""},rX=-1,nt={},nr={},nn=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,rX,"ip6zone"],[43,8,"ipcidr"],[53,rX,"dns",!0],[54,rX,"dns4",!0],[55,rX,"dns6",!0],[56,rX,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,rX,"unix",!1,!0],[421,rX,"ipfs"],[421,rX,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,rX,"garlic64"],[448,0,"tls"],[449,rX,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,rX,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,rX,"memory"]];function createProtocol(O,U,$,J,en){return{code:O,size:U,name:$,resolvable:!!J,path:!!en}}function protocols_table_getProtocol(O){if("number"==typeof O){if(null!=nr[O])return nr[O];throw Error(`no protocol with code: ${O}`)}if("string"==typeof O){if(null!=nt[O])return nt[O];throw Error(`no protocol with name: ${O}`)}throw Error(`invalid protocol id type: ${typeof O}`)}function convertToString(O,U){let $=protocols_table_getProtocol(O);switch($.code){case 4:case 41:return bytes2ip(U);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return bytes2str(U);case 6:case 273:case 33:case 132:return bytes2port(U).toString();case 421:return bytes2mh(U);case 444:case 445:return bytes2onion(U);case 466:return bytes2mb(U);default:return(0,rB.B)(U,"base16")}}function convertToBytes(O,U){let $=protocols_table_getProtocol(O);switch($.code){case 4:case 41:return ip2bytes(U);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return str2bytes(U);case 6:case 273:case 33:case 132:return port2bytes(parseInt(U,10));case 421:return mh2bytes(U);case 444:return onion2bytes(U);case 445:return onion32bytes(U);case 466:return mb2bytes(U);default:return(0,rJ.m)(U,"base16")}}nn.forEach(O=>{let U=createProtocol(...O);nr[U.code]=U,nt[U.name]=U}),protocols_table_getProtocol("ip4"),protocols_table_getProtocol("ip6"),protocols_table_getProtocol("ipcidr");let ni=Object.values(rW.gh).map(O=>O.decoder),no=function(){let O=ni[0].or(ni[1]);return ni.slice(2).forEach(U=>O=O.or(U)),O}();function ip2bytes(O){if(!isIP(O))throw Error("invalid ip address");return toBytes(O)}function bytes2ip(O){let U=ip_toString(O,0,O.length);if(null==U)throw Error("ipBuff is required");if(!isIP(U))throw Error("invalid ip address");return U}function port2bytes(O){let U=new ArrayBuffer(2),$=new DataView(U);return $.setUint16(0,O),new Uint8Array(U)}function bytes2port(O){let U=new DataView(O.buffer);return U.getUint16(O.byteOffset)}function str2bytes(O){let U=(0,rJ.m)(O),$=Uint8Array.from(encode(U.length));return concat_concat([$,U],$.length+U.length)}function bytes2str(O){let U=src_decode(O);if((O=O.slice(encodingLength(U))).length!==U)throw Error("inconsistent lengths");return(0,rB.B)(O)}function mh2bytes(O){let U;U="Q"===O[0]||"1"===O[0]?rY.Jx(rR.base58btc.decode(`z${O}`)).bytes:rC.k0.parse(O).multihash.bytes;let $=Uint8Array.from(encode(U.length));return concat_concat([$,U],$.length+U.length)}function mb2bytes(O){let U=no.decode(O),$=Uint8Array.from(encode(U.length));return concat_concat([$,U],$.length+U.length)}function bytes2mb(O){let U=src_decode(O),$=O.slice(encodingLength(U));if($.length!==U)throw Error("inconsistent lengths");return"u"+(0,rB.B)($,"base64url")}function bytes2mh(O){let U=src_decode(O),$=O.slice(encodingLength(U));if($.length!==U)throw Error("inconsistent lengths");return(0,rB.B)($,"base58btc")}function onion2bytes(O){let U=O.split(":");if(2!==U.length)throw Error(`failed to parse onion addr: ["'${U.join('", "')}'"]' does not contain a port number`);if(16!==U[0].length)throw Error(`failed to parse onion addr: ${U[0]} not a Tor onion address.`);let $=r$.base32.decode("b"+U[0]),J=parseInt(U[1],10);if(J<1||J>65536)throw Error("Port number is not in range(1, 65536)");let en=port2bytes(J);return concat_concat([$,en],$.length+en.length)}function onion32bytes(O){let U=O.split(":");if(2!==U.length)throw Error(`failed to parse onion addr: ["'${U.join('", "')}'"]' does not contain a port number`);if(56!==U[0].length)throw Error(`failed to parse onion addr: ${U[0]} not a Tor onion3 address.`);let $=r$.base32.decode(`b${U[0]}`),J=parseInt(U[1],10);if(J<1||J>65536)throw Error("Port number is not in range(1, 65536)");let en=port2bytes(J);return concat_concat([$,en],$.length+en.length)}function bytes2onion(O){let U=O.slice(0,O.length-2),$=O.slice(O.length-2),J=(0,rB.B)(U,"base32"),en=bytes2port($);return`${J}:${en}`}function stringToMultiaddrParts(O){O=cleanPath(O);let U=[],$=[],J=null,en=O.split("/").slice(1);if(1===en.length&&""===en[0])return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let es=0;es=en.length)throw ParseError("invalid address: "+O);if(!0===ea.path){J=cleanPath(en.slice(es).join("/")),U.push([ea.code,convertToBytes(ea.code,J)]),$.push([ea.code,J]);break}let eu=convertToBytes(ea.code,en[es]);U.push([ea.code,eu]),$.push([ea.code,convertToString(ea.code,eu)])}return{string:stringTuplesToString($),bytes:tuplesToBytes(U),tuples:U,stringTuples:$,path:J}}function bytesToMultiaddrParts(O){let U=[],$=[],J=null,en=0;for(;enO.length)throw ParseError("Invalid address Uint8Array: "+(0,rB.B)(O,"base16"));U.push([es,ef]);let eg=convertToString(es,ef);if($.push([es,eg]),!0===ea.path){J=eg;break}}return{bytes:Uint8Array.from(O),string:stringTuplesToString($),tuples:U,stringTuples:$,path:J}}function stringTuplesToString(O){let U=[];return O.map(O=>{let $=protocols_table_getProtocol(O[0]);return U.push($.name),O.length>1&&null!=O[1]&&U.push(O[1]),null}),cleanPath(U.join("/"))}function tuplesToBytes(O){return concat_concat(O.map(O=>{let U=protocols_table_getProtocol(O[0]),$=Uint8Array.from(encode(U.code));return O.length>1&&null!=O[1]&&($=concat_concat([$,O[1]])),$}))}function sizeForAddr(O,U){if(O.size>0)return O.size/8;if(0===O.size)return 0;{let O=src_decode(U instanceof Uint8Array?U:Uint8Array.from(U));return O+encodingLength(O)}}function cleanPath(O){return"/"+O.trim().split("/").filter(O=>O).join("/")}function ParseError(O){return Error("Error parsing address: "+O)}let na=Symbol.for("nodejs.util.inspect.custom"),nu=[protocols_table_getProtocol("dns").code,protocols_table_getProtocol("dns4").code,protocols_table_getProtocol("dns6").code,protocols_table_getProtocol("dnsaddr").code],nh=new Map,nd=Symbol.for("@multiformats/js-multiaddr/multiaddr");function isMultiaddr(O){return!!O?.[nd]}let DefaultMultiaddr=class DefaultMultiaddr{bytes;#e;#t;#r;#n;[nd]=!0;constructor(O){let U;if(null==O&&(O=""),O instanceof Uint8Array)U=bytesToMultiaddrParts(O);else if("string"==typeof O){if(O.length>0&&"/"!==O.charAt(0))throw Error(`multiaddr "${O}" must start with a "/"`);U=stringToMultiaddrParts(O)}else if(isMultiaddr(O))U=bytesToMultiaddrParts(O.bytes);else throw Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=U.bytes,this.#e=U.string,this.#t=U.tuples,this.#r=U.stringTuples,this.#n=U.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let O,U,$,J;let en="",es=protocols_table_getProtocol("tcp"),eo=protocols_table_getProtocol("udp"),ea=protocols_table_getProtocol("ip4"),eu=protocols_table_getProtocol("ip6"),ef=protocols_table_getProtocol("dns6"),eg=protocols_table_getProtocol("ip6zone");for(let[ev,e_]of this.stringTuples())ev===eg.code&&(en=`%${e_??""}`),nu.includes(ev)&&(U=es.name,J=443,$=`${e_??""}${en}`,O=ev===ef.code?6:4),(ev===es.code||ev===eo.code)&&(U=protocols_table_getProtocol(ev).name,J=parseInt(e_??"")),(ev===ea.code||ev===eu.code)&&(U=protocols_table_getProtocol(ev).name,$=`${e_??""}${en}`,O=ev===eu.code?6:4);if(null==O||null==U||null==$||null==J)throw Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');let ev={family:O,host:$,transport:U,port:J};return ev}protos(){return this.#t.map(([O])=>Object.assign({},protocols_table_getProtocol(O)))}protoCodes(){return this.#t.map(([O])=>O)}protoNames(){return this.#t.map(([O])=>protocols_table_getProtocol(O).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(O){return O=new DefaultMultiaddr(O),new DefaultMultiaddr(this.toString()+O.toString())}decapsulate(O){let U=O.toString(),$=this.toString(),J=$.lastIndexOf(U);if(J<0)throw Error(`Address ${this.toString()} does not contain subaddress: ${O.toString()}`);return new DefaultMultiaddr($.slice(0,J))}decapsulateCode(O){let U=this.tuples();for(let $=U.length-1;$>=0;$--)if(U[$][0]===O)return new DefaultMultiaddr(tuplesToBytes(U.slice(0,$)));return this}getPeerId(){try{let O=[];this.stringTuples().forEach(([U,$])=>{U===nt.p2p.code&&O.push([U,$]),U===nt["p2p-circuit"].code&&(O=[])});let U=O.pop();if(U?.[1]!=null){let O=U[1];if("Q"===O[0]||"1"===O[0])return(0,rB.B)(rR.base58btc.decode(`z${O}`),"base58btc");return(0,rB.B)(rC.k0.parse(O).multihash.bytes,"base58btc")}return null}catch(O){return null}}getPath(){return this.#n}equals(O){return equals(this.bytes,O.bytes)}async resolve(O){let U=this.protos().find(O=>O.resolvable);if(null==U)return[this];let $=nh.get(U.name);if(null==$)throw new errors_CodeError(`no available resolver for ${U.name}`,"ERR_NO_AVAILABLE_RESOLVER");let J=await $(this,O);return J.map(O=>new DefaultMultiaddr(O))}nodeAddress(){let O=this.toOptions();if("tcp"!==O.transport&&"udp"!==O.transport)throw Error(`multiaddr must have a valid format - no protocol with name: "${O.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:O.family,address:O.host,port:O.port}}isThinWaistAddress(O){let U=(O??this).protos();return 2===U.length&&(4===U[0].code||41===U[0].code)&&(6===U[1].code||273===U[1].code)}[na](){return`Multiaddr(${this.#e})`}};function src_multiaddr(O){return new DefaultMultiaddr(O)}!function(O){O.Relay="relay",O.Store="store",O.LightPush="lightpush",O.Filter="filter"}(eu||(eu={})),function(O){O.GENERIC_FAIL="Generic error",O.ENCODE_FAILED="Failed to encode",O.DECODE_FAILED="Failed to decode",O.SIZE_TOO_BIG="Size is too big",O.TOPIC_NOT_CONFIGURED="Topic not configured",O.NO_PEER_AVAILABLE="No peer available",O.REMOTE_PEER_FAULT="Remote peer fault",O.REMOTE_PEER_REJECTED="Remote peer rejected"}(ef||(ef={})),function(O){O.BACKWARD="backward",O.FORWARD="forward"}(eg||(eg={})),function(O){O.BOOTSTRAP="bootstrap",O.PEER_EXCHANGE="peer-exchange"}(ev||(ev={})),function(O){O.PEER_DISCOVERY_BOOTSTRAP="peer:discovery:bootstrap",O.PEER_DISCOVERY_PEER_EXCHANGE="peer:discovery:peer-exchange",O.PEER_CONNECT_BOOTSTRAP="peer:connected:bootstrap",O.PEER_CONNECT_PEER_EXCHANGE="peer:connected:peer-exchange"}(e_||(e_={}));var nf=$(4461);let events_EventEmitter=class events_EventEmitter extends EventTarget{#i=new Map;listenerCount(O){let U=this.#i.get(O);return null==U?0:U.length}addEventListener(O,U,$){super.addEventListener(O,U,$);let J=this.#i.get(O);null==J&&(J=[],this.#i.set(O,J)),J.push({callback:U,once:(!0!==$&&!1!==$&&$?.once)??!1})}removeEventListener(O,U,$){super.removeEventListener(O.toString(),U??null,$);let J=this.#i.get(O);null!=J&&(J=J.filter(({callback:O})=>O!==U),this.#i.set(O,J))}dispatchEvent(O){let U=super.dispatchEvent(O),$=this.#i.get(O.type);return null==$||($=$.filter(({once:O})=>!O),this.#i.set(O.type,$)),U}safeDispatchEvent(O,U){return this.dispatchEvent(new np(O,U))}};let CustomEventPolyfill=class CustomEventPolyfill extends Event{detail;constructor(O,U){super(O,U),this.detail=U?.detail}};let np=globalThis.CustomEvent??CustomEventPolyfill;var ng=$(9710),n_=$(5856),nw=$.t(n_,2);/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */let nE=BigInt(0),nS=BigInt(1),nA=BigInt(2),nI=BigInt(3),nP=BigInt(8),nk=Object.freeze({a:nE,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:nS,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),divNearest=(O,U)=>(O+U/nA)/U,nT={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(O){let{n:U}=nk,$=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),J=-nS*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),en=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),es=$,eo=BigInt("0x100000000000000000000000000000000"),ea=divNearest(es*O,U),eu=divNearest(-J*O,U),ef=esm_mod(O-ea*$-eu*en,U),eg=esm_mod(-ea*J-eu*es,U),ev=ef>eo,e_=eg>eo;if(ev&&(ef=U-ef),e_&&(eg=U-eg),ef>eo||eg>eo)throw Error("splitScalarEndo: Endomorphism failed, k="+O);return{k1neg:ev,k1:ef,k2neg:e_,k2:eg}}},nR=32,nC=32,nB=32,nN=nR+1,nD=2*nR+1;function weierstrass(O){let{a:U,b:$}=nk,J=esm_mod(O*O),en=esm_mod(J*O);return esm_mod(en+U*O+$)}let nM=nk.a===nE;let ShaError=class ShaError extends Error{constructor(O){super(O)}};function assertJacPoint(O){if(!(O instanceof JacobianPoint))throw TypeError("JacobianPoint expected")}let JacobianPoint=class JacobianPoint{constructor(O,U,$){this.x=O,this.y=U,this.z=$}static fromAffine(O){if(!(O instanceof Point))throw TypeError("JacobianPoint#fromAffine: expected Point");return O.equals(Point.ZERO)?JacobianPoint.ZERO:new JacobianPoint(O.x,O.y,nS)}static toAffineBatch(O){let U=invertBatch(O.map(O=>O.z));return O.map((O,$)=>O.toAffine(U[$]))}static normalizeZ(O){return JacobianPoint.toAffineBatch(O).map(JacobianPoint.fromAffine)}equals(O){assertJacPoint(O);let{x:U,y:$,z:J}=this,{x:en,y:es,z:eo}=O,ea=esm_mod(J*J),eu=esm_mod(eo*eo),ef=esm_mod(U*eu),eg=esm_mod(en*ea),ev=esm_mod(esm_mod($*eo)*eu),e_=esm_mod(esm_mod(es*J)*ea);return ef===eg&&ev===e_}negate(){return new JacobianPoint(this.x,esm_mod(-this.y),this.z)}double(){let{x:O,y:U,z:$}=this,J=esm_mod(O*O),en=esm_mod(U*U),es=esm_mod(en*en),eo=O+en,ea=esm_mod(nA*(esm_mod(eo*eo)-J-es)),eu=esm_mod(nI*J),ef=esm_mod(eu*eu),eg=esm_mod(ef-nA*ea),ev=esm_mod(eu*(ea-eg)-nP*es),e_=esm_mod(nA*U*$);return new JacobianPoint(eg,ev,e_)}add(O){assertJacPoint(O);let{x:U,y:$,z:J}=this,{x:en,y:es,z:eo}=O;if(en===nE||es===nE)return this;if(U===nE||$===nE)return O;let ea=esm_mod(J*J),eu=esm_mod(eo*eo),ef=esm_mod(U*eu),eg=esm_mod(en*ea),ev=esm_mod(esm_mod($*eo)*eu),e_=esm_mod(esm_mod(es*J)*ea),ew=esm_mod(eg-ef),eE=esm_mod(e_-ev);if(ew===nE)return eE===nE?this.double():JacobianPoint.ZERO;let eS=esm_mod(ew*ew),eA=esm_mod(ew*eS),eI=esm_mod(ef*eS),eP=esm_mod(eE*eE-eA-nA*eI),ek=esm_mod(eE*(eI-eP)-ev*eA),eT=esm_mod(J*eo*ew);return new JacobianPoint(eP,ek,eT)}subtract(O){return this.add(O.negate())}multiplyUnsafe(O){let U=JacobianPoint.ZERO;if("bigint"==typeof O&&O===nE)return U;let $=normalizeScalar(O);if($===nS)return this;if(!nM){let O=U,J=this;for(;$>nE;)$&nS&&(O=O.add(J)),J=J.double(),$>>=nS;return O}let{k1neg:J,k1:en,k2neg:es,k2:eo}=nT.splitScalar($),ea=U,eu=U,ef=this;for(;en>nE||eo>nE;)en&nS&&(ea=ea.add(ef)),eo&nS&&(eu=eu.add(ef)),ef=ef.double(),en>>=nS,eo>>=nS;return J&&(ea=ea.negate()),es&&(eu=eu.negate()),eu=new JacobianPoint(esm_mod(eu.x*nT.beta),eu.y,eu.z),ea.add(eu)}precomputeWindow(O){let U=nM?128/O+1:256/O+1,$=[],J=this,en=J;for(let es=0;es>=eg,eo>ea&&(eo-=ef,O+=nS);let ev=$,e_=$+Math.abs(eo)-1,ew=U%2!=0,eE=eo<0;0===eo?es=es.add(constTimeNegate(ew,J[ev])):en=en.add(constTimeNegate(eE,J[e_]))}return{p:en,f:es}}multiply(O,U){let $,J,en=normalizeScalar(O);if(nM){let{k1neg:O,k1:es,k2neg:eo,k2:ea}=nT.splitScalar(en),{p:eu,f:ef}=this.wNAF(es,U),{p:eg,f:ev}=this.wNAF(ea,U);eu=constTimeNegate(O,eu),eg=constTimeNegate(eo,eg),eg=new JacobianPoint(esm_mod(eg.x*nT.beta),eg.y,eg.z),$=eu.add(eg),J=ef.add(ev)}else{let{p:O,f:es}=this.wNAF(en,U);$=O,J=es}return JacobianPoint.normalizeZ([$,J])[0]}toAffine(O){let{x:U,y:$,z:J}=this,en=this.equals(JacobianPoint.ZERO);null==O&&(O=en?nP:invert(J));let es=O,eo=esm_mod(es*es),ea=esm_mod(eo*es),eu=esm_mod(U*eo),ef=esm_mod($*ea),eg=esm_mod(J*es);if(en)return Point.ZERO;if(eg!==nS)throw Error("invZ was invalid");return new Point(eu,ef)}};function constTimeNegate(O,U){let $=U.negate();return O?$:U}JacobianPoint.BASE=new JacobianPoint(nk.Gx,nk.Gy,nS),JacobianPoint.ZERO=new JacobianPoint(nE,nS,nE);let nO=new WeakMap;let Point=class Point{constructor(O,U){this.x=O,this.y=U}_setWindowSize(O){this._WINDOW_SIZE=O,nO.delete(this)}hasEvenY(){return this.y%nA===nE}static fromCompressedHex(O){let U=32===O.length,$=bytesToNumber(U?O:O.subarray(1));if(!isValidFieldElement($))throw Error("Point is not on curve");let J=weierstrass($),en=sqrtMod(J),es=(en&nS)===nS;if(U)es&&(en=esm_mod(-en));else{let U=(1&O[0])==1;U!==es&&(en=esm_mod(-en))}let eo=new Point($,en);return eo.assertValidity(),eo}static fromUncompressedHex(O){let U=bytesToNumber(O.subarray(1,nR+1)),$=bytesToNumber(O.subarray(nR+1,2*nR+1)),J=new Point(U,$);return J.assertValidity(),J}static fromHex(O){let U=esm_ensureBytes(O),$=U.length,J=U[0];if($===nR||$===nN&&(2===J||3===J))return this.fromCompressedHex(U);if($===nD&&4===J)return this.fromUncompressedHex(U);throw Error(`Point.fromHex: received invalid point. Expected 32-${nN} compressed bytes or ${nD} uncompressed bytes, not ${$}`)}static fromPrivateKey(O){return Point.BASE.multiply(normalizePrivateKey(O))}static fromSignature(O,U,$){let{r:J,s:en}=normalizeSignature(U);if(![0,1,2,3].includes($))throw Error("Cannot recover: invalid recovery bit");let es=truncateHash(esm_ensureBytes(O)),{n:eo}=nk,ea=2===$||3===$?J+eo:J,eu=invert(ea,eo),ef=esm_mod(-es*eu,eo),eg=esm_mod(en*eu,eo),ev=1&$?"03":"02",e_=Point.fromHex(ev+numTo32bStr(ea)),ew=Point.BASE.multiplyAndAddUnsafe(e_,ef,eg);if(!ew)throw Error("Cannot recover signature: point at infinify");return ew.assertValidity(),ew}toRawBytes(O=!1){return hexToBytes(this.toHex(O))}toHex(O=!1){let U=numTo32bStr(this.x);if(!O)return`04${U}${numTo32bStr(this.y)}`;{let O=this.hasEvenY()?"02":"03";return`${O}${U}`}}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){let O="Point is not on elliptic curve",{x:U,y:$}=this;if(!isValidFieldElement(U)||!isValidFieldElement($))throw Error(O);let J=esm_mod($*$),en=weierstrass(U);if(esm_mod(J-en)!==nE)throw Error(O)}equals(O){return this.x===O.x&&this.y===O.y}negate(){return new Point(this.x,esm_mod(-this.y))}double(){return JacobianPoint.fromAffine(this).double().toAffine()}add(O){return JacobianPoint.fromAffine(this).add(JacobianPoint.fromAffine(O)).toAffine()}subtract(O){return this.add(O.negate())}multiply(O){return JacobianPoint.fromAffine(this).multiply(O,this).toAffine()}multiplyAndAddUnsafe(O,U,$){let J=JacobianPoint.fromAffine(this),en=U===nE||U===nS||this!==Point.BASE?J.multiplyUnsafe(U):J.multiply(U),es=JacobianPoint.fromAffine(O).multiplyUnsafe($),eo=en.add(es);return eo.equals(JacobianPoint.ZERO)?void 0:eo.toAffine()}};function sliceDER(O){return Number.parseInt(O[0],16)>=8?"00"+O:O}function parseDERInt(O){if(O.length<2||2!==O[0])throw Error(`Invalid signature integer tag: ${esm_bytesToHex(O)}`);let U=O[1],$=O.subarray(2,U+2);if(!U||$.length!==U)throw Error("Invalid signature integer: wrong length");if(0===$[0]&&$[1]<=127)throw Error("Invalid signature integer: trailing length");return{data:bytesToNumber($),left:O.subarray(U+2)}}function parseDERSignature(O){if(O.length<2||48!=O[0])throw Error(`Invalid signature tag: ${esm_bytesToHex(O)}`);if(O[1]!==O.length-2)throw Error("Invalid signature: incorrect length");let{data:U,left:$}=parseDERInt(O.subarray(2)),{data:J,left:en}=parseDERInt($);if(en.length)throw Error(`Invalid signature: left bytes after parsing: ${esm_bytesToHex(en)}`);return{r:U,s:J}}Point.BASE=new Point(nk.Gx,nk.Gy),Point.ZERO=new Point(nE,nE);let Signature=class Signature{constructor(O,U){this.r=O,this.s=U,this.assertValidity()}static fromCompact(O){let U=O instanceof Uint8Array,$="Signature.fromCompact";if("string"!=typeof O&&!U)throw TypeError(`${$}: Expected string or Uint8Array`);let J=U?esm_bytesToHex(O):O;if(128!==J.length)throw Error(`${$}: Expected 64-byte hex`);return new Signature(hexToNumber(J.slice(0,64)),hexToNumber(J.slice(64,128)))}static fromDER(O){let U=O instanceof Uint8Array;if("string"!=typeof O&&!U)throw TypeError("Signature.fromDER: Expected string or Uint8Array");let{r:$,s:J}=parseDERSignature(U?O:hexToBytes(O));return new Signature($,J)}static fromHex(O){return this.fromDER(O)}assertValidity(){let{r:O,s:U}=this;if(!isWithinCurveOrder(O))throw Error("Invalid Signature: r must be 0 < r < n");if(!isWithinCurveOrder(U))throw Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){let O=nk.n>>nS;return this.s>O}normalizeS(){return this.hasHighS()?new Signature(this.r,esm_mod(-this.s,nk.n)):this}toDERRawBytes(){return hexToBytes(this.toDERHex())}toDERHex(){let O=sliceDER(numberToHexUnpadded(this.s)),U=sliceDER(numberToHexUnpadded(this.r)),$=O.length/2,J=U.length/2,en=numberToHexUnpadded($),es=numberToHexUnpadded(J),eo=numberToHexUnpadded(J+$+4);return`30${eo}02${es}${U}02${en}${O}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return hexToBytes(this.toCompactHex())}toCompactHex(){return numTo32bStr(this.r)+numTo32bStr(this.s)}};function esm_concatBytes(...O){if(!O.every(O=>O instanceof Uint8Array))throw Error("Uint8Array list expected");if(1===O.length)return O[0];let U=O.reduce((O,U)=>O+U.length,0),$=new Uint8Array(U);for(let U=0,J=0;UU.toString(16).padStart(2,"0"));function esm_bytesToHex(O){if(!(O instanceof Uint8Array))throw Error("Expected Uint8Array");let U="";for(let $=0;$0)return BigInt(O);if("bigint"==typeof O&&isWithinCurveOrder(O))return O;throw TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function esm_mod(O,U=nk.P){let $=O%U;return $>=nE?$:U+$}function pow2(O,U){let{P:$}=nk,J=O;for(;U-- >nE;)J*=J,J%=$;return J}function sqrtMod(O){let{P:U}=nk,$=BigInt(6),J=BigInt(11),en=BigInt(22),es=BigInt(23),eo=BigInt(44),ea=BigInt(88),eu=O*O*O%U,ef=eu*eu*O%U,eg=pow2(ef,nI)*ef%U,ev=pow2(eg,nI)*ef%U,e_=pow2(ev,nA)*eu%U,ew=pow2(e_,J)*e_%U,eE=pow2(ew,en)*ew%U,eS=pow2(eE,eo)*eE%U,eA=pow2(eS,ea)*eS%U,eI=pow2(eA,eo)*eE%U,eP=pow2(eI,nI)*ef%U,ek=pow2(eP,es)*ew%U,eT=pow2(ek,$)*eu%U,eR=pow2(eT,nA),eC=eR*eR%U;if(eC!==O)throw Error("Cannot find square root");return eR}function invert(O,U=nk.P){if(O===nE||U<=nE)throw Error(`invert: expected positive integers, got n=${O} mod=${U}`);let $=esm_mod(O,U),J=U,en=nE,es=nS,eo=nS,ea=nE;for(;$!==nE;){let O=J/$,U=J%$,eu=en-eo*O,ef=es-ea*O;J=$,$=U,en=eo,es=ea,eo=eu,ea=ef}let eu=J;if(eu!==nS)throw Error("invert: does not exist");return esm_mod(en,U)}function invertBatch(O,U=nk.P){let $=Array(O.length),J=O.reduce((O,J,en)=>J===nE?O:($[en]=O,esm_mod(O*J,U)),nS),en=invert(J,U);return O.reduceRight((O,J,en)=>J===nE?O:($[en]=esm_mod(O*$[en],U),esm_mod(O*J,U)),en),$}function bits2int_2(O){let U=8*O.length-8*nC,$=bytesToNumber(O);return U>0?$>>BigInt(U):$}function truncateHash(O,U=!1){let $=bits2int_2(O);if(U)return $;let{n:J}=nk;return $>=J?$-J:$}let HmacDrbg=class HmacDrbg{constructor(O,U){if(this.hashLen=O,this.qByteLen=U,"number"!=typeof O||O<2)throw Error("hashLen must be a number");if("number"!=typeof U||U<2)throw Error("qByteLen must be a number");this.v=new Uint8Array(O).fill(1),this.k=new Uint8Array(O).fill(0),this.counter=0}hmac(...O){return nH.hmacSha256(this.k,...O)}hmacSync(...O){return en(this.k,...O)}checkSync(){if("function"!=typeof en)throw new ShaError("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(O=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),O),this.v=await this.hmac(this.v),0!==O.length&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),O),this.v=await this.hmac(this.v))}reseedSync(O=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),O),this.v=this.hmacSync(this.v),0!==O.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),O),this.v=this.hmacSync(this.v))}async generate(){this.incr();let O=0,U=[];for(;O0)U=BigInt(O);else if("string"==typeof O){if(O.length!==2*nC)throw Error("Expected 32 bytes of private key");U=hexToNumber(O)}else if(O instanceof Uint8Array){if(O.length!==nC)throw Error("Expected 32 bytes of private key");U=bytesToNumber(O)}else throw TypeError("Expected valid private key");if(!isWithinCurveOrder(U))throw Error("Expected private key: 0 < key < n");return U}function normalizePublicKey(O){return O instanceof Point?(O.assertValidity(),O):Point.fromHex(O)}function normalizeSignature(O){if(O instanceof Signature)return O.assertValidity(),O;try{return Signature.fromDER(O)}catch(U){return Signature.fromCompact(O)}}function getPublicKey(O,U=!1){return Point.fromPrivateKey(O).toRawBytes(U)}function bits2int(O){let U=O.length>nR?O.slice(0,nR):O;return bytesToNumber(U)}function bits2octets(O){let U=bits2int(O),$=esm_mod(U,nk.n);return int2octets(${O=esm_ensureBytes(O);let U=nC+8;if(O.length1024)throw Error("Expected valid bytes of private key as per FIPS 186");let $=esm_mod(bytesToNumber(O),nk.n-nS)+nS;return numTo32b($)},randomBytes:(O=32)=>{if(nK.web)return nK.web.getRandomValues(new Uint8Array(O));if(nK.node){let{randomBytes:U}=nK.node;return Uint8Array.from(U(O))}throw Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>nH.hashToPrivateKey(nH.randomBytes(nC+8)),precompute(O=8,U=Point.BASE){let $=U===Point.BASE?U:new Point(U.x,U.y);return $._setWindowSize(O),$.multiply(nI),$},sha256:async(...O)=>{if(nK.web){let U=await nK.web.subtle.digest("SHA-256",esm_concatBytes(...O));return new Uint8Array(U)}if(nK.node){let{createHash:U}=nK.node,$=U("sha256");return O.forEach(O=>$.update(O)),Uint8Array.from($.digest())}throw Error("The environment doesn't have sha256 function")},hmacSha256:async(O,...U)=>{if(nK.web){let $=await nK.web.subtle.importKey("raw",O,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),J=esm_concatBytes(...U),en=await nK.web.subtle.sign("HMAC",$,J);return new Uint8Array(en)}if(nK.node){let{createHmac:$}=nK.node,J=$("sha256",O);return U.forEach(O=>J.update(O)),Uint8Array.from(J.digest())}throw Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(O,...U)=>{let $=nj[O];if(void 0===$){let U=await nH.sha256(Uint8Array.from(O,O=>O.charCodeAt(0)));$=esm_concatBytes(U,U),nj[O]=$}return nH.sha256($,...U)},taggedHashSync:(O,...U)=>{if("function"!=typeof J)throw new ShaError("sha256Sync is undefined, you need to set it");let $=nj[O];if(void 0===$){let U=J(Uint8Array.from(O,O=>O.charCodeAt(0)));$=esm_concatBytes(U,U),nj[O]=$}return J($,...U)},_JacobianPoint:JacobianPoint};Object.defineProperties(nH,{sha256Sync:{configurable:!1,get:()=>J,set(O){J||(J=O)}},hmacSha256Sync:{configurable:!1,get:()=>en,set(O){en||(en=O)}}});var nq=$(9055);function keccak256(O){return new Uint8Array(nq.keccak256.arrayBuffer(O))}function verifySignature(O,U,$){try{let J=Signature.fromCompact(O.slice(0,64));return verify(J,U,$)}catch{return!1}}let nV="Invalid record id",nG=2;function multiaddrFromFields(O,U,$,J){return src_multiaddr("/"+O+"/"+convertToString(O,$)).encapsulate(src_multiaddr("/"+U+"/"+convertToString(U,J)))}function locationMultiaddrFromEnrFields(O,U){let $;switch(U){case"udp":return locationMultiaddrFromEnrFields(O,"udp4")||locationMultiaddrFromEnrFields(O,"udp6");case"tcp":return locationMultiaddrFromEnrFields(O,"tcp4")||locationMultiaddrFromEnrFields(O,"tcp6")}let J=U.endsWith("6"),en=O.get(J?"ip6":"ip");if(!en)return;let es=U.slice(0,3);switch(es){case"udp":$=J?O.get("udp6"):O.get("udp");break;case"tcp":$=J?O.get("tcp6"):O.get("tcp");break;default:return}if($)return multiaddrFromFields(J?"ip6":"ip4",es,en,$)}$(9642),$(8289);var n$=$(2595);let src_errors_CodeError=class src_errors_CodeError extends Error{code;props;constructor(O,U,$){super(O),this.code=U,this.name=$?.name??"CodeError",this.props=$??{}}};var base_x=function(O,U){if(O.length>=255)throw TypeError("Alphabet too long");for(var $=new Uint8Array(256),J=0;J<$.length;J++)$[J]=255;for(var en=0;en>>0,eo=new Uint8Array(es);O[U];){var eg=$[O.charCodeAt(U)];if(255===eg)return;for(var ev=0,e_=es-1;(0!==eg||ev>>0,eo[e_]=eg%256>>>0,eg=eg/256>>>0;if(0!==eg)throw Error("Non-zero carry");en=ev,U++}if(" "!==O[U]){for(var ew=es-en;ew!==es&&0===eo[ew];)ew++;for(var eE=new Uint8Array(J+(es-ew)),eS=J;ew!==es;)eE[eS++]=eo[ew++];return eE}}}function decode(O){var $=decodeUnsafe(O);if($)return $;throw Error(`Non-${U} character`)}return{encode:function(U){if(U instanceof Uint8Array||(ArrayBuffer.isView(U)?U=new Uint8Array(U.buffer,U.byteOffset,U.byteLength):Array.isArray(U)&&(U=Uint8Array.from(U))),!(U instanceof Uint8Array))throw TypeError("Expected Uint8Array");if(0===U.length)return"";for(var $=0,J=0,en=0,es=U.length;en!==es&&0===U[en];)en++,$++;for(var eo=(es-en)*eg+1>>>0,ef=new Uint8Array(eo);en!==es;){for(var ev=U[en],e_=0,ew=eo-1;(0!==ev||e_>>0,ef[ew]=ev%ea>>>0,ev=ev/ea>>>0;if(0!==ev)throw Error("Non-zero carry");J=e_,en++}for(var eE=eo-J;eE!==eo&&0===ef[eE];)eE++;for(var eS=eu.repeat($);eE{if(O instanceof Uint8Array&&"Uint8Array"===O.constructor.name)return O;if(O instanceof ArrayBuffer)return new Uint8Array(O);if(ArrayBuffer.isView(O))return new Uint8Array(O.buffer,O.byteOffset,O.byteLength);throw Error("Unknown type, must be binary type")};let Encoder=class Encoder{constructor(O,U,$){this.name=O,this.prefix=U,this.baseEncode=$}encode(O){if(O instanceof Uint8Array)return`${this.prefix}${this.baseEncode(O)}`;throw Error("Unknown type, must be binary type")}};let Decoder=class Decoder{constructor(O,U,$){if(this.name=O,this.prefix=U,void 0===U.codePointAt(0))throw Error("Invalid prefix character");this.prefixCodePoint=U.codePointAt(0),this.baseDecode=$}decode(O){if("string"==typeof O){if(O.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(O)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(O.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(O){return or(this,O)}};let ComposedDecoder=class ComposedDecoder{constructor(O){this.decoders=O}or(O){return or(this,O)}decode(O){let U=O[0],$=this.decoders[U];if($)return $.decode(O);throw RangeError(`Unable to decode multibase string ${JSON.stringify(O)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};let or=(O,U)=>new ComposedDecoder({...O.decoders||{[O.prefix]:O},...U.decoders||{[U.prefix]:U}});let Codec=class Codec{constructor(O,U,$,J){this.name=O,this.prefix=U,this.baseEncode=$,this.baseDecode=J,this.encoder=new Encoder(O,U,$),this.decoder=new Decoder(O,U,J)}encode(O){return this.encoder.encode(O)}decode(O){return this.decoder.decode(O)}};let from=({name:O,prefix:U,encode:$,decode:J})=>new Codec(O,U,$,J),baseX=({prefix:O,name:U,alphabet:$})=>{let{encode:J,decode:en}=base_x($,U);return from({prefix:O,name:U,encode:J,decode:O=>bytes_coerce(en(O))})},base_decode=(O,U,$,J)=>{let en={};for(let O=0;O=8&&(ea-=8,eo[ef++]=255&eu>>ea)}if(ea>=$||255&eu<<8-ea)throw SyntaxError("Unexpected end of data");return eo},base_encode=(O,U,$)=>{let J="="===U[U.length-1],en=(1<<$)-1,es="",eo=0,ea=0;for(let J=0;J$;)eo-=$,es+=U[en&ea>>eo];if(eo&&(es+=U[en&ea<<$-eo]),J)for(;es.length*$&7;)es+="=";return es},rfc4648=({name:O,prefix:U,bitsPerChar:$,alphabet:J})=>from({prefix:U,name:O,encode:O=>base_encode(O,J,$),decode:U=>base_decode(U,J,$,O)}),nW=baseX({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"});baseX({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var nY=128,nJ=-128,nQ=2147483648;function varint_encode(O,U,$){U=U||[];for(var J=$=$||0;O>=nQ;)U[$++]=255&O|nY,O/=128;for(;O&nJ;)U[$++]=255&O|nY,O>>>=7;return U[$]=0|O,varint_encode.bytes=$-J+1,U}var nZ=128,nX=127;function read(O,U){var $,J=0,U=U||0,en=0,es=U,eo=O.length;do{if(es>=eo)throw read.bytes=0,RangeError("Could not decode varint");$=O[es++],J+=en<28?($&nX)<=nZ);return read.bytes=es-U,J}var n0=128,n3=16384,n6=2097152,n4=268435456,n5=34359738368,n9=4398046511104,n7=562949953421312,ia=72057594037927940,il=0x7fffffffffffffff,ic={encode:varint_encode,decode:read,encodingLength:function(O){return O(ic.encode(O,U,$),U),varint_encodingLength=O=>ic.encodingLength(O),create=(O,U)=>{let $=U.byteLength,J=varint_encodingLength(O),en=J+varint_encodingLength($),es=new Uint8Array(en+$);return encodeTo(O,es,0),encodeTo($,es,J),es.set(U,en),new Digest(O,$,U,es)};let Digest=class Digest{constructor(O,U,$,J){this.code=O,this.size=U,this.digest=$,this.bytes=J}};let iu=0,ih="identity",ig=bytes_coerce,identity_digest=O=>create(iu,ig(O)),iy={code:iu,name:ih,encode:ig,digest:identity_digest},hasher_from=({name:O,code:U,encode:$})=>new Hasher(O,U,$);let Hasher=class Hasher{constructor(O,U,$){this.name=O,this.code=U,this.encode=$}digest(O){if(O instanceof Uint8Array){let U=this.encode(O);return U instanceof Uint8Array?create(this.code,U):U.then(O=>create(this.code,O))}throw Error("Unknown type, must be binary type")}};let sha=O=>async U=>new Uint8Array(await crypto.subtle.digest(O,U)),ib=hasher_from({name:"sha2-256",code:18,encode:sha("SHA-256")});hasher_from({name:"sha2-512",code:19,encode:sha("SHA-512")});var i_=$(7420),iw=$.t(i_,2);/*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) */let iE=BigInt(0),iS=BigInt(1),iA=BigInt(2),iI=BigInt(8),iP=BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),iT=Object.freeze({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l:iP,n:iP,h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")}),iR=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),iC=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742");let iB=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),iN=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),iD=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),iM=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");let ExtendedPoint=class ExtendedPoint{constructor(O,U,$,J){this.x=O,this.y=U,this.z=$,this.t=J}static fromAffine(O){if(!(O instanceof esm_Point))throw TypeError("ExtendedPoint#fromAffine: expected Point");return O.equals(esm_Point.ZERO)?ExtendedPoint.ZERO:new ExtendedPoint(O.x,O.y,iS,lib_esm_mod(O.x*O.y))}static toAffineBatch(O){let U=esm_invertBatch(O.map(O=>O.z));return O.map((O,$)=>O.toAffine(U[$]))}static normalizeZ(O){return this.toAffineBatch(O).map(this.fromAffine)}equals(O){assertExtPoint(O);let{x:U,y:$,z:J}=this,{x:en,y:es,z:eo}=O,ea=lib_esm_mod(U*eo),eu=lib_esm_mod(en*J),ef=lib_esm_mod($*eo),eg=lib_esm_mod(es*J);return ea===eu&&ef===eg}negate(){return new ExtendedPoint(lib_esm_mod(-this.x),this.y,this.z,lib_esm_mod(-this.t))}double(){let{x:O,y:U,z:$}=this,{a:J}=iT,en=lib_esm_mod(O*O),es=lib_esm_mod(U*U),eo=lib_esm_mod(iA*lib_esm_mod($*$)),ea=lib_esm_mod(J*en),eu=O+U,ef=lib_esm_mod(lib_esm_mod(eu*eu)-en-es),eg=ea+es,ev=eg-eo,e_=ea-es,ew=lib_esm_mod(ef*ev),eE=lib_esm_mod(eg*e_),eS=lib_esm_mod(ef*e_),eA=lib_esm_mod(ev*eg);return new ExtendedPoint(ew,eE,eA,eS)}add(O){assertExtPoint(O);let{x:U,y:$,z:J,t:en}=this,{x:es,y:eo,z:ea,t:eu}=O,ef=lib_esm_mod(($-U)*(eo+es)),eg=lib_esm_mod(($+U)*(eo-es)),ev=lib_esm_mod(eg-ef);if(ev===iE)return this.double();let e_=lib_esm_mod(J*iA*eu),ew=lib_esm_mod(en*iA*ea),eE=ew+e_,eS=eg+ef,eA=ew-e_,eI=lib_esm_mod(eE*ev),eP=lib_esm_mod(eS*eA),ek=lib_esm_mod(eE*eA),eT=lib_esm_mod(ev*eS);return new ExtendedPoint(eI,eP,eT,ek)}subtract(O){return this.add(O.negate())}precomputeWindow(O){let U=1+256/O,$=[],J=this,en=J;for(let es=0;es>=eg,eo>ea&&(eo-=ef,O+=iS);let ev=$,e_=$+Math.abs(eo)-1,ew=U%2!=0,eE=eo<0;0===eo?es=es.add(esm_constTimeNegate(ew,J[ev])):en=en.add(esm_constTimeNegate(eE,J[e_]))}return ExtendedPoint.normalizeZ([en,es])[0]}multiply(O,U){return this.wNAF(esm_normalizeScalar(O,iT.l),U)}multiplyUnsafe(O){let U=esm_normalizeScalar(O,iT.l,!1),$=ExtendedPoint.BASE,J=ExtendedPoint.ZERO;if(U===iE)return J;if(this.equals(J)||U===iS)return this;if(this.equals($))return this.wNAF(U);let en=J,es=this;for(;U>iE;)U&iS&&(en=en.add(es)),es=es.double(),U>>=iS;return en}isSmallOrder(){return this.multiplyUnsafe(iT.h).equals(ExtendedPoint.ZERO)}isTorsionFree(){let O=this.multiplyUnsafe(iT.l/iA).double();return iT.l%iA&&(O=O.add(this)),O.equals(ExtendedPoint.ZERO)}toAffine(O){let{x:U,y:$,z:J}=this,en=this.equals(ExtendedPoint.ZERO);null==O&&(O=en?iI:esm_invert(J));let es=lib_esm_mod(U*O),eo=lib_esm_mod($*O),ea=lib_esm_mod(J*O);if(en)return esm_Point.ZERO;if(ea!==iS)throw Error("invZ was invalid");return new esm_Point(es,eo)}fromRistrettoBytes(){legacyRist()}toRistrettoBytes(){legacyRist()}fromRistrettoHash(){legacyRist()}};function esm_constTimeNegate(O,U){let $=U.negate();return O?$:U}function assertExtPoint(O){if(!(O instanceof ExtendedPoint))throw TypeError("ExtendedPoint expected")}function assertRstPoint(O){if(!(O instanceof RistrettoPoint))throw TypeError("RistrettoPoint expected")}function legacyRist(){throw Error("Legacy method: switch to RistrettoPoint")}ExtendedPoint.BASE=new ExtendedPoint(iT.Gx,iT.Gy,iS,lib_esm_mod(iT.Gx*iT.Gy)),ExtendedPoint.ZERO=new ExtendedPoint(iE,iS,iS,iE);let RistrettoPoint=class RistrettoPoint{constructor(O){this.ep=O}static calcElligatorRistrettoMap(O){let{d:U}=iT,$=lib_esm_mod(iC*O*O),J=lib_esm_mod(($+iS)*iD),en=BigInt(-1),es=lib_esm_mod((en-U*$)*lib_esm_mod($+U)),{isValid:eo,value:ea}=uvRatio(J,es),eu=lib_esm_mod(ea*O);edIsNegative(eu)||(eu=lib_esm_mod(-eu)),eo||(ea=eu),eo||(en=$);let ef=lib_esm_mod(en*($-iS)*iM-es),eg=ea*ea,ev=lib_esm_mod((ea+ea)*es),e_=lib_esm_mod(ef*iB),ew=lib_esm_mod(iS-eg),eE=lib_esm_mod(iS+eg);return new ExtendedPoint(lib_esm_mod(ev*eE),lib_esm_mod(ew*e_),lib_esm_mod(e_*eE),lib_esm_mod(ev*ew))}static hashToCurve(O){O=lib_esm_ensureBytes(O,64);let U=bytes255ToNumberLE(O.slice(0,32)),$=this.calcElligatorRistrettoMap(U),J=bytes255ToNumberLE(O.slice(32,64)),en=this.calcElligatorRistrettoMap(J);return new RistrettoPoint($.add(en))}static fromHex(O){O=lib_esm_ensureBytes(O,32);let{a:U,d:$}=iT,J="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",en=bytes255ToNumberLE(O);if(!esm_equalBytes(numberTo32BytesLE(en),O)||edIsNegative(en))throw Error(J);let es=lib_esm_mod(en*en),eo=lib_esm_mod(iS+U*es),ea=lib_esm_mod(iS-U*es),eu=lib_esm_mod(eo*eo),ef=lib_esm_mod(ea*ea),eg=lib_esm_mod(U*$*eu-ef),{isValid:ev,value:e_}=invertSqrt(lib_esm_mod(eg*ef)),ew=lib_esm_mod(e_*ea),eE=lib_esm_mod(e_*ew*eg),eS=lib_esm_mod((en+en)*ew);edIsNegative(eS)&&(eS=lib_esm_mod(-eS));let eA=lib_esm_mod(eo*eE),eI=lib_esm_mod(eS*eA);if(!ev||edIsNegative(eI)||eA===iE)throw Error(J);return new RistrettoPoint(new ExtendedPoint(eS,eA,iS,eI))}toRawBytes(){let O,{x:U,y:$,z:J,t:en}=this.ep,es=lib_esm_mod(lib_esm_mod(J+$)*lib_esm_mod(J-$)),eo=lib_esm_mod(U*$),ea=lib_esm_mod(eo*eo),{value:eu}=invertSqrt(lib_esm_mod(es*ea)),ef=lib_esm_mod(eu*es),eg=lib_esm_mod(eu*eo),ev=lib_esm_mod(ef*eg*en);if(edIsNegative(en*ev)){let J=lib_esm_mod($*iC),en=lib_esm_mod(U*iC);U=J,$=en,O=lib_esm_mod(ef*iN)}else O=eg;edIsNegative(U*ev)&&($=lib_esm_mod(-$));let e_=lib_esm_mod((J-$)*O);return edIsNegative(e_)&&(e_=lib_esm_mod(-e_)),numberTo32BytesLE(e_)}toHex(){return lib_esm_bytesToHex(this.toRawBytes())}toString(){return this.toHex()}equals(O){assertRstPoint(O);let U=this.ep,$=O.ep,J=lib_esm_mod(U.x*$.y)===lib_esm_mod(U.y*$.x),en=lib_esm_mod(U.y*$.y)===lib_esm_mod(U.x*$.x);return J||en}add(O){return assertRstPoint(O),new RistrettoPoint(this.ep.add(O.ep))}subtract(O){return assertRstPoint(O),new RistrettoPoint(this.ep.subtract(O.ep))}multiply(O){return new RistrettoPoint(this.ep.multiply(O))}multiplyUnsafe(O){return new RistrettoPoint(this.ep.multiplyUnsafe(O))}};RistrettoPoint.BASE=new RistrettoPoint(ExtendedPoint.BASE),RistrettoPoint.ZERO=new RistrettoPoint(ExtendedPoint.ZERO);let iO=new WeakMap;let esm_Point=class esm_Point{constructor(O,U){this.x=O,this.y=U}_setWindowSize(O){this._WINDOW_SIZE=O,iO.delete(this)}static fromHex(O,U=!0){let{d:$,P:J}=iT;O=lib_esm_ensureBytes(O,32);let en=O.slice();en[31]=-129&O[31];let es=esm_bytesToNumberLE(en);if(U&&es>=J)throw Error("Expected 0 < hex < P");if(!U&&es>=iR)throw Error("Expected 0 < hex < 2**256");let eo=lib_esm_mod(es*es),ea=lib_esm_mod(eo-iS),eu=lib_esm_mod($*eo+iS),{isValid:ef,value:eg}=uvRatio(ea,eu);if(!ef)throw Error("Point.fromHex: invalid y coordinate");let ev=(eg&iS)===iS,e_=(128&O[31])!=0;return e_!==ev&&(eg=lib_esm_mod(-eg)),new esm_Point(eg,es)}static async fromPrivateKey(O){return(await getExtendedPublicKey(O)).point}toRawBytes(){let O=numberTo32BytesLE(this.y);return O[31]|=this.x&iS?128:0,O}toHex(){return lib_esm_bytesToHex(this.toRawBytes())}toX25519(){let{y:O}=this,U=lib_esm_mod((iS+O)*esm_invert(iS-O));return numberTo32BytesLE(U)}isTorsionFree(){return ExtendedPoint.fromAffine(this).isTorsionFree()}equals(O){return this.x===O.x&&this.y===O.y}negate(){return new esm_Point(lib_esm_mod(-this.x),this.y)}add(O){return ExtendedPoint.fromAffine(this).add(ExtendedPoint.fromAffine(O)).toAffine()}subtract(O){return this.add(O.negate())}multiply(O){return ExtendedPoint.fromAffine(this).multiply(O,this).toAffine()}};esm_Point.BASE=new esm_Point(iT.Gx,iT.Gy),esm_Point.ZERO=new esm_Point(iE,iS);let esm_Signature=class esm_Signature{constructor(O,U){this.r=O,this.s=U,this.assertValidity()}static fromHex(O){let U=lib_esm_ensureBytes(O,64),$=esm_Point.fromHex(U.slice(0,32),!1),J=esm_bytesToNumberLE(U.slice(32,64));return new esm_Signature($,J)}assertValidity(){let{r:O,s:U}=this;if(!(O instanceof esm_Point))throw Error("Expected Point instance");return esm_normalizeScalar(U,iT.l,!1),this}toRawBytes(){let O=new Uint8Array(64);return O.set(this.r.toRawBytes()),O.set(numberTo32BytesLE(this.s),32),O}toHex(){return lib_esm_bytesToHex(this.toRawBytes())}};function lib_esm_concatBytes(...O){if(!O.every(O=>O instanceof Uint8Array))throw Error("Expected Uint8Array list");if(1===O.length)return O[0];let U=O.reduce((O,U)=>O+U.length,0),$=new Uint8Array(U);for(let U=0,J=0;UU.toString(16).padStart(2,"0"));function lib_esm_bytesToHex(O){if(!(O instanceof Uint8Array))throw Error("Uint8Array expected");let U="";for(let $=0;$=iE?$:U+$}function esm_invert(O,U=iT.P){if(O===iE||U<=iE)throw Error(`invert: expected positive integers, got n=${O} mod=${U}`);let $=lib_esm_mod(O,U),J=U,en=iE,es=iS,eo=iS,ea=iE;for(;$!==iE;){let O=J/$,U=J%$,eu=en-eo*O,ef=es-ea*O;J=$,$=U,en=eo,es=ea,eo=eu,ea=ef}let eu=J;if(eu!==iS)throw Error("invert: does not exist");return lib_esm_mod(en,U)}function esm_invertBatch(O,U=iT.P){let $=Array(O.length),J=O.reduce((O,J,en)=>J===iE?O:($[en]=O,lib_esm_mod(O*J,U)),iS),en=esm_invert(J,U);return O.reduceRight((O,J,en)=>J===iE?O:($[en]=lib_esm_mod(O*$[en],U),lib_esm_mod(O*J,U)),en),$}function esm_pow2(O,U){let{P:$}=iT,J=O;for(;U-- >iE;)J*=J,J%=$;return J}function pow_2_252_3(O){let{P:U}=iT,$=BigInt(5),J=BigInt(10),en=BigInt(20),es=BigInt(40),eo=BigInt(80),ea=O*O%U,eu=ea*O%U,ef=esm_pow2(eu,iA)*eu%U,eg=esm_pow2(ef,iS)*O%U,ev=esm_pow2(eg,$)*eg%U,e_=esm_pow2(ev,J)*ev%U,ew=esm_pow2(e_,en)*e_%U,eE=esm_pow2(ew,es)*ew%U,eS=esm_pow2(eE,eo)*eE%U,eA=esm_pow2(eS,eo)*eE%U,eI=esm_pow2(eA,J)*ev%U,eP=esm_pow2(eI,iA)*O%U;return{pow_p_5_8:eP,b2:eu}}function uvRatio(O,U){let $=lib_esm_mod(U*U*U),J=lib_esm_mod($*$*U),en=pow_2_252_3(O*J).pow_p_5_8,es=lib_esm_mod(O*$*en),eo=lib_esm_mod(U*es*es),ea=es,eu=lib_esm_mod(es*iC),ef=eo===O,eg=eo===lib_esm_mod(-O),ev=eo===lib_esm_mod(-O*iC);return ef&&(es=ea),(eg||ev)&&(es=eu),edIsNegative(es)&&(es=lib_esm_mod(-es)),{isValid:ef||eg,value:es}}function invertSqrt(O){return uvRatio(iS,O)}function modlLE(O){return lib_esm_mod(esm_bytesToNumberLE(O),iT.l)}function esm_equalBytes(O,U){if(O.length!==U.length)return!1;for(let $=0;${if((O=lib_esm_ensureBytes(O)).length<40||O.length>1024)throw Error("Expected 40-1024 bytes of private key as per FIPS 186");return lib_esm_mod(esm_bytesToNumberLE(O),iT.l-iS)+iS},randomBytes:(O=32)=>{if(iF.web)return iF.web.getRandomValues(new Uint8Array(O));if(iF.node){let{randomBytes:U}=iF.node;return new Uint8Array(U(O).buffer)}throw Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>iK.randomBytes(32),sha512:async(...O)=>{let U=lib_esm_concatBytes(...O);if(iF.web){let O=await iF.web.subtle.digest("SHA-512",U.buffer);return new Uint8Array(O)}if(iF.node)return Uint8Array.from(iF.node.createHash("sha512").update(U).digest());throw Error("The environment doesn't have sha512 function")},precompute(O=8,U=esm_Point.BASE){let $=U.equals(esm_Point.BASE)?U:new esm_Point(U.x,U.y);return $._setWindowSize(O),$.multiply(iA),$},sha512Sync:void 0};Object.defineProperties(iK,{sha512Sync:{configurable:!1,get:()=>es,set(O){es||(es=O)}}});let ij=32,iH=64,iq=32;async function generateKey(){let O=iK.randomPrivateKey(),U=await esm_getPublicKey(O),$=concatKeys(O,U);return{privateKey:$,publicKey:U}}async function generateKeyFromSeed(O){if(O.length!==iq)throw TypeError('"seed" must be 32 bytes in length.');if(!(O instanceof Uint8Array))throw TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let U=O,$=await esm_getPublicKey(U),J=concatKeys(U,$);return{privateKey:J,publicKey:$}}async function hashAndSign(O,U){let $=O.subarray(0,iq);return esm_sign(U,$)}async function hashAndVerify(O,U,$){return esm_verify(U,$,O)}function concatKeys(O,U){let $=new Uint8Array(iH);for(let J=0;J>>31>0){let O=~this.lo+1>>>0,U=~this.hi>>>0;return 0===O&&(U=U+1>>>0),-(O+4294967296*U)}return this.lo+4294967296*this.hi}toBigInt(O=!1){if(O)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!=0){let O=~this.lo+1>>>0,U=~this.hi>>>0;return 0===O&&(U=U+1>>>0),-(BigInt(O)+(BigInt(U)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(O=!1){return this.toBigInt(O).toString()}zzEncode(){let O=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^O)>>>0,this.lo=(this.lo<<1^O)>>>0,this}zzDecode(){let O=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^O)>>>0,this.hi=(this.hi>>>1^O)>>>0,this}length(){let O=this.lo,U=(this.lo>>>28|this.hi<<4)>>>0,$=this.hi>>>24;return 0===$?0===U?O<16384?O<128?1:2:O<2097152?3:4:U<16384?U<128?5:6:U<2097152?7:8:$<128?9:10}static fromBigInt(O){if(0n===O)return i0;if(OiX)return this.fromNumber(Number(O));let U=O<0n;U&&(O=-O);let $=O>>32n,J=O-($<<32n);return U&&($=0n|~$,J=0n|~J,++J>i1&&(J=0n,++$>i1&&($=0n))),new LongBits(Number(J),Number($))}static fromNumber(O){if(0===O)return i0;let U=O<0;U&&(O=-O);let $=O>>>0,J=(O-$)/4294967296>>>0;return U&&(J=~J>>>0,$=~$>>>0,++$>4294967295&&($=0,++J>4294967295&&(J=0))),new LongBits($,J)}static from(O){return"number"==typeof O?LongBits.fromNumber(O):"bigint"==typeof O?LongBits.fromBigInt(O):"string"==typeof O?LongBits.fromBigInt(BigInt(O)):null!=O.low||null!=O.high?new LongBits(O.low>>>0,O.high>>>0):i0}};let i0=new LongBits(0,0);i0.toBigInt=function(){return 0n},i0.zzEncode=i0.zzDecode=function(){return this},i0.length=function(){return 1};let i1=4294967296n;function utf8_length(O){let U=0,$=0;for(let J=0;J191&&en<224?eo[ea++]=(31&en)<<6|63&O[U++]:en>239&&en<365?(en=((7&en)<<18|(63&O[U++])<<12|(63&O[U++])<<6|63&O[U++])-65536,eo[ea++]=55296+(en>>10),eo[ea++]=56320+(1023&en)):eo[ea++]=(15&en)<<12|(63&O[U++])<<6|63&O[U++],ea>8191&&((J??(J=[])).push(String.fromCharCode.apply(String,eo)),ea=0);return null!=J?(ea>0&&J.push(String.fromCharCode.apply(String,eo.slice(0,ea))),J.join("")):String.fromCharCode.apply(String,eo.slice(0,ea))}function write(O,U,$){let J,en;let es=$;for(let es=0;es>6|192:((64512&J)==55296&&(64512&(en=O.charCodeAt(es+1)))==56320?(J=65536+((1023&J)<<10)+(1023&en),++es,U[$++]=J>>18|240,U[$++]=J>>12&63|128):U[$++]=J>>12|224,U[$++]=J>>6&63|128),U[$++]=63&J|128);return $-es}function indexOutOfRange(O,U){return RangeError(`index out of range: ${O.pos} + ${U??1} > ${O.len}`)}function readFixed32End(O,U){return(O[U-4]|O[U-3]<<8|O[U-2]<<16|O[U-1]<<24)>>>0}let Uint8ArrayReader=class Uint8ArrayReader{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(O){this.buf=O,this.pos=0,this.len=O.length}uint32(){let O=4294967295;if(O=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(O=(O|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(O=(O|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(O=(O|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(O=(O|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return O;if((this.pos+=5)>this.len)throw this.pos=this.len,indexOutOfRange(this,10);return O}int32(){return 0|this.uint32()}sint32(){let O=this.uint32();return O>>>1^-(1&O)|0}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);let O=readFixed32End(this.buf,this.pos+=4);return O}sfixed32(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);let O=0|readFixed32End(this.buf,this.pos+=4);return O}float(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);let O=readFloatLE(this.buf,this.pos);return this.pos+=4,O}double(){if(this.pos+8>this.len)throw indexOutOfRange(this,4);let O=readDoubleLE(this.buf,this.pos);return this.pos+=8,O}bytes(){let O=this.uint32(),U=this.pos,$=this.pos+O;if($>this.len)throw indexOutOfRange(this,O);return this.pos+=O,U===$?new Uint8Array(0):this.buf.subarray(U,$)}string(){let O=this.bytes();return utf8_read(O,0,O.length)}skip(O){if("number"==typeof O){if(this.pos+O>this.len)throw indexOutOfRange(this,O);this.pos+=O}else do if(this.pos>=this.len)throw indexOutOfRange(this);while((128&this.buf[this.pos++])!=0);return this}skipType(O){switch(O){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(O=7&this.uint32());)this.skipType(O);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${O} at offset ${this.pos}`)}return this}readLongVarint(){let O=new LongBits(0,0),U=0;if(this.len-this.pos>4){for(;U<4;++U)if(O.lo=(O.lo|(127&this.buf[this.pos])<<7*U)>>>0,this.buf[this.pos++]<128)return O;if(O.lo=(O.lo|(127&this.buf[this.pos])<<28)>>>0,O.hi=(O.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return O;U=0}else{for(;U<3;++U){if(this.pos>=this.len)throw indexOutOfRange(this);if(O.lo=(O.lo|(127&this.buf[this.pos])<<7*U)>>>0,this.buf[this.pos++]<128)return O}return O.lo=(O.lo|(127&this.buf[this.pos++])<<7*U)>>>0,O}if(this.len-this.pos>4){for(;U<5;++U)if(O.hi=(O.hi|(127&this.buf[this.pos])<<7*U+3)>>>0,this.buf[this.pos++]<128)return O}else for(;U<5;++U){if(this.pos>=this.len)throw indexOutOfRange(this);if(O.hi=(O.hi|(127&this.buf[this.pos])<<7*U+3)>>>0,this.buf[this.pos++]<128)return O}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange(this,8);let O=readFixed32End(this.buf,this.pos+=4),U=readFixed32End(this.buf,this.pos+=4);return new LongBits(O,U)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){return this.readLongVarint().toNumber(!0)}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function createReader(O){return new Uint8ArrayReader(O instanceof Uint8Array?O:O.subarray())}function decodeMessage(O,U){let $=createReader(O);return U.decode($)}function pool(O){let U;let $=O??8192,J=$>>>1,en=$;return function(O){if(O<1||O>J)return(0,rN.E)(O);en+O>$&&(U=(0,rN.E)($),en=0);let es=U.subarray(en,en+=O);return(7&en)!=0&&(en=(7|en)+1),es}}let Op=class Op{fn;len;next;val;constructor(O,U,$){this.fn=O,this.len=U,this.next=void 0,this.val=$}};function noop(){}let State=class State{head;tail;len;next;constructor(O){this.head=O.head,this.tail=O.tail,this.len=O.len,this.next=O.states}};let i2=pool();function writer_alloc(O){return null!=globalThis.Buffer?(0,rN.E)(O):i2(O)}let Uint8ArrayWriter=class Uint8ArrayWriter{len;head;tail;states;constructor(){this.len=0,this.head=new Op(noop,0,0),this.tail=this.head,this.states=null}_push(O,U,$){return this.tail=this.tail.next=new Op(O,U,$),this.len+=U,this}uint32(O){return this.len+=(this.tail=this.tail.next=new VarintOp((O>>>=0)<128?1:O<16384?2:O<2097152?3:O<268435456?4:5,O)).len,this}int32(O){return O<0?this._push(writeVarint64,10,LongBits.fromNumber(O)):this.uint32(O)}sint32(O){return this.uint32((O<<1^O>>31)>>>0)}uint64(O){let U=LongBits.fromBigInt(O);return this._push(writeVarint64,U.length(),U)}uint64Number(O){let U=LongBits.fromNumber(O);return this._push(writeVarint64,U.length(),U)}uint64String(O){return this.uint64(BigInt(O))}int64(O){return this.uint64(O)}int64Number(O){return this.uint64Number(O)}int64String(O){return this.uint64String(O)}sint64(O){let U=LongBits.fromBigInt(O).zzEncode();return this._push(writeVarint64,U.length(),U)}sint64Number(O){let U=LongBits.fromNumber(O).zzEncode();return this._push(writeVarint64,U.length(),U)}sint64String(O){return this.sint64(BigInt(O))}bool(O){return this._push(writeByte,1,O?1:0)}fixed32(O){return this._push(writeFixed32,4,O>>>0)}sfixed32(O){return this.fixed32(O)}fixed64(O){let U=LongBits.fromBigInt(O);return this._push(writeFixed32,4,U.lo)._push(writeFixed32,4,U.hi)}fixed64Number(O){let U=LongBits.fromNumber(O);return this._push(writeFixed32,4,U.lo)._push(writeFixed32,4,U.hi)}fixed64String(O){return this.fixed64(BigInt(O))}sfixed64(O){return this.fixed64(O)}sfixed64Number(O){return this.fixed64Number(O)}sfixed64String(O){return this.fixed64String(O)}float(O){return this._push(writeFloatLE,4,O)}double(O){return this._push(writeDoubleLE,8,O)}bytes(O){let U=O.length>>>0;return 0===U?this._push(writeByte,1,0):this.uint32(U)._push(writeBytes,U,O)}string(O){let U=utf8_length(O);return 0!==U?this.uint32(U)._push(write,U,O):this._push(writeByte,1,0)}fork(){return this.states=new State(this),this.head=this.tail=new Op(noop,0,0),this.len=0,this}reset(){return null!=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 Op(noop,0,0),this.len=0),this}ldelim(){let O=this.head,U=this.tail,$=this.len;return this.reset().uint32($),0!==$&&(this.tail.next=O.next,this.tail=U,this.len+=$),this}finish(){let O=this.head.next,U=writer_alloc(this.len),$=0;for(;null!=O;)O.fn(O.val,U,$),$+=O.len,O=O.next;return U}};function writeByte(O,U,$){U[$]=255&O}function writeVarint32(O,U,$){for(;O>127;)U[$++]=127&O|128,O>>>=7;U[$]=O}let VarintOp=class VarintOp extends Op{next;constructor(O,U){super(writeVarint32,O,U),this.next=void 0}};function writeVarint64(O,U,$){for(;0!==O.hi;)U[$++]=127&O.lo|128,O.lo=(O.lo>>>7|O.hi<<25)>>>0,O.hi>>>=7;for(;O.lo>127;)U[$++]=127&O.lo|128,O.lo=O.lo>>>7;U[$++]=O.lo}function writeFixed32(O,U,$){U[$]=255&O,U[$+1]=O>>>8&255,U[$+2]=O>>>16&255,U[$+3]=O>>>24}function writeBytes(O,U,$){U.set(O,$)}function writeBytesBuffer(O,U,$){U.set(O,$)}function writeStringBuffer(O,U,$){O.length<40?write(O,U,$):null!=U.utf8Write?U.utf8Write(O,$):U.set((0,rJ.m)(O),$)}function createWriter(){return new Uint8ArrayWriter}function encodeMessage(O,U){let $=createWriter();return U.encode(O,$,{lengthDelimited:!1}),$.finish()}function createCodec(O,U,$,J){return{name:O,type:U,encode:$,decode:J}}function enumeration(O){function findValue(U){if(null==O[U.toString()])throw Error("Invalid enum value");return O[U]}let encode=function(O,U){let $=findValue(O);U.int32($)},decode=function(O){let U=O.int32();return findValue(U)};return createCodec("enum",ew.VARINT,encode,decode)}function message(O,U){return createCodec("message",ew.LENGTH_DELIMITED,O,U)}null!=globalThis.Buffer&&(Uint8ArrayWriter.prototype.bytes=function(O){let U=O.length>>>0;return this.uint32(U),U>0&&this._push(writeBytesBuffer,U,O),this},Uint8ArrayWriter.prototype.string=function(O){let U=globalThis.Buffer.byteLength(O);return this.uint32(U),U>0&&this._push(writeStringBuffer,U,O),this}),function(O){O[O.VARINT=0]="VARINT",O[O.BIT64=1]="BIT64",O[O.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",O[O.START_GROUP=3]="START_GROUP",O[O.END_GROUP=4]="END_GROUP",O[O.BIT32=5]="BIT32"}(ew||(ew={})),function(O){O.RSA="RSA",O.Ed25519="Ed25519",O.Secp256k1="Secp256k1"}(eE||(eE={})),function(O){O[O.RSA=0]="RSA",O[O.Ed25519=1]="Ed25519",O[O.Secp256k1=2]="Secp256k1"}(eS||(eS={})),function(O){O.codec=()=>enumeration(eS)}(eE||(eE={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.Type&&(U.uint32(8),eE.codec().encode(O.Type,U)),null!=O.Data&&(U.uint32(18),U.bytes(O.Data)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.Type=eE.codec().decode(O);break;case 2:$.Data=O.bytes();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eA||(eA={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.Type&&(U.uint32(8),eE.codec().encode(O.Type,U)),null!=O.Data&&(U.uint32(18),U.bytes(O.Data)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.Type=eE.codec().decode(O);break;case 2:$.Data=O.bytes();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eI||(eI={}));let Ed25519PublicKey=class Ed25519PublicKey{_key;constructor(O){this._key=ensureKey(O,ij)}async verify(O,U){return hashAndVerify(this._key,U,O)}marshal(){return this._key}get bytes(){return eA.encode({Type:eE.Ed25519,Data:this.marshal()}).subarray()}equals(O){return equals(this.bytes,O.bytes)}async hash(){let{bytes:O}=await ib.digest(this.bytes);return O}};let Ed25519PrivateKey=class Ed25519PrivateKey{_key;_publicKey;constructor(O,U){this._key=ensureKey(O,iH),this._publicKey=ensureKey(U,ij)}async sign(O){return hashAndSign(this._key,O)}get public(){return new Ed25519PublicKey(this._publicKey)}marshal(){return this._key}get bytes(){return eI.encode({Type:eE.Ed25519,Data:this.marshal()}).subarray()}equals(O){return equals(this.bytes,O.bytes)}async hash(){let{bytes:O}=await ib.digest(this.bytes);return O}async id(){let O=iy.digest(this.public.bytes);return nW.encode(O.bytes).substring(1)}async export(O,U="libp2p-key"){if("libp2p-key"===U)return exporter(this.bytes,O);throw new src_errors_CodeError(`export format '${U}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function unmarshalEd25519PrivateKey(O){if(O.length>iH){O=ensureKey(O,iH+ij);let U=O.subarray(0,iH),$=O.subarray(iH,O.length);return new Ed25519PrivateKey(U,$)}O=ensureKey(O,iH);let U=O.subarray(0,iH),$=O.subarray(ij);return new Ed25519PrivateKey(U,$)}function unmarshalEd25519PublicKey(O){return O=ensureKey(O,ij),new Ed25519PublicKey(O)}async function ed25519_class_generateKeyPair(){let{privateKey:O,publicKey:U}=await generateKey();return new Ed25519PrivateKey(O,U)}async function generateKeyPairFromSeed(O){let{privateKey:U,publicKey:$}=await generateKeyFromSeed(O);return new Ed25519PrivateKey(U,$)}function ensureKey(O,U){if((O=Uint8Array.from(O??[])).length!==U)throw new src_errors_CodeError(`Key must be a Uint8Array of length ${U}, got ${O.length}`,"ERR_INVALID_KEY_TYPE");return O}var i3=$(2366);function bigIntegerToUintBase64url(O,U){let $=Uint8Array.from(O.abs().toByteArray());if($=0===$[0]?$.subarray(1):$,null!=U){if($.length>U)throw Error("byte array longer than desired length");$=concat_concat([new Uint8Array(U-$.length),$])}return(0,rB.B)($,"base64url")}function base64urlToBigInteger(O){let U=util_base64urlToBuffer(O);return new n$.jsbn.BigInteger((0,rB.B)(U,"base16"),16)}function util_base64urlToBuffer(O,U){let $=(0,rJ.m)(O,"base64urlpad");if(null!=U){if($.length>U)throw Error("byte array longer than desired length");$=concat_concat([new Uint8Array(U-$.length),$])}return $}$(4196);let i6={"P-256":256,"P-384":384,"P-521":521},i4=Object.keys(i6);function random_bytes_randomBytes(O){if(isNaN(O)||O<=0)throw new src_errors_CodeError("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return nH.randomBytes(O)}function jwk2pem_convert(O,U){return U.map(U=>base64urlToBigInteger(O[U]))}function jwk2priv(O){return n$.pki.setRsaPrivateKey(...jwk2pem_convert(O,["n","e","d","p","q","dp","dq","qi"]))}function jwk2pub(O){return n$.pki.setRsaPublicKey(...jwk2pem_convert(O,["n","e"]))}function pkcs1ToJwk(O){let U=n$.asn1.fromDer((0,rB.B)(O,"ascii")),$=n$.pki.privateKeyFromAsn1(U);return{kty:"RSA",n:bigIntegerToUintBase64url($.n),e:bigIntegerToUintBase64url($.e),d:bigIntegerToUintBase64url($.d),p:bigIntegerToUintBase64url($.p),q:bigIntegerToUintBase64url($.q),dp:bigIntegerToUintBase64url($.dP),dq:bigIntegerToUintBase64url($.dQ),qi:bigIntegerToUintBase64url($.qInv),alg:"RS256"}}function jwkToPkcs1(O){if(null==O.n||null==O.e||null==O.d||null==O.p||null==O.q||null==O.dp||null==O.dq||null==O.qi)throw new src_errors_CodeError("JWK was missing components","ERR_INVALID_PARAMETERS");let U=n$.pki.privateKeyToAsn1({n:base64urlToBigInteger(O.n),e:base64urlToBigInteger(O.e),d:base64urlToBigInteger(O.d),p:base64urlToBigInteger(O.p),q:base64urlToBigInteger(O.q),dP:base64urlToBigInteger(O.dp),dQ:base64urlToBigInteger(O.dq),qInv:base64urlToBigInteger(O.qi)});return(0,rJ.m)(n$.asn1.toDer(U).getBytes(),"ascii")}function pkixToJwk(O){let U=n$.asn1.fromDer((0,rB.B)(O,"ascii")),$=n$.pki.publicKeyFromAsn1(U);return{kty:"RSA",n:bigIntegerToUintBase64url($.n),e:bigIntegerToUintBase64url($.e)}}function jwkToPkix(O){if(null==O.n||null==O.e)throw new src_errors_CodeError("JWK was missing components","ERR_INVALID_PARAMETERS");let U=n$.pki.publicKeyToAsn1({n:base64urlToBigInteger(O.n),e:base64urlToBigInteger(O.e)});return(0,rJ.m)(n$.asn1.toDer(U).getBytes(),"ascii")}async function rsa_browser_generateKey(O){let U=await iG.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:O,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),$=await exportKey(U);return{privateKey:$[0],publicKey:$[1]}}async function rsa_browser_unmarshalPrivateKey(O){let U=await iG.get().subtle.importKey("jwk",O,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),$=[U,await derivePublicFromPrivate(O)],J=await exportKey({privateKey:$[0],publicKey:$[1]});return{privateKey:J[0],publicKey:J[1]}}async function rsa_browser_hashAndSign(O,U){let $=await iG.get().subtle.importKey("jwk",O,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),J=await iG.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},$,Uint8Array.from(U));return new Uint8Array(J,0,J.byteLength)}async function rsa_browser_hashAndVerify(O,U,$){let J=await iG.get().subtle.importKey("jwk",O,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return iG.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},J,U,$)}async function exportKey(O){if(null==O.privateKey||null==O.publicKey)throw new src_errors_CodeError("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([iG.get().subtle.exportKey("jwk",O.privateKey),iG.get().subtle.exportKey("jwk",O.publicKey)])}async function derivePublicFromPrivate(O){return iG.get().subtle.importKey("jwk",{kty:O.kty,n:O.n,e:O.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function convertKey(O,U,$,J){let en=U?jwk2pub(O):jwk2priv(O),es=(0,rB.B)(Uint8Array.from($),"ascii"),eo=J(es,en);return(0,rJ.m)(eo,"ascii")}function encrypt(O,U){return convertKey(O,!0,U,(O,U)=>U.encrypt(O))}function decrypt(O,U){return convertKey(O,!1,U,(O,U)=>U.decrypt(O))}i4.join(" / "),$(8439),$(411);let RsaPublicKey=class RsaPublicKey{_key;constructor(O){this._key=O}async verify(O,U){return rsa_browser_hashAndVerify(this._key,U,O)}marshal(){return jwkToPkix(this._key)}get bytes(){return eA.encode({Type:eE.RSA,Data:this.marshal()}).subarray()}encrypt(O){return encrypt(this._key,O)}equals(O){return equals(this.bytes,O.bytes)}async hash(){let{bytes:O}=await ib.digest(this.bytes);return O}};let RsaPrivateKey=class RsaPrivateKey{_key;_publicKey;constructor(O,U){this._key=O,this._publicKey=U}genSecret(){return random_bytes_randomBytes(16)}async sign(O){return rsa_browser_hashAndSign(this._key,O)}get public(){if(null==this._publicKey)throw new src_errors_CodeError("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new RsaPublicKey(this._publicKey)}decrypt(O){return decrypt(this._key,O)}marshal(){return jwkToPkcs1(this._key)}get bytes(){return eI.encode({Type:eE.RSA,Data:this.marshal()}).subarray()}equals(O){return equals(this.bytes,O.bytes)}async hash(){let{bytes:O}=await ib.digest(this.bytes);return O}async id(){let O=await this.public.hash();return(0,rB.B)(O,"base58btc")}async export(O,U="pkcs-8"){if("pkcs-8"===U){let U=new n$.util.ByteBuffer(this.marshal()),$=n$.asn1.fromDer(U),J=n$.pki.privateKeyFromAsn1($),en={algorithm:"aes256",count:1e4,saltSize:16,prfAlgorithm:"sha512"};return n$.pki.encryptRsaPrivateKey(J,O,en)}if("libp2p-key"===U)return exporter(this.bytes,O);throw new src_errors_CodeError(`export format '${U}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};async function unmarshalRsaPrivateKey(O){let U=pkcs1ToJwk(O),$=await rsa_browser_unmarshalPrivateKey(U);return new RsaPrivateKey($.privateKey,$.publicKey)}function unmarshalRsaPublicKey(O){let U=pkixToJwk(O);return new RsaPublicKey(U)}async function fromJwk(O){let U=await rsa_browser_unmarshalPrivateKey(O);return new RsaPrivateKey(U.privateKey,U.publicKey)}async function rsa_class_generateKeyPair(O){let U=await rsa_browser_generateKey(O);return new RsaPrivateKey(U.privateKey,U.publicKey)}function secp256k1_generateKey(){return nH.randomPrivateKey()}async function secp256k1_hashAndSign(O,U){let{digest:$}=await ib.digest(U);try{return await sign($,O)}catch(O){throw new src_errors_CodeError(String(O),"ERR_INVALID_INPUT")}}async function secp256k1_hashAndVerify(O,U,$){try{let{digest:J}=await ib.digest($);return verify(U,J,O)}catch(O){throw new src_errors_CodeError(String(O),"ERR_INVALID_INPUT")}}function secp256k1_compressPublicKey(O){let U=Point.fromHex(O).toRawBytes(!0);return U}function validatePrivateKey(O){try{getPublicKey(O,!0)}catch(O){throw new src_errors_CodeError(String(O),"ERR_INVALID_PRIVATE_KEY")}}function validatePublicKey(O){try{Point.fromHex(O)}catch(O){throw new src_errors_CodeError(String(O),"ERR_INVALID_PUBLIC_KEY")}}function computePublicKey(O){try{return getPublicKey(O,!0)}catch(O){throw new src_errors_CodeError(String(O),"ERR_INVALID_PRIVATE_KEY")}}let Secp256k1PublicKey=class Secp256k1PublicKey{_key;constructor(O){validatePublicKey(O),this._key=O}async verify(O,U){return secp256k1_hashAndVerify(this._key,U,O)}marshal(){return secp256k1_compressPublicKey(this._key)}get bytes(){return eA.encode({Type:eE.Secp256k1,Data:this.marshal()}).subarray()}equals(O){return equals(this.bytes,O.bytes)}async hash(){let{bytes:O}=await ib.digest(this.bytes);return O}};let Secp256k1PrivateKey=class Secp256k1PrivateKey{_key;_publicKey;constructor(O,U){this._key=O,this._publicKey=U??computePublicKey(O),validatePrivateKey(this._key),validatePublicKey(this._publicKey)}async sign(O){return secp256k1_hashAndSign(this._key,O)}get public(){return new Secp256k1PublicKey(this._publicKey)}marshal(){return this._key}get bytes(){return eI.encode({Type:eE.Secp256k1,Data:this.marshal()}).subarray()}equals(O){return equals(this.bytes,O.bytes)}async hash(){let{bytes:O}=await ib.digest(this.bytes);return O}async id(){let O=await this.public.hash();return(0,rB.B)(O,"base58btc")}async export(O,U="libp2p-key"){if("libp2p-key"===U)return exporter(this.bytes,O);throw new src_errors_CodeError(`export format '${U}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function unmarshalSecp256k1PrivateKey(O){return new Secp256k1PrivateKey(O)}function unmarshalSecp256k1PublicKey(O){return new Secp256k1PublicKey(O)}async function secp256k1_class_generateKeyPair(){let O=secp256k1_generateKey();return new Secp256k1PrivateKey(O)}let i5={secp256k1:rS};var i8=$(6831),i9=$(3062);let i7=Symbol.for("nodejs.util.inspect.custom"),se=Object.values(rW.gh).map(O=>O.decoder).reduce((O,U)=>O.or(U),rW.gh.identity.decoder),sr=114,sn=36,si=37;let PeerIdImpl=class PeerIdImpl{type;multihash;privateKey;publicKey;string;constructor(O){this.type=O.type,this.multihash=O.multihash,this.privateKey=O.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[rT]=!0;toString(){return null==this.string&&(this.string=rR.base58btc.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return rC.k0.createV1(sr,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(O){if(O instanceof Uint8Array)return equals(this.multihash.bytes,O);if("string"==typeof O)return peerIdFromString(O).equals(this);if(O?.multihash?.bytes!=null)return equals(this.multihash.bytes,O.multihash.bytes);throw Error("not valid Id")}[i7](){return`PeerId(${this.toString()})`}};let RSAPeerIdImpl=class RSAPeerIdImpl extends PeerIdImpl{type="RSA";publicKey;constructor(O){super({...O,type:"RSA"}),this.publicKey=O.publicKey}};let Ed25519PeerIdImpl=class Ed25519PeerIdImpl extends PeerIdImpl{type="Ed25519";publicKey;constructor(O){super({...O,type:"Ed25519"}),this.publicKey=O.multihash.digest}};let Secp256k1PeerIdImpl=class Secp256k1PeerIdImpl extends PeerIdImpl{type="secp256k1";publicKey;constructor(O){super({...O,type:"secp256k1"}),this.publicKey=O.multihash.digest}};function peerIdFromPeerId(O){if("RSA"===O.type)return new RSAPeerIdImpl(O);if("Ed25519"===O.type)return new Ed25519PeerIdImpl(O);if("secp256k1"===O.type)return new Secp256k1PeerIdImpl(O);throw new errors_CodeError("Not a PeerId","ERR_INVALID_PARAMETERS")}function peerIdFromString(O,U){if(U=U??se,"1"===O.charAt(0)||"Q"===O.charAt(0)){let U=rY.Jx(rR.base58btc.decode(`z${O}`));return O.startsWith("12D")?new Ed25519PeerIdImpl({multihash:U}):O.startsWith("16U")?new Secp256k1PeerIdImpl({multihash:U}):new RSAPeerIdImpl({multihash:U})}return src_peerIdFromBytes(se.decode(O))}function src_peerIdFromBytes(O){try{let U=rY.Jx(O);if(U.code===i8.identity.code){if(U.digest.length===sn)return new Ed25519PeerIdImpl({multihash:U});if(U.digest.length===si)return new Secp256k1PeerIdImpl({multihash:U})}if(U.code===i9.sha256.code)return new RSAPeerIdImpl({multihash:U})}catch{return peerIdFromCID(rC.k0.decode(O))}throw Error("Supplied PeerID CID is invalid")}function peerIdFromCID(O){if(null==O||null==O.multihash||null==O.version||1===O.version&&O.code!==sr)throw Error("Supplied PeerID CID is invalid");let U=O.multihash;if(U.code===i9.sha256.code)return new RSAPeerIdImpl({multihash:O.multihash});if(U.code===i8.identity.code){if(U.digest.length===sn)return new Ed25519PeerIdImpl({multihash:O.multihash});if(U.digest.length===si)return new Secp256k1PeerIdImpl({multihash:O.multihash})}throw Error("Supplied PeerID CID is invalid")}async function src_peerIdFromKeys(O,U){return O.length===sn?new Ed25519PeerIdImpl({multihash:rY.Ue(i8.identity.code,O),privateKey:U}):O.length===si?new Secp256k1PeerIdImpl({multihash:rY.Ue(i8.identity.code,O),privateKey:U}):new RSAPeerIdImpl({multihash:await i9.sha256.digest(O),publicKey:O,privateKey:U})}function createPeerIdFromPublicKey(O){let U=new i5.secp256k1.Secp256k1PublicKey(O);return src_peerIdFromKeys(U.bytes,void 0)}function decodeMultiaddrs(O){let U=[],$=0;for(;$O+nG+U.bytes.length,0),$=new Uint8Array(U),J=new DataView($.buffer),en=0;return O.forEach(O=>{if(O.getPeerId())throw Error("`multiaddr` field MUST not contain peer id");J.setUint16(en,O.bytes.length),en+=nG,$.set(O.bytes,en),en+=O.bytes.length}),$}let decodeRelayShard=O=>{if((O=new Uint8Array(O)).length<3)throw Error("Insufficient data");let U=new DataView(O.buffer),$=U.getUint16(0),J=[];if(130===O.length)for(let O=0;O<1024;O++){let $=Math.floor(O/8)+2,en=7-O%8;U.getUint8($)&1<=O.length)throw Error("Unexpected end of data");J.push(U.getUint16(es))}}return{cluster:$,indexList:J}},encodeRelayShard=O=>{let{cluster:U,indexList:$}=O,J=$.length>=64?130:3+2*$.length,en=new ArrayBuffer(J),es=new DataView(en);if(es.setUint16(0,U),$.length>=64)for(let O of $){let U=Math.floor(O/8)+2,$=7-O%8;es.setUint8(U,es.getUint8(U)|1<<$)}else{es.setUint8(2,$.length);for(let O=0,U=3;O<$.length;O++,U+=2)es.setUint16(U,$[O])}return new Uint8Array(en)};function encodeWaku2(O){let U=0;return O.lightPush&&(U+=1),U<<=1,O.filter&&(U+=1),U<<=1,O.store&&(U+=1),U<<=1,O.relay&&(U+=1),U}function decodeWaku2(O){let U={relay:!1,store:!1,filter:!1,lightPush:!1};return O%2&&(U.relay=!0),(O>>=1)%2&&(U.store=!0),(O>>=1)%2&&(U.filter=!0),(O>>=1)%2&&(U.lightPush=!0),U}let RawEnr=class RawEnr extends Map{seq;signature;constructor(O={},U=BigInt(1),$){super(Object.entries(O)),this.seq=U,this.signature=$}set(O,U){return this.signature=void 0,this.seq++,super.set(O,U)}get id(){let O=this.get("id");if(!O)throw Error("id not found.");return(0,ng.Md)(O)}get publicKey(){if("v4"===this.id)return this.get("secp256k1");throw Error(nV)}get rs(){let O=this.get("rs");if(O)return decodeRelayShard(O)}get rsv(){let O=this.get("rsv");if(O)return decodeRelayShard(O)}get ip(){return getStringValue(this,"ip","ip4")}set ip(O){setStringValue(this,"ip","ip4",O)}get tcp(){return getNumberAsStringValue(this,"tcp","tcp")}set tcp(O){setNumberAsStringValue(this,"tcp","tcp",O)}get udp(){return getNumberAsStringValue(this,"udp","udp")}set udp(O){setNumberAsStringValue(this,"udp","udp",O)}get ip6(){return getStringValue(this,"ip6","ip6")}set ip6(O){setStringValue(this,"ip6","ip6",O)}get tcp6(){return getNumberAsStringValue(this,"tcp6","tcp")}set tcp6(O){setNumberAsStringValue(this,"tcp6","tcp",O)}get udp6(){return getNumberAsStringValue(this,"udp6","udp")}set udp6(O){setNumberAsStringValue(this,"udp6","udp",O)}get multiaddrs(){let O=this.get("multiaddrs");if(O)return decodeMultiaddrs(O)}set multiaddrs(O){deleteUndefined(this,"multiaddrs",O,encodeMultiaddrs)}get waku2(){let O=this.get("waku2");if(O)return decodeWaku2(O[0])}set waku2(O){deleteUndefined(this,"waku2",O,O=>new Uint8Array([encodeWaku2(O)]))}};function getStringValue(O,U,$){let J=O.get(U);if(J)return convertToString($,J)}function getNumberAsStringValue(O,U,$){let J=O.get(U);if(J)return Number(convertToString($,J))}function setStringValue(O,U,$,J){deleteUndefined(O,U,J,convertToBytes.bind({},$))}function setNumberAsStringValue(O,U,$,J){setStringValue(O,U,$,J?.toString(10))}function deleteUndefined(O,U,$,J){void 0!==$?O.set(U,J($)):O.delete(U)}async function v4_sign(O,U){return sign(keccak256(U),O,{der:!1})}function nodeId(O){let U=Point.fromHex(O),$=U.toRawBytes(!1);return(0,ng.ci)(keccak256($.slice(1)))}let so=nf("waku:enr");!function(O){O.TCP="tcp",O.UDP="udp"}(eP||(eP={})),function(O){O.TCP4="tcp4",O.UDP4="udp4",O.TCP6="tcp6",O.UDP6="udp6"}(ek||(ek={}));let enr_ENR=class enr_ENR extends RawEnr{static RECORD_PREFIX="enr:";peerId;static async create(O={},U=BigInt(1),$){let J=new enr_ENR(O,U,$);try{let O=J.publicKey;O&&(J.peerId=await createPeerIdFromPublicKey(O))}catch(O){so("Could not calculate peer id for ENR",O)}return J}get nodeId(){if("v4"===this.id)return this.publicKey?nodeId(this.publicKey):void 0;throw Error(nV)}getLocationMultiaddr=locationMultiaddrFromEnrFields.bind({},this);get shardInfo(){return this.rs&&this.rsv&&so("Warning: ENR contains both `rs` and `rsv` fields."),this.rs||this.rsv}setLocationMultiaddr(O){let U=O.protoNames();if(2!==U.length&&"udp"!==U[1]&&"tcp"!==U[1])throw Error("Invalid multiaddr");let $=O.tuples();if(!$[0][1]||!$[1][1])throw Error("Invalid multiaddr");4===$[0][0]?(this.set("ip",$[0][1]),this.set(U[1],$[1][1])):(this.set("ip6",$[0][1]),this.set(U[1]+"6",$[1][1]))}getAllLocationMultiaddrs(){let O=[];for(let U of Object.values(ek)){let $=this.getLocationMultiaddr(U);$&&O.push($)}let U=this.multiaddrs??[];return O.concat(U)}get peerInfo(){let O=this.peerId;if(O)return{id:O,multiaddrs:this.getAllLocationMultiaddrs(),protocols:[]}}getFullMultiaddr(O){if(this.peerId){let U=this.getLocationMultiaddr(O);if(U)return U.encapsulate(`/p2p/${this.peerId.toString()}`)}}getFullMultiaddrs(){if(this.peerId&&this.multiaddrs){let O=this.peerId;return this.multiaddrs.map(U=>U.encapsulate(`/p2p/${O.toString()}`))}return[]}verify(O,U){if(!this.get("id")||"v4"!==this.id)throw Error(nV);if(!this.publicKey)throw Error("Failed to verify ENR: No public key");return verifySignature(U,keccak256(O),this.publicKey)}async sign(O,U){if("v4"===this.id)this.signature=await v4_sign(U,O);else throw Error(nV);return this.signature}};var sa=$(7054);let EnrDecoder=class EnrDecoder{static fromString(O){if(!O.startsWith(enr_ENR.RECORD_PREFIX))throw Error(`"string encoded ENR must start with '${enr_ENR.RECORD_PREFIX}'`);return EnrDecoder.fromRLP((0,rJ.m)(O.slice(4),"base64url"))}static fromRLP(O){let U=sa.J(O).map(ng.nr);return fromValues(U)}};async function fromValues(O){let{signature:U,seq:$,kvs:J}=checkValues(O),en={};for(let O=0;OO.indexList.map(U=>`/waku/2/rs/${O.cluster}/${U}`);function ensurePubsubTopicIsConfigured(O,U){if(!U.includes(O))throw Error(`PubSub topic ${O} has not been configured on this instance. Configured topics are: ${U}. Please update your configuration by passing in the topic during Waku node instantiation.`)}!function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.proof&&O.proof.byteLength>0&&(U.uint32(10),U.bytes(O.proof)),null!=O.merkleRoot&&O.merkleRoot.byteLength>0&&(U.uint32(18),U.bytes(O.merkleRoot)),null!=O.epoch&&O.epoch.byteLength>0&&(U.uint32(26),U.bytes(O.epoch)),null!=O.shareX&&O.shareX.byteLength>0&&(U.uint32(34),U.bytes(O.shareX)),null!=O.shareY&&O.shareY.byteLength>0&&(U.uint32(42),U.bytes(O.shareY)),null!=O.nullifier&&O.nullifier.byteLength>0&&(U.uint32(50),U.bytes(O.nullifier)),null!=O.rlnIdentifier&&O.rlnIdentifier.byteLength>0&&(U.uint32(58),U.bytes(O.rlnIdentifier)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={proof:new Uint8Array(0),merkleRoot:new Uint8Array(0),epoch:new Uint8Array(0),shareX:new Uint8Array(0),shareY:new Uint8Array(0),nullifier:new Uint8Array(0),rlnIdentifier:new Uint8Array(0)},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.proof=O.bytes();break;case 2:$.merkleRoot=O.bytes();break;case 3:$.epoch=O.bytes();break;case 4:$.shareX=O.bytes();break;case 5:$.shareY=O.bytes();break;case 6:$.nullifier=O.bytes();break;case 7:$.rlnIdentifier=O.bytes();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eT||(eT={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.payload&&O.payload.byteLength>0&&(U.uint32(10),U.bytes(O.payload)),null!=O.contentTopic&&""!==O.contentTopic&&(U.uint32(18),U.string(O.contentTopic)),null!=O.version&&(U.uint32(24),U.uint32(O.version)),null!=O.timestamp&&(U.uint32(80),U.sint64(O.timestamp)),null!=O.meta&&(U.uint32(90),U.bytes(O.meta)),null!=O.rateLimitProof&&(U.uint32(170),eT.codec().encode(O.rateLimitProof,U)),null!=O.ephemeral&&(U.uint32(248),U.bool(O.ephemeral)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={payload:new Uint8Array(0),contentTopic:""},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.payload=O.bytes();break;case 2:$.contentTopic=O.string();break;case 3:$.version=O.uint32();break;case 10:$.timestamp=O.sint64();break;case 11:$.meta=O.bytes();break;case 21:$.rateLimitProof=eT.codec().decode(O,O.uint32());break;case 31:$.ephemeral=O.bool();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eR||(eR={})),function(O){let U,$;(function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.contentTopic&&""!==O.contentTopic&&(U.uint32(10),U.string(O.contentTopic)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={contentTopic:""},J=null==U?O.len:O.pos+U;for(;O.pos>>3==1?$.contentTopic=O.string():O.skipType(7&U)}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())})(U=O.ContentFilter||(O.ContentFilter={})),O.codec=()=>(null==$&&($=message((U,$,J={})=>{if(!1!==J.lengthDelimited&&$.fork(),null!=U.subscribe&&!1!==U.subscribe&&($.uint32(8),$.bool(U.subscribe)),null!=U.topic&&""!==U.topic&&($.uint32(18),$.string(U.topic)),null!=U.contentFilters)for(let J of U.contentFilters)$.uint32(26),O.ContentFilter.codec().encode(J,$);!1!==J.lengthDelimited&&$.ldelim()},(U,$)=>{let J={subscribe:!1,topic:"",contentFilters:[]},en=null==$?U.len:U.pos+$;for(;U.pos>>3){case 1:J.subscribe=U.bool();break;case 2:J.topic=U.string();break;case 3:J.contentFilters.push(O.ContentFilter.codec().decode(U,U.uint32()));break;default:U.skipType(7&$)}}return J})),$),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eC||(eC={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{if(!1!==$.lengthDelimited&&U.fork(),null!=O.messages)for(let $ of O.messages)U.uint32(10),eM.codec().encode($,U);!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={messages:[]},J=null==U?O.len:O.pos+U;for(;O.pos>>3==1?$.messages.push(eM.codec().decode(O,O.uint32())):O.skipType(7&U)}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eB||(eB={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.requestId&&""!==O.requestId&&(U.uint32(10),U.string(O.requestId)),null!=O.request&&(U.uint32(18),eC.codec().encode(O.request,U)),null!=O.push&&(U.uint32(26),eB.codec().encode(O.push,U)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={requestId:""},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.requestId=O.string();break;case 2:$.request=eC.codec().decode(O,O.uint32());break;case 3:$.push=eB.codec().decode(O,O.uint32());break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eN||(eN={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.proof&&O.proof.byteLength>0&&(U.uint32(10),U.bytes(O.proof)),null!=O.merkleRoot&&O.merkleRoot.byteLength>0&&(U.uint32(18),U.bytes(O.merkleRoot)),null!=O.epoch&&O.epoch.byteLength>0&&(U.uint32(26),U.bytes(O.epoch)),null!=O.shareX&&O.shareX.byteLength>0&&(U.uint32(34),U.bytes(O.shareX)),null!=O.shareY&&O.shareY.byteLength>0&&(U.uint32(42),U.bytes(O.shareY)),null!=O.nullifier&&O.nullifier.byteLength>0&&(U.uint32(50),U.bytes(O.nullifier)),null!=O.rlnIdentifier&&O.rlnIdentifier.byteLength>0&&(U.uint32(58),U.bytes(O.rlnIdentifier)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={proof:new Uint8Array(0),merkleRoot:new Uint8Array(0),epoch:new Uint8Array(0),shareX:new Uint8Array(0),shareY:new Uint8Array(0),nullifier:new Uint8Array(0),rlnIdentifier:new Uint8Array(0)},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.proof=O.bytes();break;case 2:$.merkleRoot=O.bytes();break;case 3:$.epoch=O.bytes();break;case 4:$.shareX=O.bytes();break;case 5:$.shareY=O.bytes();break;case 6:$.nullifier=O.bytes();break;case 7:$.rlnIdentifier=O.bytes();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eD||(eD={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.payload&&O.payload.byteLength>0&&(U.uint32(10),U.bytes(O.payload)),null!=O.contentTopic&&""!==O.contentTopic&&(U.uint32(18),U.string(O.contentTopic)),null!=O.version&&(U.uint32(24),U.uint32(O.version)),null!=O.timestamp&&(U.uint32(80),U.sint64(O.timestamp)),null!=O.meta&&(U.uint32(90),U.bytes(O.meta)),null!=O.rateLimitProof&&(U.uint32(170),eD.codec().encode(O.rateLimitProof,U)),null!=O.ephemeral&&(U.uint32(248),U.bool(O.ephemeral)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={payload:new Uint8Array(0),contentTopic:""},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.payload=O.bytes();break;case 2:$.contentTopic=O.string();break;case 3:$.version=O.uint32();break;case 10:$.timestamp=O.sint64();break;case 11:$.meta=O.bytes();break;case 21:$.rateLimitProof=eD.codec().decode(O,O.uint32());break;case 31:$.ephemeral=O.bool();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eM||(eM={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.contentTopic&&""!==O.contentTopic&&(U.uint32(18),U.string(O.contentTopic)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={contentTopic:""},J=null==U?O.len:O.pos+U;for(;O.pos>>3==2?$.contentTopic=O.string():O.skipType(7&U)}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eO||(eO={})),function(O){let U,$,J;(function(O){O.SUBSCRIBER_PING="SUBSCRIBER_PING",O.SUBSCRIBE="SUBSCRIBE",O.UNSUBSCRIBE="UNSUBSCRIBE",O.UNSUBSCRIBE_ALL="UNSUBSCRIBE_ALL"})(U=O.FilterSubscribeType||(O.FilterSubscribeType={})),function(O){O[O.SUBSCRIBER_PING=0]="SUBSCRIBER_PING",O[O.SUBSCRIBE=1]="SUBSCRIBE",O[O.UNSUBSCRIBE=2]="UNSUBSCRIBE",O[O.UNSUBSCRIBE_ALL=3]="UNSUBSCRIBE_ALL"}($||($={})),function(O){O.codec=()=>enumeration($)}(U=O.FilterSubscribeType||(O.FilterSubscribeType={})),O.codec=()=>(null==J&&(J=message((U,J,en={})=>{if(!1!==en.lengthDelimited&&J.fork(),null!=U.requestId&&""!==U.requestId&&(J.uint32(10),J.string(U.requestId)),null!=U.filterSubscribeType&&0!==$[U.filterSubscribeType]&&(J.uint32(16),O.FilterSubscribeType.codec().encode(U.filterSubscribeType,J)),null!=U.pubsubTopic&&(J.uint32(82),J.string(U.pubsubTopic)),null!=U.contentTopics)for(let O of U.contentTopics)J.uint32(90),J.string(O);!1!==en.lengthDelimited&&J.ldelim()},($,J)=>{let en={requestId:"",filterSubscribeType:U.SUBSCRIBER_PING,contentTopics:[]},es=null==J?$.len:$.pos+J;for(;$.pos>>3){case 1:en.requestId=$.string();break;case 2:en.filterSubscribeType=O.FilterSubscribeType.codec().decode($);break;case 10:en.pubsubTopic=$.string();break;case 11:en.contentTopics.push($.string());break;default:$.skipType(7&U)}}return en})),J),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eL||(eL={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.requestId&&""!==O.requestId&&(U.uint32(10),U.string(O.requestId)),null!=O.statusCode&&0!==O.statusCode&&(U.uint32(80),U.uint32(O.statusCode)),null!=O.statusDesc&&(U.uint32(90),U.string(O.statusDesc)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={requestId:"",statusCode:0},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.requestId=O.string();break;case 10:$.statusCode=O.uint32();break;case 11:$.statusDesc=O.string();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eU||(eU={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.wakuMessage&&(U.uint32(10),ej.codec().encode(O.wakuMessage,U)),null!=O.pubsubTopic&&(U.uint32(18),U.string(O.pubsubTopic)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.wakuMessage=ej.codec().decode(O,O.uint32());break;case 2:$.pubsubTopic=O.string();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eF||(eF={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.proof&&O.proof.byteLength>0&&(U.uint32(10),U.bytes(O.proof)),null!=O.merkleRoot&&O.merkleRoot.byteLength>0&&(U.uint32(18),U.bytes(O.merkleRoot)),null!=O.epoch&&O.epoch.byteLength>0&&(U.uint32(26),U.bytes(O.epoch)),null!=O.shareX&&O.shareX.byteLength>0&&(U.uint32(34),U.bytes(O.shareX)),null!=O.shareY&&O.shareY.byteLength>0&&(U.uint32(42),U.bytes(O.shareY)),null!=O.nullifier&&O.nullifier.byteLength>0&&(U.uint32(50),U.bytes(O.nullifier)),null!=O.rlnIdentifier&&O.rlnIdentifier.byteLength>0&&(U.uint32(58),U.bytes(O.rlnIdentifier)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={proof:new Uint8Array(0),merkleRoot:new Uint8Array(0),epoch:new Uint8Array(0),shareX:new Uint8Array(0),shareY:new Uint8Array(0),nullifier:new Uint8Array(0),rlnIdentifier:new Uint8Array(0)},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.proof=O.bytes();break;case 2:$.merkleRoot=O.bytes();break;case 3:$.epoch=O.bytes();break;case 4:$.shareX=O.bytes();break;case 5:$.shareY=O.bytes();break;case 6:$.nullifier=O.bytes();break;case 7:$.rlnIdentifier=O.bytes();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eK||(eK={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.payload&&O.payload.byteLength>0&&(U.uint32(10),U.bytes(O.payload)),null!=O.contentTopic&&""!==O.contentTopic&&(U.uint32(18),U.string(O.contentTopic)),null!=O.version&&(U.uint32(24),U.uint32(O.version)),null!=O.timestamp&&(U.uint32(80),U.sint64(O.timestamp)),null!=O.meta&&(U.uint32(90),U.bytes(O.meta)),null!=O.rateLimitProof&&(U.uint32(170),eK.codec().encode(O.rateLimitProof,U)),null!=O.ephemeral&&(U.uint32(248),U.bool(O.ephemeral)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={payload:new Uint8Array(0),contentTopic:""},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.payload=O.bytes();break;case 2:$.contentTopic=O.string();break;case 3:$.version=O.uint32();break;case 10:$.timestamp=O.sint64();break;case 11:$.meta=O.bytes();break;case 21:$.rateLimitProof=eK.codec().decode(O,O.uint32());break;case 31:$.ephemeral=O.bool();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(ej||(ej={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.pubsubTopic&&""!==O.pubsubTopic&&(U.uint32(10),U.string(O.pubsubTopic)),null!=O.message&&(U.uint32(18),e$.codec().encode(O.message,U)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={pubsubTopic:""},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.pubsubTopic=O.string();break;case 2:$.message=e$.codec().decode(O,O.uint32());break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eH||(eH={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.isSuccess&&!1!==O.isSuccess&&(U.uint32(8),U.bool(O.isSuccess)),null!=O.info&&(U.uint32(18),U.string(O.info)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={isSuccess:!1},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.isSuccess=O.bool();break;case 2:$.info=O.string();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eq||(eq={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.requestId&&""!==O.requestId&&(U.uint32(10),U.string(O.requestId)),null!=O.request&&(U.uint32(18),eH.codec().encode(O.request,U)),null!=O.response&&(U.uint32(26),eq.codec().encode(O.response,U)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={requestId:""},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.requestId=O.string();break;case 2:$.request=eH.codec().decode(O,O.uint32());break;case 3:$.response=eq.codec().decode(O,O.uint32());break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eV||(eV={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.proof&&O.proof.byteLength>0&&(U.uint32(10),U.bytes(O.proof)),null!=O.merkleRoot&&O.merkleRoot.byteLength>0&&(U.uint32(18),U.bytes(O.merkleRoot)),null!=O.epoch&&O.epoch.byteLength>0&&(U.uint32(26),U.bytes(O.epoch)),null!=O.shareX&&O.shareX.byteLength>0&&(U.uint32(34),U.bytes(O.shareX)),null!=O.shareY&&O.shareY.byteLength>0&&(U.uint32(42),U.bytes(O.shareY)),null!=O.nullifier&&O.nullifier.byteLength>0&&(U.uint32(50),U.bytes(O.nullifier)),null!=O.rlnIdentifier&&O.rlnIdentifier.byteLength>0&&(U.uint32(58),U.bytes(O.rlnIdentifier)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={proof:new Uint8Array(0),merkleRoot:new Uint8Array(0),epoch:new Uint8Array(0),shareX:new Uint8Array(0),shareY:new Uint8Array(0),nullifier:new Uint8Array(0),rlnIdentifier:new Uint8Array(0)},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.proof=O.bytes();break;case 2:$.merkleRoot=O.bytes();break;case 3:$.epoch=O.bytes();break;case 4:$.shareX=O.bytes();break;case 5:$.shareY=O.bytes();break;case 6:$.nullifier=O.bytes();break;case 7:$.rlnIdentifier=O.bytes();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eG||(eG={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.payload&&O.payload.byteLength>0&&(U.uint32(10),U.bytes(O.payload)),null!=O.contentTopic&&""!==O.contentTopic&&(U.uint32(18),U.string(O.contentTopic)),null!=O.version&&(U.uint32(24),U.uint32(O.version)),null!=O.timestamp&&(U.uint32(80),U.sint64(O.timestamp)),null!=O.meta&&(U.uint32(90),U.bytes(O.meta)),null!=O.rateLimitProof&&(U.uint32(170),eG.codec().encode(O.rateLimitProof,U)),null!=O.ephemeral&&(U.uint32(248),U.bool(O.ephemeral)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={payload:new Uint8Array(0),contentTopic:""},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.payload=O.bytes();break;case 2:$.contentTopic=O.string();break;case 3:$.version=O.uint32();break;case 10:$.timestamp=O.sint64();break;case 11:$.meta=O.bytes();break;case 21:$.rateLimitProof=eG.codec().decode(O,O.uint32());break;case 31:$.ephemeral=O.bool();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(e$||(e$={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.digest&&O.digest.byteLength>0&&(U.uint32(10),U.bytes(O.digest)),null!=O.receiverTime&&0n!==O.receiverTime&&(U.uint32(16),U.sint64(O.receiverTime)),null!=O.senderTime&&0n!==O.senderTime&&(U.uint32(24),U.sint64(O.senderTime)),null!=O.pubsubTopic&&""!==O.pubsubTopic&&(U.uint32(34),U.string(O.pubsubTopic)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={digest:new Uint8Array(0),receiverTime:0n,senderTime:0n,pubsubTopic:""},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.digest=O.bytes();break;case 2:$.receiverTime=O.sint64();break;case 3:$.senderTime=O.sint64();break;case 4:$.pubsubTopic=O.string();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eW||(eW={})),function(O){let U,$,J;(function(O){O.BACKWARD="BACKWARD",O.FORWARD="FORWARD"})(U=O.Direction||(O.Direction={})),function(O){O[O.BACKWARD=0]="BACKWARD",O[O.FORWARD=1]="FORWARD"}($||($={})),function(O){O.codec=()=>enumeration($)}(U=O.Direction||(O.Direction={})),O.codec=()=>(null==J&&(J=message((U,$,J={})=>{!1!==J.lengthDelimited&&$.fork(),null!=U.pageSize&&($.uint32(8),$.uint64(U.pageSize)),null!=U.cursor&&($.uint32(18),eW.codec().encode(U.cursor,$)),null!=U.direction&&($.uint32(24),O.Direction.codec().encode(U.direction,$)),!1!==J.lengthDelimited&&$.ldelim()},(U,$)=>{let J={},en=null==$?U.len:U.pos+$;for(;U.pos>>3){case 1:J.pageSize=U.uint64();break;case 2:J.cursor=eW.codec().decode(U,U.uint32());break;case 3:J.direction=O.Direction.codec().decode(U);break;default:U.skipType(7&$)}}return J})),J),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eY||(eY={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.contentTopic&&""!==O.contentTopic&&(U.uint32(10),U.string(O.contentTopic)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={contentTopic:""},J=null==U?O.len:O.pos+U;for(;O.pos>>3==1?$.contentTopic=O.string():O.skipType(7&U)}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eJ||(eJ={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{if(!1!==$.lengthDelimited&&U.fork(),null!=O.pubsubTopic&&(U.uint32(18),U.string(O.pubsubTopic)),null!=O.contentFilters)for(let $ of O.contentFilters)U.uint32(26),eJ.codec().encode($,U);null!=O.pagingInfo&&(U.uint32(34),eY.codec().encode(O.pagingInfo,U)),null!=O.startTime&&(U.uint32(40),U.sint64(O.startTime)),null!=O.endTime&&(U.uint32(48),U.sint64(O.endTime)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={contentFilters:[]},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 2:$.pubsubTopic=O.string();break;case 3:$.contentFilters.push(eJ.codec().decode(O,O.uint32()));break;case 4:$.pagingInfo=eY.codec().decode(O,O.uint32());break;case 5:$.startTime=O.sint64();break;case 6:$.endTime=O.sint64();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eQ||(eQ={})),function(O){let U,$,J;(function(O){O.NONE="NONE",O.INVALID_CURSOR="INVALID_CURSOR"})(U=O.HistoryError||(O.HistoryError={})),function(O){O[O.NONE=0]="NONE",O[O.INVALID_CURSOR=1]="INVALID_CURSOR"}($||($={})),function(O){O.codec=()=>enumeration($)}(U=O.HistoryError||(O.HistoryError={})),O.codec=()=>(null==J&&(J=message((U,J,en={})=>{if(!1!==en.lengthDelimited&&J.fork(),null!=U.messages)for(let O of U.messages)J.uint32(18),e1.codec().encode(O,J);null!=U.pagingInfo&&(J.uint32(26),eY.codec().encode(U.pagingInfo,J)),null!=U.error&&0!==$[U.error]&&(J.uint32(32),O.HistoryError.codec().encode(U.error,J)),!1!==en.lengthDelimited&&J.ldelim()},($,J)=>{let en={messages:[],error:U.NONE},es=null==J?$.len:$.pos+J;for(;$.pos>>3){case 2:en.messages.push(e1.codec().decode($,$.uint32()));break;case 3:en.pagingInfo=eY.codec().decode($,$.uint32());break;case 4:en.error=O.HistoryError.codec().decode($);break;default:$.skipType(7&U)}}return en})),J),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eZ||(eZ={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.requestId&&""!==O.requestId&&(U.uint32(10),U.string(O.requestId)),null!=O.query&&(U.uint32(18),eQ.codec().encode(O.query,U)),null!=O.response&&(U.uint32(26),eZ.codec().encode(O.response,U)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={requestId:""},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.requestId=O.string();break;case 2:$.query=eQ.codec().decode(O,O.uint32());break;case 3:$.response=eZ.codec().decode(O,O.uint32());break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(eX||(eX={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.proof&&O.proof.byteLength>0&&(U.uint32(10),U.bytes(O.proof)),null!=O.merkleRoot&&O.merkleRoot.byteLength>0&&(U.uint32(18),U.bytes(O.merkleRoot)),null!=O.epoch&&O.epoch.byteLength>0&&(U.uint32(26),U.bytes(O.epoch)),null!=O.shareX&&O.shareX.byteLength>0&&(U.uint32(34),U.bytes(O.shareX)),null!=O.shareY&&O.shareY.byteLength>0&&(U.uint32(42),U.bytes(O.shareY)),null!=O.nullifier&&O.nullifier.byteLength>0&&(U.uint32(50),U.bytes(O.nullifier)),null!=O.rlnIdentifier&&O.rlnIdentifier.byteLength>0&&(U.uint32(58),U.bytes(O.rlnIdentifier)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={proof:new Uint8Array(0),merkleRoot:new Uint8Array(0),epoch:new Uint8Array(0),shareX:new Uint8Array(0),shareY:new Uint8Array(0),nullifier:new Uint8Array(0),rlnIdentifier:new Uint8Array(0)},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.proof=O.bytes();break;case 2:$.merkleRoot=O.bytes();break;case 3:$.epoch=O.bytes();break;case 4:$.shareX=O.bytes();break;case 5:$.shareY=O.bytes();break;case 6:$.nullifier=O.bytes();break;case 7:$.rlnIdentifier=O.bytes();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(e0||(e0={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.payload&&O.payload.byteLength>0&&(U.uint32(10),U.bytes(O.payload)),null!=O.contentTopic&&""!==O.contentTopic&&(U.uint32(18),U.string(O.contentTopic)),null!=O.version&&(U.uint32(24),U.uint32(O.version)),null!=O.timestamp&&(U.uint32(80),U.sint64(O.timestamp)),null!=O.meta&&(U.uint32(90),U.bytes(O.meta)),null!=O.rateLimitProof&&(U.uint32(170),e0.codec().encode(O.rateLimitProof,U)),null!=O.ephemeral&&(U.uint32(248),U.bool(O.ephemeral)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={payload:new Uint8Array(0),contentTopic:""},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.payload=O.bytes();break;case 2:$.contentTopic=O.string();break;case 3:$.version=O.uint32();break;case 10:$.timestamp=O.sint64();break;case 11:$.meta=O.bytes();break;case 21:$.rateLimitProof=e0.codec().decode(O,O.uint32());break;case 31:$.ephemeral=O.bool();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(e1||(e1={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.enr&&(U.uint32(10),U.bytes(O.enr)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={},J=null==U?O.len:O.pos+U;for(;O.pos>>3==1?$.enr=O.bytes():O.skipType(7&U)}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(e3||(e3={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.numPeers&&(U.uint32(8),U.uint64(O.numPeers)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={},J=null==U?O.len:O.pos+U;for(;O.pos>>3==1?$.numPeers=O.uint64():O.skipType(7&U)}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(e6||(e6={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{if(!1!==$.lengthDelimited&&U.fork(),null!=O.peerInfos)for(let $ of O.peerInfos)U.uint32(10),e3.codec().encode($,U);!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={peerInfos:[]},J=null==U?O.len:O.pos+U;for(;O.pos>>3==1?$.peerInfos.push(e3.codec().decode(O,O.uint32())):O.skipType(7&U)}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(e5||(e5={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.query&&(U.uint32(10),e6.codec().encode(O.query,U)),null!=O.response&&(U.uint32(18),e5.codec().encode(O.response,U)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.query=e6.codec().decode(O,O.uint32());break;case 2:$.response=e5.codec().decode(O,O.uint32());break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(e9||(e9={}));let sc="/waku/2/default-waku/proto",su=nf("waku:message:version-0"),sf=BigInt(1e6),sp=0;let DecodedMessage=class DecodedMessage{pubsubTopic;proto;constructor(O,U){this.pubsubTopic=O,this.proto=U}get ephemeral(){return!!this.proto.ephemeral}get payload(){return this.proto.payload}get contentTopic(){return this.proto.contentTopic}get _rawTimestamp(){return this.proto.timestamp}get timestamp(){try{if(this.proto.timestamp){let O=this.proto.timestamp/sf;return new Date(Number(O))}return}catch(O){return}}get meta(){return this.proto.meta}get version(){return this.proto.version??0}get rateLimitProof(){return this.proto.rateLimitProof}};let version_0_Encoder=class version_0_Encoder{contentTopic;ephemeral;pubsubTopic;metaSetter;constructor(O,U=!1,$,J){if(this.contentTopic=O,this.ephemeral=U,this.pubsubTopic=$,this.metaSetter=J,!O||""===O)throw Error("Content topic must be specified")}async toWire(O){return eR.encode(await this.toProtoObj(O))}async toProtoObj(O){let U=O.timestamp??new Date,$={payload:O.payload,version:sp,contentTopic:this.contentTopic,timestamp:BigInt(U.valueOf())*sf,meta:void 0,rateLimitProof:O.rateLimitProof,ephemeral:this.ephemeral};if(this.metaSetter){let O=this.metaSetter($);return{...$,meta:O}}return $}};function createEncoder({pubsubTopic:O=sc,contentTopic:U,ephemeral:$,metaSetter:J}){return new version_0_Encoder(U,$,O,J)}let version_0_Decoder=class version_0_Decoder{pubsubTopic;contentTopic;constructor(O,U){if(this.pubsubTopic=O,this.contentTopic=U,!U||""===U)throw Error("Content topic must be specified")}fromWireToProtoObj(O){let U=eR.decode(O);return su("Message decoded",U),Promise.resolve({payload:U.payload,contentTopic:U.contentTopic,version:U.version??void 0,timestamp:U.timestamp??void 0,meta:U.meta??void 0,rateLimitProof:U.rateLimitProof??void 0,ephemeral:U.ephemeral??!1})}async fromProtoObj(O,U){return U.version??0!==sp?(su("Failed to decode due to incorrect version, expected:",sp,", actual:",U.version),Promise.resolve(void 0)):new DecodedMessage(O,U)}};function createDecoder(O,U=sc){return new version_0_Decoder(U,O)}let sm="/relay-ping/1/ping/null",sy=nf("waku:keep-alive");let KeepAliveManager=class KeepAliveManager{pingKeepAliveTimers;relayKeepAliveTimers;options;relay;constructor(O,U){this.pingKeepAliveTimers=new Map,this.relayKeepAliveTimers=new Map,this.options=O,this.relay=U}start(O,U,$){this.stop(O);let{pingKeepAlive:J,relayKeepAlive:en}=this.options,es=O.toString();if(0!==J){let en=setInterval(()=>{(async()=>{let en;try{try{en=await U.ping(O),sy(`Ping succeeded (${es})`,en)}catch(O){sy(`Ping failed for peer (${es}). + Next ping will be attempted in ${J} seconds. + `);return}try{await $.patch(O,{metadata:{ping:(0,ng.iY)(en.toString())}})}catch(O){sy("Failed to update ping",O)}}catch(O){sy(`Ping failed (${es})`,O)}})()},1e3*J);this.pingKeepAliveTimers.set(es,en)}let eo=this.relay;if(eo&&0!==en){let U=this.scheduleRelayPings(eo,en,O.toString());this.relayKeepAliveTimers.set(O,U)}}stop(O){let U=O.toString();this.pingKeepAliveTimers.has(U)&&(clearInterval(this.pingKeepAliveTimers.get(U)),this.pingKeepAliveTimers.delete(U)),this.relayKeepAliveTimers.has(O)&&(this.relayKeepAliveTimers.get(O)?.map(clearInterval),this.relayKeepAliveTimers.delete(O))}stopAll(){for(let O of[...Object.values(this.pingKeepAliveTimers),...Object.values(this.relayKeepAliveTimers)])clearInterval(O);this.pingKeepAliveTimers.clear(),this.relayKeepAliveTimers.clear()}scheduleRelayPings(O,U,$){let J=[];for(let en of O.pubsubTopics){let es=O.getMeshPeers(en);if(!es.includes($))continue;let eo=createEncoder({pubsubTopic:en,contentTopic:sm,ephemeral:!0}),ea=setInterval(()=>{sy("Sending Waku Relay ping message"),O.send(eo,{payload:new Uint8Array([1])}).catch(O=>sy("Failed to send relay ping",O))},1e3*U);J.push(ea)}return J}};let sb=nf("waku:connection-manager"),sv=1,sE=3,sS=3;let ConnectionManager=class ConnectionManager extends events_EventEmitter{configuredPubSubTopics;static instances=new Map;keepAliveManager;options;libp2p;dialAttemptsForPeer=new Map;dialErrorsForPeer=new Map;currentActiveDialCount=0;pendingPeerDialQueue=[];static create(O,U,$,J,en,es){let eo=ConnectionManager.instances.get(O);return eo||(eo=new ConnectionManager(U,$,J,en,es),ConnectionManager.instances.set(O,eo)),eo}async getPeersByDiscovery(){let O=await this.libp2p.peerStore.all(),U=this.libp2p.getConnections().map(O=>O.remotePeer),$=[],J=[],en=[],es=[];for(let U of O){let O=await this.getTagNamesForPeer(U.id);O.includes(ev.BOOTSTRAP)?$.push(U):O.includes(ev.PEER_EXCHANGE)&&J.push(U)}for(let O of U){let U=await this.libp2p.peerStore.get(O),$=await this.getTagNamesForPeer(O);$.includes(ev.BOOTSTRAP)?en.push(U):$.includes(ev.PEER_EXCHANGE)&&es.push(U)}return{DISCOVERED:{[ev.BOOTSTRAP]:$,[ev.PEER_EXCHANGE]:J},CONNECTED:{[ev.BOOTSTRAP]:en,[ev.PEER_EXCHANGE]:es}}}constructor(O,U,$,J,en){super(),this.configuredPubSubTopics=$,this.libp2p=O,this.configuredPubSubTopics=$,this.options={maxDialAttemptsForPeer:sE,maxBootstrapPeersAllowed:sv,maxParallelDials:sS,...en},this.keepAliveManager=new KeepAliveManager(U,J),this.run().then(()=>sb("Connection Manager is now running")).catch(O=>sb("Unexpected error while running service",O)),this.dialPeerStorePeers().catch(O=>sb("Unexpected error while dialing peer store peers",O))}async dialPeerStorePeers(){let O=await this.libp2p.peerStore.all(),U=[];for(let $ of O)this.libp2p.getConnections().find(O=>O.remotePeer===$.id)||U.push(this.attemptDial($.id));try{await Promise.all(U)}catch(O){sb("Unexpected error while dialing peer store peers",O)}}async run(){this.startPeerDiscoveryListener(),this.startPeerConnectionListener(),this.startPeerDisconnectionListener()}stop(){this.keepAliveManager.stopAll(),this.libp2p.removeEventListener("peer:connect",this.onEventHandlers["peer:connect"]),this.libp2p.removeEventListener("peer:disconnect",this.onEventHandlers["peer:disconnect"]),this.libp2p.removeEventListener("peer:discovery",this.onEventHandlers["peer:discovery"])}async dialPeer(O){this.currentActiveDialCount+=1;let U=0;for(;U{O.tags=Array.from(new Set([...O.tags,...$]))}),this.dialAttemptsForPeer.delete(O.toString());break}catch($){$ instanceof AggregateError?sb(`Error dialing peer ${O.toString()} - ${$.errors}`):sb(`Error dialing peer ${O.toString()} - ${$.message}`),this.dialErrorsForPeer.set(O.toString(),$),U++,this.dialAttemptsForPeer.set(O.toString(),U)}if(this.currentActiveDialCount--,this.processDialQueue(),U===this.options.maxDialAttemptsForPeer)try{let U=this.dialErrorsForPeer.get(O.toString());if(U){let $;U instanceof AggregateError?U.errors?0===U.errors.length?sb("Errors array is empty for AggregateError"):$=JSON.stringify(U.errors[0]):sb("No errors array found for AggregateError"):$=U.message,sb(`Deleting undialable peer ${O.toString()} from peer store. Error: ${$}`)}this.dialErrorsForPeer.delete(O.toString()),await this.libp2p.peerStore.delete(O)}catch(U){throw Error(`Error deleting undialable peer ${O.toString()} from peer store - ${U}`)}}async dropConnection(O){try{this.keepAliveManager.stop(O),await this.libp2p.hangUp(O),sb(`Dropped connection with peer ${O.toString()}`)}catch(U){sb(`Error dropping connection with peer ${O.toString()} - ${U}`)}}processDialQueue(){if(this.pendingPeerDialQueue.length>0&&this.currentActiveDialCount{sb(O)})}}startPeerDiscoveryListener(){this.libp2p.addEventListener("peer:discovery",this.onEventHandlers["peer:discovery"])}startPeerConnectionListener(){this.libp2p.addEventListener("peer:connect",this.onEventHandlers["peer:connect"])}startPeerDisconnectionListener(){this.libp2p.addEventListener("peer:disconnect",this.onEventHandlers["peer:disconnect"])}async attemptDial(O){if(await this.shouldDialPeer(O)){if(this.currentActiveDialCount>=this.options.maxParallelDials){this.pendingPeerDialQueue.push(O);return}this.dialPeer(O).catch(U=>{sb(`Error dialing peer ${O.toString()} : ${U}`)})}}onEventHandlers={"peer:discovery":O=>{(async()=>{let{id:U}=O.detail;await this.dispatchDiscoveryEvent(U);try{await this.attemptDial(U)}catch(O){sb(`Error dialing peer ${U.toString()} : ${O}`)}})()},"peer:connect":O=>{(async()=>{let U=O.detail;this.keepAliveManager.start(U,this.libp2p.services.ping,this.libp2p.peerStore);let $=(await this.getTagNamesForPeer(U)).includes(ev.BOOTSTRAP);if($){let O=this.libp2p.getConnections().filter(O=>O.tags.includes(ev.BOOTSTRAP));O.length>this.options.maxBootstrapPeersAllowed?await this.dropConnection(U):this.dispatchEvent(new np(e_.PEER_CONNECT_BOOTSTRAP,{detail:U}))}else this.dispatchEvent(new np(e_.PEER_CONNECT_PEER_EXCHANGE,{detail:U}))})()},"peer:disconnect":()=>O=>{this.keepAliveManager.stop(O.detail)}};async shouldDialPeer(O){let U=this.libp2p.getConnections(O).length>0;if(U)return sb(`Already connected to peer ${O.toString()}. Not dialing.`),!1;if(!await this.isPeerTopicConfigured(O)){let U=await this.getPeerShardInfo(O,this.libp2p.peerStore);return sb(`Discovered peer ${O.toString()} with ShardInfo ${U} is not part of any of the configured pubsub topics (${this.configuredPubSubTopics}). + Not dialing.`),!1}return!!await this.isPeerDialableBasedOnBootstrapStatus(O)||(sb(`Peer ${O.toString()} is not dialable based on bootstrap status. Not dialing.`),!1)}async isPeerDialableBasedOnBootstrapStatus(O){let U=await this.getTagNamesForPeer(O),$=U.some(O=>O===ev.BOOTSTRAP);if(!$)return!0;{let O=this.libp2p.getConnections().filter(O=>O.tags.find(O=>O===ev.BOOTSTRAP)).length;if(Othis.configuredPubSubTopics.includes(O));return J}async getPeerShardInfo(O,U){let $=await U.get(O),J=$.metadata.get("shardInfo");if(J)return decodeRelayShard(J)}};let sA=300,sI=300,sP="js-waku",sk=nf("waku:waku");let waku_WakuNode=class waku_WakuNode{pubsubTopics;libp2p;relay;store;filter;lightPush;connectionManager;constructor(O,U,$,J,en,es,eo){this.pubsubTopics=U,this.libp2p=$,J&&(this.store=J($)),es&&(this.filter=es($)),en&&(this.lightPush=en($)),eo&&(this.relay=eo($));let ea=O.pingKeepAlive||sA,eu=this.relay?O.relayKeepAlive||sI:0,ef=this.libp2p.peerId.toString();this.connectionManager=ConnectionManager.create(ef,$,{pingKeepAlive:ea,relayKeepAlive:eu},U,this.relay),sk("Waku node created",ef,`relay: ${!!this.relay}, store: ${!!this.store}, light push: ${!!this.lightPush}, filter: ${!!this.filter}`)}async dial(O,U){let $=U??[],J=mapToPeerIdOrMultiaddr(O);void 0===U&&(this.relay&&$.push(eu.Relay),this.store&&$.push(eu.Store),this.filter&&$.push(eu.Filter),this.lightPush&&$.push(eu.LightPush));let en=[];return $.includes(eu.Relay)&&(this.relay?this.relay.gossipSub.multicodecs.forEach(O=>en.push(O)):sk("Relay codec not included in dial codec: protocol not mounted locally")),$.includes(eu.Store)&&(this.store?en.push(this.store.multicodec):sk("Store codec not included in dial codec: protocol not mounted locally")),$.includes(eu.LightPush)&&(this.lightPush?en.push(this.lightPush.multicodec):sk("Light Push codec not included in dial codec: protocol not mounted locally")),$.includes(eu.Filter)&&(this.filter?en.push(this.filter.multicodec):sk("Filter codec not included in dial codec: protocol not mounted locally")),sk(`Dialing to ${J.toString()} with protocols ${$}`),this.libp2p.dialProtocol(J,en)}async start(){await this.libp2p.start()}async stop(){this.connectionManager.stop(),await this.libp2p.stop()}isStarted(){return this.libp2p.isStarted()}getLocalMultiaddrWithID(){let O=this.libp2p.getMultiaddrs().find(O=>O.toString().match(/127\.0\.0\.1/));if(!O||""===O.toString())throw"Not listening on localhost";return O+"/p2p/"+this.libp2p.peerId.toString()}};function mapToPeerIdOrMultiaddr(O){return isPeerId(O)?O:src_multiaddr(O)}function groupByContentTopic(O){let U=new Map;return O.forEach(O=>{let $=U.get(O.contentTopic);$||(U.set(O.contentTopic,[]),$=U.get(O.contentTopic)),$.push(O)}),U}let sT=60;async function toAsyncIterator(O,U,$){let J;let en=$?.iteratorDelay??sT,es=[];J=await O.subscribe(U,O=>{es.push(O)});let eo=Number.isInteger($?.timeoutMs),ea=$?.timeoutMs??0,eu=Date.now();return{iterator:async function*(){for(;;){if(eo&&Date.now()-eu>=ea)return;await wait(en);let O=es.shift();if(!J&&0===es.length)return O;(O||!J)&&(yield O)}}(),async stop(){J&&(await J(),J=void 0)}}}function wait(O){return new Promise(U=>{setTimeout(U,O)})}function isAsyncIterable(O){return null!=O[Symbol.asyncIterator]}var dist_src=function(O){if(isAsyncIterable(O))return(async()=>{let U=[];for await(let $ of O)U.push($);return U})();let U=[];for(let $ of O)U.push($);return U};let sR=Symbol.for("@achingbrain/uint8arraylist");function findBufAndOffset(O,U){if(null==U||U<0)throw RangeError("index is out of bounds");let $=0;for(let J of O){let O=$+J.byteLength;if(U0&&this.appendAll(O)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...O){this.appendAll(O)}appendAll(O){let U=0;for(let $ of O)if($ instanceof Uint8Array)U+=$.byteLength,this.bufs.push($);else if(isUint8ArrayList($))U+=$.byteLength,this.bufs.push(...$.bufs);else throw Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=U}prepend(...O){this.prependAll(O)}prependAll(O){let U=0;for(let $ of O.reverse())if($ instanceof Uint8Array)U+=$.byteLength,this.bufs.unshift($);else if(isUint8ArrayList($))U+=$.byteLength,this.bufs.unshift(...$.bufs);else throw Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=U}get(O){let U=findBufAndOffset(this.bufs,O);return U.buf[U.index]}set(O,U){let $=findBufAndOffset(this.bufs,O);$.buf[$.index]=U}write(O,U=0){if(O instanceof Uint8Array)for(let $=0;$0;)if(O>=this.bufs[0].byteLength)O-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(O),this.length-=O;break}}}slice(O,U){let{bufs:$,length:J}=this._subList(O,U);return concat_concat($,J)}subarray(O,U){let{bufs:$,length:J}=this._subList(O,U);return 1===$.length?$[0]:concat_concat($,J)}sublist(O,U){let{bufs:$,length:J}=this._subList(O,U),en=new src_Uint8ArrayList;return en.length=J,en.bufs=$,en}_subList(O,U){if(O=O??0,U=U??this.length,O<0&&(O=this.length+O),U<0&&(U=this.length+U),O<0||U>this.length)throw RangeError("index is out of bounds");if(O===U)return{bufs:[],length:0};if(0===O&&U===this.length)return{bufs:[...this.bufs],length:this.length};let $=[],J=0;for(let en=0;en=ea)continue;let eu=O>=eo&&Oeo&&U<=ea;if(eu&&ef){if(O===eo&&U===ea){$.push(es);break}let J=O-eo;$.push(es.subarray(J,J+(U-O)));break}if(eu){if(0===O){$.push(es);continue}$.push(es.subarray(O-eo));continue}if(ef){if(U===ea){$.push(es);break}$.push(es.subarray(0,U-eo));break}$.push(es)}return{bufs:$,length:U-O}}indexOf(O,U=0){let $;if(!isUint8ArrayList(O)&&!(O instanceof Uint8Array))throw TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let J=O instanceof Uint8Array?O:O.subarray();if(isNaN(U=Number(U??0))&&(U=0),U<0&&(U=this.length+U),U<0&&(U=0),0===O.length)return U>this.length?this.length:U;let en=J.byteLength;if(0===en)throw TypeError("search must be at least 1 byte long");let es=256,eo=new Int32Array(es);for(let O=0;O=0;U--){let en=this.get(O+U);if(J[U]!==en){$=Math.max(1,U-ea[en]);break}}if(0===$)return O}return -1}getInt8(O){let U=this.subarray(O,O+1),$=new DataView(U.buffer,U.byteOffset,U.byteLength);return $.getInt8(0)}setInt8(O,U){let $=(0,rN.E)(1),J=new DataView($.buffer,$.byteOffset,$.byteLength);J.setInt8(0,U),this.write($,O)}getInt16(O,U){let $=this.subarray(O,O+2),J=new DataView($.buffer,$.byteOffset,$.byteLength);return J.getInt16(0,U)}setInt16(O,U,$){let J=(0,rN.u)(2),en=new DataView(J.buffer,J.byteOffset,J.byteLength);en.setInt16(0,U,$),this.write(J,O)}getInt32(O,U){let $=this.subarray(O,O+4),J=new DataView($.buffer,$.byteOffset,$.byteLength);return J.getInt32(0,U)}setInt32(O,U,$){let J=(0,rN.u)(4),en=new DataView(J.buffer,J.byteOffset,J.byteLength);en.setInt32(0,U,$),this.write(J,O)}getBigInt64(O,U){let $=this.subarray(O,O+8),J=new DataView($.buffer,$.byteOffset,$.byteLength);return J.getBigInt64(0,U)}setBigInt64(O,U,$){let J=(0,rN.u)(8),en=new DataView(J.buffer,J.byteOffset,J.byteLength);en.setBigInt64(0,U,$),this.write(J,O)}getUint8(O){let U=this.subarray(O,O+1),$=new DataView(U.buffer,U.byteOffset,U.byteLength);return $.getUint8(0)}setUint8(O,U){let $=(0,rN.E)(1),J=new DataView($.buffer,$.byteOffset,$.byteLength);J.setUint8(0,U),this.write($,O)}getUint16(O,U){let $=this.subarray(O,O+2),J=new DataView($.buffer,$.byteOffset,$.byteLength);return J.getUint16(0,U)}setUint16(O,U,$){let J=(0,rN.u)(2),en=new DataView(J.buffer,J.byteOffset,J.byteLength);en.setUint16(0,U,$),this.write(J,O)}getUint32(O,U){let $=this.subarray(O,O+4),J=new DataView($.buffer,$.byteOffset,$.byteLength);return J.getUint32(0,U)}setUint32(O,U,$){let J=(0,rN.u)(4),en=new DataView(J.buffer,J.byteOffset,J.byteLength);en.setUint32(0,U,$),this.write(J,O)}getBigUint64(O,U){let $=this.subarray(O,O+8),J=new DataView($.buffer,$.byteOffset,$.byteLength);return J.getBigUint64(0,U)}setBigUint64(O,U,$){let J=(0,rN.u)(8),en=new DataView(J.buffer,J.byteOffset,J.byteLength);en.setBigUint64(0,U,$),this.write(J,O)}getFloat32(O,U){let $=this.subarray(O,O+4),J=new DataView($.buffer,$.byteOffset,$.byteLength);return J.getFloat32(0,U)}setFloat32(O,U,$){let J=(0,rN.u)(4),en=new DataView(J.buffer,J.byteOffset,J.byteLength);en.setFloat32(0,U,$),this.write(J,O)}getFloat64(O,U){let $=this.subarray(O,O+8),J=new DataView($.buffer,$.byteOffset,$.byteLength);return J.getFloat64(0,U)}setFloat64(O,U,$){let J=(0,rN.u)(8),en=new DataView(J.buffer,J.byteOffset,J.byteLength);en.setFloat64(0,U,$),this.write(J,O)}equals(O){if(null==O||!(O instanceof src_Uint8ArrayList)||O.bufs.length!==this.bufs.length)return!1;for(let U=0;UO+U.byteLength,0)),$.length=U,$}};function utils_isAsyncIterable(O){return null!=O[Symbol.asyncIterator]}let defaultEncoder=O=>{let U=encodingLength(O),$=(0,rN.E)(U);return encode(O,$),defaultEncoder.bytes=U,$};function encode_encode(O,U){U=U??{};let $=U.lengthEncoder??defaultEncoder;function*maybeYield(O){let U=$(O.byteLength);U instanceof Uint8Array?yield U:yield*U,O instanceof Uint8Array?yield O:yield*O}return utils_isAsyncIterable(O)?async function*(){for await(let U of O)yield*maybeYield(U)}():function*(){for(let U of O)yield*maybeYield(U)}()}defaultEncoder.bytes=0,encode_encode.single=(O,U)=>{U=U??{};let $=U.lengthEncoder??defaultEncoder;return new src_Uint8ArrayList($(O.byteLength),O)};var sC=$(2594);let sB=8,sN=4194304;!function(O){O[O.LENGTH=0]="LENGTH",O[O.DATA=1]="DATA"}(e7||(e7={}));let defaultDecoder=O=>{let U=src_decode(O);return defaultDecoder.bytes=encodingLength(U),U};function decode_decode(O,U){let $=new src_Uint8ArrayList,J=e7.LENGTH,en=-1,es=U?.lengthDecoder??defaultDecoder,eo=U?.maxLengthLength??sB,ea=U?.maxDataLength??sN;function*maybeYield(){for(;$.byteLength>0;){if(J===e7.LENGTH)try{if((en=es($))<0)throw sC(Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(en>ea)throw sC(Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let O=es.bytes;$.consume(O),U?.onLength!=null&&U.onLength(en),J=e7.DATA}catch(O){if(O instanceof RangeError){if($.byteLength>eo)throw sC(Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw O}if(J===e7.DATA){if($.byteLength0)throw sC(Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let U of O)$.append(U),yield*maybeYield();if($.byteLength>0)throw sC(Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}function pDefer(){let O={};return O.promise=new Promise((U,$)=>{O.resolve=U,O.reject=$}),O}defaultDecoder.bytes=0,decode_decode.fromReader=(O,U)=>{let $=1,J=async function*(){for(;;)try{let{done:U,value:J}=await O.next($);if(!0===U)return;null!=J&&(yield J)}catch(O){if("ERR_UNDER_READ"===O.code)return{done:!0,value:null};throw O}finally{$=1}}(),onLength=O=>{$=O};return decode_decode(J,{...U??{},onLength})};let FixedFIFO=class FixedFIFO{buffer;mask;top;btm;next;constructor(O){if(!(O>0)||(O-1&O)!=0)throw Error("Max size for a FixedFIFO should be a power of two");this.buffer=Array(O),this.mask=O-1,this.top=0,this.btm=0,this.next=null}push(O){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=O,this.top=this.top+1&this.mask,!0)}shift(){let O=this.buffer[this.btm];if(void 0!==O)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,O}isEmpty(){return void 0===this.buffer[this.btm]}};let FIFO=class FIFO{size;hwm;head;tail;constructor(O={}){this.hwm=O.splitLimit??16,this.head=new FixedFIFO(this.hwm),this.tail=this.head,this.size=0}calculateSize(O){return O?.byteLength!=null?O.byteLength:1}push(O){if(O?.value!=null&&(this.size+=this.calculateSize(O.value)),!this.head.push(O)){let U=this.head;this.head=U.next=new FixedFIFO(2*this.head.buffer.length),this.head.push(O)}}shift(){let O=this.tail.shift();if(void 0===O&&null!=this.tail.next){let U=this.tail.next;this.tail.next=null,this.tail=U,O=this.tail.shift()}return O?.value!=null&&(this.size-=this.calculateSize(O.value)),O}isEmpty(){return this.head.isEmpty()}};let src_AbortError=class src_AbortError extends Error{type;code;constructor(O,U){super(O??"The operation was aborted"),this.type="aborted",this.code=U??"ABORT_ERR"}};function src_pushable(O={}){let getNext=O=>{let U=O.shift();if(null==U)return{done:!0};if(null!=U.error)throw U.error;return{done:!0===U.done,value:U.value}};return _pushable(getNext,O)}function pushableV(O={}){let getNext=O=>{let U;let $=[];for(;!O.isEmpty()&&null!=(U=O.shift());){if(null!=U.error)throw U.error;!1===U.done&&$.push(U.value)}return null==U?{done:!0}:{done:!0===U.done,value:$}};return _pushable(getNext,O)}function _pushable(O,U){let $,J,en;let es=(U=U??{}).onEnd,eo=new FIFO,ea=pDefer(),waitNext=async()=>{try{if(!eo.isEmpty())return O(eo);if(en)return{done:!0};return await new Promise((U,en)=>{J=es=>{J=null,eo.push(es);try{U(O(eo))}catch(O){en(O)}return $}})}finally{eo.isEmpty()&&queueMicrotask(()=>{ea.resolve(),ea=pDefer()})}},bufferNext=O=>null!=J?J(O):(eo.push(O),$),bufferError=O=>(eo=new FIFO,null!=J)?J({error:O}):(eo.push({error:O}),$),push=O=>{if(en)return $;if(U?.objectMode!==!0&&O?.byteLength==null)throw Error("objectMode was not true but tried to push non-Uint8Array value");return bufferNext({done:!1,value:O})},end=O=>en?$:(en=!0,null!=O?bufferError(O):bufferNext({done:!0})),_return=()=>(eo=new FIFO,end(),{done:!0}),_throw=O=>(end(O),{done:!0});if($={[Symbol.asyncIterator](){return this},next:waitNext,return:_return,throw:_throw,push,end,get readableLength(){return eo.size},onEmpty:async O=>{let U,$;let J=O?.signal;if(J?.throwIfAborted(),!eo.isEmpty()){null!=J&&(U=new Promise((O,U)=>{$=()=>{U(new src_AbortError)},J.addEventListener("abort",$)}));try{await Promise.race([ea.promise,U])}finally{null!=$&&null!=J&&J?.removeEventListener("abort",$)}}}},null==es)return $;let eu=$;return $={[Symbol.asyncIterator](){return this},next:()=>eu.next(),throw:O=>(eu.throw(O),null!=es&&(es(O),es=void 0),{done:!0}),return:()=>(eu.return(),null!=es&&(es(),es=void 0),{done:!0}),push,end:O=>(eu.end(O),null!=es&&(es(O),es=void 0),$),get readableLength(){return eu.readableLength}}}function src_isAsyncIterable(O){return null!=O[Symbol.asyncIterator]}var it_merge_dist_src=function(...O){let U=[];for(let $ of O)src_isAsyncIterable($)||U.push($);return U.length===O.length?function*(){for(let O of U)yield*O}():async function*(){let U=src_pushable({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(O.map(async O=>{for await(let $ of O)U.push($)})),U.end()}catch(O){U.end(O)}}),yield*U}()};function pipe(O,...U){if(null==O)throw Error("Empty pipeline");if(isDuplex(O)){let U=O;O=()=>U.source}else if(isIterable(O)||dist_src_isAsyncIterable(O)){let U=O;O=()=>U}let $=[O,...U];if($.length>1&&isDuplex($[$.length-1])&&($[$.length-1]=$[$.length-1].sink),$.length>2)for(let O=1;O<$.length-1;O++)isDuplex($[O])&&($[O]=duplexPipelineFn($[O]));return rawPipe(...$)}let rawPipe=(...O)=>{let U;for(;O.length>0;)U=O.shift()(U);return U},dist_src_isAsyncIterable=O=>O?.[Symbol.asyncIterator]!=null,isIterable=O=>O?.[Symbol.iterator]!=null,isDuplex=O=>null!=O&&null!=O.sink&&null!=O.source,duplexPipelineFn=O=>U=>{let $=O.sink(U);if($?.then!=null){let U;let J=src_pushable({objectMode:!0});$.then(()=>{J.end()},O=>{J.end(O)});let en=O.source;if(dist_src_isAsyncIterable(en))U=async function*(){yield*en,J.end()};else if(isIterable(en))U=function*(){yield*en,J.end()};else throw Error("Unknown duplex source type - must be Iterable or AsyncIterable");return it_merge_dist_src(J,U())}return O.source},sD=nf("waku:libp2p-utils");function selectRandomPeer(O){if(0===O.length)return;let U=Math.round(Math.random()*(O.length-1));return O[U]}async function selectLowestLatencyPeer(O,U){if(0===U.length)return;let $=await Promise.all(U.map(async U=>{let $=(await O.get(U.id)).metadata.get("ping");if(!$)return{peer:U,ping:1/0};let J=Number((0,ng.Md)($))??1/0;return{peer:U,ping:J}})),J=$.sort((O,U)=>O.ping-U.ping)[0];if(J)return J.ping!==1/0?J.peer:void 0}async function getPeersForProtocol(O,U){let $=[];return await O.forEach(O=>{for(let J=0;J{"open"===O.status&&(U?O.timeline.open>U.timeline.open&&(U=O):U=O)}),U)}async function filterPeers(O,U,$){let J=O.filter(O=>O.tags.has(ev.BOOTSTRAP)).slice(0,$),en=O.filter(O=>!O.tags.has(ev.BOOTSTRAP));if(0===U)return[...J,...en];let es=[...J];for(;es.length0;){let O=Math.floor(Math.random()*en.length),U=en.splice(O,1)[0];es.push(U)}return es}let StreamManager=class StreamManager{multicodec;getConnections;addEventListener;streamPool;log;constructor(O,U,$){this.multicodec=O,this.getConnections=U,this.addEventListener=$,this.log=nf(`waku:stream-manager:${O}`),this.addEventListener("peer:update",this.handlePeerUpdateStreamPool.bind(this)),this.getStream=this.getStream.bind(this),this.streamPool=new Map}async getStream(O){let U=O.id.toString(),$=this.streamPool.get(U);if(!$)return this.newStream(O);this.streamPool.delete(U),this.prepareNewStream(O);let J=await $;return J&&"closed"!==J.status?J:this.newStream(O)}async newStream(O){let U=this.getConnections(O.id),$=selectConnection(U);if(!$)throw Error("Failed to get a connection to the peer");return $.newStream(this.multicodec)}prepareNewStream(O){let U=this.newStream(O).catch(()=>{this.log(`Failed to prepare a new stream for ${O.id.toString()}`)});this.streamPool.set(O.id.toString(),U)}handlePeerUpdateStreamPool=O=>{let U=O.detail.peer;U.protocols.includes(this.multicodec)&&(this.log(`Preemptively opening a stream to ${U.id.toString()}`),this.prepareNewStream(U))}};let BaseProtocol=class BaseProtocol{multicodec;components;addLibp2pEventListener;removeLibp2pEventListener;streamManager;constructor(O,U){this.multicodec=O,this.components=U,this.addLibp2pEventListener=U.events.addEventListener.bind(U.events),this.removeLibp2pEventListener=U.events.removeEventListener.bind(U.events),this.streamManager=new StreamManager(O,U.connectionManager.getConnections.bind(U.connectionManager),this.addLibp2pEventListener)}async getStream(O){return this.streamManager.getStream(O)}get peerStore(){return this.components.peerStore}async peers(){return getPeersForProtocol(this.peerStore,[this.multicodec])}async getPeer(O){let{peer:U}=await selectPeerForProtocol(this.peerStore,[this.multicodec],O);return U}async getPeers({numPeers:O,maxBootstrapPeers:U}={maxBootstrapPeers:1,numPeers:0}){let $=await getPeersForProtocol(this.peerStore,[this.multicodec]);return filterPeers($,O,U)}};var sM=$(1872);let FilterPushRpc=class FilterPushRpc{proto;constructor(O){this.proto=O}static decode(O){let U=eF.decode(O);return new FilterPushRpc(U)}encode(){return eF.encode(this.proto)}get wakuMessage(){return this.proto.wakuMessage}get pubsubTopic(){return this.proto.pubsubTopic}};let FilterSubscribeRpc=class FilterSubscribeRpc{proto;constructor(O){this.proto=O}static createSubscribeRequest(O,U){return new FilterSubscribeRpc({requestId:(0,sM.Z)(),filterSubscribeType:eL.FilterSubscribeType.SUBSCRIBE,pubsubTopic:O,contentTopics:U})}static createUnsubscribeRequest(O,U){return new FilterSubscribeRpc({requestId:(0,sM.Z)(),filterSubscribeType:eL.FilterSubscribeType.UNSUBSCRIBE,pubsubTopic:O,contentTopics:U})}static createUnsubscribeAllRequest(O){return new FilterSubscribeRpc({requestId:(0,sM.Z)(),filterSubscribeType:eL.FilterSubscribeType.UNSUBSCRIBE_ALL,pubsubTopic:O,contentTopics:[]})}static createSubscriberPingRequest(){return new FilterSubscribeRpc({requestId:(0,sM.Z)(),filterSubscribeType:eL.FilterSubscribeType.SUBSCRIBER_PING,pubsubTopic:"",contentTopics:[]})}static decode(O){let U=eL.decode(O);return new FilterSubscribeRpc(U)}encode(){return eL.encode(this.proto)}get filterSubscribeType(){return this.proto.filterSubscribeType}get requestId(){return this.proto.requestId}get pubsubTopic(){return this.proto.pubsubTopic}get contentTopics(){return this.proto.contentTopics}};let FilterSubscribeResponse=class FilterSubscribeResponse{proto;constructor(O){this.proto=O}static decode(O){let U=eU.decode(O);return new FilterSubscribeResponse(U)}encode(){return eU.encode(this.proto)}get statusCode(){return this.proto.statusCode}get statusDesc(){return this.proto.statusDesc}get requestId(){return this.proto.requestId}};let sO=nf("waku:filter:v2"),sL={SUBSCRIBE:"/vac/waku/filter-subscribe/2.0.0-beta1",PUSH:"/vac/waku/filter-push/2.0.0-beta1"};let Subscription=class Subscription{peer;pubsubTopic;newStream;subscriptionCallbacks;constructor(O,U,$){this.peer=U,this.pubsubTopic=O,this.newStream=$,this.subscriptionCallbacks=new Map}async subscribe(O,U){let $=Array.isArray(O)?O:[O],J=groupByContentTopic($),en=Array.from(J.keys()),es=await this.newStream(this.peer),eo=FilterSubscribeRpc.createSubscribeRequest(this.pubsubTopic,en);try{let O=await pipe([eo.encode()],encode_encode,es,decode_decode,async O=>await dist_src(O));if(!O||!O.length)throw Error(`No response received for request ${eo.requestId}: ${O}`);let{statusCode:U,requestId:$,statusDesc:J}=FilterSubscribeResponse.decode(O[0].slice());if(U<200||U>=300)throw Error(`Filter subscribe request ${$} failed with status code ${U}: ${J}`);sO("Subscribed to peer ",this.peer.id.toString(),"for content topics",en)}catch(O){throw Error("Error subscribing to peer: "+this.peer.id.toString()+" for content topics: "+en+": "+O)}J.forEach((O,$)=>{let J={decoders:O,callback:U};this.subscriptionCallbacks.set($,J)})}async unsubscribe(O){let U=await this.newStream(this.peer),$=FilterSubscribeRpc.createUnsubscribeRequest(this.pubsubTopic,O);try{await pipe([$.encode()],encode_encode,U.sink)}catch(O){throw Error("Error subscribing: "+O)}O.forEach(O=>{this.subscriptionCallbacks.delete(O)})}async ping(){let O=await this.newStream(this.peer),U=FilterSubscribeRpc.createSubscriberPingRequest();try{let $=await pipe([U.encode()],encode_encode,O,decode_decode,async O=>await dist_src(O)),{statusCode:J,requestId:en,statusDesc:es}=FilterSubscribeResponse.decode($[0].slice());if(J<200||J>=300)throw Error(`Filter ping request ${en} failed with status code ${J}: ${es}`);sO("Ping successful")}catch(O){throw sO("Error pinging: ",O),Error("Error pinging: "+O)}}async unsubscribeAll(){let O=await this.newStream(this.peer),U=FilterSubscribeRpc.createUnsubscribeAllRequest(this.pubsubTopic);try{let $=await pipe([U.encode()],encode_encode,O,decode_decode,async O=>await dist_src(O)),{statusCode:J,requestId:en,statusDesc:es}=FilterSubscribeResponse.decode($[0].slice());if(J<200||J>=300)throw Error(`Filter unsubscribe all request ${en} failed with status code ${J}: ${es}`);this.subscriptionCallbacks.clear(),sO("Unsubscribed from all content topics")}catch(O){throw Error("Error unsubscribing from all content topics: "+O)}}async processMessage(O){let U=O.contentTopic,$=this.subscriptionCallbacks.get(U);if(!$){sO("No subscription callback available for ",U);return}await pushMessage($,this.pubsubTopic,O)}};let Filter=class Filter extends BaseProtocol{pubsubTopics=[];activeSubscriptions=new Map;NUM_PEERS_PROTOCOL=1;getActiveSubscription(O,U){return this.activeSubscriptions.get(`${O}_${U}`)}setActiveSubscription(O,U,$){return this.activeSubscriptions.set(`${O}_${U}`,$),$}constructor(O,U){super(sL.SUBSCRIBE,O.components),this.pubsubTopics=U?.pubsubTopics||[sc],O.handle(sL.PUSH,this.onRequest.bind(this)).catch(O=>{sO("Failed to register ",sL.PUSH,O)}),this.activeSubscriptions=new Map}async createSubscription(O=sc){ensurePubsubTopicIsConfigured(O,this.pubsubTopics);let U=(await this.getPeers({maxBootstrapPeers:1,numPeers:this.NUM_PEERS_PROTOCOL}))[0],$=this.getActiveSubscription(O,U.id.toString())??this.setActiveSubscription(O,U.id.toString(),new Subscription(O,U,this.getStream.bind(this,U)));return $}toSubscriptionIterator(O){return toAsyncIterator(this,O)}async subscribe(O,U){let $=await this.createSubscription();await $.subscribe(O,U);let J=Array.from(groupByContentTopic(Array.isArray(O)?O:[O]).keys());return async()=>{await $.unsubscribe(J)}}onRequest(O){sO("Receiving message push");try{pipe(O.stream,decode_decode,async U=>{for await(let $ of U){let U=FilterPushRpc.decode($.slice()),{pubsubTopic:J,wakuMessage:en}=U;if(!en){sO("Received empty message");return}if(!J){sO("PubSub topic missing from push message");return}let es=O.connection.remotePeer.toString(),eo=this.getActiveSubscription(J,es);if(!eo){sO(`No subscription locally registered for topic ${J}`);return}await eo.processMessage(en)}}).then(()=>{sO("Receiving pipe closed.")},O=>{sO("Error with receiving pipe",O)})}catch(O){sO("Error decoding message",O)}}};function filter_wakuFilter(O={}){return U=>new Filter(U,O)}async function pushMessage(O,U,$){let{decoders:J,callback:en}=O,{contentTopic:es}=$;if(!es){sO("Message has no content topic, skipping");return}try{let O=J.map(O=>O.fromProtoObj(U,$).then(O=>O||Promise.reject("Decoding failed"))),es=await Promise.any(O);await en(es)}catch(O){sO("Error decoding message",O)}}let sU=1048576,sF=1,isSizeValid=O=>!(O.length/sU>sF);let PushRpc=class PushRpc{proto;constructor(O){this.proto=O}static createRequest(O,U){return new PushRpc({requestId:(0,sM.Z)(),request:{message:O,pubsubTopic:U},response:void 0})}static decode(O){let U=eV.decode(O);return new PushRpc(U)}encode(){return eV.encode(this.proto)}get query(){return this.proto.request}get response(){return this.proto.response}};let sK=nf("waku:light-push"),sj="/vac/waku/lightpush/2.0.0-beta1";let LightPush=class LightPush extends BaseProtocol{pubsubTopics;NUM_PEERS_PROTOCOL=1;constructor(O,U){super(sj,O.components),this.pubsubTopics=U?.pubsubTopics??[sc]}async preparePushMessage(O,U,$){try{if(!isSizeValid(U.payload))return sK("Failed to send waku light push: message is bigger than 1MB"),{query:null,error:ef.SIZE_TOO_BIG};let J=await O.toProtoObj(U);if(!J)return sK("Failed to encode to protoMessage, aborting push"),{query:null,error:ef.ENCODE_FAILED};let en=PushRpc.createRequest(J,$);return{query:en,error:null}}catch(O){return sK("Failed to prepare push message",O),{query:null,error:ef.GENERIC_FAIL}}}async send(O,U){let{pubsubTopic:$}=O;ensurePubsubTopicIsConfigured($,this.pubsubTopics);let J=[],{query:en,error:es}=await this.preparePushMessage(O,U,$);if(es||!en)return{recipients:J,errors:[es]};let eo=await this.getPeers({maxBootstrapPeers:1,numPeers:this.NUM_PEERS_PROTOCOL});if(!eo.length)return{recipients:J,errors:[ef.NO_PEER_AVAILABLE]};let ea=eo.map(async O=>{let U,$,es;try{U=await this.getStream(O)}catch(U){return sK(`Failed to get a stream for remote peer${O.id.toString()}`,U),{recipients:J,error:ef.REMOTE_PEER_FAULT}}try{$=await pipe([en.encode()],encode_encode,U,decode_decode,async O=>await dist_src(O))}catch(O){return sK("Failed to send waku light push request",O),{recipients:J,error:ef.GENERIC_FAIL}}let eo=new src_Uint8ArrayList;$.forEach(O=>{eo.append(O)});try{es=PushRpc.decode(eo).response}catch(O){return sK("Failed to decode push reply",O),{recipients:J,error:ef.DECODE_FAILED}}return es?es.isSuccess?(J.some(U=>U.equals(O.id))||J.push(O.id),{recipients:J}):(sK("Remote peer rejected the message: ",es.info),{recipients:J,error:ef.REMOTE_PEER_REJECTED}):(sK("Remote peer fault: No response in PushRPC"),{recipients:J,error:ef.REMOTE_PEER_FAULT})}),eu=await Promise.allSettled(ea),eg=eu.filter(O=>"fulfilled"===O.status).map(O=>O.value.error).filter(O=>void 0!==O);return{recipients:J,errors:eg}}};function light_push_wakuLightPush(O={}){return U=>new LightPush(U,O)}function isDefined(O){return!!O}let sH={payload:new Uint8Array,contentTopic:"",version:void 0,timestamp:void 0,meta:void 0,rateLimitProof:void 0,ephemeral:void 0};function toProtoMessage(O){return{...sH,...O}}let sq=BigInt(1e6);!function(O){O.BACKWARD="backward",O.FORWARD="forward"}(te||(te={}));let HistoryRpc=class HistoryRpc{proto;constructor(O){this.proto=O}get query(){return this.proto.query}get response(){return this.proto.response}static createQuery(O){let U,$;let J=O.contentTopics.map(O=>({contentTopic:O})),en=directionToProto(O.pageDirection),es={pageSize:BigInt(O.pageSize),cursor:O.cursor,direction:en};return O.startTime&&(U=BigInt(O.startTime.valueOf())*sq),O.endTime&&($=BigInt(O.endTime.valueOf())*sq),new HistoryRpc({requestId:(0,sM.Z)(),query:{pubsubTopic:O.pubsubTopic,contentFilters:J,pagingInfo:es,startTime:U,endTime:$},response:void 0})}decode(O){let U=eX.decode(O);return new HistoryRpc(U)}encode(){return eX.encode(this.proto)}};function directionToProto(O){switch(O){case te.BACKWARD:return eY.Direction.BACKWARD;case te.FORWARD:return eY.Direction.FORWARD;default:return eY.Direction.BACKWARD}}var sz=eZ.HistoryError;let sV=nf("waku:store"),sG="/vac/waku/store/2.0.0-beta4",s$=10;let Store=class Store extends BaseProtocol{pubsubTopics;NUM_PEERS_PROTOCOL=1;constructor(O,U){super(sG,O.components),this.pubsubTopics=U?.pubsubTopics??[sc]}async processMessages(O,U,$){let J=!1,en=await Promise.all(O),es=en.filter(isDefined);return this.shouldReverseOrder($)&&(es=es.reverse()),await Promise.all(es.map(async O=>{O&&!J&&(J=!!await U(O))})),J}shouldReverseOrder(O){return void 0===O?.pageDirection||O?.pageDirection===te.BACKWARD}queryOrderedCallback=this.queryWithOrderedCallback;async queryWithOrderedCallback(O,U,$){for await(let J of this.queryGenerator(O,$))if(await this.processMessages(J,U,$))break}async queryWithPromiseCallback(O,U,$){let J=!1;for await(let en of this.queryGenerator(O,$)){let O=en.map(async O=>{J||(J=!!await U(O))});if(await Promise.all(O),J)break}}async *queryGenerator(O,U){let $,J;if(0===O.length)throw Error("No decoders provided");U?.timeFilter&&($=U.timeFilter.startTime,J=U.timeFilter.endTime);let en=Array.from(new Set(O.map(O=>O.pubsubTopic)));if(en.length>1)throw Error("API does not support querying multiple pubsub topics at once");let es=en[0];if(ensurePubsubTopicIsConfigured(es,this.pubsubTopics),U?.cursor?.pubsubTopic&&U.cursor.pubsubTopic!==es)throw Error(`Cursor pubsub topic (${U?.cursor?.pubsubTopic}) does not match decoder pubsub topic (${es})`);let eo=new Map;O.forEach(O=>{if(eo.has(O.contentTopic))throw Error("API does not support different decoder per content topic");eo.set(O.contentTopic,O)});let ea=O.filter(O=>O.pubsubTopic===es).map(O=>O.contentTopic);if(0===ea.length)throw Error("No decoders found for topic "+es);let eu=Object.assign({pubsubTopic:es,pageDirection:te.BACKWARD,pageSize:s$},U,{contentTopics:ea,startTime:$,endTime:J});sV("Querying history with the following options",U);let ef=(await this.getPeers({numPeers:this.NUM_PEERS_PROTOCOL,maxBootstrapPeers:1}))[0];for await(let O of paginate(this.getStream.bind(this,ef),eu,eo,U?.cursor))yield O}};async function*paginate(O,U,$,J){if(U.contentTopics.toString()!==Array.from($.keys()).toString())throw Error("Internal error, the decoders should match the query's content topics");let en=J;for(;;){U.cursor=en;let J=HistoryRpc.createQuery(U);sV("Querying store peer",`for (${U.pubsubTopic})`,U.contentTopics);let es=await O(),eo=await pipe([J.encode()],encode_encode,es,decode_decode,async O=>await dist_src(O)),ea=new src_Uint8ArrayList;eo.forEach(O=>{ea.append(O)});let eu=J.decode(ea);if(!eu.response){sV("Stopping pagination due to store `response` field missing");break}let ef=eu.response;if(ef.error&&ef.error!==sz.NONE)throw"History response contains an Error: "+ef.error;if(!ef.messages||!ef.messages.length){sV("Stopping pagination due to store `response.messages` field missing or empty");break}sV(`${ef.messages.length} messages retrieved from store`),yield ef.messages.map(O=>{let J=O.contentTopic;if(void 0!==J){let en=$.get(J);if(en)return en.fromProtoObj(U.pubsubTopic,toProtoMessage(O))}return Promise.resolve(void 0)});let eg=ef.pagingInfo?.cursor;if(void 0===eg){sV("Stopping pagination due to `response.pagingInfo.cursor` missing from store response");break}en=eg;let ev=ef.pagingInfo?.pageSize,e_=J.query?.pagingInfo?.pageSize;if(ev&&e_&&evnew Store(U,O)}let TimeoutError=class TimeoutError extends Error{constructor(O){super(O),this.name="TimeoutError"}};let p_timeout_AbortError=class p_timeout_AbortError extends Error{constructor(O){super(),this.name="AbortError",this.message=O}};let getDOMException=O=>void 0===globalThis.DOMException?new p_timeout_AbortError(O):new DOMException(O),getAbortedReason=O=>{let U=void 0===O.reason?getDOMException("This operation was aborted."):O.reason;return U instanceof Error?U:getDOMException(U)};function pTimeout(O,U){let $;let{milliseconds:J,fallback:en,message:es,customTimers:eo={setTimeout,clearTimeout}}=U,ea=new Promise((ea,eu)=>{if("number"!=typeof J||1!==Math.sign(J))throw TypeError(`Expected \`milliseconds\` to be a positive number, got \`${J}\``);if(U.signal){let{signal:O}=U;O.aborted&&eu(getAbortedReason(O)),O.addEventListener("abort",()=>{eu(getAbortedReason(O))})}if(J===Number.POSITIVE_INFINITY){O.then(ea,eu);return}let ef=new TimeoutError;$=eo.setTimeout.call(void 0,()=>{if(en){try{ea(en())}catch(O){eu(O)}return}"function"==typeof O.cancel&&O.cancel(),!1===es?ea():es instanceof Error?eu(es):(ef.message=es??`Promise timed out after ${J} milliseconds`,eu(ef))},J),(async()=>{try{ea(await O)}catch(O){eu(O)}})()}),eu=ea.finally(()=>{eu.clear()});return eu.clear=()=>{eo.clearTimeout.call(void 0,$),$=void 0},eu}let normalizeEmitter=O=>{let U=O.on||O.addListener||O.addEventListener,$=O.off||O.removeListener||O.removeEventListener;if(!U||!$)throw TypeError("Emitter is not compatible");return{addListener:U.bind(O),removeListener:$.bind(O)}};function pEventMultiple(O,U,$){let J;let en=new Promise((en,es)=>{if(!(($={rejectionEvents:["error"],multiArgs:!1,resolveImmediately:!1,...$}).count>=0&&($.count===Number.POSITIVE_INFINITY||Number.isInteger($.count))))throw TypeError("The `count` option should be at least 0 or more");$.signal?.throwIfAborted();let eo=[U].flat(),ea=[],{addListener:eu,removeListener:ef}=normalizeEmitter(O),onItem=(...O)=>{let U=$.multiArgs?O:O[0];(!$.filter||$.filter(U))&&(ea.push(U),$.count===ea.length&&(J(),en(ea)))},rejectHandler=O=>{J(),es(O)};for(let O of(J=()=>{for(let O of eo)ef(O,onItem);for(let O of $.rejectionEvents)ef(O,rejectHandler)},eo))eu(O,onItem);for(let O of $.rejectionEvents)eu(O,rejectHandler);$.signal&&$.signal.addEventListener("abort",()=>{rejectHandler($.signal.reason)},{once:!0}),$.resolveImmediately&&en(ea)});if(en.cancel=J,"number"==typeof $.timeout){let O=pTimeout(en,{milliseconds:$.timeout});return O.cancel=J,O}return en}function pEvent(O,U,$){"function"==typeof $&&($={filter:$}),$={...$,count:1,resolveImmediately:!1};let J=pEventMultiple(O,U,$),en=J.then(O=>O[0]);return en.cancel=J.cancel,en}let sW=nf("waku:wait-for-remote-peer");async function waitForRemotePeer(O,U,$){if(U=U??getEnabledProtocols(O),!O.isStarted())return Promise.reject("Waku node is not started");let J=[];if(U.includes(eu.Relay)){if(!O.relay)throw Error("Cannot wait for Relay peer: protocol not mounted");J.push(waitForGossipSubPeerInMesh(O.relay))}if(U.includes(eu.Store)){if(!O.store)throw Error("Cannot wait for Store peer: protocol not mounted");J.push(waitForConnectedPeer(O.store))}if(U.includes(eu.LightPush)){if(!O.lightPush)throw Error("Cannot wait for LightPush peer: protocol not mounted");J.push(waitForConnectedPeer(O.lightPush))}if(U.includes(eu.Filter)){if(!O.filter)throw Error("Cannot wait for Filter peer: protocol not mounted");J.push(waitForConnectedPeer(O.filter))}$?await rejectOnTimeout(Promise.all(J),$,"Timed out waiting for a remote peer."):await Promise.all(J)}async function waitForConnectedPeer(O){let U=O.multicodec,$=await O.peers();if($.length){sW(`${U} peer found: `,$[0].id.toString());return}await new Promise($=>{let cb=J=>{J.detail?.protocols?.includes(U)&&(sW("Resolving for",U,J.detail.protocols),O.removeLibp2pEventListener("peer:identify",cb),$())};O.addLibp2pEventListener("peer:identify",cb)})}async function waitForGossipSubPeerInMesh(O){let U=O.getMeshPeers(),$=O.pubsubTopics;for(let J of $)for(;0==U.length;)await pEvent(O.gossipSub,"gossipsub:heartbeat"),U=O.getMeshPeers(J)}let awaitTimeout=(O,U)=>new Promise(($,J)=>setTimeout(()=>J(U),O));async function rejectOnTimeout(O,U,$){await Promise.race([O,awaitTimeout(U,$)])}function getEnabledProtocols(O){let U=[];return O.relay&&U.push(eu.Relay),O.filter&&U.push(eu.Filter),O.store&&U.push(eu.Store),O.lightPush&&U.push(eu.LightPush),U}let src_CodeError=class src_CodeError extends Error{code;constructor(O,U){super(O),this.code=U}};let dist_src_AbortError=class dist_src_AbortError extends src_CodeError{type;constructor(O){super(O,"ABORT_ERR"),this.type="aborted"}};function byteStream(O){let U=src_pushable();O.sink(U).catch(O=>{U.end(O)}),O.sink=async O=>{for await(let $ of O)U.push($);U.end()};let $=O.source;null!=O.source[Symbol.iterator]?$=O.source[Symbol.iterator]():null!=O.source[Symbol.asyncIterator]&&($=O.source[Symbol.asyncIterator]());let J=new src_Uint8ArrayList,en={read:async(O,U)=>{let en;U?.signal?.throwIfAborted();let es=new Promise((O,$)=>{en=()=>{$(new dist_src_AbortError("Read aborted"))},U?.signal?.addEventListener("abort",en)});try{if(null==O){let{done:O,value:U}=await Promise.race([$.next(),es]);if(!0===O)return new src_Uint8ArrayList;return U}for(;J.byteLength{$?.signal?.throwIfAborted(),O instanceof Uint8Array?U.push(O):U.push(O.subarray()),await U.onEmpty($)},unwrap:()=>{let U=O.source;return O.source=async function*(){yield*J,yield*U}(),O}};return en}let dist_src_CodeError=class dist_src_CodeError extends Error{code;constructor(O,U){super(O),this.code=U}};let defaultLengthDecoder=O=>src_decode(O);function lpStream(O,U){let $=byteStream(O),J={read:async O=>{let J=-1,en=new src_Uint8ArrayList,es=U?.lengthDecoder??defaultLengthDecoder;for(;;){en.append(await $.read(1,O));try{J=es(en)}catch(O){if(O instanceof RangeError)continue;throw O}if(J>-1)break;if(U?.maxLengthLength!=null&&en.byteLength>U.maxLengthLength)throw new dist_src_CodeError("message length length too long","ERR_MSG_LENGTH_TOO_LONG")}if(U?.maxDataLength!=null&&J>U.maxDataLength)throw new dist_src_CodeError("message length too long","ERR_MSG_DATA_TOO_LONG");return $.read(J,O)},write:async(O,J)=>{await $.write(encode_encode.single(O,U),J)},unwrap:()=>$.unwrap()};return J}function pair(){let O=pDefer(),U=!1;return{sink:async $=>{if(U)throw Error("already piped");U=!0,O.resolve($)},source:async function*(){let U=await O.promise;yield*U}()}}function duplexPair(){let O=pair(),U=pair();return[{source:O.source,sink:U.sink},{source:U.source,sink:O.sink}]}defaultLengthDecoder.bytes=0;let sY=65535,sJ=sY-16,sQ=!!globalThis.process?.env?.DUMP_SESSION_KEYS,u8a=O=>O instanceof Uint8Array,u32=O=>new Uint32Array(O.buffer,O.byteOffset,Math.floor(O.byteLength/4)),createView=O=>new DataView(O.buffer,O.byteOffset,O.byteLength),sZ=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];if(!sZ)throw Error("Non little-endian hardware is not supported");function utils_utf8ToBytes(O){if("string"!=typeof O)throw Error(`utf8ToBytes expected string, got ${typeof O}`);return new Uint8Array(new TextEncoder().encode(O))}function utils_toBytes(O){if("string"==typeof O)O=utils_utf8ToBytes(O);else if(u8a(O))O=O.slice();else throw Error(`expected Uint8Array, got ${typeof O}`);return O}let isPlainObject=O=>"[object Object]"===Object.prototype.toString.call(O)&&O.constructor===Object;function checkOpts(O,U){if(void 0!==U&&("object"!=typeof U||!isPlainObject(U)))throw Error("options must be object or undefined");let $=Object.assign(O,U);return $}function utils_ensureBytes(O,U){if(!(O instanceof Uint8Array))throw Error("Uint8Array expected");if("number"==typeof U&&O.length!==U)throw Error(`Uint8Array length ${U} expected`)}function utils_equalBytes(O,U){if(O.length!==U.length)throw Error("equalBytes: Different size of Uint8Arrays");let $=!0;for(let J=0;J(Object.assign(U,O),U);function setBigUint64(O,U,$,J){if("function"==typeof O.setBigUint64)return O.setBigUint64(U,$,J);let en=BigInt(32),es=BigInt(4294967295),eo=Number($>>en&es),ea=Number($&es),eu=J?4:0,ef=J?0:4;O.setUint32(U+eu,eo,J),O.setUint32(U+ef,ea,J)}function number(O){if(!Number.isSafeInteger(O)||O<0)throw Error(`Wrong positive integer: ${O}`)}function bool(O){if("boolean"!=typeof O)throw Error(`Expected boolean, not ${O}`)}function _assert_bytes(O,...U){if(!(O instanceof Uint8Array))throw Error("Expected Uint8Array");if(U.length>0&&!U.includes(O.length))throw Error(`Expected Uint8Array of length ${U}, not of length=${O.length}`)}function exists(O,U=!0){if(O.destroyed)throw Error("Hash instance has been destroyed");if(U&&O.finished)throw Error("Hash#digest() has already been called")}function output(O,U){_assert_bytes(O);let $=U.outputLen;if(O.length<$)throw Error(`digestInto() expects output buffer of length at least ${$}`)}let u8to16=(O,U)=>255&O[U++]|(255&O[U++])<<8;let Poly1305=class Poly1305{constructor(O){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,utils_ensureBytes(O=utils_toBytes(O),32);let U=u8to16(O,0),$=u8to16(O,2),J=u8to16(O,4),en=u8to16(O,6),es=u8to16(O,8),eo=u8to16(O,10),ea=u8to16(O,12),eu=u8to16(O,14);this.r[0]=8191&U,this.r[1]=(U>>>13|$<<3)&8191,this.r[2]=($>>>10|J<<6)&7939,this.r[3]=(J>>>7|en<<9)&8191,this.r[4]=(en>>>4|es<<12)&255,this.r[5]=es>>>1&8190,this.r[6]=(es>>>14|eo<<2)&8191,this.r[7]=(eo>>>11|ea<<5)&8065,this.r[8]=(ea>>>8|eu<<8)&8191,this.r[9]=eu>>>5&127;for(let U=0;U<8;U++)this.pad[U]=u8to16(O,16+2*U)}process(O,U,$=!1){let J=$?0:2048,{h:en,r:es}=this,eo=es[0],ea=es[1],eu=es[2],ef=es[3],eg=es[4],ev=es[5],e_=es[6],ew=es[7],eE=es[8],eS=es[9],eA=u8to16(O,U+0),eI=u8to16(O,U+2),eP=u8to16(O,U+4),ek=u8to16(O,U+6),eT=u8to16(O,U+8),eR=u8to16(O,U+10),eC=u8to16(O,U+12),eB=u8to16(O,U+14),eN=en[0]+(8191&eA),eD=en[1]+((eA>>>13|eI<<3)&8191),eM=en[2]+((eI>>>10|eP<<6)&8191),eO=en[3]+((eP>>>7|ek<<9)&8191),eL=en[4]+((ek>>>4|eT<<12)&8191),eU=en[5]+(eT>>>1&8191),eF=en[6]+((eT>>>14|eR<<2)&8191),eK=en[7]+((eR>>>11|eC<<5)&8191),ej=en[8]+((eC>>>8|eB<<8)&8191),eH=en[9]+(eB>>>5|J),eq=0,eV=0+eN*eo+eD*(5*eS)+eM*(5*eE)+eO*(5*ew)+eL*(5*e_);eq=eV>>>13,eV&=8191,eV+=eU*(5*ev)+eF*(5*eg)+eK*(5*ef)+ej*(5*eu)+eH*(5*ea),eq+=eV>>>13,eV&=8191;let eG=eq+eN*ea+eD*eo+eM*(5*eS)+eO*(5*eE)+eL*(5*ew);eq=eG>>>13,eG&=8191,eG+=eU*(5*e_)+eF*(5*ev)+eK*(5*eg)+ej*(5*ef)+eH*(5*eu),eq+=eG>>>13,eG&=8191;let e$=eq+eN*eu+eD*ea+eM*eo+eO*(5*eS)+eL*(5*eE);eq=e$>>>13,e$&=8191,e$+=eU*(5*ew)+eF*(5*e_)+eK*(5*ev)+ej*(5*eg)+eH*(5*ef),eq+=e$>>>13,e$&=8191;let eW=eq+eN*ef+eD*eu+eM*ea+eO*eo+eL*(5*eS);eq=eW>>>13,eW&=8191,eW+=eU*(5*eE)+eF*(5*ew)+eK*(5*e_)+ej*(5*ev)+eH*(5*eg),eq+=eW>>>13,eW&=8191;let eY=eq+eN*eg+eD*ef+eM*eu+eO*ea+eL*eo;eq=eY>>>13,eY&=8191,eY+=eU*(5*eS)+eF*(5*eE)+eK*(5*ew)+ej*(5*e_)+eH*(5*ev),eq+=eY>>>13,eY&=8191;let eJ=eq+eN*ev+eD*eg+eM*ef+eO*eu+eL*ea;eq=eJ>>>13,eJ&=8191,eJ+=eU*eo+eF*(5*eS)+eK*(5*eE)+ej*(5*ew)+eH*(5*e_),eq+=eJ>>>13,eJ&=8191;let eQ=eq+eN*e_+eD*ev+eM*eg+eO*ef+eL*eu;eq=eQ>>>13,eQ&=8191,eQ+=eU*ea+eF*eo+eK*(5*eS)+ej*(5*eE)+eH*(5*ew),eq+=eQ>>>13,eQ&=8191;let eZ=eq+eN*ew+eD*e_+eM*ev+eO*eg+eL*ef;eq=eZ>>>13,eZ&=8191,eZ+=eU*eu+eF*ea+eK*eo+ej*(5*eS)+eH*(5*eE),eq+=eZ>>>13,eZ&=8191;let eX=eq+eN*eE+eD*ew+eM*e_+eO*ev+eL*eg;eq=eX>>>13,eX&=8191,eX+=eU*ef+eF*eu+eK*ea+ej*eo+eH*(5*eS),eq+=eX>>>13,eX&=8191;let e0=eq+eN*eS+eD*eE+eM*ew+eO*e_+eL*ev;eq=e0>>>13,e0&=8191,e0+=eU*eg+eF*ef+eK*eu+ej*ea+eH*eo,eq+=e0>>>13,e0&=8191,eV=8191&(eq=(eq=(eq<<2)+eq|0)+eV|0),eq>>>=13,eG+=eq,en[0]=eV,en[1]=eG,en[2]=e$,en[3]=eW,en[4]=eY,en[5]=eJ,en[6]=eQ,en[7]=eZ,en[8]=eX,en[9]=e0}finalize(){let{h:O,pad:U}=this,$=new Uint16Array(10),J=O[1]>>>13;O[1]&=8191;for(let U=2;U<10;U++)O[U]+=J,J=O[U]>>>13,O[U]&=8191;O[0]+=5*J,J=O[0]>>>13,O[0]&=8191,O[1]+=J,J=O[1]>>>13,O[1]&=8191,O[2]+=J,$[0]=O[0]+5,J=$[0]>>>13,$[0]&=8191;for(let U=1;U<10;U++)$[U]=O[U]+J,J=$[U]>>>13,$[U]&=8191;$[9]-=8192;let en=(1^J)-1;for(let O=0;O<10;O++)$[O]&=en;en=~en;for(let U=0;U<10;U++)O[U]=O[U]&en|$[U];O[0]=(O[0]|O[1]<<13)&65535,O[1]=(O[1]>>>3|O[2]<<10)&65535,O[2]=(O[2]>>>6|O[3]<<7)&65535,O[3]=(O[3]>>>9|O[4]<<4)&65535,O[4]=(O[4]>>>12|O[5]<<1|O[6]<<14)&65535,O[5]=(O[6]>>>2|O[7]<<11)&65535,O[6]=(O[7]>>>5|O[8]<<8)&65535,O[7]=(O[8]>>>8|O[9]<<5)&65535;let es=O[0]+U[0];O[0]=65535&es;for(let $=1;$<8;$++)es=(O[$]+U[$]|0)+(es>>>16)|0,O[$]=65535&es}update(O){exists(this);let{buffer:U,blockLen:$}=this;O=utils_toBytes(O);let J=O.length;for(let en=0;en>>0,O[en++]=$[U]>>>8;return O}digest(){let{buffer:O,outputLen:U}=this;this.digestInto(O);let $=O.slice(0,U);return this.destroy(),$}};function wrapConstructorWithKey(O){let hashC=(U,$)=>O($).update(utils_toBytes(U)).digest(),U=O(new Uint8Array(32));return hashC.outputLen=U.outputLen,hashC.blockLen=U.blockLen,hashC.create=U=>O(U),hashC}let sX=wrapConstructorWithKey(O=>new Poly1305(O)),s6=utils_utf8ToBytes("expand 16-byte k"),s4=utils_utf8ToBytes("expand 32-byte k"),s5=u32(s6),s8=u32(s4);function rotl(O,U){return O<>>32-U}function isAligned32(O){return O.byteOffset%4==0}let s9=64,s7=16,oe=4294967296-1,ot=new Uint32Array;function runCipher(O,U,$,J,en,es,eo,ea){let eu=en.length,ef=new Uint8Array(s9),eg=u32(ef),ev=isAligned32(en)&&isAligned32(es),e_=ev?u32(en):ot,ew=ev?u32(es):ot;for(let eE=0;eE=oe)throw Error("arx: counter overflow");let eS=Math.min(s9,eu-eE);if(ev&&eS===s9){let O=eE/4;if(eE%4!=0)throw Error("arx: invalid block position");for(let U=0,$;U{_assert_bytes(U),_assert_bytes(ea),_assert_bytes(eu);let ev=eu.length;if(ef||(ef=new Uint8Array(ev)),_assert_bytes(ef),number(eg),eg<0||eg>=oe)throw Error("arx: counter overflow");if(ef.length0;)e_.pop().fill(0);return ef}}function chachaCore(O,U,$,J,en,es=20){let eo=O[0],ea=O[1],eu=O[2],ef=O[3],eg=U[0],ev=U[1],e_=U[2],ew=U[3],eE=U[4],eS=U[5],eA=U[6],eI=U[7],eP=en,ek=$[0],eT=$[1],eR=$[2],eC=eo,eB=ea,eN=eu,eD=ef,eM=eg,eO=ev,eL=e_,eU=ew,eF=eE,eK=eS,ej=eA,eH=eI,eq=eP,eV=ek,eG=eT,e$=eR;for(let O=0;O{O.update(U);let $=U.length%16;$&&O.update(oo.subarray($))},oa=new Uint8Array(32);function computeTag(O,U,$,J,en){let es=O(U,$,oa),eo=sX.create(es);en&&updatePadded(eo,en),updatePadded(eo,J);let ea=new Uint8Array(16),eu=createView(ea);setBigUint64(eu,0,BigInt(en?en.length:0),!0),setBigUint64(eu,8,BigInt(J.length),!0),eo.update(ea);let ef=eo.digest();return es.fill(0),ef}let _poly1305_aead=O=>(U,$,J)=>{let en=16;return utils_ensureBytes(U,32),utils_ensureBytes($),{encrypt:(es,eo)=>{let ea=es.length,eu=ea+en;eo?utils_ensureBytes(eo,eu):eo=new Uint8Array(eu),O(U,$,es,eo,1);let ef=computeTag(O,U,$,eo.subarray(0,-en),J);return eo.set(ef,ea),eo},decrypt:(es,eo)=>{let ea=es.length,eu=ea-en;if(eaBigInt(O))),og=new Uint32Array(80),om=new Uint32Array(80);let SHA512=class SHA512 extends oc.N{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:O,Al:U,Bh:$,Bl:J,Ch:en,Cl:es,Dh:eo,Dl:ea,Eh:eu,El:ef,Fh:eg,Fl:ev,Gh:e_,Gl:ew,Hh:eE,Hl:eS}=this;return[O,U,$,J,en,es,eo,ea,eu,ef,eg,ev,e_,ew,eE,eS]}set(O,U,$,J,en,es,eo,ea,eu,ef,eg,ev,e_,ew,eE,eS){this.Ah=0|O,this.Al=0|U,this.Bh=0|$,this.Bl=0|J,this.Ch=0|en,this.Cl=0|es,this.Dh=0|eo,this.Dl=0|ea,this.Eh=0|eu,this.El=0|ef,this.Fh=0|eg,this.Fl=0|ev,this.Gh=0|e_,this.Gl=0|ew,this.Hh=0|eE,this.Hl=0|eS}process(O,U){for(let $=0;$<16;$++,U+=4)og[$]=O.getUint32(U),om[$]=O.getUint32(U+=4);for(let O=16;O<80;O++){let U=0|og[O-15],$=0|om[O-15],J=ou.ZP.rotrSH(U,$,1)^ou.ZP.rotrSH(U,$,8)^ou.ZP.shrSH(U,$,7),en=ou.ZP.rotrSL(U,$,1)^ou.ZP.rotrSL(U,$,8)^ou.ZP.shrSL(U,$,7),es=0|og[O-2],eo=0|om[O-2],ea=ou.ZP.rotrSH(es,eo,19)^ou.ZP.rotrBH(es,eo,61)^ou.ZP.shrSH(es,eo,6),eu=ou.ZP.rotrSL(es,eo,19)^ou.ZP.rotrBL(es,eo,61)^ou.ZP.shrSL(es,eo,6),ef=ou.ZP.add4L(en,eu,om[O-7],om[O-16]),eg=ou.ZP.add4H(ef,J,ea,og[O-7],og[O-16]);og[O]=0|eg,om[O]=0|ef}let{Ah:$,Al:J,Bh:en,Bl:es,Ch:eo,Cl:ea,Dh:eu,Dl:ef,Eh:eg,El:ev,Fh:e_,Fl:ew,Gh:eE,Gl:eS,Hh:eA,Hl:eI}=this;for(let O=0;O<80;O++){let U=ou.ZP.rotrSH(eg,ev,14)^ou.ZP.rotrSH(eg,ev,18)^ou.ZP.rotrBH(eg,ev,41),eP=ou.ZP.rotrSL(eg,ev,14)^ou.ZP.rotrSL(eg,ev,18)^ou.ZP.rotrBL(eg,ev,41),ek=eg&e_^~eg&eE,eT=ev&ew^~ev&eS,eR=ou.ZP.add5L(eI,eP,eT,of[O],om[O]),eC=ou.ZP.add5H(eR,eA,U,ek,od[O],og[O]),eB=0|eR,eN=ou.ZP.rotrSH($,J,28)^ou.ZP.rotrBH($,J,34)^ou.ZP.rotrBH($,J,39),eD=ou.ZP.rotrSL($,J,28)^ou.ZP.rotrBL($,J,34)^ou.ZP.rotrBL($,J,39),eM=$&en^$&eo^en&eo,eO=J&es^J&ea^es&ea;eA=0|eE,eI=0|eS,eE=0|e_,eS=0|ew,e_=0|eg,ew=0|ev,({h:eg,l:ev}=ou.ZP.add(0|eu,0|ef,0|eC,0|eB)),eu=0|eo,ef=0|ea,eo=0|en,ea=0|es,en=0|$,es=0|J;let eL=ou.ZP.add3L(eB,eD,eO);$=ou.ZP.add3H(eL,eC,eN,eM),J=0|eL}({h:$,l:J}=ou.ZP.add(0|this.Ah,0|this.Al,0|$,0|J)),({h:en,l:es}=ou.ZP.add(0|this.Bh,0|this.Bl,0|en,0|es)),({h:eo,l:ea}=ou.ZP.add(0|this.Ch,0|this.Cl,0|eo,0|ea)),({h:eu,l:ef}=ou.ZP.add(0|this.Dh,0|this.Dl,0|eu,0|ef)),({h:eg,l:ev}=ou.ZP.add(0|this.Eh,0|this.El,0|eg,0|ev)),({h:e_,l:ew}=ou.ZP.add(0|this.Fh,0|this.Fl,0|e_,0|ew)),({h:eE,l:eS}=ou.ZP.add(0|this.Gh,0|this.Gl,0|eE,0|eS)),({h:eA,l:eI}=ou.ZP.add(0|this.Hh,0|this.Hl,0|eA,0|eI)),this.set($,J,en,es,eo,ea,eu,ef,eg,ev,e_,ew,eE,eS,eA,eI)}roundClean(){og.fill(0),om.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};let SHA512_224=class SHA512_224 extends SHA512{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}};let SHA512_256=class SHA512_256 extends SHA512{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}};let SHA384=class SHA384 extends SHA512{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}};let oy=(0,oh.hE)(()=>new SHA512);(0,oh.hE)(()=>new SHA512_224),(0,oh.hE)(()=>new SHA512_256),(0,oh.hE)(()=>new SHA384),BigInt(0);let ob=BigInt(1),ov=BigInt(2),utils_u8a=O=>O instanceof Uint8Array,o_=Array.from({length:256},(O,U)=>U.toString(16).padStart(2,"0"));function abstract_utils_bytesToHex(O){if(!utils_u8a(O))throw Error("Uint8Array expected");let U="";for(let $=0;$O+U.length,0)),$=0;return O.forEach(O=>{if(!utils_u8a(O))throw Error("Uint8Array expected");U.set(O,$),$+=O.length}),U}let bitMask=O=>(ov<new Uint8Array(O),u8fr=O=>Uint8Array.from(O);function createHmacDrbg(O,U,$){if("number"!=typeof O||O<2)throw Error("hashLen must be a number");if("number"!=typeof U||U<2)throw Error("qByteLen must be a number");if("function"!=typeof $)throw Error("hmacFn must be a function");let J=u8n(O),en=u8n(O),es=0,reset=()=>{J.fill(1),en.fill(0),es=0},h=(...O)=>$(en,J,...O),reseed=(O=u8n())=>{en=h(u8fr([0]),O),J=h(),0!==O.length&&(en=h(u8fr([1]),O),J=h())},gen=()=>{if(es++>=1e3)throw Error("drbg: tried 1000 values");let O=0,$=[];for(;O{let $;for(reset(),reseed(O);!($=U(gen()));)reseed();return reset(),$};return genUntil}let ow={bigint:O=>"bigint"==typeof O,function:O=>"function"==typeof O,boolean:O=>"boolean"==typeof O,string:O=>"string"==typeof O,isSafeInteger:O=>Number.isSafeInteger(O),array:O=>Array.isArray(O),field:(O,U)=>U.Fp.isValid(O),hash:O=>"function"==typeof O&&Number.isSafeInteger(O.outputLen)};function utils_validateObject(O,U,$={}){let checkField=(U,$,J)=>{let en=ow[$];if("function"!=typeof en)throw Error(`Invalid validator "${$}", expected function`);let es=O[U];if((!J||void 0!==es)&&!en(es,O))throw Error(`Invalid param ${String(U)}=${es} (${typeof es}), expected ${$}`)};for(let[O,$]of Object.entries(U))checkField(O,$,!1);for(let[O,U]of Object.entries($))checkField(O,U,!0);return O}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */let oE=BigInt(0),oS=BigInt(1),oA=BigInt(2),oI=BigInt(3),oP=BigInt(4),ok=BigInt(5),oT=BigInt(8);function modular_mod(O,U){let $=O%U;return $>=oE?$:U+$}function pow(O,U,$){if($<=oE||U 0");if($===oS)return oE;let J=oS;for(;U>oE;)U&oS&&(J=J*O%$),O=O*O%$,U>>=oS;return J}function modular_pow2(O,U,$){let J=O;for(;U-- >oE;)J*=J,J%=$;return J}function modular_invert(O,U){if(O===oE||U<=oE)throw Error(`invert: expected positive integers, got n=${O} mod=${U}`);let $=modular_mod(O,U),J=U,en=oE,es=oS,eo=oS,ea=oE;for(;$!==oE;){let O=J/$,U=J%$,eu=en-eo*O,ef=es-ea*O;J=$,$=U,en=eo,es=ea,eo=eu,ea=ef}let eu=J;if(eu!==oS)throw Error("invert: does not exist");return modular_mod(en,U)}function tonelliShanks(O){let U,$,J;let en=(O-oS)/oA;for(U=O-oS,$=0;U%oA===oE;U/=oA,$++);for(J=oA;J(modular_mod(O,U)&oS)===oS,oR=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function validateField(O){let U={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},$=oR.reduce((O,U)=>(O[U]="function",O),U);return utils_validateObject(O,$)}function FpPow(O,U,$){if($ 0");if($===oE)return O.ONE;if($===oS)return U;let J=O.ONE,en=U;for(;$>oE;)$&oS&&(J=O.mul(J,en)),en=O.sqr(en),$>>=oS;return J}function FpInvertBatch(O,U){let $=Array(U.length),J=U.reduce((U,J,en)=>O.is0(J)?U:($[en]=U,O.mul(U,J)),O.ONE),en=O.inv(J);return U.reduceRight((U,J,en)=>O.is0(J)?U:($[en]=O.mul(U,$[en]),O.mul(U,J)),en),$}function nLength(O,U){let $=void 0!==U?U:O.toString(2).length,J=Math.ceil($/8);return{nBitLength:$,nByteLength:J}}function Field(O,U,$=!1,J={}){if(O<=oE)throw Error(`Expected Fp ORDER > 0, got ${O}`);let{nBitLength:en,nByteLength:es}=nLength(O,U);if(es>2048)throw Error("Field lengths over 2048 bytes are not supported");let eo=FpSqrt(O),ea=Object.freeze({ORDER:O,BITS:en,BYTES:es,MASK:bitMask(en),ZERO:oE,ONE:oS,create:U=>modular_mod(U,O),isValid:U=>{if("bigint"!=typeof U)throw Error(`Invalid field element: expected bigint, got ${typeof U}`);return oE<=U&&UO===oE,isOdd:O=>(O&oS)===oS,neg:U=>modular_mod(-U,O),eql:(O,U)=>O===U,sqr:U=>modular_mod(U*U,O),add:(U,$)=>modular_mod(U+$,O),sub:(U,$)=>modular_mod(U-$,O),mul:(U,$)=>modular_mod(U*$,O),pow:(O,U)=>FpPow(ea,O,U),div:(U,$)=>modular_mod(U*modular_invert($,O),O),sqrN:O=>O*O,addN:(O,U)=>O+U,subN:(O,U)=>O-U,mulN:(O,U)=>O*U,inv:U=>modular_invert(U,O),sqrt:J.sqrt||(O=>eo(ea,O)),invertBatch:O=>FpInvertBatch(ea,O),cmov:(O,U,$)=>$?U:O,toBytes:O=>$?utils_numberToBytesLE(O,es):abstract_utils_numberToBytesBE(O,es),fromBytes:O=>{if(O.length!==es)throw Error(`Fp.fromBytes: expected ${es}, got ${O.length}`);return $?utils_bytesToNumberLE(O):abstract_utils_bytesToNumberBE(O)}});return Object.freeze(ea)}function FpSqrtEven(O,U){if(!O.isOdd)throw Error("Field doesn't have isOdd");let $=O.sqrt(U);return O.isOdd($)?O.neg($):$}function hashToPrivateScalar(O,U,$=!1){O=abstract_utils_ensureBytes("privateHash",O);let J=O.length,en=nLength(U).nByteLength+8;if(en<24||J1024)throw Error(`hashToPrivateScalar: expected ${en}-1024 bytes of input, got ${J}`);let es=$?utils_bytesToNumberLE(O):abstract_utils_bytesToNumberBE(O);return modular_mod(es,U-oS)+oS}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */let oC=BigInt(0),oB=BigInt(1);function wNAF(O,U){let constTimeNegate=(O,U)=>{let $=U.negate();return O?$:U},opts=O=>{let $=Math.ceil(U/O)+1,J=2**(O-1);return{windows:$,windowSize:J}};return{constTimeNegate,unsafeLadder(U,$){let J=O.ZERO,en=U;for(;$>oC;)$&oB&&(J=J.add(en)),en=en.double(),$>>=oB;return J},precomputeWindow(O,U){let{windows:$,windowSize:J}=opts(U),en=[],es=O,eo=es;for(let O=0;O<$;O++){eo=es,en.push(eo);for(let O=1;O>=eg,en>es&&(en-=ef,J+=oB);let ev=U,e_=U+Math.abs(en)-1,ew=O%2!=0,eE=en<0;0===en?ea=ea.add(constTimeNegate(ew,$[ev])):eo=eo.add(constTimeNegate(eE,$[e_]))}return{p:eo,f:ea}},wNAFCached(O,U,$,J){let en=O._WINDOW_SIZE||1,es=U.get(O);return es||(es=this.precomputeWindow(O,en),1!==en&&U.set(O,J(es))),this.wNAF(en,es,$)}}}function validateBasic(O){return validateField(O.Fp),utils_validateObject(O,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...nLength(O.n,O.nBitLength),...O,p:O.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */let oN=BigInt(0),ox=BigInt(1),oD=BigInt(2),oM=BigInt(8),oO={zip215:!0};function validateOpts(O){let U=validateBasic(O);return utils_validateObject(O,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...U})}function twistedEdwards(O){let U=validateOpts(O),{Fp:$,n:J,prehash:en,hash:es,randomBytes:eo,nByteLength:ea,h:eu}=U,ef=oD<{try{return{isValid:!0,value:$.sqrt(O*$.inv(U))}}catch(O){return{isValid:!1,value:oN}}}),e_=U.adjustScalarBytes||(O=>O),ew=U.domain||((O,U,$)=>{if(U.length||$)throw Error("Contexts/pre-hash are not supported");return O}),inBig=O=>"bigint"==typeof O&&oNinBig(O)&&inBig(U)&&OO===oN||inRange(O,ef);function assertInRange(O,U){if(inRange(O,U))return O;throw Error(`Expected valid scalar < ${U}, got ${typeof O} ${O}`)}function assertGE0(O){return O===oN?O:assertInRange(O,J)}let eE=new Map;function isPoint(O){if(!(O instanceof Point))throw Error("ExtendedPoint expected")}let Point=class Point{constructor(O,U,$,J){if(this.ex=O,this.ey=U,this.ez=$,this.et=J,!in0MaskRange(O))throw Error("x required");if(!in0MaskRange(U))throw Error("y required");if(!in0MaskRange($))throw Error("z required");if(!in0MaskRange(J))throw Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(O){if(O instanceof Point)throw Error("extended point not allowed");let{x:U,y:$}=O||{};if(!in0MaskRange(U)||!in0MaskRange($))throw Error("invalid affine point");return new Point(U,$,ox,eg(U*$))}static normalizeZ(O){let U=$.invertBatch(O.map(O=>O.ez));return O.map((O,$)=>O.toAffine(U[$])).map(Point.fromAffine)}_setWindowSize(O){this._WINDOW_SIZE=O,eE.delete(this)}assertValidity(){let{a:O,d:$}=U;if(this.is0())throw Error("bad point: ZERO");let{ex:J,ey:en,ez:es,et:eo}=this,ea=eg(J*J),eu=eg(en*en),ef=eg(es*es),ev=eg(ef*ef),e_=eg(ea*O),ew=eg(ef*eg(e_+eu)),eE=eg(ev+eg($*eg(ea*eu)));if(ew!==eE)throw Error("bad point: equation left != right (1)");let eS=eg(J*en),eA=eg(es*eo);if(eS!==eA)throw Error("bad point: equation left != right (2)")}equals(O){isPoint(O);let{ex:U,ey:$,ez:J}=this,{ex:en,ey:es,ez:eo}=O,ea=eg(U*eo),eu=eg(en*J),ef=eg($*eo),ev=eg(es*J);return ea===eu&&ef===ev}is0(){return this.equals(Point.ZERO)}negate(){return new Point(eg(-this.ex),this.ey,this.ez,eg(-this.et))}double(){let{a:O}=U,{ex:$,ey:J,ez:en}=this,es=eg($*$),eo=eg(J*J),ea=eg(oD*eg(en*en)),eu=eg(O*es),ef=$+J,ev=eg(eg(ef*ef)-es-eo),e_=eu+eo,ew=e_-ea,eE=eu-eo,eS=eg(ev*ew),eA=eg(e_*eE),eI=eg(ev*eE),eP=eg(ew*e_);return new Point(eS,eA,eP,eI)}add(O){isPoint(O);let{a:$,d:J}=U,{ex:en,ey:es,ez:eo,et:ea}=this,{ex:eu,ey:ef,ez:ev,et:e_}=O;if($===BigInt(-1)){let O=eg((es-en)*(ef+eu)),U=eg((es+en)*(ef-eu)),$=eg(U-O);if($===oN)return this.double();let J=eg(eo*oD*e_),ew=eg(ea*oD*ev),eE=ew+J,eS=U+O,eA=ew-J,eI=eg(eE*$),eP=eg(eS*eA),ek=eg(eE*eA),eT=eg($*eS);return new Point(eI,eP,eT,ek)}let ew=eg(en*eu),eE=eg(es*ef),eS=eg(ea*J*e_),eA=eg(eo*ev),eI=eg((en+es)*(eu+ef)-ew-eE),eP=eA-eS,ek=eA+eS,eT=eg(eE-$*ew),eR=eg(eI*eP),eC=eg(ek*eT),eB=eg(eI*eT),eN=eg(eP*ek);return new Point(eR,eC,eN,eB)}subtract(O){return this.add(O.negate())}wNAF(O){return eI.wNAFCached(this,eE,O,Point.normalizeZ)}multiply(O){let{p:U,f:$}=this.wNAF(assertInRange(O,J));return Point.normalizeZ([U,$])[0]}multiplyUnsafe(O){let U=assertGE0(O);return U===oN?eA:this.equals(eA)||U===ox?this:this.equals(eS)?this.wNAF(U).p:eI.unsafeLadder(this,U)}isSmallOrder(){return this.multiplyUnsafe(eu).is0()}isTorsionFree(){return eI.unsafeLadder(this,J).is0()}toAffine(O){let{ex:U,ey:J,ez:en}=this,es=this.is0();null==O&&(O=es?oM:$.inv(en));let eo=eg(U*O),ea=eg(J*O),eu=eg(en*O);if(es)return{x:oN,y:ox};if(eu!==ox)throw Error("invZ was invalid");return{x:eo,y:ea}}clearCofactor(){let{h:O}=U;return O===ox?this:this.multiplyUnsafe(O)}static fromHex(O,J=!1){let{d:en,a:es}=U,eo=$.BYTES;O=abstract_utils_ensureBytes("pointHex",O,eo);let ea=O.slice(),eu=O[eo-1];ea[eo-1]=-129&eu;let e_=utils_bytesToNumberLE(ea);e_===oN||(J?assertInRange(e_,ef):assertInRange(e_,$.ORDER));let ew=eg(e_*e_),eE=eg(ew-ox),eS=eg(en*ew-es),{isValid:eA,value:eI}=ev(eE,eS);if(!eA)throw Error("Point.fromHex: invalid y coordinate");let eP=(eI&ox)===ox,ek=(128&eu)!=0;if(!J&&eI===oN&&ek)throw Error("Point.fromHex: x=0 and x_0=1");return ek!==eP&&(eI=eg(-eI)),Point.fromAffine({x:eI,y:e_})}static fromPrivateKey(O){return getExtendedPublicKey(O).point}toRawBytes(){let{x:O,y:U}=this.toAffine(),J=utils_numberToBytesLE(U,$.BYTES);return J[J.length-1]|=O&ox?128:0,J}toHex(){return abstract_utils_bytesToHex(this.toRawBytes())}};Point.BASE=new Point(U.Gx,U.Gy,ox,eg(U.Gx*U.Gy)),Point.ZERO=new Point(oN,ox,ox,oN);let{BASE:eS,ZERO:eA}=Point,eI=wNAF(Point,8*ea);function modN(O){return modular_mod(O,J)}function modN_LE(O){return modN(utils_bytesToNumberLE(O))}function getExtendedPublicKey(O){let U=ea;O=abstract_utils_ensureBytes("private key",O,U);let $=abstract_utils_ensureBytes("hashed private key",es(O),2*U),J=e_($.slice(0,U)),en=$.slice(U,2*U),eo=modN_LE(J),eu=eS.multiply(eo),ef=eu.toRawBytes();return{head:J,prefix:en,scalar:eo,point:eu,pointBytes:ef}}function getPublicKey(O){return getExtendedPublicKey(O).pointBytes}function hashDomainToScalar(O=new Uint8Array,...U){let $=abstract_utils_concatBytes(...U);return modN_LE(es(ew($,abstract_utils_ensureBytes("context",O),!!en)))}function sign(O,U,J={}){O=abstract_utils_ensureBytes("message",O),en&&(O=en(O));let{prefix:es,scalar:eo,pointBytes:eu}=getExtendedPublicKey(U),ef=hashDomainToScalar(J.context,es,O),eg=eS.multiply(ef).toRawBytes(),ev=hashDomainToScalar(J.context,eg,eu,O),e_=modN(ef+ev*eo);assertGE0(e_);let ew=abstract_utils_concatBytes(eg,utils_numberToBytesLE(e_,$.BYTES));return abstract_utils_ensureBytes("result",ew,2*ea)}let eP=oO;function verify(O,U,J,es=eP){let eo,ea,eu;let{context:ef,zip215:eg}=es,ev=$.BYTES;O=abstract_utils_ensureBytes("signature",O,2*ev),U=abstract_utils_ensureBytes("message",U),en&&(U=en(U));let e_=utils_bytesToNumberLE(O.slice(ev,2*ev));try{eo=Point.fromHex(J,eg),ea=Point.fromHex(O.slice(0,ev),eg),eu=eS.multiplyUnsafe(e_)}catch(O){return!1}if(!eg&&eo.isSmallOrder())return!1;let ew=hashDomainToScalar(ef,ea.toRawBytes(),eo.toRawBytes(),U),eE=ea.add(eo.multiplyUnsafe(ew));return eE.subtract(eu).clearCofactor().equals(Point.ZERO)}eS._setWindowSize(8);let ek={getExtendedPublicKey,randomPrivateKey:()=>eo($.BYTES),precompute:(O=8,U=Point.BASE)=>(U._setWindowSize(O),U.multiply(BigInt(3)),U)};return{CURVE:U,getPublicKey,sign,verify,ExtendedPoint:Point,utils:ek}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */let oL=BigInt(0),oU=BigInt(1);function montgomery_validateOpts(O){return utils_validateObject(O,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...O})}function montgomery(O){let U=montgomery_validateOpts(O),{P:$}=U,modP=O=>modular_mod(O,$),J=U.montgomeryBits,en=Math.ceil(J/8),es=U.nByteLength,eo=U.adjustScalarBytes||(O=>O),ea=U.powPminus2||(O=>pow(O,$-BigInt(2),$));function cswap(O,U,$){let J=modP(O*(U-$));return[U=modP(U-J),$=modP($+J)]}function assertFieldElement(O){if("bigint"==typeof O&&oL<=O&&O<$)return O;throw Error("Expected valid scalar 0 < scalar < CURVE.P")}let eu=(U.a-BigInt(2))/BigInt(4);function montgomeryLadder(O,U){let $;let en=assertFieldElement(O),es=assertFieldElement(U),eo=en,ef=oU,eg=oL,ev=en,e_=oU,ew=oL;for(let O=BigInt(J-1);O>=oL;O--){let U=es>>O&oU;ew^=U,ef=($=cswap(ew,ef,ev))[0],ev=$[1],eg=($=cswap(ew,eg,e_))[0],e_=$[1],ew=U;let J=ef+eg,en=modP(J*J),ea=ef-eg,eE=modP(ea*ea),eS=en-eE,eA=ev+e_,eI=ev-e_,eP=modP(eI*J),ek=modP(eA*ea),eT=eP+ek,eR=eP-ek;ev=modP(eT*eT),e_=modP(eo*modP(eR*eR)),ef=modP(en*eE),eg=modP(eS*(en+modP(eu*eS)))}ef=($=cswap(ew,ef,ev))[0],ev=$[1],eg=($=cswap(ew,eg,e_))[0],e_=$[1];let eE=ea(eg);return modP(ef*eE)}function encodeUCoordinate(O){return utils_numberToBytesLE(modP(O),en)}function decodeUCoordinate(O){let U=abstract_utils_ensureBytes("u coordinate",O,en);return es===en&&(U[es-1]&=127),utils_bytesToNumberLE(U)}function decodeScalar(O){let U=abstract_utils_ensureBytes("scalar",O);if(U.length!==en&&U.length!==es)throw Error(`Expected ${en} or ${es} bytes, got ${U.length}`);return utils_bytesToNumberLE(eo(U))}function scalarMult(O,U){let $=decodeUCoordinate(U),J=decodeScalar(O),en=montgomeryLadder($,J);if(en===oL)throw Error("Invalid private or public key received");return encodeUCoordinate(en)}let ef=encodeUCoordinate(U.Gu);function scalarMultBase(O){return scalarMult(O,ef)}return{scalarMult,scalarMultBase,getSharedSecret:(O,U)=>scalarMult(O,U),getPublicKey:O=>scalarMultBase(O),utils:{randomPrivateKey:()=>U.randomBytes(U.nByteLength)},GuBytes:ef}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */let oF=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),oK=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),oj=BigInt(0),oH=BigInt(1),oq=BigInt(2),oz=BigInt(5),oV=BigInt(10),oG=BigInt(20),o$=BigInt(40),oW=BigInt(80);function ed25519_pow_2_252_3(O){let U=oF,$=O*O%U,J=$*O%U,en=modular_pow2(J,oq,U)*J%U,es=modular_pow2(en,oH,U)*O%U,eo=modular_pow2(es,oz,U)*es%U,ea=modular_pow2(eo,oV,U)*eo%U,eu=modular_pow2(ea,oG,U)*ea%U,ef=modular_pow2(eu,o$,U)*eu%U,eg=modular_pow2(ef,oW,U)*ef%U,ev=modular_pow2(eg,oW,U)*ef%U,e_=modular_pow2(ev,oV,U)*eo%U,ew=modular_pow2(e_,oq,U)*O%U;return{pow_p_5_8:ew,b2:J}}function adjustScalarBytes(O){return O[0]&=248,O[31]&=127,O[31]|=64,O}function ed25519_uvRatio(O,U){let $=oF,J=modular_mod(U*U*U,$),en=modular_mod(J*J*U,$),es=ed25519_pow_2_252_3(O*en).pow_p_5_8,eo=modular_mod(O*J*es,$),ea=modular_mod(U*eo*eo,$),eu=eo,ef=modular_mod(eo*oK,$),eg=ea===O,ev=ea===modular_mod(-O,$),e_=ea===modular_mod(-O*oK,$);return eg&&(eo=eu),(ev||e_)&&(eo=ef),modular_isNegativeLE(eo,$)&&(eo=modular_mod(-eo,$)),{isValid:eg||ev,value:eo}}let oY=Field(oF,void 0,!0),oJ={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:oY,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:oy,randomBytes:oh.O6,adjustScalarBytes,uvRatio:ed25519_uvRatio},oQ=twistedEdwards(oJ);function ed25519_domain(O,U,$){if(U.length>255)throw Error("Context is too big");return(0,oh.eV)((0,oh.iY)("SigEd25519 no Ed25519 collisions"),new Uint8Array([$?1:0,U.length]),U,O)}twistedEdwards({...oJ,domain:ed25519_domain}),twistedEdwards({...oJ,domain:ed25519_domain,prehash:oy});let oZ=montgomery({P:oF,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:O=>{let U=oF,{pow_p_5_8:$,b2:J}=ed25519_pow_2_252_3(O);return modular_mod(modular_pow2($,BigInt(3),U)*J,U)},adjustScalarBytes,randomBytes:oh.O6}),oX=(oY.ORDER+BigInt(3))/BigInt(8);function ed25519_assertRstPoint(O){if(!(O instanceof RistPoint))throw Error("RistrettoPoint expected")}oY.pow(oq,oX),oY.sqrt(oY.neg(oY.ONE)),oY.ORDER,BigInt(5),BigInt(8),BigInt(486662),FpSqrtEven(oY,oY.neg(BigInt(486664)));let o0=null,o1=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),o2=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),o3=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),o6=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),ed25519_invertSqrt=O=>ed25519_uvRatio(oH,O),o4=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),ed25519_bytes255ToNumberLE=O=>oQ.CURVE.Fp.create(bytesToNumberLE(O)&o4);function calcElligatorRistrettoMap(O){let{d:U}=oQ.CURVE,$=oQ.CURVE.Fp.ORDER,J=oQ.CURVE.Fp.create,en=J(o0*O*O),es=J((en+oH)*o3),eo=BigInt(-1),ea=J((eo-U*en)*J(en+U)),{isValid:eu,value:ef}=ed25519_uvRatio(es,ea),eg=J(ef*O);isNegativeLE(eg,$)||(eg=J(-eg)),eu||(ef=eg),eu||(eo=en);let ev=J(eo*(en-oH)*o6-ea),e_=ef*ef,ew=J((ef+ef)*ea),eE=J(ev*o1),eS=J(oH-e_),eA=J(oH+e_);return new oQ.ExtendedPoint(J(ew*eA),J(eS*eE),J(eE*eA),J(ew*eS))}let RistPoint=class RistPoint{constructor(O){this.ep=O}static fromAffine(O){return new RistPoint(oQ.ExtendedPoint.fromAffine(O))}static hashToCurve(O){O=ensureBytes("ristrettoHash",O,64);let U=ed25519_bytes255ToNumberLE(O.slice(0,32)),$=calcElligatorRistrettoMap(U),J=ed25519_bytes255ToNumberLE(O.slice(32,64)),en=calcElligatorRistrettoMap(J);return new RistPoint($.add(en))}static fromHex(O){O=ensureBytes("ristrettoHex",O,32);let{a:U,d:$}=oQ.CURVE,J=oQ.CURVE.Fp.ORDER,en=oQ.CURVE.Fp.create,es="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",eo=ed25519_bytes255ToNumberLE(O);if(!equalBytes(numberToBytesLE(eo,32),O)||isNegativeLE(eo,J))throw Error(es);let ea=en(eo*eo),eu=en(oH+U*ea),ef=en(oH-U*ea),eg=en(eu*eu),ev=en(ef*ef),e_=en(U*$*eg-ev),{isValid:ew,value:eE}=ed25519_invertSqrt(en(e_*ev)),eS=en(eE*ef),eA=en(eE*eS*e_),eI=en((eo+eo)*eS);isNegativeLE(eI,J)&&(eI=en(-eI));let eP=en(eu*eA),ek=en(eI*eP);if(!ew||isNegativeLE(ek,J)||eP===oj)throw Error(es);return new RistPoint(new oQ.ExtendedPoint(eI,eP,oH,ek))}toRawBytes(){let O,{ex:U,ey:$,ez:J,et:en}=this.ep,es=oQ.CURVE.Fp.ORDER,eo=oQ.CURVE.Fp.create,ea=eo(eo(J+$)*eo(J-$)),eu=eo(U*$),ef=eo(eu*eu),{value:eg}=ed25519_invertSqrt(eo(ea*ef)),ev=eo(eg*ea),e_=eo(eg*eu),ew=eo(ev*e_*en);if(isNegativeLE(en*ew,es)){let J=eo($*o0),en=eo(U*o0);U=J,$=en,O=eo(ev*o2)}else O=e_;isNegativeLE(U*ew,es)&&($=eo(-$));let eE=eo((J-$)*O);return isNegativeLE(eE,es)&&(eE=eo(-eE)),numberToBytesLE(eE,32)}toHex(){return bytesToHex(this.toRawBytes())}toString(){return this.toHex()}equals(O){ed25519_assertRstPoint(O);let{ex:U,ey:$}=this.ep,{ex:J,ey:en}=O.ep,es=oQ.CURVE.Fp.create,eo=es(U*en)===es($*J),ea=es($*en)===es(U*J);return eo||ea}add(O){return ed25519_assertRstPoint(O),new RistPoint(this.ep.add(O.ep))}subtract(O){return ed25519_assertRstPoint(O),new RistPoint(this.ep.subtract(O.ep))}multiply(O){return new RistPoint(this.ep.multiply(O))}multiplyUnsafe(O){return new RistPoint(this.ep.multiplyUnsafe(O))}};var o5=$(5493);let HMAC=class HMAC extends oh.kb{constructor(O,U){super(),this.finished=!1,this.destroyed=!1,o5.ZP.hash(O);let $=(0,oh.O0)(U);if(this.iHash=O.create(),"function"!=typeof this.iHash.update)throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let J=this.blockLen,en=new Uint8Array(J);en.set($.length>J?O.create().update($).digest():$);for(let O=0;Onew HMAC(O,U).update($).digest();function extract(O,U,$){return o5.ZP.hash(O),void 0===$&&($=new Uint8Array(O.outputLen)),hmac_hmac(O,(0,oh.O0)($),(0,oh.O0)(U))}hmac_hmac.create=(O,U)=>new HMAC(O,U);let o8=new Uint8Array([0]),o9=new Uint8Array;function expand(O,U,$,J=32){if(o5.ZP.hash(O),o5.ZP.number(J),J>255*O.outputLen)throw Error("Length should be <= 255*HashLen");let en=Math.ceil(J/O.outputLen);void 0===$&&($=o9);let es=new Uint8Array(en*O.outputLen),eo=hmac_hmac.create(O,U),ea=eo._cloneInto(),eu=new Uint8Array(eo.outputLen);for(let U=0;U(0,o7.J)(O),getHKDF(O,U){let $=extract(o7.J,U,O),J=expand(o7.J,$,void 0,96),en=J,es=en.subarray(0,32),eo=en.subarray(32,64),ea=en.subarray(64,96);return[es,eo,ea]},generateX25519KeyPair(){let O=oZ.utils.randomPrivateKey(),U=oZ.getPublicKey(O);return{publicKey:U,privateKey:O}},generateX25519KeyPairFromSeed(O){let U=oZ.getPublicKey(O);return{publicKey:U,privateKey:O}},generateX25519SharedKey:(O,U)=>oZ.getSharedSecret(O,U),chaCha20Poly1305Encrypt:(O,U,$,J)=>ol(J,U,$).encrypt(O),chaCha20Poly1305Decrypt:(O,U,$,J,en)=>ol(J,U,$).decrypt(O,en)},allocUnsafe=O=>globalThis.Buffer?globalThis.Buffer.allocUnsafe(O):new Uint8Array(O),uint16BEEncode=O=>{let U=allocUnsafe(2);return new DataView(U.buffer,U.byteOffset,U.byteLength).setUint16(0,O,!1),U};uint16BEEncode.bytes=2;let uint16BEDecode=O=>{if(O.length<2)throw RangeError("Could not decode int16BE");return O instanceof Uint8Array?new DataView(O.buffer,O.byteOffset,O.byteLength).getUint16(0,!1):O.getUint16(0)};function encode0(O){return concat_concat([O.ne,O.ciphertext],O.ne.length+O.ciphertext.length)}function encode1(O){return concat_concat([O.ne,O.ns,O.ciphertext],O.ne.length+O.ns.length+O.ciphertext.length)}function encode2(O){return concat_concat([O.ns,O.ciphertext],O.ns.length+O.ciphertext.length)}function decode0(O){if(O.length<32)throw Error("Cannot decode stage 0 MessageBuffer: length less than 32 bytes.");return{ne:O.subarray(0,32),ciphertext:O.subarray(32,O.length),ns:new Uint8Array(0)}}function decode1(O){if(O.length<80)throw Error("Cannot decode stage 1 MessageBuffer: length less than 80 bytes.");return{ne:O.subarray(0,32),ns:O.subarray(32,80),ciphertext:O.subarray(80,O.length)}}function decode2(O){if(O.length<48)throw Error("Cannot decode stage 2 MessageBuffer: length less than 48 bytes.");return{ne:new Uint8Array(0),ns:O.subarray(0,48),ciphertext:O.subarray(48,O.length)}}uint16BEDecode.bytes=2;let at=16;function encryptStream(O,U){return async function*($){for await(let J of $)for(let $=0;$J.length&&(en=J.length);let es=O.encrypt(J.subarray($,en),O.session);U?.encryptedPackets.increment(),yield uint16BEEncode(es.byteLength),yield es}}}function decryptStream(O,U){return async function*($){for await(let J of $)for(let $=0;$J.length&&(en=J.length),en-at<$)throw Error("Invalid chunk");let es=J.subarray($,en),eo=J.subarray($,en-at),{plaintext:ea,valid:eu}=O.decrypt(es,O.session,eo);if(!eu)throw U?.decryptErrors.increment(),Error("Failed to validate decrypted chunk");U?.decryptedPackets.increment(),yield ea}}}let ar=32,an=64,ai=32;async function ed25519_browser_generateKey(){let O=oQ.utils.randomPrivateKey(),U=oQ.getPublicKey(O),$=ed25519_browser_concatKeys(O,U);return{privateKey:$,publicKey:U}}async function ed25519_browser_generateKeyFromSeed(O){if(O.length!==ai)throw TypeError('"seed" must be 32 bytes in length.');if(!(O instanceof Uint8Array))throw TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let U=O,$=oQ.getPublicKey(U),J=ed25519_browser_concatKeys(U,$);return{privateKey:J,publicKey:$}}async function ed25519_browser_hashAndSign(O,U){let $=O.subarray(0,ai);return oQ.sign(U,$)}async function ed25519_browser_hashAndVerify(O,U,$){return oQ.verify(U,$,O)}function ed25519_browser_concatKeys(O,U){let $=new Uint8Array(an);for(let J=0;Jenumeration(tr)}(tt||(tt={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.Type&&(U.uint32(8),tt.codec().encode(O.Type,U)),null!=O.Data&&(U.uint32(18),U.bytes(O.Data)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.Type=tt.codec().decode(O);break;case 2:$.Data=O.bytes();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(ta||(ta={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.Type&&(U.uint32(8),tt.codec().encode(O.Type,U)),null!=O.Data&&(U.uint32(18),U.bytes(O.Data)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.Type=tt.codec().decode(O);break;case 2:$.Data=O.bytes();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(tu||(tu={}));let ed25519_class_Ed25519PublicKey=class ed25519_class_Ed25519PublicKey{_key;constructor(O){this._key=ed25519_class_ensureKey(O,ar)}async verify(O,U){return ed25519_browser_hashAndVerify(this._key,U,O)}marshal(){return this._key}get bytes(){return ta.encode({Type:tt.Ed25519,Data:this.marshal()}).subarray()}equals(O){return equals(this.bytes,O.bytes)}async hash(){let{bytes:O}=await i9.sha256.digest(this.bytes);return O}};let ed25519_class_Ed25519PrivateKey=class ed25519_class_Ed25519PrivateKey{_key;_publicKey;constructor(O,U){this._key=ed25519_class_ensureKey(O,an),this._publicKey=ed25519_class_ensureKey(U,ar)}async sign(O){return ed25519_browser_hashAndSign(this._key,O)}get public(){return new ed25519_class_Ed25519PublicKey(this._publicKey)}marshal(){return this._key}get bytes(){return tu.encode({Type:tt.Ed25519,Data:this.marshal()}).subarray()}equals(O){return equals(this.bytes,O.bytes)}async hash(){let{bytes:O}=await i9.sha256.digest(this.bytes);return O}async id(){let O=i8.identity.digest(this.public.bytes);return rR.base58btc.encode(O.bytes).substring(1)}async export(O,U="libp2p-key"){if("libp2p-key"===U)return exporter_exporter(this.bytes,O);throw new errors_CodeError(`export format '${U}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function ed25519_class_unmarshalEd25519PrivateKey(O){if(O.length>an){O=ed25519_class_ensureKey(O,an+ar);let U=O.subarray(0,an),$=O.subarray(an,O.length);return new ed25519_class_Ed25519PrivateKey(U,$)}O=ed25519_class_ensureKey(O,an);let U=O.subarray(0,an),$=O.subarray(ar);return new ed25519_class_Ed25519PrivateKey(U,$)}function ed25519_class_unmarshalEd25519PublicKey(O){return O=ed25519_class_ensureKey(O,ar),new ed25519_class_Ed25519PublicKey(O)}async function keys_ed25519_class_generateKeyPair(){let{privateKey:O,publicKey:U}=await ed25519_browser_generateKey();return new ed25519_class_Ed25519PrivateKey(O,U)}async function ed25519_class_generateKeyPairFromSeed(O){let{privateKey:U,publicKey:$}=await ed25519_browser_generateKeyFromSeed(O);return new ed25519_class_Ed25519PrivateKey(U,$)}function ed25519_class_ensureKey(O,U){if((O=Uint8Array.from(O??[])).length!==U)throw new errors_CodeError(`Key must be a Uint8Array of length ${U}, got ${O.length}`,"ERR_INVALID_KEY_TYPE");return O}function util_bigIntegerToUintBase64url(O,U){let $=Uint8Array.from(O.abs().toByteArray());if($=0===$[0]?$.subarray(1):$,null!=U){if($.length>U)throw Error("byte array longer than desired length");$=concat_concat([new Uint8Array(U-$.length),$])}return(0,rB.B)($,"base64url")}function util_base64urlToBigInteger(O){let U=src_util_base64urlToBuffer(O);return new n$.jsbn.BigInteger((0,rB.B)(U,"base16"),16)}function src_util_base64urlToBuffer(O,U){let $=(0,rJ.m)(O,"base64urlpad");if(null!=U){if($.length>U)throw Error("byte array longer than desired length");$=concat_concat([new Uint8Array(U-$.length),$])}return $}let af={"P-256":256,"P-384":384,"P-521":521},ag=Object.keys(af);async function keys_importer_importer(O,U){let $=as.base64.decode(O),J=ciphers_aes_gcm_browser_create();return J.decrypt($,U)}function src_random_bytes_randomBytes(O){if(isNaN(O)||O<=0)throw new errors_CodeError("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return(0,oh.O6)(O)}function keys_jwk2pem_convert(O,U){return U.map(U=>util_base64urlToBigInteger(O[U]))}function jwk2pem_jwk2priv(O){return n$.pki.setRsaPrivateKey(...keys_jwk2pem_convert(O,["n","e","d","p","q","dp","dq","qi"]))}function jwk2pem_jwk2pub(O){return n$.pki.setRsaPublicKey(...keys_jwk2pem_convert(O,["n","e"]))}function rsa_utils_pkcs1ToJwk(O){let U=n$.asn1.fromDer((0,rB.B)(O,"ascii")),$=n$.pki.privateKeyFromAsn1(U);return{kty:"RSA",n:util_bigIntegerToUintBase64url($.n),e:util_bigIntegerToUintBase64url($.e),d:util_bigIntegerToUintBase64url($.d),p:util_bigIntegerToUintBase64url($.p),q:util_bigIntegerToUintBase64url($.q),dp:util_bigIntegerToUintBase64url($.dP),dq:util_bigIntegerToUintBase64url($.dQ),qi:util_bigIntegerToUintBase64url($.qInv),alg:"RS256"}}function rsa_utils_jwkToPkcs1(O){if(null==O.n||null==O.e||null==O.d||null==O.p||null==O.q||null==O.dp||null==O.dq||null==O.qi)throw new errors_CodeError("JWK was missing components","ERR_INVALID_PARAMETERS");let U=n$.pki.privateKeyToAsn1({n:util_base64urlToBigInteger(O.n),e:util_base64urlToBigInteger(O.e),d:util_base64urlToBigInteger(O.d),p:util_base64urlToBigInteger(O.p),q:util_base64urlToBigInteger(O.q),dP:util_base64urlToBigInteger(O.dp),dQ:util_base64urlToBigInteger(O.dq),qInv:util_base64urlToBigInteger(O.qi)});return(0,rJ.m)(n$.asn1.toDer(U).getBytes(),"ascii")}function rsa_utils_pkixToJwk(O){let U=n$.asn1.fromDer((0,rB.B)(O,"ascii")),$=n$.pki.publicKeyFromAsn1(U);return{kty:"RSA",n:util_bigIntegerToUintBase64url($.n),e:util_bigIntegerToUintBase64url($.e)}}function rsa_utils_jwkToPkix(O){if(null==O.n||null==O.e)throw new errors_CodeError("JWK was missing components","ERR_INVALID_PARAMETERS");let U=n$.pki.publicKeyToAsn1({n:util_base64urlToBigInteger(O.n),e:util_base64urlToBigInteger(O.e)});return(0,rJ.m)(n$.asn1.toDer(U).getBytes(),"ascii")}async function keys_rsa_browser_generateKey(O){let U=await ao.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:O,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),$=await rsa_browser_exportKey(U);return{privateKey:$[0],publicKey:$[1]}}async function keys_rsa_browser_unmarshalPrivateKey(O){let U=await ao.get().subtle.importKey("jwk",O,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),$=[U,await rsa_browser_derivePublicFromPrivate(O)],J=await rsa_browser_exportKey({privateKey:$[0],publicKey:$[1]});return{privateKey:J[0],publicKey:J[1]}}async function keys_rsa_browser_hashAndSign(O,U){let $=await ao.get().subtle.importKey("jwk",O,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),J=await ao.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},$,Uint8Array.from(U));return new Uint8Array(J,0,J.byteLength)}async function keys_rsa_browser_hashAndVerify(O,U,$){let J=await ao.get().subtle.importKey("jwk",O,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return ao.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},J,U,$)}async function rsa_browser_exportKey(O){if(null==O.privateKey||null==O.publicKey)throw new errors_CodeError("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([ao.get().subtle.exportKey("jwk",O.privateKey),ao.get().subtle.exportKey("jwk",O.publicKey)])}async function rsa_browser_derivePublicFromPrivate(O){return ao.get().subtle.importKey("jwk",{kty:O.kty,n:O.n,e:O.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function rsa_browser_convertKey(O,U,$,J){let en=U?jwk2pem_jwk2pub(O):jwk2pem_jwk2priv(O),es=(0,rB.B)(Uint8Array.from($),"ascii"),eo=J(es,en);return(0,rJ.m)(eo,"ascii")}function rsa_browser_encrypt(O,U){return rsa_browser_convertKey(O,!0,U,(O,U)=>U.encrypt(O))}function rsa_browser_decrypt(O,U){return rsa_browser_convertKey(O,!1,U,(O,U)=>U.decrypt(O))}function keySize(O){if("RSA"!==O.kty)throw new errors_CodeError("invalid key type","ERR_INVALID_KEY_TYPE");if(null==O.n)throw new errors_CodeError("invalid key modulus","ERR_INVALID_KEY_MODULUS");let U=(0,rJ.m)(O.n,"base64url");return 8*U.length}ag.join(" / ");let am=8192;let rsa_class_RsaPublicKey=class rsa_class_RsaPublicKey{_key;constructor(O){this._key=O}async verify(O,U){return keys_rsa_browser_hashAndVerify(this._key,U,O)}marshal(){return rsa_utils_jwkToPkix(this._key)}get bytes(){return ta.encode({Type:tt.RSA,Data:this.marshal()}).subarray()}encrypt(O){return rsa_browser_encrypt(this._key,O)}equals(O){return equals(this.bytes,O.bytes)}async hash(){let{bytes:O}=await i9.sha256.digest(this.bytes);return O}};let rsa_class_RsaPrivateKey=class rsa_class_RsaPrivateKey{_key;_publicKey;constructor(O,U){this._key=O,this._publicKey=U}genSecret(){return src_random_bytes_randomBytes(16)}async sign(O){return keys_rsa_browser_hashAndSign(this._key,O)}get public(){if(null==this._publicKey)throw new errors_CodeError("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new rsa_class_RsaPublicKey(this._publicKey)}decrypt(O){return rsa_browser_decrypt(this._key,O)}marshal(){return rsa_utils_jwkToPkcs1(this._key)}get bytes(){return tu.encode({Type:tt.RSA,Data:this.marshal()}).subarray()}equals(O){return equals(this.bytes,O.bytes)}async hash(){let{bytes:O}=await i9.sha256.digest(this.bytes);return O}async id(){let O=await this.public.hash();return(0,rB.B)(O,"base58btc")}async export(O,U="pkcs-8"){if("pkcs-8"===U){let U=new n$.util.ByteBuffer(this.marshal()),$=n$.asn1.fromDer(U),J=n$.pki.privateKeyFromAsn1($),en={algorithm:"aes256",count:1e4,saltSize:16,prfAlgorithm:"sha512"};return n$.pki.encryptRsaPrivateKey(J,O,en)}if("libp2p-key"===U)return exporter_exporter(this.bytes,O);throw new errors_CodeError(`export format '${U}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};async function rsa_class_unmarshalRsaPrivateKey(O){let U=rsa_utils_pkcs1ToJwk(O);if(keySize(U)>am)throw new errors_CodeError("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let $=await keys_rsa_browser_unmarshalPrivateKey(U);return new rsa_class_RsaPrivateKey($.privateKey,$.publicKey)}function rsa_class_unmarshalRsaPublicKey(O){let U=rsa_utils_pkixToJwk(O);if(keySize(U)>am)throw new errors_CodeError("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new rsa_class_RsaPublicKey(U)}async function rsa_class_fromJwk(O){if(keySize(O)>am)throw new errors_CodeError("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let U=await keys_rsa_browser_unmarshalPrivateKey(O);return new rsa_class_RsaPrivateKey(U.privateKey,U.publicKey)}async function keys_rsa_class_generateKeyPair(O){if(O>am)throw new errors_CodeError("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let U=await keys_rsa_browser_generateKey(O);return new rsa_class_RsaPrivateKey(U.privateKey,U.publicKey)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function validatePointOpts(O){let U=validateBasic(O);utils_validateObject(U,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:$,Fp:J,a:en}=U;if($){if(!J.eql(en,J.ZERO))throw Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof $||"bigint"!=typeof $.beta||"function"!=typeof $.splitScalar)throw Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...U})}let{bytesToNumberBE:ab,hexToBytes:av}=rA,a_={Err:class extends Error{constructor(O=""){super(O)}},_parseInt(O){let{Err:U}=a_;if(O.length<2||2!==O[0])throw new U("Invalid signature integer tag");let $=O[1],J=O.subarray(2,$+2);if(!$||J.length!==$)throw new U("Invalid signature integer: wrong length");if(128&J[0])throw new U("Invalid signature integer: negative");if(0===J[0]&&!(128&J[1]))throw new U("Invalid signature integer: unnecessary leading zero");return{d:ab(J),l:O.subarray($+2)}},toSig(O){let{Err:U}=a_,$="string"==typeof O?av(O):O;if(!($ instanceof Uint8Array))throw Error("ui8a expected");let J=$.length;if(J<2||48!=$[0])throw new U("Invalid signature tag");if($[1]!==J-2)throw new U("Invalid signature: incorrect length");let{d:en,l:es}=a_._parseInt($.subarray(2)),{d:eo,l:ea}=a_._parseInt(es);if(ea.length)throw new U("Invalid signature: left bytes after parsing");return{r:en,s:eo}},hexFromSig(O){let slice=O=>8&Number.parseInt(O[0],16)?"00"+O:O,h=O=>{let U=O.toString(16);return 1&U.length?`0${U}`:U},U=slice(h(O.s)),$=slice(h(O.r)),J=U.length/2,en=$.length/2,es=h(J),eo=h(en);return`30${h(en+J+4)}02${eo}${$}02${es}${U}`}},aw=BigInt(0),aE=BigInt(1),aS=(BigInt(2),BigInt(3));function weierstrassPoints(O){let U=validatePointOpts(O),{Fp:$}=U,J=U.toBytes||((O,U,J)=>{let en=U.toAffine();return abstract_utils_concatBytes(Uint8Array.from([4]),$.toBytes(en.x),$.toBytes(en.y))}),en=U.fromBytes||(O=>{let U=O.subarray(1),J=$.fromBytes(U.subarray(0,$.BYTES)),en=$.fromBytes(U.subarray($.BYTES,2*$.BYTES));return{x:J,y:en}});function weierstrassEquation(O){let{a:J,b:en}=U,es=$.sqr(O),eo=$.mul(es,O);return $.add($.add(eo,$.mul(O,J)),en)}if(!$.eql($.sqr(U.Gy),weierstrassEquation(U.Gx)))throw Error("bad generator point: equation left != right");function isWithinCurveOrder(O){return"bigint"==typeof O&&aw$.eql(O,$.ZERO);return is0(U)&&is0(J)?Point.ZERO:new Point(U,J,$.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(O){let U=$.invertBatch(O.map(O=>O.pz));return O.map((O,$)=>O.toAffine(U[$])).map(Point.fromAffine)}static fromHex(O){let U=Point.fromAffine(en(abstract_utils_ensureBytes("pointHex",O)));return U.assertValidity(),U}static fromPrivateKey(O){return Point.BASE.multiply(normPrivateKeyToScalar(O))}_setWindowSize(O){this._WINDOW_SIZE=O,es.delete(this)}assertValidity(){if(this.is0()){if(U.allowInfinityPoint)return;throw Error("bad point: ZERO")}let{x:O,y:J}=this.toAffine();if(!$.isValid(O)||!$.isValid(J))throw Error("bad point: x or y not FE");let en=$.sqr(J),es=weierstrassEquation(O);if(!$.eql(en,es))throw Error("bad point: equation left != right");if(!this.isTorsionFree())throw Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:O}=this.toAffine();if($.isOdd)return!$.isOdd(O);throw Error("Field doesn't support isOdd")}equals(O){assertPrjPoint(O);let{px:U,py:J,pz:en}=this,{px:es,py:eo,pz:ea}=O,eu=$.eql($.mul(U,ea),$.mul(es,en)),ef=$.eql($.mul(J,ea),$.mul(eo,en));return eu&&ef}negate(){return new Point(this.px,$.neg(this.py),this.pz)}double(){let{a:O,b:J}=U,en=$.mul(J,aS),{px:es,py:eo,pz:ea}=this,eu=$.ZERO,ef=$.ZERO,eg=$.ZERO,ev=$.mul(es,es),e_=$.mul(eo,eo),ew=$.mul(ea,ea),eE=$.mul(es,eo);return eE=$.add(eE,eE),eg=$.mul(es,ea),eg=$.add(eg,eg),eu=$.mul(O,eg),ef=$.mul(en,ew),ef=$.add(eu,ef),eu=$.sub(e_,ef),ef=$.add(e_,ef),ef=$.mul(eu,ef),eu=$.mul(eE,eu),eg=$.mul(en,eg),ew=$.mul(O,ew),eE=$.sub(ev,ew),eE=$.mul(O,eE),eE=$.add(eE,eg),eg=$.add(ev,ev),ev=$.add(eg,ev),ev=$.add(ev,ew),ev=$.mul(ev,eE),ef=$.add(ef,ev),ew=$.mul(eo,ea),ew=$.add(ew,ew),ev=$.mul(ew,eE),eu=$.sub(eu,ev),eg=$.mul(ew,e_),eg=$.add(eg,eg),eg=$.add(eg,eg),new Point(eu,ef,eg)}add(O){assertPrjPoint(O);let{px:J,py:en,pz:es}=this,{px:eo,py:ea,pz:eu}=O,ef=$.ZERO,eg=$.ZERO,ev=$.ZERO,e_=U.a,ew=$.mul(U.b,aS),eE=$.mul(J,eo),eS=$.mul(en,ea),eA=$.mul(es,eu),eI=$.add(J,en),eP=$.add(eo,ea);eI=$.mul(eI,eP),eP=$.add(eE,eS),eI=$.sub(eI,eP),eP=$.add(J,es);let ek=$.add(eo,eu);return eP=$.mul(eP,ek),ek=$.add(eE,eA),eP=$.sub(eP,ek),ek=$.add(en,es),ef=$.add(ea,eu),ek=$.mul(ek,ef),ef=$.add(eS,eA),ek=$.sub(ek,ef),ev=$.mul(e_,eP),ef=$.mul(ew,eA),ev=$.add(ef,ev),ef=$.sub(eS,ev),ev=$.add(eS,ev),eg=$.mul(ef,ev),eS=$.add(eE,eE),eS=$.add(eS,eE),eA=$.mul(e_,eA),eP=$.mul(ew,eP),eS=$.add(eS,eA),eA=$.sub(eE,eA),eA=$.mul(e_,eA),eP=$.add(eP,eA),eE=$.mul(eS,eP),eg=$.add(eg,eE),eE=$.mul(ek,eP),ef=$.mul(eI,ef),ef=$.sub(ef,eE),eE=$.mul(eI,eS),ev=$.mul(ek,ev),ev=$.add(ev,eE),new Point(ef,eg,ev)}subtract(O){return this.add(O.negate())}is0(){return this.equals(Point.ZERO)}wNAF(O){return ea.wNAFCached(this,es,O,O=>{let U=$.invertBatch(O.map(O=>O.pz));return O.map((O,$)=>O.toAffine(U[$])).map(Point.fromAffine)})}multiplyUnsafe(O){let J=Point.ZERO;if(O===aw)return J;if(assertGE(O),O===aE)return this;let{endo:en}=U;if(!en)return ea.unsafeLadder(this,O);let{k1neg:es,k1:eo,k2neg:eu,k2:ef}=en.splitScalar(O),eg=J,ev=J,e_=this;for(;eo>aw||ef>aw;)eo&aE&&(eg=eg.add(e_)),ef&aE&&(ev=ev.add(e_)),e_=e_.double(),eo>>=aE,ef>>=aE;return es&&(eg=eg.negate()),eu&&(ev=ev.negate()),ev=new Point($.mul(ev.px,en.beta),ev.py,ev.pz),eg.add(ev)}multiply(O){let J,en;assertGE(O);let es=O,{endo:eo}=U;if(eo){let{k1neg:O,k1:U,k2neg:eu,k2:ef}=eo.splitScalar(es),{p:eg,f:ev}=this.wNAF(U),{p:e_,f:ew}=this.wNAF(ef);eg=ea.constTimeNegate(O,eg),e_=ea.constTimeNegate(eu,e_),e_=new Point($.mul(e_.px,eo.beta),e_.py,e_.pz),J=eg.add(e_),en=ev.add(ew)}else{let{p:O,f:U}=this.wNAF(es);J=O,en=U}return Point.normalizeZ([J,en])[0]}multiplyAndAddUnsafe(O,U,$){let J=Point.BASE,mul=(O,U)=>U!==aw&&U!==aE&&O.equals(J)?O.multiply(U):O.multiplyUnsafe(U),en=mul(this,U).add(mul(O,$));return en.is0()?void 0:en}toAffine(O){let{px:U,py:J,pz:en}=this,es=this.is0();null==O&&(O=es?$.ONE:$.inv(en));let eo=$.mul(U,O),ea=$.mul(J,O),eu=$.mul(en,O);if(es)return{x:$.ZERO,y:$.ZERO};if(!$.eql(eu,$.ONE))throw Error("invZ was invalid");return{x:eo,y:ea}}isTorsionFree(){let{h:O,isTorsionFree:$}=U;if(O===aE)return!0;if($)return $(Point,this);throw Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:O,clearCofactor:$}=U;return O===aE?this:$?$(Point,this):this.multiplyUnsafe(U.h)}toRawBytes(O=!0){return this.assertValidity(),J(Point,this,O)}toHex(O=!0){return abstract_utils_bytesToHex(this.toRawBytes(O))}};Point.BASE=new Point(U.Gx,U.Gy,$.ONE),Point.ZERO=new Point($.ZERO,$.ONE,$.ZERO);let eo=U.nBitLength,ea=wNAF(Point,U.endo?Math.ceil(eo/2):eo);return{CURVE:U,ProjectivePoint:Point,normPrivateKeyToScalar,weierstrassEquation,isWithinCurveOrder}}function weierstrass_validateOpts(O){let U=validateBasic(O);return utils_validateObject(U,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...U})}function weierstrass_weierstrass(O){let U=weierstrass_validateOpts(O),{Fp:$,n:J}=U,en=$.BYTES+1,es=2*$.BYTES+1;function isValidFieldElement(O){return awabstract_utils_bytesToHex(abstract_utils_numberToBytesBE(O,U.nByteLength));function isBiggerThanHalfOrder(O){let U=J>>aE;return O>U}function normalizeS(O){return isBiggerThanHalfOrder(O)?modN(-O):O}let slcNum=(O,U,$)=>abstract_utils_bytesToNumberBE(O.slice(U,$));let Signature=class Signature{constructor(O,U,$){this.r=O,this.s=U,this.recovery=$,this.assertValidity()}static fromCompact(O){let $=U.nByteLength;return O=abstract_utils_ensureBytes("compactSignature",O,2*$),new Signature(slcNum(O,0,$),slcNum(O,$,2*$))}static fromDER(O){let{r:U,s:$}=a_.toSig(abstract_utils_ensureBytes("DER",O));return new Signature(U,$)}assertValidity(){if(!ef(this.r))throw Error("r must be 0 < r < CURVE.n");if(!ef(this.s))throw Error("s must be 0 < s < CURVE.n")}addRecoveryBit(O){return new Signature(this.r,this.s,O)}recoverPublicKey(O){let{r:J,s:en,recovery:es}=this,ea=e_(abstract_utils_ensureBytes("msgHash",O));if(null==es||![0,1,2,3].includes(es))throw Error("recovery id invalid");let eu=2===es||3===es?J+U.n:J;if(eu>=$.ORDER)throw Error("recovery id 2 or 3 invalid");let ef=(1&es)==0?"02":"03",eg=eo.fromHex(ef+numToNByteStr(eu)),ev=invN(eu),ew=modN(-ea*ev),eE=modN(en*ev),eS=eo.BASE.multiplyAndAddUnsafe(eg,ew,eE);if(!eS)throw Error("point at infinify");return eS.assertValidity(),eS}hasHighS(){return isBiggerThanHalfOrder(this.s)}normalizeS(){return this.hasHighS()?new Signature(this.r,modN(-this.s),this.recovery):this}toDERRawBytes(){return abstract_utils_hexToBytes(this.toDERHex())}toDERHex(){return a_.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return abstract_utils_hexToBytes(this.toCompactHex())}toCompactHex(){return numToNByteStr(this.r)+numToNByteStr(this.s)}};let eg={isValidPrivateKey(O){try{return ea(O),!0}catch(O){return!1}},normPrivateKeyToScalar:ea,randomPrivateKey:()=>{let O=U.randomBytes($.BYTES+8),en=hashToPrivateScalar(O,J);return abstract_utils_numberToBytesBE(en,U.nByteLength)},precompute:(O=8,U=eo.BASE)=>(U._setWindowSize(O),U.multiply(BigInt(3)),U)};function getPublicKey(O,U=!0){return eo.fromPrivateKey(O).toRawBytes(U)}function isProbPub(O){let U=O instanceof Uint8Array,$="string"==typeof O,J=(U||$)&&O.length;return U?J===en||J===es:$?J===2*en||J===2*es:O instanceof eo}function getSharedSecret(O,U,$=!0){if(isProbPub(O))throw Error("first arg must be private key");if(!isProbPub(U))throw Error("second arg must be public key");let J=eo.fromHex(U);return J.multiply(ea(O)).toRawBytes($)}let ev=U.bits2int||function(O){let $=abstract_utils_bytesToNumberBE(O),J=8*O.length-U.nBitLength;return J>0?$>>BigInt(J):$},e_=U.bits2int_modN||function(O){return modN(ev(O))},ew=bitMask(U.nBitLength);function int2octets(O){if("bigint"!=typeof O)throw Error("bigint expected");if(!(aw<=O&&OO in en))throw Error("sign() legacy options not supported");let{hash:es,randomBytes:eu}=U,{lowS:eg,prehash:ew,extraEntropy:eS}=en;null==eg&&(eg=!0),O=abstract_utils_ensureBytes("msgHash",O),ew&&(O=abstract_utils_ensureBytes("prehashed msgHash",es(O)));let eA=e_(O),eI=ea(J),eP=[int2octets(eI),int2octets(eA)];if(null!=eS){let O=!0===eS?eu($.BYTES):eS;eP.push(abstract_utils_ensureBytes("extraEntropy",O,$.BYTES))}let ek=abstract_utils_concatBytes(...eP),eT=eA;return{seed:ek,k2sig:function(O){let U=ev(O);if(!ef(U))return;let $=invN(U),J=eo.BASE.multiply(U).toAffine(),en=modN(J.x);if(en===aw)return;let es=modN($*modN(eT+en*eI));if(es===aw)return;let ea=(J.x===en?0:2)|Number(J.y&aE),eu=es;return eg&&isBiggerThanHalfOrder(es)&&(eu=normalizeS(es),ea^=1),new Signature(en,eu,ea)}}}let eE={lowS:U.lowS,prehash:!1},eS={lowS:U.lowS,prehash:!1};function sign(O,$,J=eE){let{seed:en,k2sig:es}=prepSig(O,$,J),eo=U,ea=createHmacDrbg(eo.hash.outputLen,eo.nByteLength,eo.hmac);return ea(en,es)}return eo.BASE._setWindowSize(8),{CURVE:U,getPublicKey,getSharedSecret,sign,verify:function(O,$,J,en=eS){let es,ea;let eu=O;if($=abstract_utils_ensureBytes("msgHash",$),J=abstract_utils_ensureBytes("publicKey",J),"strict"in en)throw Error("options.strict was renamed to lowS");let{lowS:ef,prehash:eg}=en;try{if("string"==typeof eu||eu instanceof Uint8Array)try{ea=Signature.fromDER(eu)}catch(O){if(!(O instanceof a_.Err))throw O;ea=Signature.fromCompact(eu)}else if("object"==typeof eu&&"bigint"==typeof eu.r&&"bigint"==typeof eu.s){let{r:O,s:U}=eu;ea=new Signature(O,U)}else throw Error("PARSE");es=eo.fromHex(J)}catch(O){if("PARSE"===O.message)throw Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(ef&&ea.hasHighS())return!1;eg&&($=U.hash($));let{r:ev,s:ew}=ea,eE=e_($),eA=invN(ew),eI=modN(eE*eA),eP=modN(ev*eA),ek=eo.BASE.multiplyAndAddUnsafe(es,eI,eP)?.toAffine();if(!ek)return!1;let eT=modN(ek.x);return eT===ev},ProjectivePoint:eo,Signature,utils:eg}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function getHash(O){return{hash:O,hmac:(U,...$)=>hmac_hmac(O,U,(0,oh.eV)(...$)),randomBytes:oh.O6}}function createCurve(O,U){let create=U=>weierstrass_weierstrass({...O,...getHash(U)});return Object.freeze({...create(U),create})}BigInt(4);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */let aA=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),aI=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ak=BigInt(1),aT=BigInt(2),secp256k1_divNearest=(O,U)=>(O+U/aT)/U;function secp256k1_sqrtMod(O){let U=aA,$=BigInt(3),J=BigInt(6),en=BigInt(11),es=BigInt(22),eo=BigInt(23),ea=BigInt(44),eu=BigInt(88),ef=O*O*O%U,eg=ef*ef*O%U,ev=modular_pow2(eg,$,U)*eg%U,e_=modular_pow2(ev,$,U)*eg%U,ew=modular_pow2(e_,aT,U)*ef%U,eE=modular_pow2(ew,en,U)*ew%U,eS=modular_pow2(eE,es,U)*eE%U,eA=modular_pow2(eS,ea,U)*eS%U,eI=modular_pow2(eA,eu,U)*eA%U,eP=modular_pow2(eI,ea,U)*eS%U,ek=modular_pow2(eP,$,U)*eg%U,eT=modular_pow2(ek,eo,U)*eE%U,eR=modular_pow2(eT,J,U)*ef%U,eC=modular_pow2(eR,aT,U);if(!aR.eql(aR.sqr(eC),O))throw Error("Cannot find square root");return eC}let aR=Field(aA,void 0,void 0,{sqrt:secp256k1_sqrtMod}),aC=createCurve({a:BigInt(0),b:BigInt(7),Fp:aR,n:aI,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:O=>{let U=aI,$=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),J=-ak*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),en=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),es=$,eo=BigInt("0x100000000000000000000000000000000"),ea=secp256k1_divNearest(es*O,U),eu=secp256k1_divNearest(-J*O,U),ef=modular_mod(O-ea*$-eu*en,U),eg=modular_mod(-ea*J-eu*es,U),ev=ef>eo,e_=eg>eo;if(ev&&(ef=U-ef),e_&&(eg=U-eg),ef>eo||eg>eo)throw Error("splitScalar: Endomorphism failed, k="+O);return{k1neg:ev,k1:ef,k2neg:e_,k2:eg}}}},o7.J),aB=BigInt(0),fe=O=>"bigint"==typeof O&&aBO.charCodeAt(0)));$=concatBytes(U,U),aN[O]=$}return sha256(concatBytes($,...U))}let modP=O=>mod(O,aA),modN=O=>mod(O,aI),aD=aC.ProjectivePoint;function keys_secp256k1_generateKey(){return aC.utils.randomPrivateKey()}async function keys_secp256k1_hashAndSign(O,U){let{digest:$}=await i9.sha256.digest(U);try{let U=aC.sign($,O);return U.toDERRawBytes()}catch(O){throw new errors_CodeError(String(O),"ERR_INVALID_INPUT")}}async function keys_secp256k1_hashAndVerify(O,U,$){try{let{digest:J}=await i9.sha256.digest($);return aC.verify(U,J,O)}catch(O){throw new errors_CodeError(String(O),"ERR_INVALID_INPUT")}}function keys_secp256k1_compressPublicKey(O){let U=aC.ProjectivePoint.fromHex(O).toRawBytes(!0);return U}function secp256k1_validatePrivateKey(O){try{aC.getPublicKey(O,!0)}catch(O){throw new errors_CodeError(String(O),"ERR_INVALID_PRIVATE_KEY")}}function secp256k1_validatePublicKey(O){try{aC.ProjectivePoint.fromHex(O)}catch(O){throw new errors_CodeError(String(O),"ERR_INVALID_PUBLIC_KEY")}}function secp256k1_computePublicKey(O){try{return aC.getPublicKey(O,!0)}catch(O){throw new errors_CodeError(String(O),"ERR_INVALID_PRIVATE_KEY")}}let secp256k1_class_Secp256k1PublicKey=class secp256k1_class_Secp256k1PublicKey{_key;constructor(O){secp256k1_validatePublicKey(O),this._key=O}async verify(O,U){return keys_secp256k1_hashAndVerify(this._key,U,O)}marshal(){return keys_secp256k1_compressPublicKey(this._key)}get bytes(){return ta.encode({Type:tt.Secp256k1,Data:this.marshal()}).subarray()}equals(O){return equals(this.bytes,O.bytes)}async hash(){let{bytes:O}=await i9.sha256.digest(this.bytes);return O}};let secp256k1_class_Secp256k1PrivateKey=class secp256k1_class_Secp256k1PrivateKey{_key;_publicKey;constructor(O,U){this._key=O,this._publicKey=U??secp256k1_computePublicKey(O),secp256k1_validatePrivateKey(this._key),secp256k1_validatePublicKey(this._publicKey)}async sign(O){return keys_secp256k1_hashAndSign(this._key,O)}get public(){return new secp256k1_class_Secp256k1PublicKey(this._publicKey)}marshal(){return this._key}get bytes(){return tu.encode({Type:tt.Secp256k1,Data:this.marshal()}).subarray()}equals(O){return equals(this.bytes,O.bytes)}async hash(){let{bytes:O}=await i9.sha256.digest(this.bytes);return O}async id(){let O=await this.public.hash();return(0,rB.B)(O,"base58btc")}async export(O,U="libp2p-key"){if("libp2p-key"===U)return exporter_exporter(this.bytes,O);throw new errors_CodeError(`export format '${U}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function secp256k1_class_unmarshalSecp256k1PrivateKey(O){return new secp256k1_class_Secp256k1PrivateKey(O)}function secp256k1_class_unmarshalSecp256k1PublicKey(O){return new secp256k1_class_Secp256k1PublicKey(O)}async function keys_secp256k1_class_generateKeyPair(){let O=keys_secp256k1_generateKey();return new secp256k1_class_Secp256k1PrivateKey(O)}let aM={rsa:rP,ed25519:rI,secp256k1:rk};function keys_unsupportedKey(O){let U=Object.keys(aM).join(" / ");return new errors_CodeError(`invalid or unsupported key type ${O}. Must be ${U}`,"ERR_UNSUPPORTED_KEY_TYPE")}function keys_typeToKey(O){if("rsa"===(O=O.toLowerCase())||"ed25519"===O||"secp256k1"===O)return aM[O];throw keys_unsupportedKey(O)}async function src_keys_generateKeyPair(O,U){return keys_typeToKey(O).generateKeyPair(U??2048)}function src_keys_unmarshalPublicKey(O){let U=ta.decode(O),$=U.Data??new Uint8Array;switch(U.Type){case tt.RSA:return aM.rsa.unmarshalRsaPublicKey($);case tt.Ed25519:return aM.ed25519.unmarshalEd25519PublicKey($);case tt.Secp256k1:return aM.secp256k1.unmarshalSecp256k1PublicKey($);default:throw keys_unsupportedKey(U.Type??"unknown")}}function src_keys_marshalPublicKey(O,U){return keys_typeToKey(U=(U??"rsa").toLowerCase()),O.bytes}async function src_keys_unmarshalPrivateKey(O){let U=tu.decode(O),$=U.Data??new Uint8Array;switch(U.Type){case tt.RSA:return aM.rsa.unmarshalRsaPrivateKey($);case tt.Ed25519:return aM.ed25519.unmarshalEd25519PrivateKey($);case tt.Secp256k1:return aM.secp256k1.unmarshalSecp256k1PrivateKey($);default:throw keys_unsupportedKey(U.Type??"RSA")}}function keys_marshalPrivateKey(O,U){return keys_typeToKey(U=(U??"rsa").toLowerCase()),O.bytes}async function keys_importKey(O,U){try{let $=await keys_importer_importer(O,U);return await src_keys_unmarshalPrivateKey($)}catch(O){}let $=n$.pki.decryptRsaPrivateKey(O,U);if(null===$)throw new errors_CodeError("Cannot read the key, most likely the password is wrong or not a RSA key","ERR_CANNOT_DECRYPT_PEM");let J=n$.asn1.toDer(n$.pki.privateKeyToAsn1($));return J=(0,rJ.m)(J.getBytes(),"ascii"),aM.rsa.unmarshalRsaPrivateKey(J)}async function getPayload(O,U,$){let J=await signPayload(O,getHandshakePayload(U));if(null==O.publicKey)throw Error("PublicKey was missing from local PeerId");return createHandshakePayload(O.publicKey,J,$)}function createHandshakePayload(O,U,$){return td.encode({identityKey:O,identitySig:U,extensions:$??{webtransportCerthashes:[]}}).subarray()}async function signPayload(O,U){if(null==O.privateKey)throw Error("PrivateKey was missing from PeerId");let $=await src_keys_unmarshalPrivateKey(O.privateKey);return $.sign(U)}async function getPeerIdFromPayload(O){return src_peerIdFromKeys(O.identityKey)}function decodePayload(O){return td.decode(O)}function getHandshakePayload(O){let U=(0,rJ.m)("noise-libp2p-static-key:");return concat_concat([U,O],U.length+O.length)}async function verifySignedPayload(O,U,$){let J=await src_peerIdFromKeys(U.identityKey);if(!J.equals($))throw Error(`Payload identity key ${J.toString()} does not match expected remote peer ${$.toString()}`);let en=getHandshakePayload(O);if(null==J.publicKey)throw Error("PublicKey was missing from PeerId");if(null==U.identitySig)throw Error("Signature was missing from message");let es=src_keys_unmarshalPublicKey(J.publicKey),eo=await es.verify(en,U.identitySig);if(!eo)throw Error("Static key doesn't match to peer that signed payload!");return J}function isValidPublicKey(O){return O instanceof Uint8Array&&32===O.length}function createDisabledLogger(O){let logger=()=>{};return logger.enabled=!1,logger.color="",logger.diff=0,logger.log=()=>{},logger.namespace=O,logger.destroy=()=>!0,logger.extend=()=>logger,logger}function logger(O){let U=createDisabledLogger(`${O}:trace`);return nf.enabled(`${O}:trace`)&&null!=nf.names.map(O=>O.toString()).find(O=>O.includes(":trace"))&&(U=nf(`${O}:trace`)),Object.assign(nf(O),{error:nf(`${O}:error`),trace:U})}!function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{if(!1!==$.lengthDelimited&&U.fork(),null!=O.webtransportCerthashes)for(let $ of O.webtransportCerthashes)U.uint32(10),U.bytes($);!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={webtransportCerthashes:[]},J=null==U?O.len:O.pos+U;for(;O.pos>>3==1?$.webtransportCerthashes.push(O.bytes()):O.skipType(7&U)}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(th||(th={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),(!0===$.writeDefaults||null!=O.identityKey&&O.identityKey.byteLength>0)&&(U.uint32(10),U.bytes(O.identityKey??new Uint8Array(0))),(!0===$.writeDefaults||null!=O.identitySig&&O.identitySig.byteLength>0)&&(U.uint32(18),U.bytes(O.identitySig??new Uint8Array(0))),null!=O.extensions&&(U.uint32(34),th.codec().encode(O.extensions,U,{writeDefaults:!1})),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={identityKey:new Uint8Array(0),identitySig:new Uint8Array(0)},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.identityKey=O.bytes();break;case 2:$.identitySig=O.bytes();break;case 4:$.extensions=th.codec().decode(O,O.uint32());break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(td||(td={})),nf.formatters.b=O=>null==O?"undefined":rR.base58btc.baseEncode(O),nf.formatters.t=O=>null==O?"undefined":r$.base32.baseEncode(O),nf.formatters.m=O=>null==O?"undefined":as.base64.baseEncode(O),nf.formatters.p=O=>null==O?"undefined":O.toString(),nf.formatters.c=O=>null==O?"undefined":O.toString(),nf.formatters.k=O=>null==O?"undefined":O.toString(),nf.formatters.a=O=>null==O?"undefined":O.toString();let aO=logger("libp2p:noise");function logLocalStaticKeys(O){eo(`LOCAL_STATIC_PUBLIC_KEY ${(0,rB.B)(O.publicKey,"hex")}`),eo(`LOCAL_STATIC_PRIVATE_KEY ${(0,rB.B)(O.privateKey,"hex")}`)}function logLocalEphemeralKeys(O){O?(eo(`LOCAL_PUBLIC_EPHEMERAL_KEY ${(0,rB.B)(O.publicKey,"hex")}`),eo(`LOCAL_PRIVATE_EPHEMERAL_KEY ${(0,rB.B)(O.privateKey,"hex")}`)):eo("Missing local ephemeral keys.")}function logRemoteStaticKey(O){eo(`REMOTE_STATIC_PUBLIC_KEY ${(0,rB.B)(O,"hex")}`)}function logRemoteEphemeralKey(O){eo(`REMOTE_EPHEMERAL_PUBLIC_KEY ${(0,rB.B)(O,"hex")}`)}function logCipherState(O){O.cs1&&O.cs2?(eo(`CIPHER_STATE_1 ${O.cs1.n.getUint64()} ${(0,rB.B)(O.cs1.k,"hex")}`),eo(`CIPHER_STATE_2 ${O.cs2.n.getUint64()} ${(0,rB.B)(O.cs2.k,"hex")}`)):eo("Missing cipher state.")}eo=sQ?aO:Object.assign(()=>{},{enabled:!1,trace:()=>{},error:()=>{}});let aL=0,aU=4294967295,aF="Cipherstate has reached maximum n, a new handshake must be performed";let Nonce=class Nonce{n;bytes;view;constructor(O=aL){this.n=O,this.bytes=new Uint8Array(12),this.view=new DataView(this.bytes.buffer,this.bytes.byteOffset,this.bytes.byteLength),this.view.setUint32(4,O,!0)}increment(){this.n++,this.view.setUint32(4,this.n,!0)}getBytes(){return this.bytes}getUint64(){return this.n}assertValue(){if(this.n>aU)throw Error(aF)}};let AbstractHandshake=class AbstractHandshake{crypto;constructor(O){this.crypto=O}encryptWithAd(O,U,$){let J=this.encrypt(O.k,O.n,U,$);return O.n.increment(),J}decryptWithAd(O,U,$,J){let{plaintext:en,valid:es}=this.decrypt(O.k,O.n,U,$,J);return es&&O.n.increment(),{plaintext:en,valid:es}}hasKey(O){return!this.isEmptyKey(O.k)}createEmptyKey(){return new Uint8Array(32)}isEmptyKey(O){let U=this.createEmptyKey();return equals(U,O)}encrypt(O,U,$,J){return U.assertValue(),this.crypto.chaCha20Poly1305Encrypt(J,U.getBytes(),$,O)}encryptAndHash(O,U){let $;return $=this.hasKey(O.cs)?this.encryptWithAd(O.cs,O.h,U):U,this.mixHash(O,$),$}decrypt(O,U,$,J,en){U.assertValue();let es=this.crypto.chaCha20Poly1305Decrypt(J,U.getBytes(),$,O,en);return es?{plaintext:es,valid:!0}:{plaintext:new Uint8Array(0),valid:!1}}decryptAndHash(O,U){let $;let J=!0;return this.hasKey(O.cs)?{plaintext:$,valid:J}=this.decryptWithAd(O.cs,O.h,U):$=U,this.mixHash(O,U),{plaintext:$,valid:J}}dh(O,U){try{let $=this.crypto.generateX25519SharedKey(O,U);if(32===$.length)return $;return $.subarray(0,32)}catch(U){let O=U;return aO.error(O),new Uint8Array(32)}}mixHash(O,U){O.h=this.getHash(O.h,U)}getHash(O,U){let $=this.crypto.hashSHA256(concat_concat([O,U],O.length+U.length));return $}mixKey(O,U){let[$,J]=this.crypto.getHKDF(O.ck,U);O.cs=this.initializeKey(J),O.ck=$}initializeKey(O){return{k:O,n:new Nonce}}initializeSymmetric(O){let U=(0,rJ.m)(O,"utf-8"),$=this.hashProtocolName(U),J=$,en=this.createEmptyKey(),es=this.initializeKey(en);return{cs:es,ck:J,h:$}}hashProtocolName(O){if(!(O.length<=32))return this.getHash(O,new Uint8Array(0));{let U=new Uint8Array(32);return U.set(O),U}}split(O){let[U,$]=this.crypto.getHKDF(O.ck,new Uint8Array(0)),J=this.initializeKey(U),en=this.initializeKey($);return{cs1:J,cs2:en}}writeMessageRegular(O,U){let $=this.encryptWithAd(O,new Uint8Array(0),U),J=this.createEmptyKey(),en=new Uint8Array(0);return{ne:J,ns:en,ciphertext:$}}readMessageRegular(O,U){return this.decryptWithAd(O,new Uint8Array(0),U.ciphertext)}};let XX=class XX extends AbstractHandshake{initializeInitiator(O,U,$,J){let en="Noise_XX_25519_ChaChaPoly_SHA256",es=this.initializeSymmetric(en);this.mixHash(es,O);let eo=new Uint8Array(32);return{ss:es,s:U,rs:$,psk:J,re:eo}}initializeResponder(O,U,$,J){let en="Noise_XX_25519_ChaChaPoly_SHA256",es=this.initializeSymmetric(en);this.mixHash(es,O);let eo=new Uint8Array(32);return{ss:es,s:U,rs:$,psk:J,re:eo}}writeMessageA(O,U,$){let J=new Uint8Array(0);void 0!==$?O.e=$:O.e=this.crypto.generateX25519KeyPair();let en=O.e.publicKey;this.mixHash(O.ss,en);let es=this.encryptAndHash(O.ss,U);return{ne:en,ns:J,ciphertext:es}}writeMessageB(O,U){O.e=this.crypto.generateX25519KeyPair();let $=O.e.publicKey;this.mixHash(O.ss,$),this.mixKey(O.ss,this.dh(O.e.privateKey,O.re));let J=O.s.publicKey,en=this.encryptAndHash(O.ss,J);this.mixKey(O.ss,this.dh(O.s.privateKey,O.re));let es=this.encryptAndHash(O.ss,U);return{ne:$,ns:en,ciphertext:es}}writeMessageC(O,U){let $=O.s.publicKey,J=this.encryptAndHash(O.ss,$);this.mixKey(O.ss,this.dh(O.s.privateKey,O.re));let en=this.encryptAndHash(O.ss,U),es=this.createEmptyKey(),eo={ne:es,ns:J,ciphertext:en},{cs1:ea,cs2:eu}=this.split(O.ss);return{h:O.ss.h,messageBuffer:eo,cs1:ea,cs2:eu}}readMessageA(O,U){return isValidPublicKey(U.ne)&&(O.re=U.ne),this.mixHash(O.ss,O.re),this.decryptAndHash(O.ss,U.ciphertext)}readMessageB(O,U){if(isValidPublicKey(U.ne)&&(O.re=U.ne),this.mixHash(O.ss,O.re),!O.e)throw Error("Handshake state `e` param is missing.");this.mixKey(O.ss,this.dh(O.e.privateKey,O.re));let{plaintext:$,valid:J}=this.decryptAndHash(O.ss,U.ns);J&&isValidPublicKey($)&&(O.rs=$),this.mixKey(O.ss,this.dh(O.e.privateKey,O.rs));let{plaintext:en,valid:es}=this.decryptAndHash(O.ss,U.ciphertext);return{plaintext:en,valid:J&&es}}readMessageC(O,U){let{plaintext:$,valid:J}=this.decryptAndHash(O.ss,U.ns);if(J&&isValidPublicKey($)&&(O.rs=$),!O.e)throw Error("Handshake state `e` param is missing.");this.mixKey(O.ss,this.dh(O.e.privateKey,O.rs));let{plaintext:en,valid:es}=this.decryptAndHash(O.ss,U.ciphertext),{cs1:eo,cs2:ea}=this.split(O.ss);return{h:O.ss.h,plaintext:en,valid:J&&es,cs1:eo,cs2:ea}}initSession(O,U,$){let J;let en=this.createEmptyKey(),es=new Uint8Array(32);return{hs:J=O?this.initializeInitiator(U,$,es,en):this.initializeResponder(U,$,es,en),i:O,mc:0}}sendMessage(O,U,$){let J;if(0===O.mc)J=this.writeMessageA(O.hs,U,$);else if(1===O.mc)J=this.writeMessageB(O.hs,U);else if(2===O.mc){let{h:$,messageBuffer:en,cs1:es,cs2:eo}=this.writeMessageC(O.hs,U);J=en,O.h=$,O.cs1=es,O.cs2=eo}else if(O.mc>2){if(O.i){if(!O.cs1)throw Error("CS1 (cipher state) is not defined");J=this.writeMessageRegular(O.cs1,U)}else{if(!O.cs2)throw Error("CS2 (cipher state) is not defined");J=this.writeMessageRegular(O.cs2,U)}}else throw Error("Session invalid.");return O.mc++,J}recvMessage(O,U){let $=new Uint8Array(0),J=!1;if(0===O.mc)({plaintext:$,valid:J}=this.readMessageA(O.hs,U));else if(1===O.mc)({plaintext:$,valid:J}=this.readMessageB(O.hs,U));else if(2===O.mc){let{h:en,plaintext:es,valid:eo,cs1:ea,cs2:eu}=this.readMessageC(O.hs,U);$=es,J=eo,O.h=en,O.cs1=ea,O.cs2=eu}return O.mc++,{plaintext:$,valid:J}}};let XXHandshake=class XXHandshake{isInitiator;session;remotePeer;remoteExtensions={webtransportCerthashes:[]};payload;connection;xx;staticKeypair;prologue;constructor(O,U,$,J,en,es,eo,ea){this.isInitiator=O,this.payload=U,this.prologue=$,this.staticKeypair=en,this.connection=es,eo&&(this.remotePeer=eo),this.xx=ea??new XX(J),this.session=this.xx.initSession(this.isInitiator,this.prologue,this.staticKeypair)}async propose(){if(logLocalStaticKeys(this.session.hs.s),this.isInitiator){aO.trace("Stage 0 - Initiator starting to send first message.");let O=this.xx.sendMessage(this.session,new Uint8Array(0));await this.connection.write(encode0(O)),aO.trace("Stage 0 - Initiator finished sending first message."),logLocalEphemeralKeys(this.session.hs.e)}else{aO.trace("Stage 0 - Responder waiting to receive first message...");let O=decode0((await this.connection.read()).subarray()),{valid:U}=this.xx.recvMessage(this.session,O);if(!U)throw new InvalidCryptoExchangeError("xx handshake stage 0 validation fail");aO.trace("Stage 0 - Responder received first message."),logRemoteEphemeralKey(this.session.hs.re)}}async exchange(){if(this.isInitiator){aO.trace("Stage 1 - Initiator waiting to receive first message from responder...");let O=decode1((await this.connection.read()).subarray()),{plaintext:U,valid:$}=this.xx.recvMessage(this.session,O);if(!$)throw new InvalidCryptoExchangeError("xx handshake stage 1 validation fail");aO.trace("Stage 1 - Initiator received the message."),logRemoteEphemeralKey(this.session.hs.re),logRemoteStaticKey(this.session.hs.rs),aO.trace("Initiator going to check remote's signature...");try{let O=decodePayload(U);this.remotePeer=this.remotePeer||await getPeerIdFromPayload(O),await verifySignedPayload(this.session.hs.rs,O,this.remotePeer),this.setRemoteNoiseExtension(O.extensions)}catch(U){let O=U;throw new UnexpectedPeerError(`Error occurred while verifying signed payload: ${O.message}`)}aO.trace("All good with the signature!")}else{aO.trace("Stage 1 - Responder sending out first message with signed payload and static key.");let O=this.xx.sendMessage(this.session,this.payload);await this.connection.write(encode1(O)),aO.trace("Stage 1 - Responder sent the second handshake message with signed payload."),logLocalEphemeralKeys(this.session.hs.e)}}async finish(){if(this.isInitiator){aO.trace("Stage 2 - Initiator sending third handshake message.");let O=this.xx.sendMessage(this.session,this.payload);await this.connection.write(encode2(O)),aO.trace("Stage 2 - Initiator sent message with signed payload.")}else{aO.trace("Stage 2 - Responder waiting for third handshake message...");let O=decode2((await this.connection.read()).subarray()),{plaintext:U,valid:$}=this.xx.recvMessage(this.session,O);if(!$)throw new InvalidCryptoExchangeError("xx handshake stage 2 validation fail");aO.trace("Stage 2 - Responder received the message, finished handshake.");try{let O=decodePayload(U);this.remotePeer=this.remotePeer||await getPeerIdFromPayload(O),await verifySignedPayload(this.session.hs.rs,O,this.remotePeer),this.setRemoteNoiseExtension(O.extensions)}catch(U){let O=U;throw new UnexpectedPeerError(`Error occurred while verifying signed payload: ${O.message}`)}}logCipherState(this.session)}encrypt(O,U){let $=this.getCS(U);return this.xx.encryptWithAd($,new Uint8Array(0),O)}decrypt(O,U,$){let J=this.getCS(U,!1);return this.xx.decryptWithAd(J,new Uint8Array(0),O,$)}getRemoteStaticKey(){return this.session.hs.rs}getCS(O,U=!0){if(!O.cs1||!O.cs2)throw new InvalidCryptoExchangeError("Handshake not completed properly, cipher state does not exist.");return this.isInitiator?U?O.cs1:O.cs2:U?O.cs2:O.cs1}setRemoteNoiseExtension(O){O&&(this.remoteExtensions=O)}};function registerMetrics(O){return{xxHandshakeSuccesses:O.registerCounter("libp2p_noise_xxhandshake_successes_total",{help:"Total count of noise xxHandshakes successes_"}),xxHandshakeErrors:O.registerCounter("libp2p_noise_xxhandshake_error_total",{help:"Total count of noise xxHandshakes errors"}),encryptedPackets:O.registerCounter("libp2p_noise_encrypted_packets_total",{help:"Total count of noise encrypted packets successfully"}),decryptedPackets:O.registerCounter("libp2p_noise_decrypted_packets_total",{help:"Total count of noise decrypted packets"}),decryptErrors:O.registerCounter("libp2p_noise_decrypt_errors_total",{help:"Total count of noise decrypt errors"})}}let Noise=class Noise{protocol="/noise";crypto;prologue;staticKeys;extensions;metrics;constructor(O={}){let{staticNoiseKey:U,extensions:$,crypto:J,prologueBytes:en,metrics:es}=O;this.crypto=J??ae,this.extensions=$,this.metrics=es?registerMetrics(es):void 0,U?this.staticKeys=this.crypto.generateX25519KeyPairFromSeed(U):this.staticKeys=this.crypto.generateX25519KeyPair(),this.prologue=en??new Uint8Array(0)}async secureOutbound(O,U,$){let J=lpStream(U,{lengthEncoder:uint16BEEncode,lengthDecoder:uint16BEDecode,maxDataLength:sY}),en=await this.performHandshake({connection:J,isInitiator:!0,localPeer:O,remotePeer:$}),es=await this.createSecureConnection(J,en);return{conn:es,remoteExtensions:en.remoteExtensions,remotePeer:en.remotePeer}}async secureInbound(O,U,$){let J=lpStream(U,{lengthEncoder:uint16BEEncode,lengthDecoder:uint16BEDecode,maxDataLength:sY}),en=await this.performHandshake({connection:J,isInitiator:!1,localPeer:O,remotePeer:$}),es=await this.createSecureConnection(J,en);return{conn:es,remotePeer:en.remotePeer,remoteExtensions:en.remoteExtensions}}async performHandshake(O){let U=await getPayload(O.localPeer,this.staticKeys.publicKey,this.extensions);return this.performXXHandshake(O,U)}async performXXHandshake(O,U){let{isInitiator:$,remotePeer:J,connection:en}=O,es=new XXHandshake($,U,this.prologue,this.crypto,this.staticKeys,en,J);try{await es.propose(),await es.exchange(),await es.finish(),this.metrics?.xxHandshakeSuccesses.increment()}catch(O){if(this.metrics?.xxHandshakeErrors.increment(),O instanceof Error)throw O.message=`Error occurred during XX handshake: ${O.message}`,O}return es}async createSecureConnection(O,U){let[$,J]=duplexPair(),en=O.unwrap();return await pipe($,encryptStream(U,this.metrics),en,O=>decode_decode(O,{lengthDecoder:uint16BEDecode}),decryptStream(U,this.metrics),$),J}};function noise(O={}){return()=>new Noise(O)}let abort_error_AbortError=class abort_error_AbortError extends Error{constructor(O,U){super(O??"The operation was aborted"),this.type="aborted",this.code=U??"ABORT_ERR"}};function getIterator(O){if(null!=O){if("function"==typeof O[Symbol.iterator])return O[Symbol.iterator]();if("function"==typeof O[Symbol.asyncIterator])return O[Symbol.asyncIterator]();if("function"==typeof O.next)return O}throw Error("argument is not an iterator or iterable")}function abortableSource(O,U,$){let J=$??{},en=getIterator(O);return async function*(){let $;let abortHandler=()=>{null!=$&&$()};for(U.addEventListener("abort",abortHandler);;){let es;try{if(U.aborted){let{abortMessage:O,abortCode:U}=J;throw new abort_error_AbortError(O,U)}let O=new Promise((O,U)=>{$=()=>{let{abortMessage:O,abortCode:$}=J;U(new abort_error_AbortError(O,$))}});es=await Promise.race([O,en.next()]),$=null}catch(es){U.removeEventListener("abort",abortHandler);let $="aborted"===es.type&&U.aborted;if($&&null!=J.onAbort&&J.onAbort(O),"function"==typeof en.return)try{let O=en.return();O instanceof Promise&&O.catch(O=>{null!=J.onReturnError&&J.onReturnError(O)})}catch(O){null!=J.onReturnError&&J.onReturnError(O)}if($&&!0===J.returnOnAbort)return;throw es}if(!0===es.done)break;yield es.value}U.removeEventListener("abort",abortHandler)}()}var aK=$(5719);!function(O){O[O.NEW_STREAM=0]="NEW_STREAM",O[O.MESSAGE_RECEIVER=1]="MESSAGE_RECEIVER",O[O.MESSAGE_INITIATOR=2]="MESSAGE_INITIATOR",O[O.CLOSE_RECEIVER=3]="CLOSE_RECEIVER",O[O.CLOSE_INITIATOR=4]="CLOSE_INITIATOR",O[O.RESET_RECEIVER=5]="RESET_RECEIVER",O[O.RESET_INITIATOR=6]="RESET_INITIATOR"}(tf||(tf={}));let aj=Object.freeze({0:"NEW_STREAM",1:"MESSAGE_RECEIVER",2:"MESSAGE_INITIATOR",3:"CLOSE_RECEIVER",4:"CLOSE_INITIATOR",5:"RESET_RECEIVER",6:"RESET_INITIATOR"}),aH=Object.freeze({NEW_STREAM:tf.NEW_STREAM,MESSAGE:tf.MESSAGE_INITIATOR,CLOSE:tf.CLOSE_INITIATOR,RESET:tf.RESET_INITIATOR}),aq=Object.freeze({MESSAGE:tf.MESSAGE_RECEIVER,CLOSE:tf.CLOSE_RECEIVER,RESET:tf.RESET_RECEIVER}),az=1048576,aV=4194304;let decode_Decoder=class decode_Decoder{_buffer;_headerInfo;_maxMessageSize;_maxUnprocessedMessageQueueSize;constructor(O=az,U=aV){this._buffer=new src_Uint8ArrayList,this._headerInfo=null,this._maxMessageSize=O,this._maxUnprocessedMessageQueueSize=U}write(O){if(null==O||0===O.length)return[];if(this._buffer.append(O),this._buffer.byteLength>this._maxUnprocessedMessageQueueSize)throw Object.assign(Error("unprocessed message queue size too large!"),{code:"ERR_MSG_QUEUE_TOO_BIG"});let U=[];for(;0!==this._buffer.length;){if(null==this._headerInfo)try{this._headerInfo=this._decodeHeader(this._buffer)}catch(O){if("ERR_MSG_TOO_BIG"===O.code)throw O;break}let{id:O,type:$,length:J,offset:en}=this._headerInfo,es=this._buffer.length-en;if(esthis._maxMessageSize)throw Object.assign(Error("message size too large!"),{code:"ERR_MSG_TOO_BIG"});return{id:U>>3,type:es,offset:$+en,length:J}}};let aG=128,a$=127;function readVarInt(O,U=0){let $,J=0,en=0,es=U,eo=O.length;do{if(es>=eo||en>49)throw U=0,RangeError("Could not decode varint");$=O.get(es++),J+=en<28?($&a$)<=aG);return{value:J,offset:U=es-U}}function it_batched_bytes_dist_src_isAsyncIterable(O){return null!=O[Symbol.asyncIterator]}let aW=1048576,DEFAULT_SERIALIZE=(O,U)=>{U.append(O)};var it_batched_bytes_dist_src=function(O,U){return it_batched_bytes_dist_src_isAsyncIterable(O)?async function*(){let $=new src_Uint8ArrayList,J=!1,en=pDefer(),es=Number(U?.size??aW);if((isNaN(es)||0===es||es<0)&&(es=aW),es!==Math.round(es))throw Error("Batch size must be an integer");let eo=U?.yieldAfter??0,ea=U?.serialize??DEFAULT_SERIALIZE;for(Promise.resolve().then(async()=>{try{let U;for await(let J of O){if(ea(J,$),$.byteLength>=es){clearTimeout(U),en.resolve();continue}U=setTimeout(()=>{en.resolve()},eo)}clearTimeout(U),en.resolve()}catch(O){en.reject(O)}finally{J=!0}});!J;)if(await en.promise,en=pDefer(),$.byteLength>0){let O=$;$=new src_Uint8ArrayList,yield O.subarray()}}():function*(){let $=new src_Uint8ArrayList,J=Number(U?.size??aW);if((isNaN(J)||0===J||J<0)&&(J=aW),J!==Math.round(J))throw Error("Batch size must be an integer");let en=U?.serialize??DEFAULT_SERIALIZE;for(let U of O)en(U,$),$.byteLength>=J&&(yield $.subarray(0,J),$.consume(J));$.byteLength>0&&(yield $.subarray())}()};function alloc_unsafe_browser_allocUnsafe(O){return new Uint8Array(O)}let aY=10240;let encode_Encoder=class encode_Encoder{_pool;_poolOffset;constructor(){this._pool=alloc_unsafe_browser_allocUnsafe(aY),this._poolOffset=0}write(O,U){let $=this._pool,J=this._poolOffset;encode(O.id<<3|O.type,$,J),J+=encodingLength(O.id<<3|O.type),(O.type===tf.NEW_STREAM||O.type===tf.MESSAGE_INITIATOR||O.type===tf.MESSAGE_RECEIVER)&&null!=O.data?(encode(O.data.length,$,J),J+=encodingLength(O.data.length)):(encode(0,$,J),J+=encodingLength(0));let en=$.subarray(this._poolOffset,J);aY-J<100?(this._pool=alloc_unsafe_browser_allocUnsafe(aY),this._poolOffset=0):this._poolOffset=J,U.append(en),(O.type===tf.NEW_STREAM||O.type===tf.MESSAGE_INITIATOR||O.type===tf.MESSAGE_RECEIVER)&&null!=O.data&&U.append(O.data)}};let aJ=new encode_Encoder;async function*src_encode_encode(O,U=0){if(null==U||0===U){for await(let U of O){let O=new src_Uint8ArrayList;for(let $ of U)aJ.write($,O);yield O.subarray()}return}yield*it_batched_bytes_dist_src(O,{size:U,serialize:(O,U)=>{for(let $ of O)aJ.write($,U)}})}let race_signal_dist_src_AbortError=class race_signal_dist_src_AbortError extends Error{type;code;constructor(O,U){super(O??"The operation was aborted"),this.type="aborted",this.code=U??"ABORT_ERR"}};async function raceSignal(O,U,$){let J;if(null==U)return O;if(U.aborted)return Promise.reject(new race_signal_dist_src_AbortError($?.errorMessage,$?.errorCode));let en=new race_signal_dist_src_AbortError($?.errorMessage,$?.errorCode);try{return await Promise.race([O,new Promise((O,$)=>{J=()=>{$(en)},U.addEventListener("abort",J)})])}finally{null!=J&&U.removeEventListener("abort",J)}}let aQ="ERR_STREAM_RESET",aZ="ERR_SINK_INVALID_STATE",aX=5e3;function isPromise(O){return null!=O&&"function"==typeof O.then}let AbstractStream=class AbstractStream{id;direction;timeline;protocol;metadata;source;status;readStatus;writeStatus;sinkController;sinkEnd;endErr;streamSource;onEnd;onCloseRead;onCloseWrite;onReset;onAbort;sendCloseWriteTimeout;log;constructor(O){this.sinkController=new AbortController,this.sinkEnd=pDefer(),this.log=O.log,this.status="open",this.readStatus="ready",this.writeStatus="ready",this.id=O.id,this.metadata=O.metadata??{},this.direction=O.direction,this.timeline={open:Date.now()},this.sendCloseWriteTimeout=O.sendCloseWriteTimeout??aX,this.onEnd=O.onEnd,this.onCloseRead=O?.onCloseRead,this.onCloseWrite=O?.onCloseWrite,this.onReset=O?.onReset,this.onAbort=O?.onAbort,this.source=this.streamSource=src_pushable({onEnd:O=>{null!=O?this.log.trace("source ended with error",O):this.log.trace("source ended"),this.onSourceEnd(O)}}),this.sink=this.sink.bind(this)}async sink(O){if("ready"!==this.writeStatus)throw new errors_CodeError(`writable end state is "${this.writeStatus}" not "ready"`,aZ);try{this.writeStatus="writing";let U={signal:this.sinkController.signal};if("outbound"===this.direction){let O=this.sendNewStream(U);isPromise(O)&&await O}for await(let $ of(O=abortableSource(O,this.sinkController.signal,{returnOnAbort:!0}),this.log.trace("sink reading from source"),O)){$=$ instanceof Uint8Array?new src_Uint8ArrayList($):$;let O=this.sendData($,U);isPromise(O)&&await O}this.log.trace('sink finished reading from source, write status is "%s"',this.writeStatus),"writing"===this.writeStatus&&(this.writeStatus="closing",this.log.trace("send close write to remote"),await this.sendCloseWrite({signal:AbortSignal.timeout(this.sendCloseWriteTimeout)}),this.writeStatus="closed"),this.onSinkEnd()}catch(O){throw this.log.trace("sink ended with error, calling abort with error",O),this.abort(O),O}finally{this.log.trace("resolve sink end"),this.sinkEnd.resolve()}}onSourceEnd(O){null==this.timeline.closeRead&&(this.timeline.closeRead=Date.now(),this.readStatus="closed",null!=O&&null==this.endErr&&(this.endErr=O),this.onCloseRead?.(),null!=this.timeline.closeWrite?(this.log.trace("source and sink ended"),this.timeline.close=Date.now(),"aborted"!==this.status&&"reset"!==this.status&&(this.status="closed"),null!=this.onEnd&&this.onEnd(this.endErr)):this.log.trace("source ended, waiting for sink to end"))}onSinkEnd(O){null==this.timeline.closeWrite&&(this.timeline.closeWrite=Date.now(),this.writeStatus="closed",null!=O&&null==this.endErr&&(this.endErr=O),this.onCloseWrite?.(),null!=this.timeline.closeRead?(this.log.trace("sink and source ended"),this.timeline.close=Date.now(),"aborted"!==this.status&&"reset"!==this.status&&(this.status="closed"),null!=this.onEnd&&this.onEnd(this.endErr)):this.log.trace("sink ended, waiting for source to end"))}async close(O){this.log.trace("closing gracefully"),this.status="closing",await Promise.all([this.closeRead(O),this.closeWrite(O)]),this.status="closed",this.log.trace("closed gracefully")}async closeRead(O={}){if("closing"===this.readStatus||"closed"===this.readStatus)return;this.log.trace('closing readable end of stream with starting read status "%s"',this.readStatus);let U=this.readStatus;this.readStatus="closing","reset"!==this.status&&"aborted"!==this.status&&null==this.timeline.closeRead&&(this.log.trace("send close read to remote"),await this.sendCloseRead(O)),"ready"===U&&(this.log.trace("ending internal source queue"),this.streamSource.end()),this.log.trace("closed readable end of stream")}async closeWrite(O={}){"closing"!==this.writeStatus&&"closed"!==this.writeStatus&&(this.log.trace('closing writable end of stream with starting write status "%s"',this.writeStatus),"ready"===this.writeStatus&&(this.log.trace("sink was never sunk, sink an empty array"),await raceSignal(this.sink([]),O.signal)),"writing"===this.writeStatus&&await new Promise((U,$)=>{queueMicrotask(()=>{this.log.trace("aborting source passed to .sink"),this.sinkController.abort(),raceSignal(this.sinkEnd.promise,O.signal).then(U,$)})}),this.writeStatus="closed",this.log.trace("closed writable end of stream"))}abort(O){if("closed"===this.status||"aborted"===this.status||"reset"===this.status)return;this.log("abort with error",O),this.log("try to send reset to remote");let U=this.sendReset();isPromise(U)&&U.catch(O=>{this.log.error("error sending reset message",O)}),this.status="aborted",this.timeline.abort=Date.now(),this._closeSinkAndSource(O),this.onAbort?.(O)}reset(){if("closed"===this.status||"aborted"===this.status||"reset"===this.status)return;let O=new errors_CodeError("stream reset",aQ);this.status="reset",this.timeline.reset=Date.now(),this._closeSinkAndSource(O),this.onReset?.()}_closeSinkAndSource(O){this._closeSink(O),this._closeSource(O)}_closeSink(O){"writing"===this.writeStatus&&(this.log.trace("end sink source"),this.sinkController.abort()),this.onSinkEnd(O)}_closeSource(O){"closing"!==this.readStatus&&"closed"!==this.readStatus&&(this.log.trace("ending source with %d bytes to be read by consumer",this.streamSource.readableLength),this.readStatus="closing",this.streamSource.end(O))}remoteCloseWrite(){if("closing"===this.readStatus||"closed"===this.readStatus){this.log("received remote close write but local source is already closed");return}this.log.trace("remote close write"),this._closeSource()}remoteCloseRead(){if("closing"===this.writeStatus||"closed"===this.writeStatus){this.log("received remote close read but local sink is already closed");return}this.log.trace("remote close read"),this._closeSink()}destroy(){if("closed"===this.status||"aborted"===this.status||"reset"===this.status){this.log("received destroy but we are already closed");return}this.log.trace("stream destroyed"),this._closeSinkAndSource()}sourcePush(O){this.streamSource.push(O)}sourceReadableLength(){return this.streamSource.readableLength}};let MplexStream=class MplexStream extends AbstractStream{name;streamId;send;types;maxDataSize;constructor(O){super(O),this.types="outbound"===O.direction?aH:aq,this.send=O.send,this.name=O.name,this.streamId=O.streamId,this.maxDataSize=O.maxDataSize}async sendNewStream(){await this.send({id:this.streamId,type:aH.NEW_STREAM,data:new src_Uint8ArrayList((0,rJ.m)(this.name))})}async sendData(O){for(O=O.sublist();O.byteLength>0;){let U=Math.min(O.byteLength,this.maxDataSize);await this.send({id:this.streamId,type:this.types.MESSAGE,data:O.sublist(0,U)}),O.consume(U)}}async sendReset(){await this.send({id:this.streamId,type:this.types.RESET})}async sendCloseWrite(){await this.send({id:this.streamId,type:this.types.CLOSE})}async sendCloseRead(){}};function createStream(O){let{id:U,name:$,send:J,onEnd:en,type:es="initiator",maxMsgSize:eo=az}=O;return new MplexStream({id:"initiator"===es?`i${U}`:`r${U}`,streamId:U,name:`${null==$?U:$}`,direction:"initiator"===es?"outbound":"inbound",maxDataSize:eo,onEnd:en,send:J,log:logger(`libp2p:mplex:stream:${es}:${U}`)})}let lt=logger("libp2p:mplex"),lr=1024,ln=1024,ls=4194304,la=5,ll=500;function printMessage(O){let U={...O,type:`${aj[O.type]} (${O.type})`};return O.type===tf.NEW_STREAM&&(U.data=(0,rB.B)(O.data instanceof Uint8Array?O.data:O.data.subarray())),(O.type===tf.MESSAGE_INITIATOR||O.type===tf.MESSAGE_RECEIVER)&&(U.data=(0,rB.B)(O.data instanceof Uint8Array?O.data:O.data.subarray(),"base16")),U}let MplexStreamMuxer=class MplexStreamMuxer{protocol="/mplex/6.7.0";sink;source;_streamId;_streams;_init;_source;closeController;rateLimiter;closeTimeout;constructor(O){O=O??{},this._streamId=0,this._streams={initiators:new Map,receivers:new Map},this._init=O,this.closeTimeout=O.closeTimeout??ll,this.sink=this._createSink(),this._source=pushableV({objectMode:!0,onEnd:()=>{for(let O of this._streams.initiators.values())O.destroy();for(let O of this._streams.receivers.values())O.destroy()}}),this.source=pipe(this._source,O=>src_encode_encode(O,this._init.minSendBytes)),this.closeController=new AbortController,this.rateLimiter=new aK.RateLimiterMemory({points:O.disconnectThreshold??la,duration:1})}get streams(){let O=[];for(let U of this._streams.initiators.values())O.push(U);for(let U of this._streams.receivers.values())O.push(U);return O}newStream(O){if(this.closeController.signal.aborted)throw Error("Muxer already closed");let U=this._streamId++;O=null==O?U.toString():O.toString();let $=this._streams.initiators;return this._newStream({id:U,name:O,type:"initiator",registry:$})}async close(O){if(this.closeController.signal.aborted)return;let U=O?.signal??AbortSignal.timeout(this.closeTimeout);try{await Promise.all(this.streams.map(async O=>O.close({signal:U}))),this._source.end(),await this._source.onEmpty({signal:U}),this.closeController.abort()}catch(O){this.abort(O)}}abort(O){this.closeController.signal.aborted||(this.streams.forEach(U=>{U.abort(O)}),this.closeController.abort(O))}_newReceiverStream(O){let{id:U,name:$}=O,J=this._streams.receivers;return this._newStream({id:U,name:$,type:"receiver",registry:J})}_newStream(O){let{id:U,name:$,type:J,registry:en}=O;if(lt("new %s stream %s",J,U),"initiator"===J&&this._streams.initiators.size===(this._init.maxOutboundStreams??ln))throw new errors_CodeError("Too many outbound streams open","ERR_TOO_MANY_OUTBOUND_STREAMS");if(en.has(U))throw Error(`${J} stream ${U} already exists!`);let send=async O=>{lt.enabled&<.trace("%s stream %s send",J,U,printMessage(O)),this._source.push(O)},onEnd=()=>{lt("%s stream with id %s and protocol %s ended",J,U,es.protocol),en.delete(U),null!=this._init.onStreamEnd&&this._init.onStreamEnd(es)},es=createStream({id:U,name:$,send,type:J,onEnd,maxMsgSize:this._init.maxMsgSize});return en.set(U,es),es}_createSink(){let sink=async O=>{try{O=abortableSource(O,this.closeController.signal,{returnOnAbort:!0});let U=new decode_Decoder(this._init.maxMsgSize,this._init.maxUnprocessedMessageQueueSize);for await(let $ of O)for(let O of U.write($))await this._handleIncoming(O);this._source.end()}catch(O){lt("error in sink",O),this._source.end(O)}};return sink}async _handleIncoming(O){let{id:U,type:$}=O;if(lt.enabled&<.trace("incoming message",printMessage(O)),O.type===tf.NEW_STREAM){if(this._streams.receivers.size===(this._init.maxInboundStreams??lr)){lt("too many inbound streams open"),this._source.push({id:U,type:tf.RESET_RECEIVER});try{await this.rateLimiter.consume("new-stream",1)}catch{lt("rate limit hit when opening too many new streams over the inbound stream limit - closing remote connection"),this.abort(Error("Too many open streams"))}return}let $=this._newReceiverStream({id:U,name:(0,rB.B)(O.data instanceof Uint8Array?O.data:O.data.subarray())});null!=this._init.onIncomingStream&&this._init.onIncomingStream($);return}let J=(1&$)==1?this._streams.initiators:this._streams.receivers,en=J.get(U);if(null==en){lt("missing stream %s for message type %s",U,aj[$]);try{await this.rateLimiter.consume("missing-stream",1)}catch{lt("rate limit hit when receiving messages for streams that do not exist - closing remote connection"),this.abort(Error("Too many messages for missing streams"))}return}let es=this._init.maxStreamBufferSize??ls;try{switch($){case tf.MESSAGE_INITIATOR:case tf.MESSAGE_RECEIVER:if(en.sourceReadableLength()>es)throw this._source.push({id:O.id,type:$===tf.MESSAGE_INITIATOR?tf.RESET_RECEIVER:tf.RESET_INITIATOR}),new errors_CodeError("Input buffer full - increase Mplex maxBufferSize to accommodate slow consumers","ERR_STREAM_INPUT_BUFFER_FULL");en.sourcePush(O.data);break;case tf.CLOSE_INITIATOR:case tf.CLOSE_RECEIVER:en.remoteCloseWrite();break;case tf.RESET_INITIATOR:case tf.RESET_RECEIVER:en.reset();break;default:lt("unknown message type %s",$)}}catch(O){lt.error("error while processing message",O),en.abort(O)}}};let Mplex=class Mplex{protocol="/mplex/6.7.0";_init;constructor(O={}){this._init=O}createStreamMuxer(O={}){return new MplexStreamMuxer({...O,...this._init})}};function mplex(O={}){return()=>new Mplex(O)}let lc=Symbol.for("@libp2p/transport");function extractSNI(O){let U;try{U=protocols_table_getProtocol("sni").code}catch(O){return null}for(let[$,J]of O)if($===U&&void 0!==J)return J;return null}function hasTLS(O){return O.some(([O,U])=>O===protocols_table_getProtocol("tls").code)}function interpretNext(O,U,$){let J=lu[protocols_table_getProtocol(O).name];if(void 0===J)throw Error(`Can't interpret protocol ${protocols_table_getProtocol(O).name}`);let en=J(U,$);return O===protocols_table_getProtocol("ip6").code?`[${en}]`:en}!function(O){O[O.FATAL_ALL=0]="FATAL_ALL",O[O.NO_FATAL=1]="NO_FATAL"}(tp||(tp={}));let lu={ip4:(O,U)=>O,ip6:(O,U)=>0===U.length?O:`[${O}]`,tcp:(O,U)=>{let $=U.pop();if(void 0===$)throw Error("Unexpected end of multiaddr");return`tcp://${interpretNext($[0],$[1]??"",U)}:${O}`},udp:(O,U)=>{let $=U.pop();if(void 0===$)throw Error("Unexpected end of multiaddr");return`udp://${interpretNext($[0],$[1]??"",U)}:${O}`},dnsaddr:(O,U)=>O,dns4:(O,U)=>O,dns6:(O,U)=>O,dns:(O,U)=>O,ipfs:(O,U)=>{let $=U.pop();if(void 0===$)throw Error("Unexpected end of multiaddr");return`${interpretNext($[0],$[1]??"",U)}/ipfs/${O}`},p2p:(O,U)=>{let $=U.pop();if(void 0===$)throw Error("Unexpected end of multiaddr");return`${interpretNext($[0],$[1]??"",U)}/p2p/${O}`},http:(O,U)=>{let $=hasTLS(U),J=extractSNI(U);if($&&null!==J)return`https://${J}`;let en=$?"https://":"http://",es=U.pop();if(void 0===es)throw Error("Unexpected end of multiaddr");let eo=interpretNext(es[0],es[1]??"",U);return eo=eo.replace("tcp://",""),`${en}${eo}`},tls:(O,U)=>{let $=U.pop();if(void 0===$)throw Error("Unexpected end of multiaddr");return interpretNext($[0],$[1]??"",U)},sni:(O,U)=>{let $=U.pop();if(void 0===$)throw Error("Unexpected end of multiaddr");return interpretNext($[0],$[1]??"",U)},https:(O,U)=>{let $=U.pop();if(void 0===$)throw Error("Unexpected end of multiaddr");let J=interpretNext($[0],$[1]??"",U);return J=J.replace("tcp://",""),`https://${J}`},ws:(O,U)=>{let $=hasTLS(U),J=extractSNI(U);if($&&null!==J)return`wss://${J}`;let en=$?"wss://":"ws://",es=U.pop();if(void 0===es)throw Error("Unexpected end of multiaddr");let eo=interpretNext(es[0],es[1]??"",U);return eo=eo.replace("tcp://",""),`${en}${eo}`},wss:(O,U)=>{let $=U.pop();if(void 0===$)throw Error("Unexpected end of multiaddr");let J=interpretNext($[0],$[1]??"",U);return J=J.replace("tcp://",""),`wss://${J}`},"p2p-websocket-star":(O,U)=>{let $=U.pop();if(void 0===$)throw Error("Unexpected end of multiaddr");return`${interpretNext($[0],$[1]??"",U)}/p2p-websocket-star`},"p2p-webrtc-star":(O,U)=>{let $=U.pop();if(void 0===$)throw Error("Unexpected end of multiaddr");return`${interpretNext($[0],$[1]??"",U)}/p2p-webrtc-star`},"p2p-webrtc-direct":(O,U)=>{let $=U.pop();if(void 0===$)throw Error("Unexpected end of multiaddr");return`${interpretNext($[0],$[1]??"",U)}/p2p-webrtc-direct`}};function multiaddrToUri(O,U){let $=src_multiaddr(O),J=$.stringTuples(),en=J.pop();if(void 0===en)throw Error("Unexpected end of multiaddr");let es=protocols_table_getProtocol(en[0]),eo=lu[es.name];if(null==eo)throw Error(`No interpreter found for ${es.name}`);let ea=eo(en[1]??"",J);return U?.assumeHttp!==!1&&en[0]===protocols_table_getProtocol("tcp").code&&(ea=ea.replace("tcp://","http://"),("443"===en[1]||"80"===en[1])&&("443"===en[1]&&(ea=ea.replace("http://","https://")),ea=ea.substring(0,ea.lastIndexOf(":")))),ea}var ready=async O=>{if(O.readyState>=2)throw Error("socket closed");1!==O.readyState&&await new Promise((U,$)=>{function cleanup(){O.removeEventListener("open",handleOpen),O.removeEventListener("error",handleErr)}function handleOpen(){cleanup(),U()}function handleErr(U){cleanup(),$(U.error??Error(`connect ECONNREFUSED ${O.url}`))}O.addEventListener("open",handleOpen),O.addEventListener("error",handleErr)})},sink=(O,U)=>{(U=U??{}).closeOnEnd=!1!==U.closeOnEnd;let sink=async $=>{for await(let U of $){try{await ready(O)}catch(O){if("socket closed"===O.message)break;throw O}if(O.readyState===O.CLOSING||O.readyState===O.CLOSED)break;O.send(U)}null!=U.closeOnEnd&&O.readyState<=1&&await new Promise((U,$)=>{O.addEventListener("close",O=>{if(O.wasClean||1006===O.code)U();else{let U=Object.assign(Error("ws error"),{event:O});$(U)}}),setTimeout(()=>{O.close()})})};return sink},lh=$(5986);function isArrayBuffer(O){return O instanceof ArrayBuffer||O?.constructor?.name==="ArrayBuffer"&&"number"==typeof O?.byteLength}var source=O=>{let U;O.binaryType="arraybuffer";let connected=async()=>{await new Promise(($,en)=>{if(J){$();return}if(null!=U){en(U);return}let cleanUp=U=>{O.removeEventListener("open",onOpen),O.removeEventListener("error",onError),U()},onOpen=()=>{cleanUp($)},onError=U=>{cleanUp(()=>{en(U.error??Error(`connect ECONNREFUSED ${O.url}`))})};O.addEventListener("open",onOpen),O.addEventListener("error",onError)})},$=async function*(){let U=new lh.zN(({push:U,stop:$,fail:J})=>{let onMessage=O=>{let $=null;"string"==typeof O.data&&($=(0,rJ.m)(O.data)),isArrayBuffer(O.data)&&($=new Uint8Array(O.data)),O.data instanceof Uint8Array&&($=O.data),null!=$&&U($)},onError=O=>{J(O.error??Error("Socket error"))};return O.addEventListener("message",onMessage),O.addEventListener("error",onError),O.addEventListener("close",$),()=>{O.removeEventListener("message",onMessage),O.removeEventListener("error",onError),O.removeEventListener("close",$)}},{highWaterMark:1/0});for await(let O of(await connected(),U))yield isArrayBuffer(O)?new Uint8Array(O):O}(),J=1===O.readyState;return O.addEventListener("open",()=>{J=!0,U=null}),O.addEventListener("close",()=>{J=!1,U=null}),O.addEventListener("error",$=>{J||(U=$.error??Error(`connect ECONNREFUSED ${O.url}`))}),Object.assign($,{connected})},duplex=(O,U)=>{U=U??{};let $=source(O),J=U.remoteAddress,en=U.remotePort;if(null!=O.url)try{let U=new URL(O.url);J=U.hostname,en=parseInt(U.port,10)}catch{}if(null==J||null==en)throw Error("Remote connection did not have address and/or port");let es={sink:sink(O,U),source:$,connected:async()=>{await $.connected()},close:async()=>{(O.readyState===O.CONNECTING||O.readyState===O.OPEN)&&await new Promise(U=>{O.addEventListener("close",()=>{U()}),O.close()})},destroy:()=>{null!=O.terminate?O.terminate():O.close()},remoteAddress:J,remotePort:en,socket:O};return es},ld=WebSocket,lf=$(2543);let lg={http:"ws",https:"wss"},lm="ws";var ws_url=(O,U)=>(0,lf.relative)(O,U,lg,lm);function connect(O,U){let $="undefined"==typeof window?"":window.location;U=U??{};let J=ws_url(O,$.toString()),en=new ld(J,U.websocket);return duplex(en,U)}var ly=$(9598);let lb="object"==typeof window&&"object"==typeof document&&9===document.nodeType,lv=ly(),l_=lb&&!lv,lw=lv&&!lb,lE=lv&&lb,lS=void 0!==globalThis.process&&void 0!==globalThis.process.release&&"node"===globalThis.process.release.name&&!lv,lA="function"==typeof importScripts&&"undefined"!=typeof self&&"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;void 0!==globalThis.process&&void 0!==globalThis.process.env&&globalThis.process.env.NODE_ENV;let lI="undefined"!=typeof navigator&&"ReactNative"===navigator.product,lP=src_base("dns4"),lk=src_base("dns6"),lT=src_base("dnsaddr"),lR=src_or(src_base("dns"),lT,lP,lk),lC=src_or(src_base("ip4"),src_base("ip6")),lB=src_or(and(lC,src_base("tcp")),and(lR,src_base("tcp"))),lN=and(lC,src_base("udp")),lx=and(lN,src_base("utp")),lD=and(lN,src_base("quic")),lM=and(lN,src_base("quic-v1")),lO=src_or(and(lB,src_base("ws")),and(lR,src_base("ws"))),lL=src_or(and(lO,src_base("p2p")),lO),lU=src_or(and(lB,src_base("wss")),and(lR,src_base("wss")),and(lB,src_base("tls"),src_base("ws")),and(lR,src_base("tls"),src_base("ws"))),lF=src_or(and(lU,src_base("p2p")),lU),lK=src_or(and(lB,src_base("http")),and(lC,src_base("http")),and(lR,src_base("http"))),lj=src_or(and(lB,src_base("https")),and(lC,src_base("https")),and(lR,src_base("https"))),lH=and(lN,src_base("webrtc-direct"),src_base("certhash")),lq=src_or(and(lH,src_base("p2p")),lH),lz=and(lM,src_base("webtransport"),src_base("certhash"),src_base("certhash")),lV=src_or(and(lz,src_base("p2p")),lz),lG=src_or(and(lL,src_base("p2p-webrtc-star"),src_base("p2p")),and(lF,src_base("p2p-webrtc-star"),src_base("p2p")),and(lL,src_base("p2p-webrtc-star")),and(lF,src_base("p2p-webrtc-star")));src_or(and(lL,src_base("p2p-websocket-star"),src_base("p2p")),and(lF,src_base("p2p-websocket-star"),src_base("p2p")),and(lL,src_base("p2p-websocket-star")),and(lF,src_base("p2p-websocket-star")));let l$=src_or(and(lK,src_base("p2p-webrtc-direct"),src_base("p2p")),and(lj,src_base("p2p-webrtc-direct"),src_base("p2p")),and(lK,src_base("p2p-webrtc-direct")),and(lj,src_base("p2p-webrtc-direct"))),lW=src_or(lO,lU,lK,lj,lG,l$,lB,lx,lD,lR,lq,lV);src_or(and(lW,src_base("p2p-stardust"),src_base("p2p")),and(lW,src_base("p2p-stardust")));let lY=src_or(and(lW,src_base("p2p")),lG,l$,lq,lV,src_base("p2p")),lJ=src_or(and(lY,src_base("p2p-circuit"),lY),and(lY,src_base("p2p-circuit")),and(src_base("p2p-circuit"),lY),and(lW,src_base("p2p-circuit")),and(src_base("p2p-circuit"),lW),src_base("p2p-circuit")),CircuitRecursive=()=>src_or(and(lJ,CircuitRecursive),lJ),lQ=CircuitRecursive();function makeMatchesFunction(O){return function(U){let $;try{$=src_multiaddr(U)}catch(O){return!1}let J=O($.protoNames());return null!==J&&(!0===J||!1===J?J:0===J.length)}}function and(...O){function partialMatch(U){if(U.length(Array.isArray($="function"==typeof O?O().partialMatch(U):O.partialMatch(U))&&(U=$),null===$)),$}return{toString:function(){return"{ "+O.join(" ")+" }"},input:O,matches:makeMatchesFunction(partialMatch),partialMatch}}function src_or(...O){function partialMatch(U){let $=null;return O.some(O=>{let J="function"==typeof O?O().partialMatch(U):O.partialMatch(U);return null!=J&&($=J,!0)}),$}let U={toString:function(){return"{ "+O.join(" ")+" }"},input:O,matches:makeMatchesFunction(partialMatch),partialMatch};return U}function src_base(O){let U=O;return{toString:function(){return U},matches:function(O){let $;try{$=src_multiaddr(O)}catch(O){return!1}let J=$.protoNames();return 1===J.length&&J[0]===U},partialMatch:function(O){return 0===O.length?null:O[0]===U?O.slice(1):null}}}src_or(and(lQ,lY,lQ),and(lY,lQ),and(lQ,lY),lQ,lY),src_or(and(lQ,src_base("webrtc"),src_base("p2p")),and(lQ,src_base("webrtc")),and(lW,src_base("webrtc"),src_base("p2p")),and(lW,src_base("webrtc")),src_base("webrtc"));let lZ=421,lX=290,l0=500;function filters_all(O){return O.filter(O=>{if(O.protoCodes().includes(lX))return!1;let U=O.decapsulateCode(lZ);return lL.matches(U)||lF.matches(U)})}function wss(O){return O.filter(O=>{if(O.protoCodes().includes(lX))return!1;let U=O.decapsulateCode(lZ);return lF.matches(U)})}function createListener(){throw Error("WebSocket Servers can not be created in the browser!")}let l1=logger("libp2p:websockets:socket");function socketToMaConn(O,U,$){$=$??{};let J={async sink(U){$?.signal!=null&&(U=abortableSource(U,$.signal));try{await O.sink(U)}catch(O){"aborted"!==O.type&&l1.error(O)}},source:null!=$.signal?abortableSource(O.source,$.signal):O.source,remoteAddr:U,timeline:{open:Date.now()},async close(U={}){let $=Date.now();U.signal=U.signal??AbortSignal.timeout(l0);let listener=()=>{let{host:O,port:U}=J.remoteAddr.toOptions();l1("timeout closing stream to %s:%s after %dms, destroying it manually",O,U,Date.now()-$),this.abort(new errors_CodeError("Socket close timeout","ERR_SOCKET_CLOSE_TIMEOUT"))};U.signal.addEventListener("abort",listener);try{await O.close()}catch(O){l1.error("error closing WebSocket gracefully",O),this.abort(O)}finally{U.signal.removeEventListener("abort",listener),J.timeline.close=Date.now()}},abort(U){let{host:$,port:en}=J.remoteAddr.toOptions();l1("timeout closing stream to %s:%s due to error",$,en,U),O.destroy(),J.timeline.close=Date.now()}};return O.socket.addEventListener("close",()=>{null==J.timeline.close&&(J.timeline.close=Date.now())},{once:!0}),J}let l2=logger("libp2p:websockets");let src_WebSockets=class src_WebSockets{init;constructor(O){this.init=O}[Symbol.toStringTag]="@libp2p/websockets";[lc]=!0;async dial(O,U){l2("dialing %s",O),U=U??{};let $=await this._connect(O,U),J=socketToMaConn($,O);l2("new outbound connection %s",J.remoteAddr);let en=await U.upgrader.upgradeOutbound(J);return l2("outbound connection %s upgraded",J.remoteAddr),en}async _connect(O,U){let $;if(U?.signal?.aborted===!0)throw new AbortError;let J=O.toOptions();l2("dialing %s:%s",J.host,J.port);let en=pDefer(),es=connect(multiaddrToUri(O),this.init);if(es.socket.addEventListener("error",()=>{let U=new errors_CodeError(`Could not connect to ${O.toString()}`,"ERR_CONNECTION_FAILED");l2.error("connection error:",U),en.reject(U)}),null==U.signal)return await Promise.race([es.connected(),en.promise]),l2("connected %s",O),es;let eo=new Promise((O,J)=>{if($=()=>{J(new AbortError),es.close().catch(O=>{l2.error("error closing raw socket",O)})},U?.signal?.aborted===!0){$();return}U?.signal?.addEventListener("abort",$)});try{await Promise.race([eo,en.promise,es.connected()])}finally{null!=$&&U?.signal?.removeEventListener("abort",$)}return l2("connected %s",O),es}createListener(O){return createListener({...this.init,...O})}filter(O){return(O=Array.isArray(O)?O:[O],this.init?.filter!=null)?this.init?.filter(O):l_||lA?wss(O):filters_all(O)}};function webSockets(O={}){return()=>new src_WebSockets(O)}let TypedEventEmitter=class TypedEventEmitter extends EventTarget{#i=new Map;listenerCount(O){let U=this.#i.get(O);return null==U?0:U.length}addEventListener(O,U,$){super.addEventListener(O,U,$);let J=this.#i.get(O);null==J&&(J=[],this.#i.set(O,J)),J.push({callback:U,once:(!0!==$&&!1!==$&&$?.once)??!1})}removeEventListener(O,U,$){super.removeEventListener(O.toString(),U??null,$);let J=this.#i.get(O);null!=J&&(J=J.filter(({callback:O})=>O!==U),this.#i.set(O,J))}dispatchEvent(O){let U=super.dispatchEvent(O),$=this.#i.get(O.type);return null==$||($=$.filter(({once:O})=>!O),this.#i.set(O.type,$)),U}safeDispatchEvent(O,U){return this.dispatchEvent(new l3(O,U))}};let events_CustomEventPolyfill=class events_CustomEventPolyfill extends Event{detail;constructor(O,U){super(O,U),this.detail=U?.detail}};let l3=globalThis.CustomEvent??events_CustomEventPolyfill,l6=Symbol.for("@libp2p/peer-discovery"),l4="bootstrap",l5=50,l8=1e8,l9={store:2,filter:1,lightPush:1},l7=/^(\d{1,3}\.){3,3}\d{1,3}$/,ce=4,ct=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,cr=16,cn={name:"v4",size:ce,isFormat:O=>l7.test(O),encode(O,U,$){$=~~$,U=U||new Uint8Array($+ce);let J=O.length,en=0;for(let es=0;es(U=~~U,`${O[U++]}.${O[U++]}.${O[U++]}.${O[U]}`)},ci={name:"v6",size:cr,isFormat:O=>O.length>0&&ct.test(O),encode(O,U,$){let J=($=~~$)+cr,en=-1,es=0,eo=0,ea=!0,eu=!1;U=U||new Uint8Array($+cr);for(let ef=0;ef>8),$=97?eg-=87:eg>=65?eg-=55:(eg-=48,eo=10*eo+eg),es=(es<<4)+eg)}if(!1===ea)!0===eu?($>8),$=en+2;O--)U[O]=U[O-2];U[en]=0,U[en+1]=0,en=$}if(en!==$&&-1!==en)for($>J-2&&($=J-2);J>en;)U[--J]=$en?U[--$]:0;else for(;$=ca)U+=3;else{let $=O.charCodeAt(es);(64512&$)!==ca?U+=3:(J=es,U+=4)}}}return U}function utf8_codec_encode(O,U,$){let J=O.length;null==$&&($=0),void 0===U&&(U=new Uint8Array(utf8_codec_encodingLength(O)+$));let en=$;for(let $=0;$>6,U[en++]=128|63&es;else if((63488&es)!==co)U[en++]=224|(61440&es)>>12,U[en++]=128|(4032&es)>>6,U[en++]=128|63&es;else{let eo=$+1;if(eo===J||es>=ca)U[en++]=239,U[en++]=191,U[en++]=189;else{let J=O.charCodeAt(eo);(64512&J)!==ca?(U[en++]=239,U[en++]=191,U[en++]=189):($=eo,es=65536|(1023&es)<<10|1023&J,U[en++]=240|(1835008&es)>>18,U[en++]=128|(258048&es)>>12,U[en++]=128|(4032&es)>>6,U[en++]=128|63&es)}}}return utf8_codec_encode.bytes=en-$,U}function utf8_codec_decode(O,U,$){let J="";null==U&&(U=0),null==$&&($=O.length);for(let en=U;en<$;){let U;let $=O[en++];if($<=128)U=$;else if($>191&&$<224)U=(31&$)<<6|63&O[en++];else if($>239&&$<365){U=((7&$)<<18|(63&O[en++])<<12|(63&O[en++])<<6|63&O[en++])-65536;let es=co|U>>10&1023;J+=String.fromCharCode(es),U=ca|1023&U}else U=(15&$)<<12|(63&O[en++])<<6|63&O[en++];J+=String.fromCharCode(U)}return utf8_codec_decode.bytes=$-U,J}utf8_codec_encode.bytes=0,utf8_codec_decode.bytes=0;let isU8Arr=O=>O instanceof Uint8Array;function bytelength(O){return"string"==typeof O?utf8_codec_encodingLength(O):O.byteLength}function buffer_utils_from(O){return O instanceof Uint8Array?O:Array.isArray(O)?new Uint8Array(O):utf8_codec_encode(O)}function buffer_utils_write(O,U,$){if("string"!=typeof U)throw Error("unknown input type");return utf8_codec_encode(U,O,$),utf8_codec_encode.bytes}let cc=16777216,cu=65536,cd=256,readUInt32BE=(O,U)=>O[U]*cc+O[U+1]*cu+O[U+2]*cd+O[U+3],readUInt16BE=(O,U)=>O[U]<<8|O[U+1],writeUInt32BE=(O,U,$)=>(U=+U,O[$+3]=U,U>>>=8,O[$+2]=U,U>>>=8,O[$+1]=U,U>>>=8,O[$]=U,$+4),writeUInt16BE=(O,U,$)=>(O[$]=U>>8,O[$+1]=255&U,$+2);function copy(O,U,$,J,en){return($<0&&(J-=$,$=0),J<0&&(J=0),en<0)?new Uint8Array(0):$>=U.length||J>=en?0:_copyActual(O,U,$,J,en)}function _copyActual(O,U,$,J,en){en-J>U.length-$&&(en=J+U.length-$);let es=en-J,eo=O.length-J;return es>eo&&(es=eo),(0!==J||enO)}}let cw=codec({encode(O,U,$){U||(U=new Uint8Array(cw.encodingLength(O))),$||($=0);let J=$,en=O.replace(/^\.|\.$/gm,"");if(en.length){let O=en.split(".");for(let J=0;J=O.length)throw Error("Cannot decode name (buffer overflow)");let ea=O[U++];if(es+=eo?0:1,0===ea)break;if((192&ea)==0){if(U+ea>O.length)throw Error("Cannot decode name (buffer overflow)");if((en+=ea+1)>254)throw Error("Cannot decode name (name too long)");$.push(utf8_codec_decode(O,U,U+ea)),U+=ea,es+=eo?0:ea}else if((192&ea)==192){if(U+1>O.length)throw Error("Cannot decode name (buffer overflow)");let $=readUInt16BE(O,U-1)-49152;if($>=J)throw Error("Cannot decode name (bad pointer)");U=$,J=$,es+=eo?0:1,eo=!0}else throw Error("Cannot decode name (bad label)")}return cw.decode.bytes=es,0===$.length?".":$.join(".")},encodingLength:O=>"."===O||".."===O?1:bytelength(O.replace(/^\.|\.$/gm,""))+2}),cE=codec({encode(O,U,$){U||(U=new Uint8Array(cE.encodingLength(O))),$||($=0);let J=buffer_utils_write(U,O,$+1);return U[$]=J,cE.encode.bytes=J+1,U},decode(O,U){U||(U=0);let $=O[U],J=utf8_codec_decode(O,U+1,U+1+$);return cE.decode.bytes=$+1,J},encodingLength:O=>bytelength(O)+1}),cS=codec({bytes:12,encode(O,U,$){U||(U=new Uint8Array(cS.encodingLength(O))),$||($=0);let J=32767&(O.flags||0),en="response"===O.type?cg:cf;return writeUInt16BE(U,O.id||0,$),writeUInt16BE(U,J|en,$+2),writeUInt16BE(U,O.questions.length,$+4),writeUInt16BE(U,O.answers.length,$+6),writeUInt16BE(U,O.authorities.length,$+8),writeUInt16BE(U,O.additionals.length,$+10),U},decode(O,U){if(U||(U=0),O.length<12)throw Error("Header must be 12 bytes");let $=readUInt16BE(O,U+2);return{id:readUInt16BE(O,U),type:$&cg?"response":"query",flags:32767&$,flag_qr:($>>15&1)==1,opcode:opcodes_toString($>>11&15),flag_aa:($>>10&1)==1,flag_tc:($>>9&1)==1,flag_rd:($>>8&1)==1,flag_ra:($>>7&1)==1,flag_z:($>>6&1)==1,flag_ad:($>>5&1)==1,flag_cd:($>>4&1)==1,rcode:rcodes_toString(15&$),questions:Array(readUInt16BE(O,U+4)),answers:Array(readUInt16BE(O,U+6)),authorities:Array(readUInt16BE(O,U+8)),additionals:Array(readUInt16BE(O,U+10))}},encodingLength:()=>12}),cA=codec({encode(O,U,$){U||(U=new Uint8Array(cA.encodingLength(O))),$||($=0);let J=O.length;return writeUInt16BE(U,J,$),copy(O,U,$+2,0,J),cA.encode.bytes=J+2,U},decode(O,U){U||(U=0);let $=readUInt16BE(O,U),J=O.slice(U+2,U+2+$);return cA.decode.bytes=$+2,J},encodingLength:O=>O.length+2}),cI=codec({encode:(O,U,$)=>(U||(U=new Uint8Array(cI.encodingLength(O))),$||($=0),cw.encode(O,U,$+2),writeUInt16BE(U,cw.encode.bytes,$),cI.encode.bytes=cw.encode.bytes+2,U),decode(O,U){U||(U=0);let $=readUInt16BE(O,U),J=cw.decode(O,U+2);return cI.decode.bytes=$+2,J},encodingLength:O=>cw.encodingLength(O)+2}),cP=codec({encode(O,U,$){U||(U=new Uint8Array(cP.encodingLength(O))),$||($=0);let J=$;return $+=2,cw.encode(O.mname,U,$),$+=cw.encode.bytes,cw.encode(O.rname,U,$),$+=cw.encode.bytes,writeUInt32BE(U,O.serial||0,$),$+=4,writeUInt32BE(U,O.refresh||0,$),$+=4,writeUInt32BE(U,O.retry||0,$),$+=4,writeUInt32BE(U,O.expire||0,$),$+=4,writeUInt32BE(U,O.minimum||0,$),$+=4,writeUInt16BE(U,$-J-2,J),cP.encode.bytes=$-J,U},decode(O,U){U||(U=0);let $=U,J={};return U+=2,J.mname=cw.decode(O,U),U+=cw.decode.bytes,J.rname=cw.decode(O,U),U+=cw.decode.bytes,J.serial=readUInt32BE(O,U),U+=4,J.refresh=readUInt32BE(O,U),U+=4,J.retry=readUInt32BE(O,U),U+=4,J.expire=readUInt32BE(O,U),U+=4,J.minimum=readUInt32BE(O,U),U+=4,cP.decode.bytes=U-$,J},encodingLength:O=>22+cw.encodingLength(O.mname)+cw.encodingLength(O.rname)}),cT=codec({encode(O,U,$){Array.isArray(O)||(O=[O]);for(let U=0;U0;){let $=O[U++];if(--J<$)throw Error("Buffer overflow");en.push(O.slice(U,U+$)),U+=$,J-=$}return cT.decode.bytes=U-$,en},encodingLength(O){Array.isArray(O)||(O=[O]);let U=2;return O.forEach(function(O){"string"==typeof O?U+=bytelength(O)+1:U+=O.length+1}),U}}),cR=codec({encode(O,U,$){U||(U=new Uint8Array(cR.encodingLength(O))),$||($=0),"string"==typeof O&&(O=buffer_utils_from(O)),O||(O=new Uint8Array(0));let J=$;$+=2;let en=O.length;return copy(O,U,$,0,en),$+=en,writeUInt16BE(U,$-J-2,J),cR.encode.bytes=$-J,U},decode(O,U){U||(U=0);let $=U,J=readUInt16BE(O,U);U+=2;let en=O.slice(U,U+J);return U+=J,cR.decode.bytes=U-$,en},encodingLength:O=>O?(isU8Arr(O)?O.length:bytelength(O))+2:2}),cC=codec({encode(O,U,$){U||(U=new Uint8Array(cC.encodingLength(O))),$||($=0);let J=$;return $+=2,cE.encode(O.cpu,U,$),$+=cE.encode.bytes,cE.encode(O.os,U,$),$+=cE.encode.bytes,writeUInt16BE(U,$-J-2,J),cC.encode.bytes=$-J,U},decode(O,U){U||(U=0);let $=U,J={};return U+=2,J.cpu=cE.decode(O,U),U+=cE.decode.bytes,J.os=cE.decode(O,U),U+=cE.decode.bytes,cC.decode.bytes=U-$,J},encodingLength:O=>cE.encodingLength(O.cpu)+cE.encodingLength(O.os)+2}),cB=codec({encode:(O,U,$)=>(U||(U=new Uint8Array(cB.encodingLength(O))),$||($=0),cw.encode(O,U,$+2),writeUInt16BE(U,cw.encode.bytes,$),cB.encode.bytes=cw.encode.bytes+2,U),decode(O,U){U||(U=0);let $=cw.decode(O,U+2);return cB.decode.bytes=cw.decode.bytes+2,$},encodingLength:O=>cw.encodingLength(O)+2}),cN=codec({encode(O,U,$){U||(U=new Uint8Array(cN.encodingLength(O))),$||($=0),writeUInt16BE(U,O.priority||0,$+2),writeUInt16BE(U,O.weight||0,$+4),writeUInt16BE(U,O.port||0,$+6),cw.encode(O.target,U,$+8);let J=cw.encode.bytes+6;return writeUInt16BE(U,J,$),cN.encode.bytes=J+2,U},decode(O,U){U||(U=0);let $=readUInt16BE(O,U),J={};return J.priority=readUInt16BE(O,U+2),J.weight=readUInt16BE(O,U+4),J.port=readUInt16BE(O,U+6),J.target=cw.decode(O,U+8),cN.decode.bytes=$+2,J},encodingLength:O=>8+cw.encodingLength(O.target)}),cx=codec({encode(O,U,$){let J=cx.encodingLength(O);return U||(U=new Uint8Array(cx.encodingLength(O))),$||($=0),O.issuerCritical&&(O.flags=cx.ISSUER_CRITICAL),writeUInt16BE(U,J-2,$),U[$+=2]=O.flags||0,$+=1,cE.encode(O.tag,U,$),$+=cE.encode.bytes,buffer_utils_write(U,O.value,$),$+=bytelength(O.value),cx.encode.bytes=J,U},decode(O,U){U||(U=0);let $=readUInt16BE(O,U);U+=2;let J=U,en={};return en.flags=O[U],U+=1,en.tag=cE.decode(O,U),U+=cE.decode.bytes,en.value=utf8_codec_decode(O,U,J+$),en.issuerCritical=!!(en.flags&cx.ISSUER_CRITICAL),cx.decode.bytes=$+2,en},encodingLength:O=>cE.encodingLength(O.tag)+cE.encodingLength(O.value)+2});cx.ISSUER_CRITICAL=128;let cD=codec({encode(O,U,$){U||(U=new Uint8Array(cD.encodingLength(O))),$||($=0);let J=$;return $+=2,writeUInt16BE(U,O.preference||0,$),$+=2,cw.encode(O.exchange,U,$),$+=cw.encode.bytes,writeUInt16BE(U,$-J-2,J),cD.encode.bytes=$-J,U},decode(O,U){U||(U=0);let $=U,J={};return U+=2,J.preference=readUInt16BE(O,U),U+=2,J.exchange=cw.decode(O,U),U+=cw.decode.bytes,cD.decode.bytes=U-$,J},encodingLength:O=>4+cw.encodingLength(O.exchange)}),cM=codec({encode:(O,U,$)=>(U||(U=new Uint8Array(cM.encodingLength(O))),$||($=0),writeUInt16BE(U,4,$),$+=2,cn.encode(O,U,$),U),decode(O,U){U||(U=0),U+=2;let $=cn.decode(O,U);return $},bytes:6}),cO=codec({encode:(O,U,$)=>(U||(U=new Uint8Array(cO.encodingLength(O))),$||($=0),writeUInt16BE(U,16,$),$+=2,ci.encode(O,U,$),cO.encode.bytes=18,U),decode(O,U){U||(U=0),U+=2;let $=ci.decode(O,U);return cO.decode.bytes=18,$},bytes:18}),dns_packet_alloc=O=>new Uint8Array(O),cL=codec({encode(O,U,$){U||(U=new Uint8Array(cL.encodingLength(O))),$||($=0);let J=$,en=toCode(O.code);if(writeUInt16BE(U,en,$),$+=2,O.data)writeUInt16BE(U,O.data.length,$),$+=2,copy(O.data,U,$),$+=O.data.length;else switch(en){case 8:{let J=O.sourcePrefixLength||0,en=O.family||familyOf(O.ip,dns_packet_alloc),es=ip_codec_encode(O.ip,dns_packet_alloc),eo=Math.ceil(J/8);writeUInt16BE(U,eo+4,$),$+=2,writeUInt16BE(U,en,$),$+=2,U[$++]=J,U[$++]=O.scopePrefixLength||0,copy(es,U,$,0,eo),$+=eo}break;case 11:O.timeout?(writeUInt16BE(U,2,$),$+=2,writeUInt16BE(U,O.timeout,$)):writeUInt16BE(U,0,$),$+=2;break;case 12:{let J=O.length||0;writeUInt16BE(U,J,$),$+=2,U.fill(0,$,$+J),$+=J}break;case 14:{let J=2*O.tags.length;for(let en of(writeUInt16BE(U,J,$),$+=2,O.tags))writeUInt16BE(U,en,$),$+=2}break;default:throw Error(`Unknown roption code: ${O.code}`)}return cL.encode.bytes=$-J,U},decode(O,U){U||(U=0);let $={};$.code=readUInt16BE(O,U),$.type=optioncodes_toString($.code),U+=2;let J=readUInt16BE(O,U);switch(U+=2,$.data=O.slice(U,U+J),$.code){case 8:$.family=readUInt16BE(O,U),U+=2,$.sourcePrefixLength=O[U++],$.scopePrefixLength=O[U++];{let en=new Uint8Array(1===$.family?4:16);copy(O,en,0,U,U+J-4),$.ip=ip_codec_decode(en)}break;case 11:J>0&&($.timeout=readUInt16BE(O,U),U+=2);break;case 14:$.tags=[];for(let en=0;en0;)J[es++]=cL.decode(O,U),U+=cL.decode.bytes,en-=cL.decode.bytes;return cU.decode.bytes=U-$,J},encodingLength:O=>2+encodingLengthList(O||[],cL)}),cF=codec({encode(O,U,$){U||(U=new Uint8Array(cF.encodingLength(O))),$||($=0);let J=$,en=O.key;if(!isU8Arr(en))throw Error("Key must be a Buffer");return $+=2,writeUInt16BE(U,O.flags,$),U[$+=2]=cF.PROTOCOL_DNSSEC,U[$+=1]=O.algorithm,$+=1,copy(en,U,$,0,en.length),$+=en.length,cF.encode.bytes=$-J,writeUInt16BE(U,cF.encode.bytes-2,J),U},decode(O,U){U||(U=0);let $=U,J={},en=readUInt16BE(O,U);if(U+=2,J.flags=readUInt16BE(O,U),O[U+=2]!==cF.PROTOCOL_DNSSEC)throw Error("Protocol must be 3");return U+=1,J.algorithm=O[U],U+=1,J.key=O.slice(U,$+en+2),U+=J.key.length,cF.decode.bytes=U-$,J},encodingLength:O=>6+bytelength(O.key)});cF.PROTOCOL_DNSSEC=3,cF.ZONE_KEY=128,cF.SECURE_ENTRYPOINT=32768;let cK=codec({encode(O,U,$){U||(U=new Uint8Array(cK.encodingLength(O))),$||($=0);let J=$,en=O.signature;if(!isU8Arr(en))throw Error("Signature must be a Buffer");return $+=2,writeUInt16BE(U,toType(O.typeCovered),$),U[$+=2]=O.algorithm,U[$+=1]=O.labels,$+=1,writeUInt32BE(U,O.originalTTL,$),$+=4,writeUInt32BE(U,O.expiration,$),$+=4,writeUInt32BE(U,O.inception,$),$+=4,writeUInt16BE(U,O.keyTag,$),$+=2,cw.encode(O.signersName,U,$),$+=cw.encode.bytes,copy(en,U,$,0,en.length),$+=en.length,cK.encode.bytes=$-J,writeUInt16BE(U,cK.encode.bytes-2,J),U},decode(O,U){U||(U=0);let $=U,J={},en=readUInt16BE(O,U);return U+=2,J.typeCovered=types_toString(readUInt16BE(O,U)),U+=2,J.algorithm=O[U],U+=1,J.labels=O[U],U+=1,J.originalTTL=readUInt32BE(O,U),U+=4,J.expiration=readUInt32BE(O,U),U+=4,J.inception=readUInt32BE(O,U),U+=4,J.keyTag=readUInt16BE(O,U),U+=2,J.signersName=cw.decode(O,U),U+=cw.decode.bytes,J.signature=O.slice(U,$+en+2),U+=J.signature.length,cK.decode.bytes=U-$,J},encodingLength:O=>20+cw.encodingLength(O.signersName)+bytelength(O.signature)}),cj=codec({encode(O,U,$){U||(U=new Uint8Array(cj.encodingLength(O))),$||($=0);let J=$;return $+=2,cw.encode(O.mbox||".",U,$),$+=cw.encode.bytes,cw.encode(O.txt||".",U,$),$+=cw.encode.bytes,cj.encode.bytes=$-J,writeUInt16BE(U,cj.encode.bytes-2,J),U},decode(O,U){U||(U=0);let $=U,J={};return U+=2,J.mbox=cw.decode(O,U)||".",U+=cw.decode.bytes,J.txt=cw.decode(O,U)||".",U+=cw.decode.bytes,cj.decode.bytes=U-$,J},encodingLength:O=>2+cw.encodingLength(O.mbox||".")+cw.encodingLength(O.txt||".")}),cH=codec({encode(O,U,$){U||(U=new Uint8Array(cH.encodingLength(O))),$||($=0);let J=$,en=[];for(let U=0;U>8]&&(en[$>>8]=[]),en[$>>8][$>>3&31]|=1<<7-(7&$)}for(let O=0;O>8]=Math.max(U[J>>8]||0,255&J)}let $=0;for(let O=0;O2+cw.encodingLength(O.nextDomain)+cH.encodingLength(O.rrtypes)}),cz=codec({encode(O,U,$){U||(U=new Uint8Array(cz.encodingLength(O))),$||($=0);let J=$,en=O.salt;if(!isU8Arr(en))throw Error("salt must be a Buffer");let es=O.nextDomain;if(!isU8Arr(es))throw Error("nextDomain must be a Buffer");return U[$+=2]=O.algorithm,U[$+=1]=O.flags,$+=1,writeUInt16BE(U,O.iterations,$),U[$+=2]=en.length,$+=1,copy(en,U,$,0,en.length),U[$+=en.length]=es.length,$+=1,copy(es,U,$,0,es.length),$+=es.length,cH.encode(O.rrtypes,U,$),$+=cH.encode.bytes,cz.encode.bytes=$-J,writeUInt16BE(U,cz.encode.bytes-2,J),U},decode(O,U){U||(U=0);let $=U,J={},en=readUInt16BE(O,U);U+=2,J.algorithm=O[U],U+=1,J.flags=O[U],U+=1,J.iterations=readUInt16BE(O,U),U+=2;let es=O[U];U+=1,J.salt=O.slice(U,U+es),U+=es;let eo=O[U];return U+=1,J.nextDomain=O.slice(U,U+eo),U+=eo,J.rrtypes=cH.decode(O,U,en-(U-$)),U+=cH.decode.bytes,cz.decode.bytes=U-$,J},encodingLength:O=>8+O.salt.length+O.nextDomain.length+cH.encodingLength(O.rrtypes)}),cV=codec({encode(O,U,$){U||(U=new Uint8Array(cV.encodingLength(O))),$||($=0);let J=$,en=O.digest;if(!isU8Arr(en))throw Error("Digest must be a Buffer");return $+=2,writeUInt16BE(U,O.keyTag,$),U[$+=2]=O.algorithm,U[$+=1]=O.digestType,$+=1,copy(en,U,$,0,en.length),$+=en.length,cV.encode.bytes=$-J,writeUInt16BE(U,cV.encode.bytes-2,J),U},decode(O,U){U||(U=0);let $=U,J={},en=readUInt16BE(O,U);return U+=2,J.keyTag=readUInt16BE(O,U),U+=2,J.algorithm=O[U],U+=1,J.digestType=O[U],U+=1,J.digest=O.slice(U,$+en+2),U+=J.digest.length,cV.decode.bytes=U-$,J},encodingLength:O=>6+bytelength(O.digest)});function renc(O){switch(O.toUpperCase()){case"A":return cM;case"PTR":case"CNAME":case"DNAME":return cB;case"TXT":return cT;case"NULL":return cR;case"AAAA":return cO;case"SRV":return cN;case"HINFO":return cC;case"CAA":return cx;case"NS":return cI;case"SOA":return cP;case"MX":return cD;case"OPT":return cU;case"DNSKEY":return cF;case"RRSIG":return cK;case"RP":return cj;case"NSEC":return cq;case"NSEC3":return cz;case"DS":return cV}return cA}let cG=codec({encode(O,U,$){U||(U=new Uint8Array(cG.encodingLength(O))),$||($=0);let J=$;if(cw.encode(O.name,U,$),$+=cw.encode.bytes,writeUInt16BE(U,toType(O.type),$),"OPT"===O.type.toUpperCase()){if("."!==O.name)throw Error("OPT name must be root.");writeUInt16BE(U,O.udpPayloadSize||4096,$+2),U[$+4]=O.extendedRcode||0,U[$+5]=O.ednsVersion||0,writeUInt16BE(U,O.flags||0,$+6),$+=8,cU.encode(O.options||[],U,$),$+=cU.encode.bytes}else{let J=toClass(void 0===O.class?"IN":O.class);O.flush&&(J|=cm),writeUInt16BE(U,J,$+2),writeUInt32BE(U,O.ttl||0,$+4),$+=8;let en=renc(O.type);en.encode(O.data,U,$),$+=en.encode.bytes}return cG.encode.bytes=$-J,U},decode(O,U){U||(U=0);let $={},J=U;if($.name=cw.decode(O,U),U+=cw.decode.bytes,$.type=types_toString(readUInt16BE(O,U)),"OPT"===$.type)$.udpPayloadSize=readUInt16BE(O,U+2),$.extendedRcode=O[U+4],$.ednsVersion=O[U+5],$.flags=readUInt16BE(O,U+6),$.flag_do=($.flags>>15&1)==1,$.options=cU.decode(O,U+8),U+=8+cU.decode.bytes;else{let J=readUInt16BE(O,U+2);$.ttl=readUInt32BE(O,U+4),$.class=classes_toString(J&cy),$.flush=!!(J&cm);let en=renc($.type);$.data=en.decode(O,U+8),U+=8+en.decode.bytes}return cG.decode.bytes=U-J,$},encodingLength(O){let U=null!==O.data&&void 0!==O.data?O.data:O.options;return cw.encodingLength(O.name)+8+renc(O.type).encodingLength(U)}}),c$=codec({encode(O,U,$){U||(U=new Uint8Array(c$.encodingLength(O))),$||($=0);let J=$;return cw.encode(O.name,U,$),$+=cw.encode.bytes,writeUInt16BE(U,toType(O.type),$),$+=2,writeUInt16BE(U,toClass(void 0===O.class?"IN":O.class),$),$+=2,c$.encode.bytes=$-J,O},decode(O,U){U||(U=0);let $=U,J={};J.name=cw.decode(O,U),U+=cw.decode.bytes,J.type=types_toString(readUInt16BE(O,U)),U+=2,J.class=classes_toString(readUInt16BE(O,U)),U+=2;let en=!!(J.class&cv);return en&&(J.class&=c_),c$.decode.bytes=U-$,J},encodingLength:O=>cw.encodingLength(O.name)+4}),cW=256,cY={encode:function(O,U,$){let J=!U;J&&(U=new Uint8Array(ue(O))),$||($=0);let en=$;return(O.questions||(O.questions=[]),O.answers||(O.answers=[]),O.authorities||(O.authorities=[]),O.additionals||(O.additionals=[]),cS.encode(O,U,$),$+=cS.encode.bytes,$=encodeList(O.questions,c$,U,$),$=encodeList(O.answers,cG,U,$),$=encodeList(O.authorities,cG,U,$),$=encodeList(O.additionals,cG,U,$),cY.encode.bytes=$-en,J&&cZ.bytes!==U.length)?U.slice(0,cZ.bytes):U},decode:function(O,U){U||(U=0);let $=U,J=cS.decode(O,U);return U+=cS.decode.bytes,U=decodeList(J.questions,c$,O,U),U=decodeList(J.answers,cG,O,U),U=decodeList(J.authorities,cG,O,U),U=decodeList(J.additionals,cG,O,U),cY.decode.bytes=U-$,J},encodingLength:function(O){return cS.encodingLength(O)+encodingLengthList(O.questions||[],c$)+encodingLengthList(O.answers||[],cG)+encodingLengthList(O.authorities||[],cG)+encodingLengthList(O.additionals||[],cG)}};function sanitizeSingle(O,U){if(O.questions)throw Error("Only one .question object expected instead of a .questions array!");let $=Object.assign({type:U},O);return $.question&&($.questions=[$.question],delete $.question),$}cY.encode.bytes=0,cY.decode.bytes=0;let cJ={encode:function(O,U,$){return U=cY.encode(sanitizeSingle(O,"query"),U,$),cJ.encode.bytes=cY.encode.bytes,U},decode:function(O,U){let $=cY.decode(O,U);return cJ.decode.bytes=cY.decode.bytes,$.questions&&($.question=$.questions[0],delete $.questions),$}};cJ.encode.bytes=0,cJ.decode.bytes=0;let cQ={encode:function(O,U,$){return U=cY.encode(sanitizeSingle(O,"response"),U,$),cQ.encode.bytes=cY.encode.bytes,U},decode:function(O,U){let $=cY.decode(O,U);return cQ.decode.bytes=cY.decode.bytes,$.questions&&($.question=$.questions[0],delete $.questions),$}};cQ.encode.bytes=0,cQ.decode.bytes=0;let cZ=cY.encode,cX=cY.decode,ue=cY.encodingLength;function streamEncode(O){let U=cZ(O),$=new Uint8Array(2+U.byteLength);return writeUInt16BE($,U.byteLength),copy(U,$,2,0,U.length),streamEncode.bytes=$.byteLength,$}function streamDecode(O){let U=readUInt16BE(O,0);if(O.byteLength255)throw Error(`Character #${O} in charset [code=${$}, char=${U.charAt(O)}] is too high! (max=255)`);if(0!==en[$])throw Error(`Character [code=${$}, char=${U.charAt(O)}] is more than once in the charset!`);en[$]=O,es[O]=$}let eo=$.charCodeAt(0),ea={name:O,encodingLength(O){let U=O.length,$=.75*U|0;return O.charCodeAt(U-1)===eo?O.charCodeAt(U-2)===eo?$-2:$-1:$},encode(O,U,$){null==U&&(U=new Uint8Array(ea.encodingLength(O))),null==$&&($=0);let J=O.length;O.charCodeAt(J-1)===eo&&(O.charCodeAt(J-2)===eo?J-=2:J-=1);let es=J%4,eu=J-es,ef=$,eg=0;for(;eg>16,U[ef++]=$>>8,U[ef++]=$,eg+=4}if(3===es){let $=en[O.charCodeAt(eg)]<<10|en[O.charCodeAt(eg+1)]<<4|en[O.charCodeAt(eg+2)]>>2;U[ef++]=$>>8,U[ef++]=$}else 2===es&&(U[ef++]=en[O.charCodeAt(eg)]<<2|en[O.charCodeAt(eg+1)]>>4);return ea.encode.bytes=ef-$,U},decode(O,U,$){null==U&&(U=0),null==$&&($=O.length);let en=$-U,eu=en%3,ef=U+en-eu,eg=[];for(let $=U;$>18&63],es[U>>12&63],es[U>>6&63],es[63&U])}if(2===eu){let U=(O[$-2]<<8)+O[$-1];eg.push(es[U>>10],es[U>>4&63],es[U<<2&63]),J===ut&&eg.push(eo)}else if(1===eu){let U=O[$-1];eg.push(es[U>>2],es[U<<4&63]),J===ut&&eg.push(eo,eo)}return ea.decode.bytes=en,String.fromCharCode.apply(String,eg)}};return ea}make("base64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/","=",ut);let un=make("base64-url","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_","=",ur),us="undefined"!=typeof global?global.AbortError:"undefined"!=typeof window?window.AbortError:null;us||(us=class extends Error{constructor(O="Request aborted."){super(O)}}),us.prototype.name="AbortError",us.prototype.code="ABORT_ERR";let uo="undefined"!=typeof globalThis&&globalThis.URL||require("url").URL;let HTTPStatusError=class HTTPStatusError extends Error{constructor(O,U,$){super("status="+U+" while requesting "+O+" ["+$+"]"),this.uri=O,this.status=U,this.method=$}toJSON(){return{code:this.code,uri:this.uri,status:this.status,method:this.method,endpoint:this.endpoint}}};HTTPStatusError.prototype.name="HTTPStatusError",HTTPStatusError.prototype.code="HTTP_STATUS";let ResponseError=class ResponseError extends Error{constructor(O,U){super(O),this.cause=U}toJSON(){return{message:this.message,endpoint:this.endpoint,code:this.code,cause:reduceError(this.cause)}}};ResponseError.prototype.name="ResponseError",ResponseError.prototype.code="RESPONSE_ERR";let common_TimeoutError=class common_TimeoutError extends Error{constructor(O){super("Timeout (t="+O+")."),this.timeout=O}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}};common_TimeoutError.prototype.name="TimeoutError",common_TimeoutError.prototype.code="ETIMEOUT";let ua=/^((\d{1,3}\.){3,3}\d{1,3})(:(\d{2,5}))?$/,ul=/^((::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?)(:(\d{2,5}))?$/i;function reduceError(O){if("string"==typeof O)return{message:O};try{let U=JSON.stringify(O);if("{}"!==U)return JSON.parse(U)}catch(O){}let U={message:String(O.message||O)};return void 0!==O.code&&(U.code=String(O.code)),U}let uc=/^(([a-z0-9]+:)\/\/)?([^/[\s:]+|\[[^\]]+\])?(:([^/\s]+))?(\/[^\s]*)?(.*)$/,uu=/\[(post|get|((ipv4|ipv6|name)=([^\]]+)))\]/ig,uh=/\[(((pk|name)=([^\]]+)))\]/ig;function parseEndpoint(O){let U=uc.exec(O),$=U[2]||"https:",J=U[3],en=U[5],es=U[6],eo=U[7];if("https:"===$||"http:"===$){let O=parseFlags(eo,uu);return{name:O.name,protocol:$,ipv4:O.ipv4,ipv6:O.ipv6,host:J,port:en,path:es,method:O.post?"POST":"GET"}}if("udp:"===$||"udp4:"===$||"udp6:"===$){let U=parseFlags(eo,uh),es=/^\[(.*)\]$/.exec(J);if(es&&"udp4:"===$)throw Error(`Endpoint parsing error: Cannot use ipv6 host with udp4: (endpoint=${O})`);if(!es&&"udp6:"===$)throw Error(`Endpoint parsing error: Incorrectly formatted host for udp6: (endpoint=${O})`);return es?new UDP6Endpoint({protocol:"udp6:",ipv6:es[1],port:en,pk:U.pk,name:U.name}):new UDP4Endpoint({protocol:"udp4:",ipv4:J,port:en,pk:U.pk,name:U.name})}throw new InvalidProtocolError($,O)}function parseFlags(O,U){U.lastIndex=0;let $={};for(;;){let J=U.exec(O);if(!J)break;J[2]?$[J[3].toLowerCase()]=J[4]:$[J[1].toLowerCase()]=!0}return $}let InvalidProtocolError=class InvalidProtocolError extends Error{constructor(O,U){super(`Invalid Endpoint: unsupported protocol "${O}" for endpoint: ${U}, supported protocols: ${ud.join(", ")}`),this.protocol=O,this.endpoint=U}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}};InvalidProtocolError.prototype.name="InvalidProtocolError",InvalidProtocolError.prototype.code="EPROTOCOL";let ud=["http:","https:","udp4:","udp6:"];let BaseEndpoint=class BaseEndpoint{constructor(O,U){this.name=O.name||null,this.protocol=O.protocol;let $="string"==typeof O.port?O.port=parseInt(O.port,10):O.port;if(null==$)this.port=U?"https:"===this.protocol?443:80:O.pk?443:53;else if("number"==typeof $||isNaN($))this.port=$;else throw Error(`Invalid Endpoint: port "${O.port}" needs to be a number: ${JSON.stringify(O)}`)}toJSON(){return this.toString()}};let UDPEndpoint=class UDPEndpoint extends BaseEndpoint{constructor(O){super(O,!1),this.pk=O.pk||null}toString(){let O=this.port!==(this.pk?443:53)?`:${this.port}`:"",U=this.pk?` [pk=${this.pk}]`:"",$=this.name?` [name=${this.name}]`:"";return`udp://${this.ipv4||`[${this.ipv6}]`}${O}${U}${$}`}};let UDP4Endpoint=class UDP4Endpoint extends UDPEndpoint{constructor(O){if(super(Object.assign({protocol:"udp4:"},O)),!O.ipv4||"string"!=typeof O.ipv4)throw Error(`Invalid Endpoint: .ipv4 "${O.ipv4}" needs to be set: ${JSON.stringify(O)}`);this.ipv4=O.ipv4}};let UDP6Endpoint=class UDP6Endpoint extends UDPEndpoint{constructor(O){if(super(Object.assign({protocol:"udp6:"},O)),!O.ipv6||"string"!=typeof O.ipv6)throw Error(`Invalid Endpoint: .ipv6 "${O.ipv6}" needs to be set: ${JSON.stringify(O)}`);this.ipv6=O.ipv6}};function safeHost(O){return ul.test(O)&&!ua.test(O)?`[${O}]`:O}let HTTPEndpoint=class HTTPEndpoint extends BaseEndpoint{constructor(O){if(super(Object.assign({protocol:"https:"},O),!0),!O.host&&(O.ipv4&&(O.host=O.ipv4),O.ipv6&&(O.host=`[${O.ipv6}]`)),!O.host||"string"!=typeof O.host)throw Error(`Invalid Endpoint: host "${O.path}" needs to be set: ${JSON.stringify(O)}`);if(this.host=O.host,this.path=O.path||"/dns-query",this.method=/^post$/i.test(O.method)?"POST":"GET",this.ipv4=O.ipv4,this.ipv6=O.ipv6,!this.ipv6){let O=ul.exec(this.host);O&&(this.ipv6=O[1])}!this.ipv4&&ua.test(this.host)&&(this.ipv4=this.host);let U=`${this.protocol}//${safeHost(this.host)}:${this.port}${this.path}`;try{this.url=new uo(U)}catch(O){throw Error(O.message+` [${U}]`)}}toString(){let O="https:"===this.protocol?"":"http://",U=this.port!==("https:"===this.protocol?443:80)?`:${this.port}`:"",$="GET"!==this.method?" [post]":"",J="/dns-query"===this.path?"":this.path,en=this.name?` [name=${this.name}]`:"",es=this.ipv4&&this.ipv4!==this.host?` [ipv4=${this.ipv4}]`:"",eo=this.ipv6&&this.ipv6!==this.host?` [ipv6=${this.ipv6}]`:"";return`${O}${safeHost(this.host)}${U}${J}${$}${es}${eo}${en}`}};function toEndpoint(O){let U;if("string"==typeof O)U=parseEndpoint(O);else{if("object"!=typeof O||null===O||Array.isArray(O))throw Error(`Can not convert ${O} to an endpoint`);if(O instanceof BaseEndpoint)return O;U=O}(null===U.protocol||void 0===U.protocol)&&(U.protocol="https:");let $=U.protocol;if("udp4:"===$)return new UDP4Endpoint(U);if("udp6:"===$)return new UDP6Endpoint(U);if("https:"===$||"http:"===$)return new HTTPEndpoint(U);throw new InvalidProtocolError($,JSON.stringify(U))}let uf="application/dns-message";function lib_browser_noop(){}function queryDns(){throw Error('Only "doh" endpoints are supported in the browser')}async function loadJSON(O,U,$,J){let en=U?U.localStoragePrefix+U.name:null;if(en)try{let O=JSON.parse(localStorage.getItem(en));if(O&&O.time>U.maxTime)return O}catch(O){}let{data:es}=await requestRaw(O,"GET",null,$,J),eo={time:Date.now(),data:JSON.parse(utf8_codec_decode(es))};if(en)try{localStorage.setItem(en,JSON.stringify(eo))}catch(O){eo.time=null}return eo}function requestRaw(O,U,$,J,en){return new Promise((es,eo)=>{let ea=new uo(O);"GET"===U&&$&&(ea.search="?dns="+un.decode($));let eu=ea.toString(),ef=new XMLHttpRequest;function ontimeout(){finish(new common_TimeoutError(J));try{ef.abort()}catch(O){}}function onload(){if(200!==ef.status)finish(new HTTPStatusError(eu,ef.status,U));else{let O;if("string"==typeof ef.response)O=utf8_codec_encode(ef.response);else if(ef.response instanceof Uint8Array)O=ef.response;else if(Array.isArray(ef.response)||ef.response instanceof ArrayBuffer)O=new Uint8Array(ef.response);else throw Error("Unprocessable response "+ef.response);finish(null,O)}}function onreadystatechange(){if(ef.readyState>1&&200!==ef.status&&0!==ef.status){finish(new HTTPStatusError(eu,ef.status,U));try{ef.abort()}catch(O){}}}ef.open(U,eu,!0),ef.setRequestHeader("Accept",uf),"POST"===U&&ef.setRequestHeader("Content-Type",uf),ef.responseType="arraybuffer",ef.timeout=J,ef.ontimeout=ontimeout,ef.onreadystatechange=onreadystatechange,ef.onerror=onerror,ef.onload=onload,"POST"===U?ef.send($):ef.send(),en&&en.addEventListener("abort",onabort);let finish=function(O,U){finish=lib_browser_noop,en&&en.removeEventListener("abort",onabort),O?es({error:O,response:ef}):es({data:U,response:ef})};function onerror(){finish(200===ef.status?Error("Inexplicable XHR Error"):new HTTPStatusError(eu,ef.status,U))}function onabort(){finish(new us);try{ef.abort()}catch(O){}}})}function request(O,U,$,J,en){return requestRaw(O,U,$,J,en)}function processResolvers(O){return O.filter(O=>O.cors||O.endpoint.cors)}let up={data:[{name:"adfree.usableprivacy.net",endpoint:{protocol:"https:",host:"adfree.usableprivacy.net"},description:"Public updns DoH service with advertising, tracker and malware filters.\nHosted in Europe by @usableprivacy, details see: https://docs.usableprivacy.com",country:"Germany",location:{lat:51.2993,long:9.491},filter:!0},{name:"adguard-dns-doh",endpoint:{protocol:"https:",host:"dns.adguard.com",ipv4:"94.140.15.15"},description:"Remove ads and protect your computer from malware (over DoH)",country:"France",location:{lat:48.8582,long:2.3387},filter:!0},{name:"adguard-dns-family-doh",endpoint:{protocol:"https:",host:"dns-family.adguard.com",ipv4:"94.140.15.16"},description:"Adguard DNS with safesearch and adult content blocking (over DoH)",country:"France",location:{lat:48.8582,long:2.3387},filter:!0},{name:"adguard-dns-unfiltered-doh",endpoint:{protocol:"https:",host:"dns-unfiltered.adguard.com",ipv4:"94.140.14.140"},description:"AdGuard public DNS servers without filters (over DoH)",country:"France",location:{lat:48.8582,long:2.3387}},{name:"ahadns-doh-chi",endpoint:{protocol:"https:",host:"doh.chi.ahadns.net",cors:!0},description:"A zero logging DNS with support for DNS-over-HTTPS (DoH) & DNS-over-TLS (DoT). Blocks ads, malware, trackers, viruses, ransomware, telemetry and more. No persistent logs. DNSSEC. Hosted in Chicago, USA. By https://ahadns.com/\nServer statistics can be seen at: https://statistics.ahadns.com/?server=chi",country:"United States",location:{lat:41.8483,long:-87.6517},filter:!0,cors:!0},{name:"ahadns-doh-in",endpoint:{protocol:"https:",host:"doh.in.ahadns.net",cors:!0},description:"A zero logging DNS with support for DNS-over-HTTPS (DoH) & DNS-over-TLS (DoT). Blocks ads, malware, trackers, viruses, ransomware, telemetry and more. No persistent logs. DNSSEC. Hosted in Mumbai, India. By https://ahadns.com/\nServer statistics can be seen at: https://statistics.ahadns.com/?server=in",country:"India",location:{lat:19.0748,long:72.8856},filter:!0,cors:!0},{name:"ahadns-doh-la",endpoint:{protocol:"https:",host:"doh.la.ahadns.net",cors:!0},description:"A zero logging DNS with support for DNS-over-HTTPS (DoH) & DNS-over-TLS (DoT). Blocks ads, malware, trackers, viruses, ransomware, telemetry and more. No persistent logs. DNSSEC. Hosted in Los Angeles, USA. By https://ahadns.com/\nServer statistics can be seen at: https://statistics.ahadns.com/?server=la",country:"United States",location:{lat:34.0549,long:-118.2578},filter:!0,cors:!0},{name:"ahadns-doh-nl",endpoint:{protocol:"https:",host:"doh.nl.ahadns.net",cors:!0},description:"A zero logging DNS with support for DNS-over-HTTPS (DoH) & DNS-over-TLS (DoT). Blocks ads, malware, trackers, viruses, ransomware, telemetry and more. No persistent logs. DNSSEC. Hosted in Amsterdam, Netherlands. By https://ahadns.com/\nServer statistics can be seen at: https://statistics.ahadns.com/?server=nl",country:"Netherlands",location:{lat:52.3824,long:4.8995},filter:!0,cors:!0},{name:"ahadns-doh-ny",endpoint:{protocol:"https:",host:"doh.ny.ahadns.net",cors:!0},description:"A zero logging DNS with support for DNS-over-HTTPS (DoH) & DNS-over-TLS (DoT). Blocks ads, malware, trackers, viruses, ransomware, telemetry and more. No persistent logs. DNSSEC. Hosted in New York. By https://ahadns.com/\nServer statistics can be seen at: https://statistics.ahadns.com/?server=ny",country:"United States",location:{lat:40.7308,long:-73.9975},filter:!0,cors:!0},{name:"ahadns-doh-pl",endpoint:{protocol:"https:",host:"doh.pl.ahadns.net",cors:!0},description:"A zero logging DNS with support for DNS-over-HTTPS (DoH) & DNS-over-TLS (DoT). Blocks ads, malware, trackers, viruses, ransomware, telemetry and more. No persistent logs. DNSSEC. Hosted in Poland. By https://ahadns.com/\nServer statistics can be seen at: https://statistics.ahadns.com/?server=pl",country:"Netherlands",location:{lat:52.3824,long:4.8995},filter:!0,cors:!0},{name:"alidns-doh",endpoint:{protocol:"https:",host:"dns.alidns.com",ipv4:"223.5.5.5",cors:!0},description:"A public DNS resolver that supports DoH/DoT in mainland China, provided by Alibaba-Cloud.\nWarning: GFW filtering rules are applied by that resolver.\nHomepage: https://alidns.com/",country:"China",location:{lat:34.7725,long:113.7266},filter:!0,log:!0,cors:!0},{name:"ams-ads-doh-nl",endpoint:{protocol:"https:",host:"dnsnl-noads.alekberg.net"},description:"Resolver in Amsterdam. DoH protocol. Non-logging. Blocks ads, malware and trackers. DNSSEC enabled.",country:"Romania",location:{lat:45.9968,long:24.997},filter:!0},{name:"ams-doh-nl",endpoint:{protocol:"https:",host:"dnsnl.alekberg.net"},description:"Resolver in Amsterdam. DoH protocol. Non-logging, non-filtering, DNSSEC.",country:"Romania",location:{lat:45.9968,long:24.997}},{name:"att",endpoint:{protocol:"https:",host:"dohtrial.att.net"},description:"AT&T test DoH server.",log:!0},{name:"bcn-ads-doh",endpoint:{protocol:"https:",host:"dnses-noads.alekberg.net"},description:"Resolver in Spain. DoH protocol. Non-logging, remove ads and malware, DNSSEC.",country:"Spain",location:{lat:41.3891,long:2.1611},filter:!0},{name:"bcn-doh",endpoint:{protocol:"https:",host:"dnses.alekberg.net"},description:"Resolver in Spain. DoH protocol. Non-logging, non-filtering, DNSSEC.",country:"Spain",location:{lat:41.3891,long:2.1611}},{name:"brahma-world",endpoint:{protocol:"https:",host:"dns.brahma.world"},description:"DNS-over-HTTPS server. Non Logging, filters ads, trackers and malware. DNSSEC ready, QNAME Minimization, No EDNS Client-Subnet.\nHosted in Stockholm, Sweden. (https://dns.brahma.world)",country:"United States",location:{lat:37.751,long:-97.822},filter:!0},{name:"cisco-doh",endpoint:{protocol:"https:",host:"doh.opendns.com",ipv4:"146.112.41.2"},description:"Remove your DNS blind spot (DoH protocol)\nWarning: modifies your queries to include a copy of your network\naddress when forwarding them to a selection of companies and organizations.",country:"United States",location:{lat:37.751,long:-97.822},filter:!0,log:!0},{name:"cloudflare",endpoint:{protocol:"https:",host:"dns.cloudflare.com",ipv4:"1.0.0.1",cors:!0},description:"Cloudflare DNS (anycast) - aka 1.1.1.1 / 1.0.0.1",country:"Australia",location:{lat:-33.494,long:143.2104},cors:!0},{name:"cloudflare-family",endpoint:{protocol:"https:",host:"family.cloudflare-dns.com",ipv4:"1.0.0.3",cors:!0},description:"Cloudflare DNS (anycast) with malware protection and parental control - aka 1.1.1.3 / 1.0.0.3",country:"Australia",location:{lat:-33.494,long:143.2104},filter:!0,cors:!0},{name:"cloudflare-ipv6",endpoint:{protocol:"https:",host:"1dot1dot1dot1.cloudflare-dns.com",cors:!0},description:"Cloudflare DNS over IPv6 (anycast)",country:"United States",location:{lat:37.751,long:-97.822},cors:!0},{name:"cloudflare-security",endpoint:{protocol:"https:",host:"security.cloudflare-dns.com",ipv4:"1.0.0.2",cors:!0},description:"Cloudflare DNS (anycast) with malware blocking - aka 1.1.1.2 / 1.0.0.2",country:"Australia",location:{lat:-33.494,long:143.2104},filter:!0,cors:!0},{name:"controld-block-malware",endpoint:{protocol:"https:",host:"freedns.controld.com",path:"/p1"},description:"ControlD Free DNS. Take CONTROL of your Internet. Block unwanted content, bypass geo-restrictions and be more productive. DoH protocol and No logging. - https://controld.com/free-dns\nThis DNS blocks Malware domains.",country:"Canada",location:{lat:43.6319,long:-79.3716},filter:!0},{name:"controld-block-malware-ad",endpoint:{protocol:"https:",host:"freedns.controld.com",path:"/p2"},description:"ControlD Free DNS. Take CONTROL of your Internet. Block unwanted content, bypass geo-restrictions and be more productive. DoH protocol and No logging. - https://controld.com/free-dns\nThis DNS blocks Malware, Ads & Tracking domains.",country:"Canada",location:{lat:43.6319,long:-79.3716},filter:!0},{name:"controld-block-malware-ad-social",endpoint:{protocol:"https:",host:"freedns.controld.com",path:"/p3"},description:"ControlD Free DNS. Take CONTROL of your Internet. Block unwanted content, bypass geo-restrictions and be more productive. DoH protocol and No logging. - https://controld.com/free-dns\nThis DNS blocks Malware, Ads & Tracking and Social Networks domains.",country:"Canada",location:{lat:43.6319,long:-79.3716},filter:!0},{name:"controld-family-friendly",endpoint:{protocol:"https:",host:"freedns.controld.com",path:"/family"},description:"ControlD Free DNS. Take CONTROL of your Internet. Block unwanted content, bypass geo-restrictions and be more productive. DoH protocol and No logging. - https://controld.com/free-dns\nThis DNS blocks Malware, Ads & Tracking, Adult Content and Drugs domains.",country:"Canada",location:{lat:43.6319,long:-79.3716},filter:!0},{name:"controld-uncensored",endpoint:{protocol:"https:",host:"freedns.controld.com",path:"/uncensored"},description:"ControlD Free DNS. Take CONTROL of your Internet. Block unwanted content, bypass geo-restrictions and be more productive. DoH protocol and No logging. - https://controld.com/free-dns\nThis DNS unblocks censored domains from various countries.",country:"Canada",location:{lat:43.6319,long:-79.3716}},{name:"controld-unfiltered",endpoint:{protocol:"https:",host:"freedns.controld.com",path:"/p0"},description:"ControlD Free DNS. Take CONTROL of your Internet. Block unwanted content, bypass geo-restrictions and be more productive. DoH protocol and No logging. - https://controld.com/free-dns\nThis is a Unfiltered DNS, no DNS record blocking or manipulation here, if you want to block Malware, Ads & Tracking or Social Network domains, use the other ControlD DNS configs.",country:"Canada",location:{lat:43.6319,long:-79.3716}},{name:"dns.digitale-gesellschaft.ch",endpoint:{protocol:"https:",host:"dns.digitale-gesellschaft.ch"},description:"Public DoH resolver operated by the Digital Society (https://www.digitale-gesellschaft.ch).\nHosted in Zurich, Switzerland.\nNon-logging, non-filtering, supports DNSSEC.",country:"Switzerland",location:{lat:47.1449,long:8.1551}},{name:"dns.ryan-palmer",endpoint:{protocol:"https:",host:"dns1.ryan-palmer.com"},description:"Non-logging, non-filtering, DNSSEC DoH Server. Hosted in the UK.",country:"United Kingdom",location:{lat:51.5164,long:-.093}},{name:"dns.sb",endpoint:{protocol:"https:",host:"doh.sb",ipv4:"185.222.222.222",cors:!0},description:"DNSSEC-enabled DoH server by https://xtom.com/\nhttps://dns.sb/doh/",country:"Unknown",location:{lat:47,long:8},cors:!0},{name:"dns.therifleman.name",endpoint:{protocol:"https:",host:"dns.therifleman.name"},description:"DNS-over-HTTPS DNS forwarder from Mumbai, India. Blocks web and Android trackers and ads.\nIP addresses are not logged, but queries are logged for 24 hours for debugging.\nReport issues, send suggestions @ joker349 at protonmail.com.\nAlso supports DoT (for android) @ dns.therifleman.name and plain DNS @ 172.104.206.174",country:"United States",location:{lat:37.751,long:-97.822},filter:!0},{name:"dnsforfamily-doh",endpoint:{protocol:"https:",host:"dns-doh.dnsforfamily.com"},description:"(DoH Protocol) (Now supports DNSSEC). Block adult websites, gambling websites, malwares and advertisements.\nIt also enforces safe search in: Google, YouTube, Bing, DuckDuckGo and Yandex.\nSocial websites like Facebook and Instagram are not blocked. No DNS queries are logged.\nAs of 26-May-2022 5.9 million websites are blocked and new websites are added to blacklist daily.\nCompletely free, no ads or any commercial motive. Operating for 4 years now.\nProvided by: https://dnsforfamily.com",country:"Finland",location:{lat:60.1758,long:24.9349},filter:!0},{name:"dnsforfamily-doh-no-safe-search",endpoint:{protocol:"https:",host:"dns-doh-no-safe-search.dnsforfamily.com"},description:"(DoH Protocol) (Now supports DNSSEC) Block adult websites, gambling websites, malwares and advertisements.\nUnlike other dnsforfamily servers, this one does not enforces safe search. So Google, YouTube, Bing, DuckDuckGo and Yandex are completely accessible without any restriction.\nSocial websites like Facebook and Instagram are not blocked. No DNS queries are logged.\nAs of 26-May-2022 5.9 million websites are blocked and new websites are added to blacklist daily.\nCompletely free, no ads or any commercial motive. Operating for 4 years now.\nWarning: This server is incompatible with anonymization.\nProvided by: https://dnsforfamily.com",country:"Finland",location:{lat:60.1758,long:24.9349},filter:!0},{name:"dnsforge.de",endpoint:{protocol:"https:",host:"dnsforge.de",cors:!0},description:"Public DoH resolver running with Pihole for Adblocking (https://dnsforge.de).\nNon-logging, AD-filtering, supports DNSSEC. Hosted in Germany.",country:"Germany",location:{lat:52.2998,long:9.447},filter:!0,cors:!0},{name:"dnshome-doh",endpoint:{protocol:"https:",host:"dns.dnshome.de"},description:"https://www.dnshome.de/ public resolver in Germany"},{name:"dnspod-doh",endpoint:{protocol:"https:",host:"doh.pub",cors:!0},description:"A public DNS resolver in mainland China provided by DNSPod (Tencent Cloud).\nhttps://www.dnspod.cn/Products/Public.DNS?lang=en",filter:!0,log:!0,cors:!0},{name:"dnswarden-asia-adblock-dohv4",endpoint:{protocol:"https:",host:"doh.asia.dnswarden.com",path:"/adblock"},description:"Hosted in Singapore. For more information look [here](https://github.com/bhanupratapys/dnswarden) or [here](https://dnswarden.com).",country:"Singapore",location:{lat:1.2929,long:103.8547},filter:!0},{name:"dnswarden-asia-adultfilter-dohv4",endpoint:{protocol:"https:",host:"doh.asia.dnswarden.com",path:"/adultfilter"},description:"Hosted in Singapore. For more information look [here](https://github.com/bhanupratapys/dnswarden) or [here](https://dnswarden.com).",country:"Singapore",location:{lat:1.2929,long:103.8547},filter:!0},{name:"dnswarden-asia-uncensor-dohv4",endpoint:{protocol:"https:",host:"doh.asia.dnswarden.com",path:"/uncensored"},description:"Hosted in Singapore. For more information look [here](https://github.com/bhanupratapys/dnswarden) or [here](https://dnswarden.com).",country:"Singapore",location:{lat:1.2929,long:103.8547}},{name:"dnswarden-eu-adblock-dohv4",endpoint:{protocol:"https:",host:"doh.eu.dnswarden.com"},description:"Hosted in Germany. For more information look [here](https://github.com/bhanupratapys/dnswarden) or [here](https://dnswarden.com).",country:"Germany",location:{lat:50.1103,long:8.7147},filter:!0},{name:"dnswarden-us-adblock-dohv4",endpoint:{protocol:"https:",host:"doh.us.dnswarden.com"},description:"Hosted in USA (Dallas) . For more information look [here](https://github.com/bhanupratapys/dnswarden) or [here](https://dnswarden.com).",country:"United States",location:{lat:32.7889,long:-96.8021},filter:!0},{name:"doh-ch-blahdns",endpoint:{protocol:"https:",host:"doh-ch.blahdns.com",cors:!0},description:"Blocks ad and Tracking, no Logging, DNSSEC, Hosted in Switzerland. By https://blahdns.com/",country:"Netherlands",location:{lat:52.3824,long:4.8995},filter:!0,cors:!0},{name:"doh-cleanbrowsing-adult",endpoint:{protocol:"https:",host:"doh.cleanbrowsing.org",path:"/doh/adult-filter/",cors:!0},description:"Blocks access to all adult, pornographic and explicit sites. It does\nnot block proxy or VPNs, nor mixed-content sites. Sites like Reddit\nare allowed. Google and Bing are set to the Safe Mode.\nBy https://cleanbrowsing.org/",filter:!0,cors:!0},{name:"doh-cleanbrowsing-family",endpoint:{protocol:"https:",host:"doh.cleanbrowsing.org",path:"/doh/family-filter/",cors:!0},description:"Blocks access to all adult, pornographic and explicit sites. It also\nblocks proxy and VPN domains that are used to bypass the filters.\nMixed content sites (like Reddit) are also blocked. Google, Bing and\nYoutube are set to the Safe Mode.\nBy https://cleanbrowsing.org/",filter:!0,cors:!0},{name:"doh-cleanbrowsing-security",endpoint:{protocol:"https:",host:"doh.cleanbrowsing.org",path:"/doh/security-filter/",cors:!0},description:"Block access to phishing, malware and malicious domains. It does not block adult content.\nBy https://cleanbrowsing.org/",filter:!0,cors:!0},{name:"doh-crypto-sx",endpoint:{protocol:"https:",host:"doh.crypto.sx",cors:!0},description:"DNS-over-HTTPS server. Anycast, no logs, no censorship, DNSSEC.\nBackend hosted by Scaleway, globally cached via Cloudflare.\nMaintained by Frank Denis.",country:"United States",location:{lat:37.751,long:-97.822},cors:!0},{name:"doh-crypto-sx-ipv6",endpoint:{protocol:"https:",host:"doh-ipv6.crypto.sx",cors:!0},description:"DNS-over-HTTPS server accessible over IPv6. Anycast, no logs, no censorship, DNSSEC.\nBackend hosted by Scaleway, globally cached via Cloudflare.\nMaintained by Frank Denis.",country:"United States",location:{lat:37.751,long:-97.822},cors:!0},{name:"doh-de-blahdns",endpoint:{protocol:"https:",host:"doh-de.blahdns.com",cors:!0},description:"Blocks ad and Tracking, no Logging, DNSSEC, Hosted in Germany. By https://blahdns.com/",country:"Germany",location:{lat:51.2993,long:9.491},filter:!0,cors:!0},{name:"doh-fi-blahdns",endpoint:{protocol:"https:",host:"doh-fi.blahdns.com",cors:!0},description:"Blocks ad and Tracking, no Logging, DNSSEC, Hosted in Finland. By https://blahdns.com/",country:"Finland",location:{lat:60.1758,long:24.9349},filter:!0,cors:!0},{name:"doh-ibksturm",endpoint:{protocol:"https:",host:"ibksturm.synology.me"},description:"DoH & DoT Server, No Logging, No Filters, DNSSEC\nRunning privately by ibksturm in Thurgau, Switzerland"},{name:"doh-jp-blahdns",endpoint:{protocol:"https:",host:"doh-jp.blahdns.com",cors:!0},description:"Blocks ad and Tracking, no Logging, DNSSEC, Hosted in Japan. By https://blahdns.com/",country:"Japan",location:{lat:35.6882,long:139.7532},filter:!0,cors:!0},{name:"doh.ffmuc.net",endpoint:{protocol:"https:",host:"doh.ffmuc.net"},description:"An open (non-logging, non-filtering, non-censoring) DoH resolver operated by Freifunk Munich with nodes in DE.\nhttps://ffmuc.net/",country:"Germany",location:{lat:51.2993,long:9.491}},{name:"doh.tiarap.org",endpoint:{protocol:"https:",host:"doh.tiarap.org"},description:"Non-Logging DNS-over-HTTPS server, cached via Cloudflare.\nFilters out ads, trackers and malware, NO ECS, supports DNSSEC.",country:"United States",location:{lat:37.751,long:-97.822},filter:!0},{name:"google",endpoint:{protocol:"https:",host:"dns.google",ipv4:"8.8.8.8",cors:!0},description:"Google DNS (anycast)",country:"United States",location:{lat:37.751,long:-97.822},log:!0,cors:!0},{name:"hdns",endpoint:{protocol:"https:",host:"query.hdns.io",cors:!0},description:"HDNS is a public DNS resolver that supports Handshake domains.\nhttps://www.hdns.io",country:"United States",location:{lat:37.7771,long:-122.406},cors:!0},{name:"he",endpoint:{protocol:"https:",host:"ordns.he.net"},description:"Hurricane Electric DoH server (anycast)\nUnknown logging policy.",country:"United States",location:{lat:37.751,long:-97.822},log:!0},{name:"id-gmail-doh",endpoint:{protocol:"https:",host:"doh.tiar.app"},description:"Non-Logging DNS-over-HTTPS server located in Singapore.\nFilters out ads, trackers and malware, supports DNSSEC, provided by id-gmail.",country:"Singapore",location:{lat:1.2929,long:103.8547},filter:!0},{name:"iij",endpoint:{protocol:"https:",host:"public.dns.iij.jp"},description:"DoH server operated by Internet Initiative Japan in Tokyo.\nhttps://www.iij.ad.jp/",country:"Japan",location:{lat:35.69,long:139.69},log:!0},{name:"iqdns-doh",endpoint:{protocol:"https:",host:"a.passcloud.xyz"},description:'Non-logging DoH service runned by V2EX.com user johnsonwil.\nReturns "no such domain" for anti-Chinese government websites. Supports DNSSEC.\nFor more information: https://www.v2ex.com/t/785666',filter:!0},{name:"jp.tiar.app-doh",endpoint:{protocol:"https:",host:"jp.tiar.app"},description:"Non-Logging, Non-Filtering DNS-over-HTTPS server in Japan.\nNo ECS, Support DNSSEC",country:"Japan",location:{lat:35.6882,long:139.7532}},{name:"jp.tiarap.org",endpoint:{protocol:"https:",host:"jp.tiarap.org"},description:"DNS-over-HTTPS Server. Non-Logging, Non-Filtering, No ECS, Support DNSSEC.\nCached via Cloudflare."},{name:"libredns",endpoint:{protocol:"https:",host:"doh.libredns.gr"},description:"DoH server in Germany. No logging, but no DNS padding and no DNSSEC support.\nhttps://libredns.gr/",country:"Germany",location:{lat:51.2993,long:9.491}},{name:"nextdns",endpoint:{protocol:"https:",host:"anycsast.dns.nextdns.io"},description:"NextDNS is a cloud-based private DNS service that gives you full control\nover what is allowed and what is blocked on the Internet.\nDNSSEC, Anycast, Non-logging, NoFilters\nhttps://www.nextdns.io/",country:"Netherlands",location:{lat:52.3891,long:4.6563}},{name:"nextdns-ultralow",endpoint:{protocol:"https:",host:"dns.nextdns.io",path:"/dnscrypt-proxy"},description:'NextDNS is a cloud-based private DNS service that gives you full control\nover what is allowed and what is blocked on the Internet.\nhttps://www.nextdns.io/\nTo select the server location, the "-ultralow" variant relies on bootstrap servers\ninstead of anycast.'},{name:"njalla-doh",endpoint:{protocol:"https:",host:"dns.njal.la",cors:!0},description:"Non-logging DoH server in Sweden operated by Njalla.\nhttps://dns.njal.la/",country:"Sweden",location:{lat:59.3247,long:18.056},cors:!0},{name:"odoh-cloudflare",endpoint:{protocol:"https:",host:"odoh.cloudflare-dns.com",cors:!0},description:"Cloudflare ODoH server.\nhttps://cloudflare.com",cors:!0},{name:"odoh-crypto-sx",endpoint:{protocol:"https:",host:"odoh.crypto.sx",cors:!0},description:"ODoH target server. Anycast, no logs.\nBackend hosted by Scaleway. Maintained by Frank Denis.",cors:!0},{name:"odoh-id-gmail",endpoint:{protocol:"https:",host:"doh.tiar.app",path:"/odoh"},description:"ODoH target server. Based in Singapore, no logs.\nFilter ads, trackers and malware.",filter:!0},{name:"odoh-jp.tiar.app",endpoint:{protocol:"https:",host:"jp.tiar.app",path:"/odoh"},description:"ODoH target server. no logs."},{name:"odoh-jp.tiarap.org",endpoint:{protocol:"https:",host:"jp.tiarap.org",path:"/odoh"},description:"ODoH target server via Cloudflare, no logs."},{name:"odoh-resolver4.dns.openinternet.io",endpoint:{protocol:"https:",host:"resolver4.dns.openinternet.io"},description:"ODoH target server. no logs, no filter, DNSSEC.\nRunning on dedicated hardware colocated at Sonic.net in Santa Rosa, CA in the United States.\nUses Sonic's recusrive DNS servers as upstream resolvers (but is not affiliated with Sonic\nin any way). Provided by https://openinternet.io"},{name:"odoh-tiarap.org",endpoint:{protocol:"https:",host:"doh.tiarap.org",path:"/odoh"},description:"ODoH target server via Cloudflare, no logs.\nFilter ads, trackers and malware.",filter:!0},{name:"publicarray-au2-doh",endpoint:{protocol:"https:",host:"doh-2.seby.io",cors:!0},description:"DNSSEC • OpenNIC • Non-logging • Uncensored - hosted on ovh.com.au\nMaintained by publicarray - https://dns.seby.io",country:"Australia",location:{lat:-33.8591,long:151.2002},cors:!0},{name:"puredns-doh",endpoint:{protocol:"https:",host:"puredns.org",ipv4:"146.190.6.13",cors:!0},description:"Public uncensored DNS resolver in Singapore - https://puredns.org\n** Only available in Indonesia and Singapore **",country:"United States",location:{lat:37.751,long:-97.822},cors:!0},{name:"quad101",endpoint:{protocol:"https:",host:"dns.twnic.tw",cors:!0},description:"DNSSEC-aware public resolver by the Taiwan Network Information Center (TWNIC)\nhttps://101.101.101.101/index_en.html",cors:!0},{name:"quad9-doh-ip4-port443-filter-ecs-pri",endpoint:{protocol:"https:",host:"dns11.quad9.net",ipv4:"149.112.112.11"},description:"Quad9 (anycast) dnssec/no-log/filter/ecs 9.9.9.11 - 149.112.112.11",country:"United States",location:{lat:37.751,long:-97.822},filter:!0},{name:"quad9-doh-ip4-port443-filter-pri",endpoint:{protocol:"https:",host:"dns.quad9.net",ipv4:"149.112.112.112"},description:"Quad9 (anycast) dnssec/no-log/filter 9.9.9.9 - 149.112.112.9 - 149.112.112.112",country:"United States",location:{lat:37.751,long:-97.822},filter:!0},{name:"quad9-doh-ip4-port443-nofilter-ecs-pri",endpoint:{protocol:"https:",host:"dns12.quad9.net",ipv4:"9.9.9.12"},description:"Quad9 (anycast) no-dnssec/no-log/no-filter/ecs 9.9.9.12 - 149.112.112.12",country:"United States",location:{lat:37.751,long:-97.822}},{name:"quad9-doh-ip4-port443-nofilter-pri",endpoint:{protocol:"https:",host:"dns10.quad9.net",ipv4:"149.112.112.10"},description:"Quad9 (anycast) no-dnssec/no-log/no-filter 9.9.9.10 - 149.112.112.10",country:"United States",location:{lat:37.751,long:-97.822}},{name:"quad9-doh-ip6-port5053-filter-pri",endpoint:{protocol:"https:",host:"dns9.quad9.net"},description:"Quad9 (anycast) dnssec/no-log/filter 2620:fe::fe - 2620:fe::9 - 2620:fe::fe:9",country:"United States",location:{lat:37.751,long:-97.822},filter:!0},{name:"safesurfer-doh",endpoint:{protocol:"https:",host:"doh.safesurfer.io"},description:"Family safety focused blocklist for over 2 million adult sites, as well as phishing and malware and more.\nFree to use, paid for customizing blocking for more categories+sites and viewing usage at my.safesurfer.io. Logs taken for viewing\nusage, data never sold - https://safesurfer.io",filter:!0,log:!0},{name:"sth-ads-doh-se",endpoint:{protocol:"https:",host:"dnsse-noads.alekberg.net"},description:"Resolver in Stockholm, Sweden. DoH server. Non-logging, remove ads and malware, DNSSEC.",country:"Bulgaria",location:{lat:42.696,long:23.332},filter:!0},{name:"sth-doh-se",endpoint:{protocol:"https:",host:"dnsse.alekberg.net"},description:"Resolver in Stockholm, Sweden. DoH server. Non-logging, non-filtering, DNSSEC.",country:"Bulgaria",location:{lat:42.696,long:23.332}},{name:"switch",endpoint:{protocol:"https:",host:"dns.switch.ch"},description:"Public DoH service provided by SWITCH in Switzerland\nhttps://www.switch.ch\nProvides protection against malware, but does not block ads.",filter:!0},{name:"uncensoreddns-dk-ipv4",endpoint:{protocol:"https:",host:"unicast.uncensoreddns.org"},description:"Also known as censurfridns.\nDoH, no logs, no filter, DNSSEC, unicast hosted in Denmark - https://blog.uncensoreddns.org",country:"Denmark",location:{lat:55.7123,long:12.0564}},{name:"uncensoreddns-ipv4",endpoint:{protocol:"https:",host:"anycast.uncensoreddns.org"},description:"Also known as censurfridns.\nDoH, no logs, no filter, DNSSEC, anycast - https://blog.uncensoreddns.org",country:"Denmark",location:{lat:55.7123,long:12.0564}},{name:"v.dnscrypt.uk-doh-ipv4",endpoint:{protocol:"https:",host:"v.dnscrypt.uk"},description:"DoH, no logs, uncensored, DNSSEC. Hosted in London UK on Digital Ocean\nhttps://www.dnscrypt.uk",country:"United Kingdom",location:{lat:51.4964,long:-.1224}}],time:1654187067783};function dns_query_processResolvers(O){let U=null===O.time||void 0===O.time?Date.now():O.time,$=processResolvers(O.data.map(O=>(O.endpoint=toEndpoint(Object.assign({name:O.name},O.endpoint)),O))),J=$.map(O=>O.endpoint);return{data:{resolvers:$,resolverByName:$.reduce((O,U)=>(O[U.name]=U,O),{}),endpoints:J,endpointByName:J.reduce((O,U)=>(O[U.name]=U,O),{})},time:U}}let ug=dns_query_processResolvers(up);function toMultiQuery(O){let U=Object.assign({type:"query"},O);return delete U.question,U.questions=[],O.question&&U.questions.push(O.question),U}function queryOne(O,U,$,J){return J&&J.aborted?Promise.reject(new us):"udp4:"===O.protocol||"udp6:"===O.protocol?queryDns(O,U,$,J):queryDoh(O,U,$,J)}function queryDoh(O,U,$,J){return request(O.url,O.method,cZ(Object.assign({flags:cW},U)),$,J).then(function(O){let U=O.data,$=O.response,J=O.error;if(void 0===J){if(0===U.length)J=new ResponseError("Empty.");else try{let O=cX(U);return O.response=$,O}catch(O){J=new ResponseError("Invalid packet (cause="+O.message+")",O)}}throw Object.assign(J,{response:$})})}let um=new uo("https://martinheidegger.github.io/dns-query/resolvers.json");function isNameString(O){return/^@/.test(O)}let Wellknown=class Wellknown{constructor(O){this.opts=Object.assign({timeout:5e3,update:!0,updateURL:um,persist:!1,localStoragePrefix:"dnsquery_",maxAge:3e5},O),this._dataP=null}_data(O,U){return O||null===this._dataP?(this._dataP=this.opts.update?loadJSON(this.opts.updateURL,this.opts.persist?{name:"resolvers.json",localStoragePrefix:this.opts.localStoragePrefix,maxTime:Date.now()-this.opts.maxAge}:null,this.opts.timeout).then(O=>dns_query_processResolvers({data:O.data.resolvers,time:O.time})).catch(()=>U||ug):Promise.resolve(ug),this._dataP):this._dataP.then(O=>O.timeO.data)}endpoints(O){if(null==O)return this.data().then(O=>O.endpoints);if("doh"===O&&(O=filterDoh),"dns"===O&&(O=filterDns),"function"==typeof O)return this.data().then(U=>U.endpoints.filter(O));if("string"==typeof O||"function"!=typeof O[Symbol.iterator])return Promise.reject(Error(`Endpoints (${O}) needs to be iterable (array).`));if(-1===(O=Array.from(O).filter(Boolean)).findIndex(isNameString))try{return Promise.resolve(O.map(toEndpoint))}catch(O){return Promise.reject(O)}return this.data().then(U=>O.map(O=>{if(isNameString(O)){let $=U.endpointByName[O.substring(1)];if(!$)throw Error(`Endpoint ${O} is not known.`);return $}return toEndpoint(O)}))}};let uy=new Wellknown;function dns_query_isPromise(O){return null!==O&&"object"==typeof O&&"function"==typeof O.then}function toPromise(O){return dns_query_isPromise(O)?O:Promise.resolve(O)}function dns_query_query(O,U){return(U=Object.assign({retries:5,timeout:3e4},U),O.question)?toPromise(U.endpoints).then($=>{if(!Array.isArray($)||0===$.length)throw Error("No endpoints defined to lookup dns records.");return queryN($.map(toEndpoint),toMultiQuery(O),U)}).then(O=>(O.question=O.questions[0],delete O.questions,O)):Promise.reject(Error("To request data you need to specify a .question!"))}function queryN(O,U,$){let J=1===O.length?O[0]:O[Math.floor(Math.random()*O.length)%O.length];return queryOne(J,U,$.timeout,$.signal).then(O=>(O.endpoint=J.toString(),O),en=>{if("AbortError"===en.name||0===$.retries)throw en.endpoint=J.toString(),en;return $.retries>0&&($.retries-=1),queryN(O,U,$)})}function filterDoh(O){return"https:"===O.protocol||"http:"===O.protocol}function filterDns(O){return"udp4:"===O.protocol||"udp6:"===O.protocol}let ub=nf("waku:dns-over-https");let DnsOverHttps=class DnsOverHttps{endpoints;retries;static async create(O,U){let $=O??await uy.endpoints("doh");return new DnsOverHttps($,U)}constructor(O,U=3){this.endpoints=O,this.retries=U}async resolveTXT(O){let U;try{let $=await dns_query_query({question:{type:"TXT",name:O}},{endpoints:this.endpoints,retries:this.retries});U=$.answers}catch(O){throw ub("query failed: ",O),Error("DNS query failed")}if(!U)throw Error(`Could not resolve ${O}`);let $=U.map(O=>O.data),J=[];return $.forEach(O=>{"string"==typeof O?J.push(O):Array.isArray(O)?O.forEach(O=>{"string"==typeof O?J.push(O):J.push((0,ng.Md)(O))}):J.push((0,ng.Md)(O))}),J}};var uv=$(7935);let ENRTree=class ENRTree{static RECORD_PREFIX=enr_ENR.RECORD_PREFIX;static TREE_PREFIX="enrtree:";static BRANCH_PREFIX="enrtree-branch:";static ROOT_PREFIX="enrtree-root:";static parseAndVerifyRoot(O,U){if(!O.startsWith(this.ROOT_PREFIX))throw Error(`ENRTree root entry must start with '${this.ROOT_PREFIX}'`);let $=ENRTree.parseRootValues(O),J=uv.decode.asBytes(U),en=O.split(" sig")[0],es=(0,ng.iY)(en),eo=(0,rJ.m)($.signature,"base64url").slice(0,64),ea=verifySignature(eo,keccak256(es),new Uint8Array(J));if(!ea)throw Error("Unable to verify ENRTree root signature");return $.eRoot}static parseRootValues(O){let U=O.match(/^enrtree-root:v1 e=([^ ]+) l=([^ ]+) seq=(\d+) sig=([^ ]+)$/);if(!Array.isArray(U))throw Error("Could not parse ENRTree root entry");U.shift();let[$,J,en,es]=U;if(!$)throw Error("Could not parse 'e' value from ENRTree root entry");if(!J)throw Error("Could not parse 'l' value from ENRTree root entry");if(!en)throw Error("Could not parse 'seq' value from ENRTree root entry");if(!es)throw Error("Could not parse 'sig' value from ENRTree root entry");return{eRoot:$,lRoot:J,seq:Number(en),signature:es}}static parseTree(O){if(!O.startsWith(this.TREE_PREFIX))throw Error(`ENRTree tree entry must start with '${this.TREE_PREFIX}'`);let U=O.match(/^enrtree:\/\/([^@]+)@(.+)$/);if(!Array.isArray(U))throw Error("Could not parse ENRTree tree entry");U.shift();let[$,J]=U;if(!$)throw Error("Could not parse public key from ENRTree tree entry");if(!J)throw Error("Could not parse domain from ENRTree tree entry");return{publicKey:$,domain:J}}static parseBranch(O){if(!O.startsWith(this.BRANCH_PREFIX))throw Error(`ENRTree branch entry must start with '${this.BRANCH_PREFIX}'`);return O.split(this.BRANCH_PREFIX)[1].split(",")}};let u_=nf("waku:discovery:fetch_nodes");async function fetchNodesUntilCapabilitiesFulfilled(O,U,$){let J={relay:O.relay??0,store:O.store??0,filter:O.filter??0,lightPush:O.lightPush??0},en=J.relay+J.store+J.filter+J.lightPush,es={relay:0,store:0,filter:0,lightPush:0},eo=0,ea=[];for(;!isSatisfied(J,es)&&eo=O.relay&&U.store>=O.store&&U.filter>=O.filter&&U.lightPush>=O.lightPush}function isNewPeer(O,U){if(!O.nodeId)return!1;for(let $ of U)if(O.nodeId===$.nodeId)return!1;return!0}function addCapabilities(O,U){O.relay&&(U.relay+=1),O.store&&(U.store+=1),O.filter&&(U.filter+=1),O.lightPush&&(U.lightPush+=1)}function helpsSatisfyCapabilities(O,U,$){if(isSatisfied(U,$))throw"Internal Error: Waku2 wanted capabilities are already fulfilled";let J=missingCapabilities(U,$);return J.relay&&O.relay||J.store&&O.store||J.filter&&O.filter||J.lightPush&&O.lightPush}function missingCapabilities(O,U){return{relay:U.relaythis._search(en,es));return uw("retrieved peers: ",eo.map(O=>({id:O.peerId?.toString(),multiaddrs:O.multiaddrs?.map(O=>O.toString())}))),eo}constructor(O){this._DNSTreeCache={},this.dns=O}async *getNextPeer(O,U){let $=Math.floor(Math.random()*O.length),{publicKey:J,domain:en}=ENRTree.parseTree(O[$]),es={domain:en,publicKey:J,visits:{}};for await(let O of yieldNodesUntilCapabilitiesFulfilled(U,this._errorTolerance,()=>this._search(en,es)))yield O}async _search(O,U){try{let $,J;let en=await this._getTXTRecord(O,U);U.visits[O]=!0;let es=getEntryType(en);try{switch(es){case ENRTree.ROOT_PREFIX:return $=ENRTree.parseAndVerifyRoot(en,U.publicKey),await this._search($,U);case ENRTree.BRANCH_PREFIX:return J=ENRTree.parseBranch(en),$=selectRandomPath(J,U),await this._search($,U);case ENRTree.RECORD_PREFIX:return EnrDecoder.fromString(en);default:return null}}catch(U){return uw(`Failed to search DNS tree ${es} at subdomain ${O}: ${U}`),null}}catch(U){return uw(`Failed to retrieve TXT record at subdomain ${O}: ${U}`),null}}async _getTXTRecord(O,U){if(this._DNSTreeCache[O])return this._DNSTreeCache[O];let $=O!==U.domain?`${O}.${U.domain}`:U.domain,J=await this.dns.resolveTXT($);if(!J.length)throw Error("Received empty result array while fetching TXT record");if(!J[0].length)throw Error("Received empty TXT record");let en=J.join("");return this._DNSTreeCache[O]=en,en}};function getEntryType(O){return O.startsWith(ENRTree.ROOT_PREFIX)?ENRTree.ROOT_PREFIX:O.startsWith(ENRTree.BRANCH_PREFIX)?ENRTree.BRANCH_PREFIX:O.startsWith(ENRTree.RECORD_PREFIX)?ENRTree.RECORD_PREFIX:""}function selectRandomPath(O,U){let $;let J={};for(let[$,en]of O.entries())U.visits[en]&&(J[$]=!0);if(Object.keys(J).length===O.length)throw Error("Unresolvable circular path detected");do $=Math.floor(Math.random()*O.length);while(J[$]);return O[$]}let uE=nf("waku:peer-discovery-dns");let PeerDiscoveryDns=class PeerDiscoveryDns extends TypedEventEmitter{nextPeer;_started;_components;_options;constructor(O,U){super(),this._started=!1,this._components=O,this._options=U;let{enrUrls:$}=U;uE("Use following EIP-1459 ENR Tree URLs: ",$)}async start(){if(uE("Starting peer discovery via dns"),this._started=!0,void 0===this.nextPeer){let{enrUrls:O}=this._options;Array.isArray(O)||(O=[O]);let{wantedNodeCapabilityCount:U}=this._options,$=await DnsNodeDiscovery.dnsOverHttp();this.nextPeer=$.getNextPeer.bind($,O,U)}for await(let O of this.nextPeer()){if(!this._started)return;let{peerInfo:U,shardInfo:$}=O;if(!U)continue;let J={[l4]:{value:this._options.tagValue??l5,ttl:this._options.tagTTL??l8}},en=!1,es=await this._components.peerStore.has(U.id);if(es){let O=await this._components.peerStore.get(U.id),$=O.tags.has(l4);$||(en=!0,await this._components.peerStore.merge(U.id,{tags:J}))}else en=!0,await this._components.peerStore.save(U.id,{tags:J,...$&&{metadata:{shardInfo:encodeRelayShard($)}}});en&&this.dispatchEvent(new l3("peer",{detail:U}))}}stop(){this._started=!1}get[l6](){return!0}get[Symbol.toStringTag](){return"@waku/bootstrap"}};function wakuDnsDiscovery(O,U=l9){return $=>new PeerDiscoveryDns($,{enrUrls:O,wantedNodeCapabilityCount:U})}let PeerExchangeRPC=class PeerExchangeRPC{proto;constructor(O){this.proto=O}static createRequest(O){let{numPeers:U}=O;return new PeerExchangeRPC({query:{numPeers:U},response:void 0})}encode(){return e9.encode(this.proto)}static decode(O){let U=e9.decode(O);return new PeerExchangeRPC(U)}get query(){return this.proto.query}get response(){return this.proto.response}};let uS="/vac/waku/peer-exchange/2.0.0-alpha1",uA=nf("waku:peer-exchange");let WakuPeerExchange=class WakuPeerExchange extends BaseProtocol{constructor(O){super(uS,O)}async query(O){let{numPeers:U}=O,$=PeerExchangeRPC.createRequest({numPeers:BigInt(U)}),J=await this.getPeer(O.peerId),en=await this.getStream(J),es=await pipe([$.encode()],encode_encode,en,decode_decode,async O=>await dist_src(O));try{let O=new src_Uint8ArrayList;es.forEach(U=>{O.append(U)});let{response:U}=PeerExchangeRPC.decode(O);if(!U){uA("PeerExchangeRPC message did not contains a `response` field");return}return Promise.all(U.peerInfos.map(O=>O.enr).filter(isDefined).map(async O=>({ENR:await EnrDecoder.fromRLP(O)})))}catch(O){uA("Failed to decode push reply",O);return}}};let uI=nf("waku:peer-exchange-discovery"),uP=10,uk=1e4,uT=3,uR=ev.PEER_EXCHANGE,uC=50,uB=1e8;let PeerExchangeDiscovery=class PeerExchangeDiscovery extends TypedEventEmitter{components;peerExchange;options;isStarted;queryingPeers=new Set;queryAttempts=new Map;handleDiscoveredPeer=O=>{let{protocols:U,peerId:$}=O.detail;!U.includes(uS)||this.queryingPeers.has($.toString())||(this.queryingPeers.add($.toString()),this.startRecurringQueries($).catch(O=>uI(`Error querying peer ${O}`)))};constructor(O,U={}){super(),this.components=O,this.peerExchange=new WakuPeerExchange(O),this.options=U,this.isStarted=!1}start(){this.isStarted||(uI("Starting peer exchange node discovery, discovering peers"),this.components.events.addEventListener("peer:identify",this.handleDiscoveredPeer))}stop(){this.isStarted&&(uI("Stopping peer exchange node discovery"),this.isStarted=!1,this.queryingPeers.clear(),this.components.events.removeEventListener("peer:identify",this.handleDiscoveredPeer))}get[l6](){return!0}get[Symbol.toStringTag](){return"@waku/peer-exchange"}startRecurringQueries=async O=>{let U=O.toString(),{queryInterval:$=uk,maxRetries:J=uT}=this.options;uI(`Querying peer: ${U} (attempt ${this.queryAttempts.get(U)??1})`),await this.query(O);let en=this.queryAttempts.get(U)??1;if(en>J){this.abortQueriesForPeer(U);return}setTimeout(()=>{this.queryAttempts.set(U,en+1),this.startRecurringQueries(O).catch(O=>{uI(`Error in startRecurringQueries: ${O}`)})},$*en)};async query(O){let U=await this.peerExchange.query({numPeers:uP,peerId:O});if(!U){uI("Peer exchange query failed, no peer info returned");return}for(let O of U){let{ENR:U}=O;if(!U){uI("No ENR in peerInfo object, skipping");continue}let{peerId:$,peerInfo:J,shardInfo:en}=U;if(!$||!J)continue;let es=await this.components.peerStore.has($);es||(await this.components.peerStore.save($,{tags:{[uR]:{value:this.options.tagValue??uC,ttl:this.options.tagTTL??uB}},...en&&{metadata:{shardInfo:encodeRelayShard(en)}}}),uI(`Discovered peer: ${$.toString()}`),this.dispatchEvent(new l3("peer",{detail:{id:$,protocols:[],multiaddrs:J.multiaddrs}})))}}abortQueriesForPeer(O){uI(`Aborting queries for peer: ${O}`),this.queryingPeers.delete(O),this.queryAttempts.delete(O)}};function wakuPeerExchangeDiscovery(){return O=>new PeerExchangeDiscovery(O)}let MessageCache=class MessageCache{gossip;msgs=new Map;msgIdToStrFn;history=[];notValidatedCount=0;constructor(O,U,$){this.gossip=O,this.msgIdToStrFn=$;for(let O=0;O{let J=this.msgs.get($.msgIdStr);if(J&&J.validated&&O.has($.topic)){let O=U.get($.topic);O||(O=[],U.set($.topic,O)),O.push($.msgId)}});return U}validate(O){let U=this.msgs.get(O);if(!U)return null;!U.validated&&this.notValidatedCount--;let{message:$,originatingPeers:J}=U;return U.validated=!0,U.originatingPeers=new Set,{message:$,originatingPeers:J}}shift(){let O=this.history[this.history.length-1];O.forEach(O=>{let U=this.msgs.get(O.msgIdStr);U&&(this.msgs.delete(O.msgIdStr),!U.validated&&this.notValidatedCount--)}),this.history.pop(),this.history.unshift([])}remove(O){let U=this.msgs.get(O);return U?(this.msgs.delete(O),U):null}};var uN=$(372);let{RPC:ux}=uN,uD=1e3,uM=60*uD,uO="/floodsub/1.0.0",uL="/meshsub/1.0.0",uU="/meshsub/1.1.0",uF=6,uK=4,uj=12,uH=4,uq=2,uz=5,uV=3,uG=6,u$=.25,uW=3,uY=100,uJ=uD,uQ=uM,uZ=16,uX=uM,u3=10*uD,u6=15,u4=300,u5=uD,u9=60,u7=2,he=10*uD,ht=5e3,hr=10,hn=3*uD,ho=2*uM,ha=12e4,hc="ERR_TOPIC_VALIDATOR_REJECT",hu="ERR_TOPIC_VALIDATOR_IGNORE",hd=0,hf=128,hp=1e3,hg=1e3,hm=1;function shuffle(O){if(O.length<=1)return O;let randInt=()=>Math.floor(Math.random()*Math.floor(O.length));for(let U=0;U0,appSpecificWeight:10,IPColocationFactorWeight:-5,IPColocationFactorThreshold:10,IPColocationFactorWhitelist:new Set,behaviourPenaltyWeight:-10,behaviourPenaltyThreshold:0,behaviourPenaltyDecay:.2,decayInterval:1e3,decayToZero:.1,retainScore:36e5},hw={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};function createPeerScoreParams(O={}){return{...h_,...O,topics:O.topics?Object.entries(O.topics).reduce((O,[U,$])=>(O[U]=createTopicScoreParams($),O),{}):{}}}function createTopicScoreParams(O={}){return{...hw,...O}}function validatePeerScoreParams(O){for(let[U,$]of Object.entries(O.topics))try{validateTopicScoreParams($)}catch(O){throw new errors_CodeError(`invalid score parameters for topic ${U}: ${O.message}`,hv)}if(O.topicScoreCap<0)throw new errors_CodeError("invalid topic score cap; must be positive (or 0 for no cap)",hv);if(null===O.appSpecificScore||void 0===O.appSpecificScore)throw new errors_CodeError("missing application specific score function",hv);if(O.IPColocationFactorWeight>0)throw new errors_CodeError("invalid IPColocationFactorWeight; must be negative (or 0 to disable)",hv);if(0!==O.IPColocationFactorWeight&&O.IPColocationFactorThreshold<1)throw new errors_CodeError("invalid IPColocationFactorThreshold; must be at least 1",hv);if(O.behaviourPenaltyWeight>0)throw new errors_CodeError("invalid BehaviourPenaltyWeight; must be negative (or 0 to disable)",hv);if(0!==O.behaviourPenaltyWeight&&(O.behaviourPenaltyDecay<=0||O.behaviourPenaltyDecay>=1))throw new errors_CodeError("invalid BehaviourPenaltyDecay; must be between 0 and 1",hv);if(O.decayInterval<1e3)throw new errors_CodeError("invalid DecayInterval; must be at least 1s",hv);if(O.decayToZero<=0||O.decayToZero>=1)throw new errors_CodeError("invalid DecayToZero; must be between 0 and 1",hv)}function validateTopicScoreParams(O){if(O.topicWeight<0)throw new errors_CodeError("invalid topic weight; must be >= 0",hv);if(0===O.timeInMeshQuantum)throw new errors_CodeError("invalid TimeInMeshQuantum; must be non zero",hv);if(O.timeInMeshWeight<0)throw new errors_CodeError("invalid TimeInMeshWeight; must be positive (or 0 to disable)",hv);if(0!==O.timeInMeshWeight&&O.timeInMeshQuantum<=0)throw new errors_CodeError("invalid TimeInMeshQuantum; must be positive",hv);if(0!==O.timeInMeshWeight&&O.timeInMeshCap<=0)throw new errors_CodeError("invalid TimeInMeshCap; must be positive",hv);if(O.firstMessageDeliveriesWeight<0)throw new errors_CodeError("invallid FirstMessageDeliveriesWeight; must be positive (or 0 to disable)",hv);if(0!==O.firstMessageDeliveriesWeight&&(O.firstMessageDeliveriesDecay<=0||O.firstMessageDeliveriesDecay>=1))throw new errors_CodeError("invalid FirstMessageDeliveriesDecay; must be between 0 and 1",hv);if(0!==O.firstMessageDeliveriesWeight&&O.firstMessageDeliveriesCap<=0)throw new errors_CodeError("invalid FirstMessageDeliveriesCap; must be positive",hv);if(O.meshMessageDeliveriesWeight>0)throw new errors_CodeError("invalid MeshMessageDeliveriesWeight; must be negative (or 0 to disable)",hv);if(0!==O.meshMessageDeliveriesWeight&&(O.meshMessageDeliveriesDecay<=0||O.meshMessageDeliveriesDecay>=1))throw new errors_CodeError("invalid MeshMessageDeliveriesDecay; must be between 0 and 1",hv);if(0!==O.meshMessageDeliveriesWeight&&O.meshMessageDeliveriesCap<=0)throw new errors_CodeError("invalid MeshMessageDeliveriesCap; must be positive",hv);if(0!==O.meshMessageDeliveriesWeight&&O.meshMessageDeliveriesThreshold<=0)throw new errors_CodeError("invalid MeshMessageDeliveriesThreshold; must be positive",hv);if(O.meshMessageDeliveriesWindow<0)throw new errors_CodeError("invalid MeshMessageDeliveriesWindow; must be non-negative",hv);if(0!==O.meshMessageDeliveriesWeight&&O.meshMessageDeliveriesActivation<1e3)throw new errors_CodeError("invalid MeshMessageDeliveriesActivation; must be at least 1s",hv);if(O.meshFailurePenaltyWeight>0)throw new errors_CodeError("invalid MeshFailurePenaltyWeight; must be negative (or 0 to disable)",hv);if(0!==O.meshFailurePenaltyWeight&&(O.meshFailurePenaltyDecay<=0||O.meshFailurePenaltyDecay>=1))throw new errors_CodeError("invalid MeshFailurePenaltyDecay; must be between 0 and 1",hv);if(O.invalidMessageDeliveriesWeight>0)throw new errors_CodeError("invalid InvalidMessageDeliveriesWeight; must be negative (or 0 to disable)",hv);if(O.invalidMessageDeliveriesDecay<=0||O.invalidMessageDeliveriesDecay>=1)throw new errors_CodeError("invalid InvalidMessageDeliveriesDecay; must be between 0 and 1",hv)}let hE={gossipThreshold:-10,publishThreshold:-50,graylistThreshold:-80,acceptPXThreshold:10,opportunisticGraftThreshold:20};function createPeerScoreThresholds(O={}){return{...hE,...O}}function computeScore(O,U,$,J){let en=0;Object.entries(U.topics).forEach(([O,U])=>{let J=$.topics[O];if(void 0===J)return;let es=0;if(U.inMesh){let O=U.meshTime/J.timeInMeshQuantum;O>J.timeInMeshCap&&(O=J.timeInMeshCap),es+=O*J.timeInMeshWeight}let eo=U.firstMessageDeliveries;if(eo>J.firstMessageDeliveriesCap&&(eo=J.firstMessageDeliveriesCap),es+=eo*J.firstMessageDeliveriesWeight,U.meshMessageDeliveriesActive&&U.meshMessageDeliveries0&&en>$.topicScoreCap&&(en=$.topicScoreCap);let es=$.appSpecificScore(O);if(en+=es*$.appSpecificWeight,U.knownIPs.forEach(O=>{if($.IPColocationFactorWhitelist.has(O))return;let U=J.get(O),es=U?U.size:0;if(es>$.IPColocationFactorThreshold){let O=es-$.IPColocationFactorThreshold,U=O*O;en+=U*$.IPColocationFactorWeight}}),U.behaviourPenalty>$.behaviourPenaltyThreshold){let O=U.behaviourPenalty-$.behaviourPenaltyThreshold,J=O*O;en+=J*$.behaviourPenaltyWeight}return en}var hS=$(2185);!function(O){O[O.unknown=0]="unknown",O[O.valid=1]="valid",O[O.invalid=2]="invalid",O[O.ignored=3]="ignored"}(tw||(tw={}));let MessageDeliveries=class MessageDeliveries{records;queue;constructor(){this.records=new Map,this.queue=new hS}getRecord(O){return this.records.get(O)}ensureRecord(O){let U=this.records.get(O);if(U)return U;U={status:tw.unknown,firstSeenTsMs:Date.now(),validated:0,peers:new Set},this.records.set(O,U);let $={msgId:O,expire:Date.now()+ha};return this.queue.push($),U}gc(){let O=Date.now(),U=this.queue.peekFront();for(;U&&U.expire!0){let J=new Set;if(U<=0)return J;for(let en of O){if(J.size>=U)break;$(en)&&(J.add(en),O.delete(en))}return J}function removeFirstNItemsFromSet(O,U){return removeItemsFromSet(O,U,()=>!0)}let MapDef=class MapDef extends Map{getDefault;constructor(O){super(),this.getDefault=O}getOrDefault(O){let U=super.get(O);return void 0===U&&(U=this.getDefault(),this.set(O,U)),U}};let hA=logger("libp2p:gossipsub:score");let PeerScore=class PeerScore{params;metrics;peerStats=new Map;peerIPs=new MapDef(()=>new Set);scoreCache=new Map;deliveryRecords=new MessageDeliveries;_backgroundInterval;scoreCacheValidityMs;computeScore;constructor(O,U,$){this.params=O,this.metrics=U,validatePeerScoreParams(O),this.scoreCacheValidityMs=$.scoreCacheValidityMs,this.computeScore=$.computeScore??computeScore}get size(){return this.peerStats.size}start(){if(this._backgroundInterval){hA("Peer score already running");return}this._backgroundInterval=setInterval(()=>this.background(),this.params.decayInterval),hA("started")}stop(){if(!this._backgroundInterval){hA("Peer score already stopped");return}clearInterval(this._backgroundInterval),delete this._backgroundInterval,this.peerIPs.clear(),this.peerStats.clear(),this.deliveryRecords.clear(),hA("stopped")}background(){this.refreshScores(),this.deliveryRecords.gc()}dumpPeerScoreStats(){return Object.fromEntries(Array.from(this.peerStats.entries()).map(([O,U])=>[O,U]))}messageFirstSeenTimestampMs(O){let U=this.deliveryRecords.getRecord(O);return U?U.firstSeenTsMs:null}refreshScores(){let O=Date.now(),U=this.params.decayToZero;this.peerStats.forEach(($,J)=>{if(!$.connected){O>$.expire&&(this.removeIPsForPeer(J,$.knownIPs),this.peerStats.delete(J),this.scoreCache.delete(J));return}Object.entries($.topics).forEach(([$,J])=>{let en=this.params.topics[$];void 0!==en&&(J.firstMessageDeliveries*=en.firstMessageDeliveriesDecay,J.firstMessageDeliveriesen.meshMessageDeliveriesActivation&&(J.meshMessageDeliveriesActive=!0)))}),$.behaviourPenalty*=this.params.behaviourPenaltyDecay,$.behaviourPenalty$)return J.score;this.metrics?.scoreFnRuns.inc();let en=this.computeScore(O,U,this.params,this.peerIPs),es=$+this.scoreCacheValidityMs;return J?(this.metrics?.scoreCachedDelta.observe(Math.abs(en-J.score)),J.score=en,J.cacheUntil=es):this.scoreCache.set(O,{score:en,cacheUntil:es}),en}addPenalty(O,U,$){let J=this.peerStats.get(O);J&&(J.behaviourPenalty+=U,this.metrics?.onScorePenalty($))}addPeer(O){let U={connected:!0,expire:0,topics:{},knownIPs:new Set,behaviourPenalty:0};this.peerStats.set(O,U)}addIP(O,U){let $=this.peerStats.get(O);$&&$.knownIPs.add(U),this.peerIPs.getOrDefault(U).add(O)}removeIP(O,U){let $=this.peerStats.get(O);$&&$.knownIPs.delete(U);let J=this.peerIPs.get(U);J&&(J.delete(O),0===J.size&&this.peerIPs.delete(U))}removePeer(O){let U=this.peerStats.get(O);if(U){if(this.score(O)>0){this.removeIPsForPeer(O,U.knownIPs),this.peerStats.delete(O);return}Object.entries(U.topics).forEach(([O,U])=>{U.firstMessageDeliveries=0;let $=this.params.topics[O].meshMessageDeliveriesThreshold;if(U.inMesh&&U.meshMessageDeliveriesActive&&U.meshMessageDeliveries<$){let O=$-U.meshMessageDeliveries;U.meshFailurePenalty+=O*O}U.inMesh=!1,U.meshMessageDeliveriesActive=!1}),U.connected=!1,U.expire=Date.now()+this.params.retainScore}}graft(O,U){let $=this.peerStats.get(O);if($){let O=this.getPtopicStats($,U);O&&(O.inMesh=!0,O.graftTime=Date.now(),O.meshTime=0,O.meshMessageDeliveriesActive=!1)}}prune(O,U){let $=this.peerStats.get(O);if($){let O=this.getPtopicStats($,U);if(O){let $=this.params.topics[U].meshMessageDeliveriesThreshold;if(O.meshMessageDeliveriesActive&&O.meshMessageDeliveries<$){let U=$-O.meshMessageDeliveries;O.meshFailurePenalty+=U*U}O.meshMessageDeliveriesActive=!1,O.inMesh=!1}}}validateMessage(O){this.deliveryRecords.ensureRecord(O)}deliverMessage(O,U,$){this.markFirstMessageDelivery(O,$);let J=this.deliveryRecords.ensureRecord(U),en=Date.now();if(J.status!==tw.unknown){hA("unexpected delivery: message from %s was first seen %s ago and has delivery status %s",O,en-J.firstSeenTsMs,tw[J.status]);return}J.status=tw.valid,J.validated=en,J.peers.forEach(U=>{U!==O.toString()&&this.markDuplicateMessageDelivery(U,$)})}rejectInvalidMessage(O,U){this.markInvalidMessageDelivery(O,U)}rejectMessage(O,U,$,J){switch(J){case tb.Error:this.markInvalidMessageDelivery(O,$);return;case tb.Blacklisted:return}let en=this.deliveryRecords.ensureRecord(U);if(en.status!==tw.unknown){hA("unexpected rejection: message from %s was first seen %s ago and has delivery status %d",O,Date.now()-en.firstSeenTsMs,tw[en.status]);return}if(J===tb.Ignore){en.status=tw.ignored,en.peers.clear();return}en.status=tw.invalid,this.markInvalidMessageDelivery(O,$),en.peers.forEach(O=>{this.markInvalidMessageDelivery(O,$)}),en.peers.clear()}duplicateMessage(O,U,$){let J=this.deliveryRecords.ensureRecord(U);if(!J.peers.has(O))switch(J.status){case tw.unknown:J.peers.add(O);break;case tw.valid:J.peers.add(O),this.markDuplicateMessageDelivery(O,$,J.validated);break;case tw.invalid:this.markInvalidMessageDelivery(O,$);case tw.ignored:}}markInvalidMessageDelivery(O,U){let $=this.peerStats.get(O);if($){let O=this.getPtopicStats($,U);O&&(O.invalidMessageDeliveries+=1)}}markFirstMessageDelivery(O,U){let $=this.peerStats.get(O);if($){let O=this.getPtopicStats($,U);if(O){let $=this.params.topics[U].firstMessageDeliveriesCap;O.firstMessageDeliveries=Math.min($,O.firstMessageDeliveries+1),O.inMesh&&($=this.params.topics[U].meshMessageDeliveriesCap,O.meshMessageDeliveries=Math.min($,O.meshMessageDeliveries+1))}}}markDuplicateMessageDelivery(O,U,$){let J=this.peerStats.get(O);if(J){let O=void 0!==$?Date.now():0,en=this.getPtopicStats(J,U);if(en&&en.inMesh){let J=this.params.topics[U];if(void 0!==$){let en=O-$,es=en>J.meshMessageDeliveriesWindow;if(this.metrics?.onDuplicateMsgDelivery(U,en,es),es)return}let es=J.meshMessageDeliveriesCap;en.meshMessageDeliveries=Math.min(es,en.meshMessageDeliveries+1)}}}removeIPsForPeer(O,U){for(let $ of U){let U=this.peerIPs.get($);U&&(U.delete(O),0===U.size&&this.peerIPs.delete($))}}getPtopicStats(O,U){let $=O.topics[U];return void 0!==$?$:void 0!==this.params.topics[U]?($={inMesh:!1,graftTime:0,meshTime:0,firstMessageDeliveries:0,meshMessageDeliveries:0,meshMessageDeliveriesActive:!1,meshFailurePenalty:0,invalidMessageDeliveries:0},O.topics[U]=$,$):null}};let IWantTracer=class IWantTracer{gossipsubIWantFollowupMs;msgIdToStrFn;metrics;promises=new Map;requestMsByMsg=new Map;requestMsByMsgExpire;constructor(O,U,$){this.gossipsubIWantFollowupMs=O,this.msgIdToStrFn=U,this.metrics=$,this.requestMsByMsgExpire=10*O}get size(){return this.promises.size}get requestMsByMsgSize(){return this.requestMsByMsg.size}addPromise(O,U){let $=Math.floor(Math.random()*U.length),J=U[$],en=this.msgIdToStrFn(J),es=this.promises.get(en);es||(es=new Map,this.promises.set(en,es));let eo=Date.now();es.has(O)||(es.set(O,eo+this.gossipsubIWantFollowupMs),this.metrics&&(this.metrics.iwantPromiseStarted.inc(1),this.requestMsByMsg.has(en)||this.requestMsByMsg.set(en,eo)))}getBrokenPromises(){let O=Date.now(),U=new Map,$=0;return this.promises.forEach((J,en)=>{J.forEach((en,es)=>{en=Date.now()?U.value:void 0}clear(){this.entries.clear()}};function getMetrics(O,U,$){return{protocolsEnabled:O.gauge({name:"gossipsub_protocol",help:"Status of enabled protocols",labelNames:["protocol"]}),topicSubscriptionStatus:O.gauge({name:"gossipsub_topic_subscription_status",help:"Status of our subscription to this topic",labelNames:["topicStr"]}),topicPeersCount:O.gauge({name:"gossipsub_topic_peer_count",help:"Number of peers subscribed to each topic",labelNames:["topicStr"]}),meshPeerCounts:O.gauge({name:"gossipsub_mesh_peer_count",help:"Number of peers in our mesh",labelNames:["topicStr"]}),meshPeerInclusionEventsFanout:O.gauge({name:"gossipsub_mesh_peer_inclusion_events_fanout_total",help:"Number of times we include peers in a topic mesh for fanout reasons",labelNames:["topic"]}),meshPeerInclusionEventsRandom:O.gauge({name:"gossipsub_mesh_peer_inclusion_events_random_total",help:"Number of times we include peers in a topic mesh for random reasons",labelNames:["topic"]}),meshPeerInclusionEventsSubscribed:O.gauge({name:"gossipsub_mesh_peer_inclusion_events_subscribed_total",help:"Number of times we include peers in a topic mesh for subscribed reasons",labelNames:["topic"]}),meshPeerInclusionEventsOutbound:O.gauge({name:"gossipsub_mesh_peer_inclusion_events_outbound_total",help:"Number of times we include peers in a topic mesh for outbound reasons",labelNames:["topic"]}),meshPeerInclusionEventsNotEnough:O.gauge({name:"gossipsub_mesh_peer_inclusion_events_not_enough_total",help:"Number of times we include peers in a topic mesh for not_enough reasons",labelNames:["topic"]}),meshPeerInclusionEventsOpportunistic:O.gauge({name:"gossipsub_mesh_peer_inclusion_events_opportunistic_total",help:"Number of times we include peers in a topic mesh for opportunistic reasons",labelNames:["topic"]}),meshPeerInclusionEventsUnknown:O.gauge({name:"gossipsub_mesh_peer_inclusion_events_unknown_total",help:"Number of times we include peers in a topic mesh for unknown reasons",labelNames:["topic"]}),meshPeerChurnEventsDisconnected:O.gauge({name:"gossipsub_peer_churn_events_disconnected_total",help:"Number of times we remove peers in a topic mesh for disconnected reasons",labelNames:["topic"]}),meshPeerChurnEventsBadScore:O.gauge({name:"gossipsub_peer_churn_events_bad_score_total",help:"Number of times we remove peers in a topic mesh for bad_score reasons",labelNames:["topic"]}),meshPeerChurnEventsPrune:O.gauge({name:"gossipsub_peer_churn_events_prune_total",help:"Number of times we remove peers in a topic mesh for prune reasons",labelNames:["topic"]}),meshPeerChurnEventsExcess:O.gauge({name:"gossipsub_peer_churn_events_excess_total",help:"Number of times we remove peers in a topic mesh for excess reasons",labelNames:["topic"]}),meshPeerChurnEventsUnknown:O.gauge({name:"gossipsub_peer_churn_events_unknown_total",help:"Number of times we remove peers in a topic mesh for unknown reasons",labelNames:["topic"]}),peersPerProtocol:O.gauge({name:"gossipsub_peers_per_protocol_count",help:"Peers connected for each topic",labelNames:["protocol"]}),heartbeatDuration:O.histogram({name:"gossipsub_heartbeat_duration_seconds",help:"The time it takes to complete one iteration of the heartbeat",buckets:[.01,.1,1]}),heartbeatSkipped:O.gauge({name:"gossipsub_heartbeat_skipped",help:"Heartbeat run took longer than heartbeat interval so next is skipped"}),acceptedMessagesTotal:O.gauge({name:"gossipsub_accepted_messages_total",help:"Total accepted messages for each topic",labelNames:["topic"]}),ignoredMessagesTotal:O.gauge({name:"gossipsub_ignored_messages_total",help:"Total ignored messages for each topic",labelNames:["topic"]}),rejectedMessagesTotal:O.gauge({name:"gossipsub_rejected_messages_total",help:"Total rejected messages for each topic",labelNames:["topic"]}),unknownValidationResultsTotal:O.gauge({name:"gossipsub_unknown_validation_results_total",help:"Total unknown validation results for each topic",labelNames:["topic"]}),asyncValidationMcacheHit:O.gauge({name:"gossipsub_async_validation_mcache_hit_total",help:"Async validation result reported by the user layer",labelNames:["hit"]}),asyncValidationDelayFromFirstSeenSec:O.histogram({name:"gossipsub_async_validation_delay_from_first_seen",help:"Async validation report delay from first seen in second",labelNames:["topic"],buckets:[.01,.03,.1,.3,1,3,10]}),asyncValidationUnknownFirstSeen:O.gauge({name:"gossipsub_async_validation_unknown_first_seen_count_total",help:"Async validation report unknown first seen value for message"}),peerReadStreamError:O.gauge({name:"gossipsub_peer_read_stream_err_count_total",help:"Peer read stream error"}),rpcRecvBytes:O.gauge({name:"gossipsub_rpc_recv_bytes_total",help:"RPC recv"}),rpcRecvCount:O.gauge({name:"gossipsub_rpc_recv_count_total",help:"RPC recv"}),rpcRecvSubscription:O.gauge({name:"gossipsub_rpc_recv_subscription_total",help:"RPC recv"}),rpcRecvMessage:O.gauge({name:"gossipsub_rpc_recv_message_total",help:"RPC recv"}),rpcRecvControl:O.gauge({name:"gossipsub_rpc_recv_control_total",help:"RPC recv"}),rpcRecvIHave:O.gauge({name:"gossipsub_rpc_recv_ihave_total",help:"RPC recv"}),rpcRecvIWant:O.gauge({name:"gossipsub_rpc_recv_iwant_total",help:"RPC recv"}),rpcRecvGraft:O.gauge({name:"gossipsub_rpc_recv_graft_total",help:"RPC recv"}),rpcRecvPrune:O.gauge({name:"gossipsub_rpc_recv_prune_total",help:"RPC recv"}),rpcDataError:O.gauge({name:"gossipsub_rpc_data_err_count_total",help:"RPC data error"}),rpcRecvError:O.gauge({name:"gossipsub_rpc_recv_err_count_total",help:"RPC recv error"}),rpcRecvNotAccepted:O.gauge({name:"gossipsub_rpc_rcv_not_accepted_total",help:"Total count of RPC dropped because acceptFrom() == false"}),rpcSentBytes:O.gauge({name:"gossipsub_rpc_sent_bytes_total",help:"RPC sent"}),rpcSentCount:O.gauge({name:"gossipsub_rpc_sent_count_total",help:"RPC sent"}),rpcSentSubscription:O.gauge({name:"gossipsub_rpc_sent_subscription_total",help:"RPC sent"}),rpcSentMessage:O.gauge({name:"gossipsub_rpc_sent_message_total",help:"RPC sent"}),rpcSentControl:O.gauge({name:"gossipsub_rpc_sent_control_total",help:"RPC sent"}),rpcSentIHave:O.gauge({name:"gossipsub_rpc_sent_ihave_total",help:"RPC sent"}),rpcSentIWant:O.gauge({name:"gossipsub_rpc_sent_iwant_total",help:"RPC sent"}),rpcSentGraft:O.gauge({name:"gossipsub_rpc_sent_graft_total",help:"RPC sent"}),rpcSentPrune:O.gauge({name:"gossipsub_rpc_sent_prune_total",help:"RPC sent"}),msgPublishCount:O.gauge({name:"gossipsub_msg_publish_count_total",help:"Total count of msg published by topic",labelNames:["topic"]}),msgPublishPeersByTopic:O.gauge({name:"gossipsub_msg_publish_peers_total",help:"Total count of peers that we publish a msg to",labelNames:["topic"]}),directPeersPublishedTotal:O.gauge({name:"gossipsub_direct_peers_published_total",help:"Total direct peers that we publish a msg to",labelNames:["topic"]}),floodsubPeersPublishedTotal:O.gauge({name:"gossipsub_floodsub_peers_published_total",help:"Total floodsub peers that we publish a msg to",labelNames:["topic"]}),meshPeersPublishedTotal:O.gauge({name:"gossipsub_mesh_peers_published_total",help:"Total mesh peers that we publish a msg to",labelNames:["topic"]}),fanoutPeersPublishedTotal:O.gauge({name:"gossipsub_fanout_peers_published_total",help:"Total fanout peers that we publish a msg to",labelNames:["topic"]}),msgPublishBytes:O.gauge({name:"gossipsub_msg_publish_bytes_total",help:"Total count of msg publish data.length bytes",labelNames:["topic"]}),msgPublishTime:O.histogram({name:"gossipsub_msg_publish_seconds",help:"Total time in seconds to publish a message",buckets:[.001,.002,.005,.01,.1,.5,1],labelNames:["topic"]}),msgForwardCount:O.gauge({name:"gossipsub_msg_forward_count_total",help:"Total count of msg forwarded by topic",labelNames:["topic"]}),msgForwardPeers:O.gauge({name:"gossipsub_msg_forward_peers_total",help:"Total count of peers that we forward a msg to",labelNames:["topic"]}),msgReceivedPreValidation:O.gauge({name:"gossipsub_msg_received_prevalidation_total",help:"Total count of recv msgs before any validation",labelNames:["topic"]}),msgReceivedError:O.gauge({name:"gossipsub_msg_received_error_total",help:"Total count of recv msgs error",labelNames:["topic"]}),prevalidationInvalidTotal:O.gauge({name:"gossipsub_pre_validation_invalid_total",help:"Total count of invalid messages received",labelNames:["topic"]}),prevalidationValidTotal:O.gauge({name:"gossipsub_pre_validation_valid_total",help:"Total count of valid messages received",labelNames:["topic"]}),prevalidationDuplicateTotal:O.gauge({name:"gossipsub_pre_validation_duplicate_total",help:"Total count of duplicate messages received",labelNames:["topic"]}),prevalidationUnknownTotal:O.gauge({name:"gossipsub_pre_validation_unknown_status_total",help:"Total count of unknown_status messages received",labelNames:["topic"]}),msgReceivedInvalid:O.gauge({name:"gossipsub_msg_received_invalid_total",help:"Tracks specific reason of invalid",labelNames:["error"]}),msgReceivedInvalidByTopic:O.gauge({name:"gossipsub_msg_received_invalid_by_topic_total",help:"Tracks specific invalid message by topic",labelNames:["topic"]}),duplicateMsgDeliveryDelay:O.histogram({name:"gossisub_duplicate_msg_delivery_delay_seconds",help:"Time since the 1st duplicated message validated",labelNames:["topic"],buckets:[.25*$.maxMeshMessageDeliveriesWindowSec,.5*$.maxMeshMessageDeliveriesWindowSec,1*$.maxMeshMessageDeliveriesWindowSec,2*$.maxMeshMessageDeliveriesWindowSec,4*$.maxMeshMessageDeliveriesWindowSec]}),duplicateMsgLateDelivery:O.gauge({name:"gossisub_duplicate_msg_late_delivery_total",help:"Total count of late duplicate message delivery by topic, which triggers P3 penalty",labelNames:["topic"]}),duplicateMsgIgnored:O.gauge({name:"gossisub_ignored_published_duplicate_msgs_total",help:"Total count of published duplicate message ignored by topic",labelNames:["topic"]}),scoreFnCalls:O.gauge({name:"gossipsub_score_fn_calls_total",help:"Total times score() is called"}),scoreFnRuns:O.gauge({name:"gossipsub_score_fn_runs_total",help:"Total times score() call actually computed computeScore(), no cache"}),scoreCachedDelta:O.histogram({name:"gossipsub_score_cache_delta",help:"Delta of score between cached values that expired",buckets:[10,100,1e3]}),peersByScoreThreshold:O.gauge({name:"gossipsub_peers_by_score_threshold_count",help:"Current count of peers by score threshold",labelNames:["threshold"]}),score:O.avgMinMax({name:"gossipsub_score",help:"Avg min max of gossip scores"}),scoreWeights:O.avgMinMax({name:"gossipsub_score_weights",help:"Separate score weights",labelNames:["topic","p"]}),scorePerMesh:O.avgMinMax({name:"gossipsub_score_per_mesh",help:"Histogram of the scores for each mesh topic",labelNames:["topic"]}),scoringPenalties:O.gauge({name:"gossipsub_scoring_penalties_total",help:"A counter of the kind of penalties being applied to peers",labelNames:["penalty"]}),behaviourPenalty:O.histogram({name:"gossipsub_peer_stat_behaviour_penalty",help:"Current peer stat behaviour_penalty at each scrape",buckets:[.25*$.behaviourPenaltyThreshold,.5*$.behaviourPenaltyThreshold,1*$.behaviourPenaltyThreshold,2*$.behaviourPenaltyThreshold,4*$.behaviourPenaltyThreshold]}),ihaveRcvIgnored:O.gauge({name:"gossipsub_ihave_rcv_ignored_total",help:"Total received IHAVE messages that we ignore for some reason",labelNames:["reason"]}),ihaveRcvMsgids:O.gauge({name:"gossipsub_ihave_rcv_msgids_total",help:"Total received IHAVE messages by topic",labelNames:["topic"]}),ihaveRcvNotSeenMsgids:O.gauge({name:"gossipsub_ihave_rcv_not_seen_msgids_total",help:"Total messages per topic we do not have, not actual requests",labelNames:["topic"]}),iwantRcvMsgids:O.gauge({name:"gossipsub_iwant_rcv_msgids_total",help:"Total received IWANT messages by topic",labelNames:["topic"]}),iwantRcvDonthaveMsgids:O.gauge({name:"gossipsub_iwant_rcv_dont_have_msgids_total",help:"Total requested messageIDs that we do not have"}),iwantPromiseStarted:O.gauge({name:"gossipsub_iwant_promise_sent_total",help:"Total count of started IWANT promises"}),iwantPromiseResolved:O.gauge({name:"gossipsub_iwant_promise_resolved_total",help:"Total count of resolved IWANT promises"}),iwantPromiseResolvedFromDuplicate:O.gauge({name:"gossipsub_iwant_promise_resolved_from_duplicate_total",help:"Total count of resolved IWANT promises from duplicate messages"}),iwantPromiseResolvedPeers:O.gauge({name:"gossipsub_iwant_promise_resolved_peers",help:"Total count of peers we have asked IWANT promises that are resolved"}),iwantPromiseBroken:O.gauge({name:"gossipsub_iwant_promise_broken",help:"Total count of broken IWANT promises"}),iwantMessagePruned:O.gauge({name:"gossipsub_iwant_message_pruned",help:"Total count of pruned IWANT messages"}),iwantPromiseDeliveryTime:O.histogram({name:"gossipsub_iwant_promise_delivery_seconds",help:"Histogram of delivery time of resolved IWANT promises",buckets:[.5*$.gossipPromiseExpireSec,1*$.gossipPromiseExpireSec,2*$.gossipPromiseExpireSec,4*$.gossipPromiseExpireSec]}),iwantPromiseUntracked:O.gauge({name:"gossip_iwant_promise_untracked",help:"Total count of untracked IWANT promise"}),connectedPeersBackoffSec:O.histogram({name:"gossipsub_connected_peers_backoff_seconds",help:"Backoff time in seconds",buckets:[1,2,4,10,20,60,120]}),cacheSize:O.gauge({name:"gossipsub_cache_size",help:"Unbounded cache sizes",labelNames:["cache"]}),mcacheSize:O.gauge({name:"gossipsub_mcache_size",help:"Current mcache msg count"}),mcacheNotValidatedCount:O.gauge({name:"gossipsub_mcache_not_validated_count",help:"Current mcache msg count not validated"}),fastMsgIdCacheCollision:O.gauge({name:"gossipsub_fastmsgid_cache_collision_total",help:"Total count of key collisions on fastmsgid cache put"}),newConnectionCount:O.gauge({name:"gossipsub_new_connection_total",help:"Total new connection by status",labelNames:["status"]}),topicStrToLabel:U,toTopic(O){return this.topicStrToLabel.get(O)??O},onJoin(O){this.topicSubscriptionStatus.set({topicStr:O},1),this.meshPeerCounts.set({topicStr:O},0)},onLeave(O){this.topicSubscriptionStatus.set({topicStr:O},0),this.meshPeerCounts.set({topicStr:O},0)},onAddToMesh(O,U,$){let J=this.toTopic(O);switch(U){case tS.Fanout:this.meshPeerInclusionEventsFanout.inc({topic:J},$);break;case tS.Random:this.meshPeerInclusionEventsRandom.inc({topic:J},$);break;case tS.Subscribed:this.meshPeerInclusionEventsSubscribed.inc({topic:J},$);break;case tS.Outbound:this.meshPeerInclusionEventsOutbound.inc({topic:J},$);break;case tS.NotEnough:this.meshPeerInclusionEventsNotEnough.inc({topic:J},$);break;case tS.Opportunistic:this.meshPeerInclusionEventsOpportunistic.inc({topic:J},$);break;default:this.meshPeerInclusionEventsUnknown.inc({topic:J},$)}},onRemoveFromMesh(O,U,$){let J=this.toTopic(O);switch(U){case tA.Dc:this.meshPeerChurnEventsDisconnected.inc({topic:J},$);break;case tA.BadScore:this.meshPeerChurnEventsBadScore.inc({topic:J},$);break;case tA.Prune:this.meshPeerChurnEventsPrune.inc({topic:J},$);break;case tA.Excess:this.meshPeerChurnEventsExcess.inc({topic:J},$);break;default:this.meshPeerChurnEventsUnknown.inc({topic:J},$)}},onReportValidation(O,U,$){if(this.asyncValidationMcacheHit.inc({hit:null!=O?"hit":"miss"}),null!=O){let $=this.toTopic(O.message.topic);switch(U){case tg.Accept:this.acceptedMessagesTotal.inc({topic:$});break;case tg.Ignore:this.ignoredMessagesTotal.inc({topic:$});break;case tg.Reject:this.rejectedMessagesTotal.inc({topic:$});break;default:this.unknownValidationResultsTotal.inc({topic:$})}}null!=$?this.asyncValidationDelayFromFirstSeenSec.observe((Date.now()-$)/1e3):this.asyncValidationUnknownFirstSeen.inc()},onScorePenalty(O){this.scoringPenalties.inc({penalty:O},1)},onIhaveRcv(O,U,$){let J=this.toTopic(O);this.ihaveRcvMsgids.inc({topic:J},U),this.ihaveRcvNotSeenMsgids.inc({topic:J},$)},onIwantRcv(O,U){for(let[U,$]of O){let O=this.toTopic(U);this.iwantRcvMsgids.inc({topic:O},$)}this.iwantRcvDonthaveMsgids.inc(U)},onForwardMsg(O,U){let $=this.toTopic(O);this.msgForwardCount.inc({topic:$},1),this.msgForwardPeers.inc({topic:$},U)},onPublishMsg(O,U,$,J,en){let es=this.toTopic(O);this.msgPublishCount.inc({topic:es},1),this.msgPublishBytes.inc({topic:es},$*J),this.msgPublishPeersByTopic.inc({topic:es},$),this.directPeersPublishedTotal.inc({topic:es},U.direct),this.floodsubPeersPublishedTotal.inc({topic:es},U.floodsub),this.meshPeersPublishedTotal.inc({topic:es},U.mesh),this.fanoutPeersPublishedTotal.inc({topic:es},U.fanout),this.msgPublishTime.observe({topic:es},en/1e3)},onMsgRecvPreValidation(O){let U=this.toTopic(O);this.msgReceivedPreValidation.inc({topic:U},1)},onMsgRecvError(O){let U=this.toTopic(O);this.msgReceivedError.inc({topic:U},1)},onPrevalidationResult(O,U){let $=this.toTopic(O);switch(U){case t_.duplicate:this.prevalidationDuplicateTotal.inc({topic:$});break;case t_.invalid:this.prevalidationInvalidTotal.inc({topic:$});break;case t_.valid:this.prevalidationValidTotal.inc({topic:$});break;default:this.prevalidationUnknownTotal.inc({topic:$})}},onMsgRecvInvalid(O,U){let $=this.toTopic(O),J=U.reason===tb.Error?U.error:U.reason;this.msgReceivedInvalid.inc({error:J},1),this.msgReceivedInvalidByTopic.inc({topic:$},1)},onDuplicateMsgDelivery(O,U,$){if(this.duplicateMsgDeliveryDelay.observe(U/1e3),$){let U=this.toTopic(O);this.duplicateMsgLateDelivery.inc({topic:U},1)}},onPublishDuplicateMsg(O){let U=this.toTopic(O);this.duplicateMsgIgnored.inc({topic:U},1)},onPeerReadStreamError(){this.peerReadStreamError.inc(1)},onRpcRecvError(){this.rpcRecvError.inc(1)},onRpcDataError(){this.rpcDataError.inc(1)},onRpcRecv(O,U){this.rpcRecvBytes.inc(U),this.rpcRecvCount.inc(1),O.subscriptions&&this.rpcRecvSubscription.inc(O.subscriptions.length),O.messages&&this.rpcRecvMessage.inc(O.messages.length),O.control&&(this.rpcRecvControl.inc(1),O.control.ihave&&this.rpcRecvIHave.inc(O.control.ihave.length),O.control.iwant&&this.rpcRecvIWant.inc(O.control.iwant.length),O.control.graft&&this.rpcRecvGraft.inc(O.control.graft.length),O.control.prune&&this.rpcRecvPrune.inc(O.control.prune.length))},onRpcSent(O,U){if(this.rpcSentBytes.inc(U),this.rpcSentCount.inc(1),O.subscriptions&&this.rpcSentSubscription.inc(O.subscriptions.length),O.messages&&this.rpcSentMessage.inc(O.messages.length),O.control){let U=O.control.ihave?.length??0,$=O.control.iwant?.length??0,J=O.control.graft?.length??0,en=O.control.prune?.length??0;U>0&&this.rpcSentIHave.inc(U),$>0&&this.rpcSentIWant.inc($),J>0&&this.rpcSentGraft.inc(J),en>0&&this.rpcSentPrune.inc(en),(U>0||$>0||J>0||en>0)&&this.rpcSentControl.inc(1)}},registerScores(O,U){let $=0,J=0,en=0,es=0;for(let eo of O)eo>=U.graylistThreshold&&$++,eo>=U.publishThreshold&&J++,eo>=U.gossipThreshold&&en++,eo>=0&&es++;this.peersByScoreThreshold.set({threshold:tk.graylist},$),this.peersByScoreThreshold.set({threshold:tk.publish},J),this.peersByScoreThreshold.set({threshold:tk.gossip},en),this.peersByScoreThreshold.set({threshold:tk.mesh},es),this.score.set(O)},registerScoreWeights(O){for(let[U,$]of O.byTopic)this.scoreWeights.set({topic:U,p:"p1"},$.p1w),this.scoreWeights.set({topic:U,p:"p2"},$.p2w),this.scoreWeights.set({topic:U,p:"p3"},$.p3w),this.scoreWeights.set({topic:U,p:"p3b"},$.p3bw),this.scoreWeights.set({topic:U,p:"p4"},$.p4w);this.scoreWeights.set({p:"p5"},O.p5w),this.scoreWeights.set({p:"p6"},O.p6w),this.scoreWeights.set({p:"p7"},O.p7w)},registerScorePerMesh(O,U){let $=new Map;for(let[J,en]of(O.forEach((O,U)=>{let J=this.topicStrToLabel.get(U)??"unknown",en=$.get(J);en||(en=new Set,$.set(J,en)),O.forEach(O=>en?.add(O))}),$)){let O=[];en.forEach($=>{O.push(U.get($)??0)}),this.scorePerMesh.set({topic:J},O)}}}}!function(O){O.forward="forward",O.publish="publish"}(tE||(tE={})),function(O){O.Fanout="fanout",O.Random="random",O.Subscribed="subscribed",O.Outbound="outbound",O.NotEnough="not_enough",O.Opportunistic="opportunistic"}(tS||(tS={})),function(O){O.Dc="disconnected",O.BadScore="bad_score",O.Prune="prune",O.Excess="excess"}(tA||(tA={})),function(O){O.GraftBackoff="graft_backoff",O.BrokenPromise="broken_promise",O.MessageDeficit="message_deficit",O.IPColocation="IP_colocation"}(tI||(tI={})),function(O){O.LowScore="low_score",O.MaxIhave="max_ihave",O.MaxIasked="max_iasked"}(tP||(tP={})),function(O){O.graylist="graylist",O.publish="publish",O.gossip="gossip",O.mesh="mesh"}(tk||(tk={})),$(1250);var hI=$(1953);let hP={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};function pbkdf2_pbkdf2(O,U,$,J,en){if("sha1"!==en&&"sha2-256"!==en&&"sha2-512"!==en){let O=Object.keys(hP).join(" / ");throw new errors_CodeError(`Hash '${en}' is unknown or not supported. Must be ${O}`,"ERR_UNSUPPORTED_HASH_TYPE")}let es=hP[en],eo=hI(O,U,$,J,es);return i3.encode64(eo,null)}let hk=(0,rJ.m)("libp2p-pubsub:");async function buildRawMessage(O,U,$,J){switch(O.type){case ty.Signing:{let en={from:O.author.toBytes(),data:J,seqno:src_random_bytes_randomBytes(8),topic:U,signature:void 0,key:void 0},es=concat_concat([hk,ux.Message.encode(en).finish()]);en.signature=await O.privateKey.sign(es),en.key=O.key;let eo={type:"signed",from:O.author,data:$,sequenceNumber:BigInt(`0x${(0,rB.B)(en.seqno,"base16")}`),topic:U,signature:en.signature,key:en.key};return{raw:en,msg:eo}}case ty.Anonymous:return{raw:{from:void 0,data:J,seqno:void 0,topic:U,signature:void 0,key:void 0},msg:{type:"unsigned",data:$,topic:U}}}}async function validateToRawMessage(O,U){switch(O){case hb:if(null!=U.signature)return{valid:!1,error:tv.SignaturePresent};if(null!=U.seqno)return{valid:!1,error:tv.SeqnoPresent};if(null!=U.key)return{valid:!1,error:tv.FromPresent};return{valid:!0,message:{type:"unsigned",topic:U.topic,data:U.data??new Uint8Array(0)}};case hy:{let O,$;if(null==U.seqno||8!==U.seqno.length)return{valid:!1,error:tv.InvalidSeqno};if(null==U.signature)return{valid:!1,error:tv.InvalidSignature};if(null==U.from)return{valid:!1,error:tv.InvalidPeerId};try{O=src_peerIdFromBytes(U.from)}catch(O){return{valid:!1,error:tv.InvalidPeerId}}if(U.key){if($=src_keys_unmarshalPublicKey(U.key),void 0!==O.publicKey&&!equals($.bytes,O.publicKey))return{valid:!1,error:tv.InvalidPeerId}}else{if(null==O.publicKey)return{valid:!1,error:tv.InvalidPeerId};$=src_keys_unmarshalPublicKey(O.publicKey)}let J={from:U.from,data:U.data,seqno:U.seqno,topic:U.topic,signature:void 0,key:void 0},en=concat_concat([hk,ux.Message.encode(J).finish()]);if(!await $.verify(en,U.signature))return{valid:!1,error:tv.InvalidSignature};return{valid:!0,message:{type:"signed",from:O,data:U.data??new Uint8Array(0),sequenceNumber:BigInt(`0x${(0,rB.B)(U.seqno,"base16")}`),topic:U.topic,signature:U.signature,key:U.key??src_keys_marshalPublicKey($)}}}}}let msgId=(O,U)=>{let $=(0,rJ.m)(U.toString(16).padStart(16,"0"),"base16"),J=new Uint8Array(O.length+$.length);return J.set(O,0),J.set($,O.length),J};function msgIdFnStrictSign(O){if("signed"!==O.type)throw Error("expected signed message type");if(null==O.sequenceNumber)throw Error("missing seqno field");return msgId(O.from.toBytes(),O.sequenceNumber)}async function msgIdFnStrictNoSign(O){return await i9.sha256.encode(O.data)}function computeScoreWeights(O,U,$,J,en){let es=0,eo=new Map;if(Object.entries(U.topics).forEach(([O,U])=>{let J=en.get(O)??"unknown",ea=$.topics[O];if(void 0===ea)return;let eu=eo.get(J);eu||(eu={p1w:0,p2w:0,p3w:0,p3bw:0,p4w:0},eo.set(J,eu));let ef=0,eg=0,ev=0,e_=0,ew=0;if(U.inMesh){let O=Math.max(U.meshTime/ea.timeInMeshQuantum,ea.timeInMeshCap);ef+=O*ea.timeInMeshWeight}let eE=U.firstMessageDeliveries;if(eE>ea.firstMessageDeliveriesCap&&(eE=ea.firstMessageDeliveriesCap),eg+=eE*ea.firstMessageDeliveriesWeight,U.meshMessageDeliveriesActive&&U.meshMessageDeliveries0&&es>$.topicScoreCap){es=$.topicScoreCap;let O=$.topicScoreCap/es;for(let U of eo.values())U.p1w*=O,U.p2w*=O,U.p3w*=O,U.p3bw*=O,U.p4w*=O}let ea=0,eu=0,ef=0,eg=$.appSpecificScore(O);ea+=eg*$.appSpecificWeight,U.knownIPs.forEach(O=>{if($.IPColocationFactorWhitelist.has(O))return;let U=J.get(O),en=U?U.size:0;if(en>$.IPColocationFactorThreshold){let O=en-$.IPColocationFactorThreshold,U=O*O;eu+=U*$.IPColocationFactorWeight}});let ev=U.behaviourPenalty*U.behaviourPenalty;return{byTopic:eo,p5w:ea,p6w:eu,p7w:ef+=ev*$.behaviourPenaltyWeight,score:es+=ea+eu+ef}}function computeAllPeersScoreWeights(O,U,$,J,en){let es={byTopic:new Map,p5w:[],p6w:[],p7w:[],score:[]};for(let eo of O){let O=U.get(eo);if(O){let U=computeScoreWeights(eo,O,$,J,en);for(let[O,$]of U.byTopic){let U=es.byTopic.get(O);U||(U={p1w:[],p2w:[],p3w:[],p3bw:[],p4w:[]},es.byTopic.set(O,U)),U.p1w.push($.p1w),U.p2w.push($.p2w),U.p3w.push($.p3w),U.p3bw.push($.p3bw),U.p4w.push($.p4w)}es.p5w.push(U.p5w),es.p6w.push(U.p6w),es.p7w.push(U.p7w),es.score.push(U.score)}else es.p5w.push(0),es.p6w.push(0),es.p7w.push(0),es.score.push(0)}return es}let OutboundStream=class OutboundStream{rawStream;pushable;closeController;maxBufferSize;constructor(O,U,$){this.rawStream=O,this.pushable=src_pushable({objectMode:!1}),this.closeController=new AbortController,this.maxBufferSize=$.maxBufferSize??1/0,pipe(abortableSource(this.pushable,this.closeController.signal,{returnOnAbort:!0}),O=>encode_encode(O),this.rawStream).catch(U)}get protocol(){return this.rawStream.protocol}push(O){if(this.pushable.readableLength>this.maxBufferSize)throw Error(`OutboundStream buffer full, size > ${this.maxBufferSize}`);this.pushable.push(O)}close(){this.closeController.abort(),this.pushable.return(),this.rawStream.close()}};let InboundStream=class InboundStream{source;rawStream;closeController;constructor(O,U={}){this.rawStream=O,this.closeController=new AbortController,this.source=abortableSource(pipe(this.rawStream,O=>decode_decode(O,U)),this.closeController.signal,{returnOnAbort:!0})}close(){this.closeController.abort(),this.rawStream.close()}};var hT=$(4481);let hR={maxSubscriptions:1/0,maxMessages:1/0,maxIhaveMessageIDs:1/0,maxIwantMessageIDs:1/0,maxControlMessages:1/0,maxPeerInfos:1/0};function decodeRpc(O,U){U={...U};let $=hT.Reader.create(O),J=O.length,en=void 0===J?$.len:$.pos+J,es={};for(;$.pos>>3){case 1:es.subscriptions&&es.subscriptions.length||(es.subscriptions=[]),es.subscriptions.length>>3){case 1:J.subscribe=O.bool();break;case 2:J.topic=O.string();break;default:O.skipType(7&U)}}return J}function decodeRpc_decodeMessage(O,U){let $=void 0===U?O.len:O.pos+U,J={};for(;O.pos<$;){let U=O.uint32();switch(U>>>3){case 1:J.from=O.bytes();break;case 2:J.data=O.bytes();break;case 3:J.seqno=O.bytes();break;case 4:J.topic=O.string();break;case 5:J.signature=O.bytes();break;case 6:J.key=O.bytes();break;default:O.skipType(7&U)}}if(!J.topic)throw Error("missing required 'topic'");return J}function decodeControlMessage(O,U,$){let J=void 0===U?O.len:O.pos+U,en={};for(;O.pos>>3){case 1:en.ihave&&en.ihave.length||(en.ihave=[]),en.ihave.length<$.maxControlMessages?en.ihave.push(decodeControlIHave(O,O.uint32(),$)):O.skipType(7&U);break;case 2:en.iwant&&en.iwant.length||(en.iwant=[]),en.iwant.length<$.maxControlMessages?en.iwant.push(decodeControlIWant(O,O.uint32(),$)):O.skipType(7&U);break;case 3:en.graft&&en.graft.length||(en.graft=[]),en.graft.length<$.maxControlMessages?en.graft.push(decodeControlGraft(O,O.uint32())):O.skipType(7&U);break;case 4:en.prune&&en.prune.length||(en.prune=[]),en.prune.length<$.maxControlMessages?en.prune.push(decodeControlPrune(O,O.uint32(),$)):O.skipType(7&U);break;default:O.skipType(7&U)}}return en}function decodeControlIHave(O,U,$){let J=void 0===U?O.len:O.pos+U,en={};for(;O.pos>>3){case 1:en.topicID=O.string();break;case 2:en.messageIDs&&en.messageIDs.length||(en.messageIDs=[]),$.maxIhaveMessageIDs-- >0?en.messageIDs.push(O.bytes()):O.skipType(7&U);break;default:O.skipType(7&U)}}return en}function decodeControlIWant(O,U,$){let J=void 0===U?O.len:O.pos+U,en={};for(;O.pos>>3==1?(en.messageIDs&&en.messageIDs.length||(en.messageIDs=[]),$.maxIwantMessageIDs-- >0?en.messageIDs.push(O.bytes()):O.skipType(7&U)):O.skipType(7&U)}return en}function decodeControlGraft(O,U){let $=void 0===U?O.len:O.pos+U,J={};for(;O.pos<$;){let U=O.uint32();U>>>3==1?J.topicID=O.string():O.skipType(7&U)}return J}function decodeControlPrune(O,U,$){let J=void 0===U?O.len:O.pos+U,en={};for(;O.pos>>3){case 1:en.topicID=O.string();break;case 2:en.peers&&en.peers.length||(en.peers=[]),$.maxPeerInfos-- >0?en.peers.push(decodePeerInfo(O,O.uint32())):O.skipType(7&U);break;case 3:en.backoff=O.uint64();break;default:O.skipType(7&U)}}return en}function decodePeerInfo(O,U){let $=void 0===U?O.len:O.pos+U,J={};for(;O.pos<$;){let U=O.uint32();switch(U>>>3){case 1:J.peerID=O.bytes();break;case 2:J.signedPeerRecord=O.bytes();break;default:O.skipType(7&U)}}return J}function multiaddrToIPStr(O){for(let U of O.tuples())switch(U[0]){case tT.ip4:case tT.ip6:return convertToString(U[0],U[1])}return null}!function(O){O[O.ip4=4]="ip4",O[O.ip6=41]="ip6"}(tT||(tT={})),function(O){O[O.started=0]="started",O[O.stopped=1]="stopped"}(tR||(tR={}));let src_GossipSub=class src_GossipSub extends TypedEventEmitter{globalSignaturePolicy;multicodecs=[uU,uL];publishConfig;dataTransform;peers=new Set;streamsInbound=new Map;streamsOutbound=new Map;outboundInflightQueue=src_pushable({objectMode:!0});direct=new Set;floodsubPeers=new Set;seenCache;acceptFromWhitelist=new Map;topics=new Map;subscriptions=new Set;mesh=new Map;fanout=new Map;fanoutLastpub=new Map;gossip=new Map;control=new Map;peerhave=new Map;iasked=new Map;backoff=new Map;outbound=new Map;msgIdFn;fastMsgIdFn;msgIdToStrFn;fastMsgIdCache;publishedMessageIds;mcache;score;topicValidators=new Map;log;heartbeatTicks=0;gossipTracer;components;directPeerInitial=null;static multicodec=uU;opts;decodeRpcLimits;metrics;status={code:tR.stopped};maxInboundStreams;maxOutboundStreams;allowedTopics;heartbeatTimer=null;constructor(O,U={}){super();let $={fallbackToFloodsub:!0,floodPublish:!0,doPX:!1,directPeers:[],D:uF,Dlo:uK,Dhi:uj,Dscore:uH,Dout:uq,Dlazy:uG,heartbeatInterval:uJ,fanoutTTL:uQ,mcacheLength:uz,mcacheGossip:uV,seenTTL:ho,gossipsubIWantFollowupMs:hn,prunePeers:uZ,pruneBackoff:uX,unsubcribeBackoff:u3,graftFloodThreshold:he,opportunisticGraftPeers:u7,opportunisticGraftTicks:u9,directConnectTicks:u4,...U,scoreParams:createPeerScoreParams(U.scoreParams),scoreThresholds:createPeerScoreThresholds(U.scoreThresholds)};if(this.components=O,this.decodeRpcLimits=$.decodeRpcLimits??hR,this.globalSignaturePolicy=$.globalSignaturePolicy??hy,$.fallbackToFloodsub&&this.multicodecs.push(uO),this.log=logger($.debugName??"libp2p:gossipsub"),this.opts=$,this.direct=new Set($.directPeers.map(O=>O.id.toString())),this.seenCache=new SimpleTimeCache({validityMs:$.seenTTL}),this.publishedMessageIds=new SimpleTimeCache({validityMs:$.seenTTL}),U.msgIdFn)this.msgIdFn=U.msgIdFn;else switch(this.globalSignaturePolicy){case hy:this.msgIdFn=msgIdFnStrictSign;break;case hb:this.msgIdFn=msgIdFnStrictNoSign}if(U.fastMsgIdFn&&(this.fastMsgIdFn=U.fastMsgIdFn,this.fastMsgIdCache=new SimpleTimeCache({validityMs:$.seenTTL})),this.msgIdToStrFn=U.msgIdToStrFn??messageIdToString,this.mcache=U.messageCache||new MessageCache($.mcacheGossip,$.mcacheLength,this.msgIdToStrFn),U.dataTransform&&(this.dataTransform=U.dataTransform),U.metricsRegister){if(!U.metricsTopicStrToLabel)throw Error("Must set metricsTopicStrToLabel with metrics");let O=Math.max(...Object.values($.scoreParams.topics).map(O=>O.meshMessageDeliveriesWindow),hg),J=getMetrics(U.metricsRegister,U.metricsTopicStrToLabel,{gossipPromiseExpireSec:this.opts.gossipsubIWantFollowupMs/1e3,behaviourPenaltyThreshold:$.scoreParams.behaviourPenaltyThreshold,maxMeshMessageDeliveriesWindowSec:O/1e3});for(let O of(J.mcacheSize.addCollect(()=>this.onScrapeMetrics(J)),this.multicodecs))J.protocolsEnabled.set({protocol:O},1);this.metrics=J}else this.metrics=null;this.gossipTracer=new IWantTracer(this.opts.gossipsubIWantFollowupMs,this.msgIdToStrFn,this.metrics),this.score=new PeerScore(this.opts.scoreParams,this.metrics,{scoreCacheValidityMs:$.heartbeatInterval}),this.maxInboundStreams=U.maxInboundStreams,this.maxOutboundStreams=U.maxOutboundStreams,this.allowedTopics=$.allowedTopics?new Set($.allowedTopics):null}getPeers(){return[...this.peers.keys()].map(O=>peerIdFromString(O))}isStarted(){return this.status.code===tR.started}async start(){if(this.isStarted())return;this.log("starting"),this.publishConfig=await getPublishConfigFromPeerId(this.globalSignaturePolicy,this.components.peerId),this.outboundInflightQueue=src_pushable({objectMode:!0}),pipe(this.outboundInflightQueue,async O=>{for await(let{peerId:U,connection:$}of O)await this.createOutboundStream(U,$)}).catch(O=>this.log.error("outbound inflight queue error",O)),await Promise.all(this.opts.directPeers.map(async O=>{await this.components.peerStore.merge(O.id,{multiaddrs:O.addrs})}));let O=this.components.registrar;await Promise.all(this.multicodecs.map(U=>O.handle(U,this.onIncomingStream.bind(this),{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams})));let U={onConnect:this.onPeerConnected.bind(this),onDisconnect:this.onPeerDisconnected.bind(this)},$=await Promise.all(this.multicodecs.map($=>O.register($,U))),J=setTimeout(this.runHeartbeat,uY);this.status={code:tR.started,registrarTopologyIds:$,heartbeatTimeout:J,hearbeatStartMs:Date.now()+uY},this.score.start(),this.directPeerInitial=setTimeout(()=>{Promise.resolve().then(async()=>{await Promise.all(Array.from(this.direct).map(async O=>await this.connect(O)))}).catch(O=>{this.log(O)})},u5),this.log("started")}async stop(){if(this.log("stopping"),this.status.code!==tR.started)return;let{registrarTopologyIds:O}=this.status;this.status={code:tR.stopped};let U=this.components.registrar;for(let $ of(await Promise.all(this.multicodecs.map(O=>U.unhandle(O))),O.forEach(O=>U.unregister(O)),this.outboundInflightQueue.end(),this.streamsOutbound.values()))$.close();for(let O of(this.streamsOutbound.clear(),this.streamsInbound.values()))O.close();this.streamsInbound.clear(),this.peers.clear(),this.subscriptions.clear(),this.heartbeatTimer&&(this.heartbeatTimer.cancel(),this.heartbeatTimer=null),this.score.stop(),this.mesh.clear(),this.fanout.clear(),this.fanoutLastpub.clear(),this.gossip.clear(),this.control.clear(),this.peerhave.clear(),this.iasked.clear(),this.backoff.clear(),this.outbound.clear(),this.gossipTracer.clear(),this.seenCache.clear(),this.fastMsgIdCache&&this.fastMsgIdCache.clear(),this.directPeerInitial&&clearTimeout(this.directPeerInitial),this.log("stopped")}dumpPeerScoreStats(){return this.score.dumpPeerScoreStats()}onIncomingStream({stream:O,connection:U}){if(!this.isStarted())return;let $=U.remotePeer;this.addPeer($,U.direction,U.remoteAddr),this.createInboundStream($,O),this.outboundInflightQueue.push({peerId:$,connection:U})}onPeerConnected(O,U){this.metrics?.newConnectionCount.inc({status:U.status}),this.isStarted()&&"open"===U.status&&(this.addPeer(O,U.direction,U.remoteAddr),this.outboundInflightQueue.push({peerId:O,connection:U}))}onPeerDisconnected(O){this.log("connection ended %p",O),this.removePeer(O)}async createOutboundStream(O,U){if(!this.isStarted())return;let $=O.toString();if(!(!this.peers.has($)||this.streamsOutbound.has($)))try{let J=new OutboundStream(await U.newStream(this.multicodecs),O=>this.log.error("outbound pipe error",O),{maxBufferSize:this.opts.maxOutboundBufferSize});this.log("create outbound stream %p",O),this.streamsOutbound.set($,J);let en=J.protocol;en===uO&&this.floodsubPeers.add($),this.metrics?.peersPerProtocol.inc({protocol:en},1),this.subscriptions.size>0&&(this.log("send subscriptions to",$),this.sendSubscriptions($,Array.from(this.subscriptions),!0))}catch(O){this.log.error("createOutboundStream error",O)}}async createInboundStream(O,U){if(!this.isStarted())return;let $=O.toString();if(!this.peers.has($))return;let J=this.streamsInbound.get($);void 0!==J&&(this.log("replacing existing inbound steam %s",$),J.close()),this.log("create inbound stream %s",$);let en=new InboundStream(U,{maxDataLength:this.opts.maxInboundDataLength});this.streamsInbound.set($,en),this.pipePeerReadStream(O,en.source).catch(O=>this.log(O))}addPeer(O,U,$){let J=O.toString();if(!this.peers.has(J)){this.log("new peer %p",O),this.peers.add(J),this.score.addPeer(J);let en=multiaddrToIPStr($);null!==en?this.score.addIP(J,en):this.log("Added peer has no IP in current address %s %s",J,$.toString()),this.outbound.has(J)||this.outbound.set(J,"outbound"===U)}}removePeer(O){let U=O.toString();if(!this.peers.has(U))return;this.log("delete peer %p",O),this.peers.delete(U);let $=this.streamsOutbound.get(U),J=this.streamsInbound.get(U);for(let O of($&&this.metrics?.peersPerProtocol.inc({protocol:$.protocol},-1),$?.close(),J?.close(),this.streamsOutbound.delete(U),this.streamsInbound.delete(U),this.topics.values()))O.delete(U);for(let[O,$]of this.mesh)!0===$.delete(U)&&this.metrics?.onRemoveFromMesh(O,tA.Dc,1);for(let O of this.fanout.values())O.delete(U);this.floodsubPeers.delete(U),this.gossip.delete(U),this.control.delete(U),this.outbound.delete(U),this.score.removePeer(U),this.acceptFromWhitelist.delete(U)}get started(){return this.status.code===tR.started}getMeshPeers(O){let U=this.mesh.get(O);return U?Array.from(U):[]}getSubscribers(O){let U=this.topics.get(O);return(U?Array.from(U):[]).map(O=>peerIdFromString(O))}getTopics(){return Array.from(this.subscriptions)}async pipePeerReadStream(O,U){try{await pipe(U,async U=>{for await(let $ of U)try{let U=$.subarray(),J=decodeRpc(U,this.decodeRpcLimits);if(this.metrics?.onRpcRecv(J,U.length),this.opts.awaitRpcHandler)try{await this.handleReceivedRpc(O,J)}catch(O){this.metrics?.onRpcRecvError(),this.log(O)}else this.handleReceivedRpc(O,J).catch(O=>{this.metrics?.onRpcRecvError(),this.log(O)})}catch(O){this.metrics?.onRpcDataError(),this.log(O)}})}catch(U){this.metrics?.onPeerReadStreamError(),this.handlePeerReadStreamError(U,O)}}handlePeerReadStreamError(O,U){this.log.error(O),this.onPeerDisconnected(U)}async handleReceivedRpc(O,U){if(!this.acceptFrom(O.toString())){this.log("received message from unacceptable peer %p",O),this.metrics?.rpcRecvNotAccepted.inc();return}let $=U.subscriptions?U.subscriptions.length:0,J=U.messages?U.messages.length:0,en=0,es=0,eo=0,ea=0;if(U.control&&(U.control.ihave&&(en=U.control.ihave.length),U.control.iwant&&(es=U.control.iwant.length),U.control.graft&&(eo=U.control.graft.length),U.control.prune&&(ea=U.control.prune.length)),this.log(`rpc.from ${O.toString()} subscriptions ${$} messages ${J} ihave ${en} iwant ${es} graft ${eo} prune ${ea}`),U.subscriptions&&U.subscriptions.length>0){let $=[];U.subscriptions.forEach(U=>{let J=U.topic,en=!0===U.subscribe;if(null!=J){if(this.allowedTopics&&!this.allowedTopics.has(J))return;this.handleReceivedSubscription(O,J,en),$.push({topic:J,subscribe:en})}}),this.dispatchEvent(new l3("subscription-change",{detail:{peerId:O,subscriptions:$}}))}if(U.messages)for(let $ of U.messages){if(this.allowedTopics&&!this.allowedTopics.has($.topic))continue;let U=this.handleReceivedMessage(O,$).catch(O=>{this.metrics?.onMsgRecvError($.topic),this.log(O)});this.opts.awaitRpcMessageHandler&&await U}U.control&&await this.handleControlMessage(O.toString(),U.control)}handleReceivedSubscription(O,U,$){this.log("subscription update from %p topic %s",O,U);let J=this.topics.get(U);null==J&&(J=new Set,this.topics.set(U,J)),$?J.add(O.toString()):J.delete(O.toString())}async handleReceivedMessage(O,U){this.metrics?.onMsgRecvPreValidation(U.topic);let $=await this.validateReceivedMessage(O,U);switch(this.metrics?.onPrevalidationResult(U.topic,$.code),$.code){case t_.duplicate:this.score.duplicateMessage(O.toString(),$.msgIdStr,U.topic),this.gossipTracer.deliverMessage($.msgIdStr,!0),this.mcache.observeDuplicate($.msgIdStr,O.toString());return;case t_.invalid:if($.msgIdStr){let J=$.msgIdStr;this.score.rejectMessage(O.toString(),J,U.topic,$.reason),this.gossipTracer.rejectMessage(J,$.reason)}else this.score.rejectInvalidMessage(O.toString(),U.topic);this.metrics?.onMsgRecvInvalid(U.topic,$);return;case t_.valid:if(this.score.validateMessage($.messageId.msgIdStr),this.gossipTracer.deliverMessage($.messageId.msgIdStr),this.mcache.put($.messageId,U,!this.opts.asyncValidation),this.subscriptions.has(U.topic)){let U=this.components.peerId.equals(O);(!U||this.opts.emitSelf)&&(super.dispatchEvent(new l3("gossipsub:message",{detail:{propagationSource:O,msgId:$.messageId.msgIdStr,msg:$.msg}})),super.dispatchEvent(new l3("message",{detail:$.msg})))}this.opts.asyncValidation||this.forwardMessage($.messageId.msgIdStr,U,O.toString())}}async validateReceivedMessage(O,U){let $=this.fastMsgIdFn?.(U),J=void 0!==$?this.fastMsgIdCache?.get($):void 0;if(J)return{code:t_.duplicate,msgIdStr:J};let en=await validateToRawMessage(this.globalSignaturePolicy,U);if(!en.valid)return{code:t_.invalid,reason:tb.Error,error:en.error};let es=en.message;try{this.dataTransform&&(es.data=this.dataTransform.inboundTransform(U.topic,es.data))}catch(O){return this.log("Invalid message, transform failed",O),{code:t_.invalid,reason:tb.Error,error:tv.TransformFailed}}let eo=await this.msgIdFn(es),ea=this.msgIdToStrFn(eo),eu={msgId:eo,msgIdStr:ea};if(void 0!==$&&this.fastMsgIdCache){let O=this.fastMsgIdCache.put($,ea);O&&this.metrics?.fastMsgIdCacheCollision.inc()}if(this.seenCache.has(ea))return{code:t_.duplicate,msgIdStr:ea};this.seenCache.put(ea);let ef=this.topicValidators.get(U.topic);if(null!=ef){let U;try{U=await ef(O,es)}catch($){let O=$.code;O===hu&&(U=tg.Ignore),U=O===hc?tg.Reject:tg.Ignore}if(U!==tg.Accept)return{code:t_.invalid,reason:rejectReasonFromAcceptance(U),msgIdStr:ea}}return{code:t_.valid,messageId:eu,msg:es}}getScore(O){return this.score.score(O)}sendSubscriptions(O,U,$){this.sendRpc(O,{subscriptions:U.map(O=>({topic:O,subscribe:$}))})}async handleControlMessage(O,U){if(void 0===U)return;let $=U.ihave?this.handleIHave(O,U.ihave):[],J=U.iwant?this.handleIWant(O,U.iwant):[],en=U.graft?await this.handleGraft(O,U.graft):[];if(U.prune&&await this.handlePrune(O,U.prune),!$.length&&!J.length&&!en.length)return;let es=this.sendRpc(O,{messages:J,control:{iwant:$,prune:en}}),eo=$[0]?.messageIDs;eo&&(es?this.gossipTracer.addPromise(O,eo):this.metrics?.iwantPromiseUntracked.inc(1))}acceptFrom(O){if(this.direct.has(O))return!0;let U=Date.now(),$=this.acceptFromWhitelist.get(O);if($&&$.messagesAccepted=U)return $.messagesAccepted+=1,!0;let J=this.score.score(O);return J>=hd?this.acceptFromWhitelist.set(O,{messagesAccepted:0,acceptUntil:U+hp}):this.acceptFromWhitelist.delete(O),J>=this.opts.scoreThresholds.graylistThreshold}handleIHave(O,U){if(!U.length)return[];let $=this.score.score(O);if($hr)return this.log("IHAVE: peer %s has advertised too many times (%d) within this heartbeat interval; ignoring",O,J),this.metrics?.ihaveRcvIgnored.inc({reason:tP.MaxIhave}),[];let en=this.iasked.get(O)??0;if(en>=ht)return this.log("IHAVE: peer %s has already advertised too many messages (%d); ignoring",O,en),this.metrics?.ihaveRcvIgnored.inc({reason:tP.MaxIasked}),[];let es=new Map;if(U.forEach(({topicID:O,messageIDs:U})=>{if(!O||!U||!this.mesh.has(O))return;let $=0;U.forEach(O=>{let U=this.msgIdToStrFn(O);!this.seenCache.has(U)&&(es.set(U,O),$++)}),this.metrics?.onIhaveRcv(O,U.length,$)}),!es.size)return[];let eo=es.size;eo+en>ht&&(eo=ht-en),this.log("IHAVE: Asking for %d out of %d messages from %s",eo,es.size,O);let ea=Array.from(es.values());return shuffle(ea),ea=ea.slice(0,eo),this.iasked.set(O,en+eo),[{messageIDs:ea}]}handleIWant(O,U){if(!U.length)return[];let $=this.score.score(O);if(${U&&U.forEach(U=>{let $=this.msgIdToStrFn(U),eo=this.mcache.getWithIWantCount($,O);if(null==eo){es++;return}if(en.set(eo.msg.topic,1+(en.get(eo.msg.topic)??0)),eo.count>uW){this.log("IWANT: Peer %s has asked for message %s too many times: ignoring request",O,U);return}J.set($,eo.msg)})}),this.metrics?.onIwantRcv(en,es),J.size)?(this.log("IWANT: Sending %d messages to %s",J.size,O),Array.from(J.values())):(this.log("IWANT: Could not provide any wanted messages to %s",O),[])}async handleGraft(O,U){let $=[],J=this.score.score(O),en=Date.now(),es=this.opts.doPX;if(U.forEach(({topicID:U})=>{if(!U)return;let eo=this.mesh.get(U);if(!eo){es=!1;return}if(eo.has(O))return;if(this.direct.has(O)){this.log("GRAFT: ignoring request from direct peer %s",O),$.push(U),es=!1;return}let ea=this.backoff.get(U)?.get(O);if("number"==typeof ea&&en=this.opts.Dhi&&!this.outbound.get(O)){$.push(U),this.addBackoff(O,U);return}this.log("GRAFT: Add mesh link from %s in %s",O,U),this.score.graft(O,U),eo.add(O),this.metrics?.onAddToMesh(U,tS.Subscribed,1)}),!$.length)return[];let eo=!1;return await Promise.all($.map(U=>this.makePrune(O,U,es,eo)))}async handlePrune(O,U){let $=this.score.score(O);for(let{topicID:J,backoff:en,peers:es}of U){if(null==J)continue;let U=this.mesh.get(J);if(!U)return;if(this.log("PRUNE: Remove mesh link to %s in %s",O,J),this.score.prune(O,J),U.has(O)&&(U.delete(O),this.metrics?.onRemoveFromMesh(J,tA.Prune,1)),"number"==typeof en&&en>0?this.doAddBackoff(O,J,1e3*en):this.addBackoff(O,J),es&&es.length){if(${this.log("peer %s didn't follow up in %d IWANT requests; adding penalty",U,O),this.score.addPenalty(U,O,tI.BrokenPromise)})}clearBackoff(){if(this.heartbeatTicks%u6!=0)return;let O=Date.now();this.backoff.forEach((U,$)=>{U.forEach(($,J)=>{$+hm*this.opts.heartbeatInterval{this.streamsOutbound.has(U)||O.push(U)}),await Promise.all(O.map(async O=>await this.connect(O)))}async pxConnect(O){O.length>this.opts.prunePeers&&(shuffle(O),O=O.slice(0,this.opts.prunePeers));let U=[];await Promise.all(O.map(async O=>{if(!O.peerID)return;let $=src_peerIdFromBytes(O.peerID),J=$.toString();if(!this.peers.has(J)){if(!O.signedPeerRecord){U.push(J);return}try{if(!await this.components.peerStore.consumePeerRecord(O.signedPeerRecord,$)){this.log("bogus peer record obtained through px: could not add peer record to address book");return}U.push(J)}catch(O){this.log("bogus peer record obtained through px: invalid signature or not a peer record")}}})),U.length&&await Promise.all(U.map(async O=>await this.connect(O)))}async connect(O){this.log("Initiating connection with %s",O);let U=peerIdFromString(O),$=await this.components.connectionManager.openConnection(U);for(let O of this.multicodecs)for(let J of this.components.registrar.getTopologies(O))J.onConnect?.(U,$)}subscribe(O){if(this.status.code!==tR.started)throw Error("Pubsub has not started");if(!this.subscriptions.has(O))for(let U of(this.subscriptions.add(O),this.peers.keys()))this.sendSubscriptions(U,[O],!0);this.join(O)}unsubscribe(O){if(this.status.code!==tR.started)throw Error("Pubsub is not started");let U=this.subscriptions.delete(O);if(this.log("unsubscribe from %s - am subscribed %s",O,U),U)for(let U of this.peers.keys())this.sendSubscriptions(U,[O],!1);this.leave(O)}join(O){if(this.status.code!==tR.started)throw Error("Gossipsub has not started");if(this.mesh.has(O))return;this.log("JOIN %s",O),this.metrics?.onJoin(O);let U=new Set,$=this.backoff.get(O),J=this.fanout.get(O);if(J&&(this.fanout.delete(O),this.fanoutLastpub.delete(O),J.forEach(O=>{!this.direct.has(O)&&this.score.score(O)>=0&&(!$||!$.has(O))&&U.add(O)}),this.metrics?.onAddToMesh(O,tS.Fanout,U.size)),U.size!U.has(O)&&!this.direct.has(O)&&this.score.score(O)>=0&&(!$||!$.has(O)));en.forEach(O=>{U.add(O)}),this.metrics?.onAddToMesh(O,tS.Random,U.size-J)}this.mesh.set(O,U),U.forEach(U=>{this.log("JOIN: Add mesh link to %s in %s",U,O),this.sendGraft(U,O)})}leave(O){if(this.status.code!==tR.started)throw Error("Gossipsub has not started");this.log("LEAVE %s",O),this.metrics?.onLeave(O);let U=this.mesh.get(O);U&&(Promise.all(Array.from(U).map(async U=>(this.log("LEAVE: Remove mesh link to %s in %s",U,O),await this.sendPrune(U,O)))).catch(O=>{this.log("Error sending prunes to mesh peers",O)}),this.mesh.delete(O))}selectPeersToForward(O,U,$){let J=new Set,en=this.topics.get(O);en&&(this.direct.forEach(O=>{en.has(O)&&U!==O&&!$?.has(O)&&J.add(O)}),this.floodsubPeers.forEach(O=>{en.has(O)&&U!==O&&!$?.has(O)&&this.score.score(O)>=this.opts.scoreThresholds.publishThreshold&&J.add(O)}));let es=this.mesh.get(O);return es&&es.size>0&&es.forEach(O=>{U===O||$?.has(O)||J.add(O)}),J}selectPeersToPublish(O){let U=new Set,$={direct:0,floodsub:0,mesh:0,fanout:0},J=this.topics.get(O);if(J){if(this.opts.floodPublish)J.forEach(O=>{this.direct.has(O)?(U.add(O),$.direct++):this.score.score(O)>=this.opts.scoreThresholds.publishThreshold&&(U.add(O),$.floodsub++)});else{this.direct.forEach(O=>{J.has(O)&&(U.add(O),$.direct++)}),this.floodsubPeers.forEach(O=>{J.has(O)&&this.score.score(O)>=this.opts.scoreThresholds.publishThreshold&&(U.add(O),$.floodsub++)});let en=this.mesh.get(O);if(en&&en.size>0)en.forEach(O=>{U.add(O),$.mesh++});else{let J=this.fanout.get(O);if(J&&J.size>0)J.forEach(O=>{U.add(O),$.fanout++});else{let J=this.getRandomGossipPeers(O,this.opts.D,O=>this.score.score(O)>=this.opts.scoreThresholds.publishThreshold);J.size>0&&(this.fanout.set(O,J),J.forEach(O=>{U.add(O),$.fanout++}))}this.fanoutLastpub.set(O,Date.now())}}}return{tosend:U,tosendCount:$}}forwardMessage(O,U,$,J){$&&this.score.deliverMessage($,O,U.topic);let en=this.selectPeersToForward(U.topic,$,J);en.forEach(O=>{this.sendRpc(O,{messages:[U]})}),this.metrics?.onForwardMsg(U.topic,en.size)}async publish(O,U,$){let J=Date.now(),en=this.dataTransform?this.dataTransform.outboundTransform(O,U):U;if(null==this.publishConfig)throw Error("PublishError.Uninitialized");let{raw:es,msg:eo}=await buildRawMessage(this.publishConfig,O,U,en),ea=await this.msgIdFn(eo),eu=this.msgIdToStrFn(ea),ef=$?.ignoreDuplicatePublishError??this.opts.ignoreDuplicatePublishError;if(this.seenCache.has(eu)){if(ef)return this.metrics?.onPublishDuplicateMsg(O),{recipients:[]};throw Error("PublishError.Duplicate")}let{tosend:eg,tosendCount:ev}=this.selectPeersToPublish(O),e_=!0===this.opts.emitSelf&&this.subscriptions.has(O),ew=$?.allowPublishToZeroPeers??this.opts.allowPublishToZeroPeers;if(0===eg.size&&!ew&&!e_)throw Error("PublishError.InsufficientPeers");for(let O of(this.seenCache.put(eu),this.mcache.put({msgId:ea,msgIdStr:eu},es,!0),this.publishedMessageIds.put(eu),eg)){let U=this.sendRpc(O,{messages:[es]});U||eg.delete(O)}let eE=Date.now()-J;return this.metrics?.onPublishMsg(O,ev,eg.size,null!=es.data?es.data.length:0,eE),e_&&(eg.add(this.components.peerId.toString()),super.dispatchEvent(new l3("gossipsub:message",{detail:{propagationSource:this.components.peerId,msgId:eu,msg:eo}})),super.dispatchEvent(new l3("message",{detail:eo}))),{recipients:Array.from(eg.values()).map(O=>peerIdFromString(O))}}reportMessageValidationResult(O,U,$){let J;if($===tg.Accept){if(null!=(J=this.mcache.validate(O))){let{message:$,originatingPeers:en}=J;this.score.deliverMessage(U,O,$.topic),this.forwardMessage(O,J.message,U,en)}}else if(J=this.mcache.remove(O)){let en=rejectReasonFromAcceptance($),{message:es,originatingPeers:eo}=J;for(let $ of(this.score.rejectMessage(U,O,es.topic,en),eo))this.score.rejectMessage($,O,es.topic,en)}let en=this.score.messageFirstSeenTimestampMs(O);this.metrics?.onReportValidation(J,$,en)}sendGraft(O,U){let $=[{topicID:U}];this.sendRpc(O,{control:{graft:$}})}async sendPrune(O,U){let $=!0,J=[await this.makePrune(O,U,this.opts.doPX,$)];this.sendRpc(O,{control:{prune:J}})}sendRpc(O,U){let $=this.streamsOutbound.get(O);if(!$)return this.log(`Cannot send RPC to ${O} as there is no open stream to it available`),!1;let J=this.control.get(O);J&&(this.piggybackControl(O,U,J),this.control.delete(O));let en=this.gossip.get(O);en&&(this.piggybackGossip(O,U,en),this.gossip.delete(O));let es=ux.encode(U).finish();try{$.push(es)}catch(U){return this.log.error(`Cannot send rpc to ${O}`,U),J&&this.control.set(O,J),en&&this.gossip.set(O,en),!1}return this.metrics?.onRpcSent(U,es.length),!0}piggybackControl(O,U,$){if($.graft)for(let J of(U.control||(U.control={}),U.control.graft||(U.control.graft=[]),$.graft))J.topicID&&this.mesh.get(J.topicID)?.has(O)&&U.control.graft.push(J);if($.prune)for(let J of(U.control||(U.control={}),U.control.prune||(U.control.prune=[]),$.prune))J.topicID&&!this.mesh.get(J.topicID)?.has(O)&&U.control.prune.push(J)}piggybackGossip(O,U,$){U.control||(U.control={}),U.control.ihave=$}async sendGraftPrune(O,U,$){let J=this.opts.doPX,en=!1;for(let[es,eo]of O){let O=eo.map(O=>({topicID:O})),ea=[],eu=U.get(es);eu&&(ea=await Promise.all(eu.map(async O=>await this.makePrune(es,O,J&&!$.get(es),en))),U.delete(es)),this.sendRpc(es,{control:{graft:O,prune:ea}})}for(let[O,es]of U){let U=await Promise.all(es.map(async U=>await this.makePrune(O,U,J&&!$.get(O),en)));this.sendRpc(O,{control:{prune:U}})}}emitGossip(O){let U=this.mcache.getGossipIDs(new Set(O.keys()));for(let[$,J]of O)this.doEmitGossip($,J,U.get($)??[])}doEmitGossip(O,U,$){if(!$.length||(shuffle($),$.length>ht&&this.log("too many messages for gossip; will truncate IHAVE list (%d messages)",$.length),!U.size))return;let J=this.opts.Dlazy,en=u$*U.size,es=U;en>J&&(J=en),J>es.size?J=es.size:es=shuffle(Array.from(es)).slice(0,J),es.forEach(U=>{let J=$;$.length>ht&&(J=shuffle(J.slice()).slice(0,ht)),this.pushGossip(U,{topicID:O,messageIDs:J})})}flush(){for(let[O,U]of this.gossip.entries())this.gossip.delete(O),this.sendRpc(O,{control:{ihave:U}});for(let[O,U]of this.control.entries())this.control.delete(O),this.sendRpc(O,{control:{graft:U.graft,prune:U.prune}})}pushGossip(O,U){this.log("Add gossip to %s",O);let $=this.gossip.get(O)||[];this.gossip.set(O,$.concat(U))}async makePrune(O,U,$,J){if(this.score.prune(O,U),this.streamsOutbound.get(O).protocol===uL)return{topicID:U,peers:[]};let en=J?this.opts.unsubcribeBackoff:this.opts.pruneBackoff,es=en/1e3;if(this.doAddBackoff(O,U,en),!$)return{topicID:U,peers:[],backoff:es};let eo=this.getRandomGossipPeers(U,this.opts.prunePeers,U=>U!==O&&this.score.score(U)>=0),ea=await Promise.all(Array.from(eo).map(async O=>{let U;let $=peerIdFromString(O);try{U=await this.components.peerStore.get($)}catch(O){if("ERR_NOT_FOUND"!==O.code)throw O}return{peerID:$.toBytes(),signedPeerRecord:U?.peerRecordEnvelope}}));return{topicID:U,peers:ea,backoff:es}}runHeartbeat=()=>{let O=this.metrics?.heartbeatDuration.startTimer();this.heartbeat().catch(O=>{this.log("Error running heartbeat",O)}).finally(()=>{if(null!=O&&O(),this.status.code===tR.started){clearTimeout(this.status.heartbeatTimeout);let O=this.opts.heartbeatInterval-(Date.now()-this.status.hearbeatStartMs)%this.opts.heartbeatInterval;O<.25*this.opts.heartbeatInterval&&(O+=this.opts.heartbeatInterval,this.metrics?.heartbeatSkipped.inc()),this.status.heartbeatTimeout=setTimeout(this.runHeartbeat,O)}})};async heartbeat(){let{D:O,Dlo:U,Dhi:$,Dscore:J,Dout:en,fanoutTTL:es}=this.opts;this.heartbeatTicks++;let eo=new Map,getScore=O=>{let U=eo.get(O);return void 0===U&&(U=this.score.score(O),eo.set(O,U)),U},ea=new Map,eu=new Map,ef=new Map;this.clearBackoff(),this.peerhave.clear(),this.metrics?.cacheSize.set({cache:"iasked"},this.iasked.size),this.iasked.clear(),this.applyIwantPenalties(),this.heartbeatTicks%this.opts.directConnectTicks==0&&await this.directConnect(),this.fastMsgIdCache?.prune(),this.seenCache.prune(),this.gossipTracer.prune(),this.publishedMessageIds.prune();let eg=new Map;this.mesh.forEach((es,eo)=>{let ev=this.topics.get(eo),e_=new Set,ew=new Set;if(eg.set(eo,ew),ev){let O=shuffle(Array.from(ev)),U=this.backoff.get(eo);for(let $ of O){let O=this.streamsOutbound.get($);if(O&&this.multicodecs.includes(O.protocol)&&!es.has($)&&!this.direct.has($)){let O=getScore($);U&&U.has($)||!(O>=0)||e_.add($),O>=this.opts.scoreThresholds.gossipThreshold&&ew.add($)}}}let prunePeer=(O,U)=>{this.log("HEARTBEAT: Remove mesh link to %s in %s",O,eo),this.addBackoff(O,eo),es.delete(O),getScore(O)>=this.opts.scoreThresholds.gossipThreshold&&ew.add(O),this.metrics?.onRemoveFromMesh(eo,U,1);let $=eu.get(O);$?$.push(eo):eu.set(O,[eo])},graftPeer=(O,U)=>{this.log("HEARTBEAT: Add mesh link to %s in %s",O,eo),this.score.graft(O,eo),es.add(O),ew.delete(O),this.metrics?.onAddToMesh(eo,U,1);let $=ea.get(O);$?$.push(eo):ea.set(O,[eo])};if(es.forEach(O=>{let U=getScore(O);U<0&&(this.log("HEARTBEAT: Prune peer %s with negative score: score=%d, topic=%s",O,U,eo),prunePeer(O,tA.BadScore),ef.set(O,!0))}),es.size{graftPeer(O,tS.NotEnough)})}if(es.size>$){let U=Array.from(es);U.sort((O,U)=>getScore(U)-getScore(O));let $=0;if((U=U.slice(0,J).concat(shuffle(U.slice(J)))).slice(0,O).forEach(O=>{this.outbound.get(O)&&$++}),${let $=U[O];for(let $=O;$>0;$--)U[$]=U[$-1];U[0]=$};if($>0){let J=$;for(let $=1;$0;$++)this.outbound.get(U[$])&&(rotate($),J--)}let J=O-$;for(let $=O;$0;$++)this.outbound.get(U[$])&&(rotate($),J--)}U.slice(O).forEach(O=>{prunePeer(O,tA.Excess)})}if(es.size>=U){let O=0;if(es.forEach(U=>{this.outbound.get(U)&&O++}),O!0===this.outbound.get(O));$.forEach(O=>{graftPeer(O,tS.Outbound)})}}if(this.heartbeatTicks%this.opts.opportunisticGraftTicks==0&&es.size>1){let O=Array.from(es).sort((O,U)=>getScore(O)-getScore(U)),U=Math.floor(es.size/2),$=getScore(O[U]);if($getScore(O)>$);for(let O of U)this.log("HEARTBEAT: Opportunistically graft peer %s on topic %s",O,eo),graftPeer(O,tS.Opportunistic)}}});let ev=Date.now();this.fanoutLastpub.forEach((O,U)=>{O+es{let J=this.topics.get($);U.forEach(O=>{(!J.has(O)||getScore(O)=this.opts.scoreThresholds.publishThreshold&&es.push($),O>=this.opts.scoreThresholds.gossipThreshold&&eo.add($)}}}if(U.size{U.add(O),eo?.delete(O)})}}),this.emitGossip(eg),await this.sendGraftPrune(ea,eu,ef),this.flush(),this.mcache.shift(),this.dispatchEvent(new l3("gossipsub:heartbeat"))}getRandomGossipPeers(O,U,$=()=>!0){let J=this.topics.get(O);if(!J)return new Set;let en=[];return J.forEach(O=>{let U=this.streamsOutbound.get(O);U&&this.multicodecs.includes(U.protocol)&&$(O)&&en.push(O)}),en=shuffle(en),U>0&&en.length>U&&(en=en.slice(0,U)),new Set(en)}onScrapeMetrics(O){O.mcacheSize.set(this.mcache.size),O.mcacheNotValidatedCount.set(this.mcache.notValidatedCount),O.cacheSize.set({cache:"direct"},this.direct.size),O.cacheSize.set({cache:"seenCache"},this.seenCache.size),O.cacheSize.set({cache:"fastMsgIdCache"},this.fastMsgIdCache?.size??0),O.cacheSize.set({cache:"publishedMessageIds"},this.publishedMessageIds.size),O.cacheSize.set({cache:"mcache"},this.mcache.size),O.cacheSize.set({cache:"score"},this.score.size),O.cacheSize.set({cache:"gossipTracer.promises"},this.gossipTracer.size),O.cacheSize.set({cache:"gossipTracer.requests"},this.gossipTracer.requestMsByMsgSize),O.cacheSize.set({cache:"topics"},this.topics.size),O.cacheSize.set({cache:"subscriptions"},this.subscriptions.size),O.cacheSize.set({cache:"mesh"},this.mesh.size),O.cacheSize.set({cache:"fanout"},this.fanout.size),O.cacheSize.set({cache:"peers"},this.peers.size),O.cacheSize.set({cache:"streamsOutbound"},this.streamsOutbound.size),O.cacheSize.set({cache:"streamsInbound"},this.streamsInbound.size),O.cacheSize.set({cache:"acceptFromWhitelist"},this.acceptFromWhitelist.size),O.cacheSize.set({cache:"gossip"},this.gossip.size),O.cacheSize.set({cache:"control"},this.control.size),O.cacheSize.set({cache:"peerhave"},this.peerhave.size),O.cacheSize.set({cache:"outbound"},this.outbound.size);let U=0,$=Date.now();for(let J of(O.connectedPeersBackoffSec.reset(),this.backoff.values()))for(let[en,es]of(U+=J.size,J.entries()))this.peers.has(en)&&O.connectedPeersBackoffSec.observe(Math.max(0,es-$)/1e3);for(let[$,J]of(O.cacheSize.set({cache:"backoff"},U),this.topics))O.topicPeersCount.set({topicStr:$},J.size);for(let[U,$]of this.mesh)O.meshPeerCounts.set({topicStr:U},$.size);let J=[],en=new Map;for(let U of(O.behaviourPenalty.reset(),this.peers.keys())){let $=this.score.score(U);J.push($),en.set(U,$),O.behaviourPenalty.observe(this.score.peerStats.get(U)?.behaviourPenalty??0)}O.registerScores(J,this.opts.scoreThresholds),O.registerScorePerMesh(this.mesh,en);let es=computeAllPeersScoreWeights(this.peers.keys(),this.score.peerStats,this.score.params,this.score.peerIPs,O.topicStrToLabel);O.registerScoreWeights(es)}};function pushOrInitMapSet(O,U,$){let J=O.get(U);void 0===J&&(O.set(U,new Set),J=O.get(U)),J.add($)}let hC=["/vac/waku/relay/2.0.0"],hB=nf("waku:relay");function messageValidator(O,U){let $=performance.now();hB(`validating message from ${O} received on ${U.topic}`);let J=tg.Accept;try{let O=eR.decode(U.data);O.contentTopic&&O.contentTopic.length&&O.payload&&O.payload.length||(J=tg.Reject)}catch(O){J=tg.Reject}let en=performance.now();return hB(`Validation time (must be <100ms): ${en-$}ms`),J}let hN=nf("waku:message:topic-only");let topic_only_message_TopicOnlyMessage=class topic_only_message_TopicOnlyMessage{pubsubTopic;proto;payload=new Uint8Array;rateLimitProof;timestamp;meta;ephemeral;constructor(O,U){this.pubsubTopic=O,this.proto=U}get contentTopic(){return this.proto.contentTopic}};let TopicOnlyDecoder=class TopicOnlyDecoder{pubsubTopic=sc;contentTopic="";fromWireToProtoObj(O){let U=eO.decode(O);return hN("Message decoded",U),Promise.resolve({contentTopic:U.contentTopic,payload:new Uint8Array,rateLimitProof:void 0,timestamp:void 0,meta:void 0,version:void 0,ephemeral:void 0})}async fromProtoObj(O,U){return new topic_only_message_TopicOnlyMessage(O,U)}};let hx=nf("waku:relay");let Relay=class Relay{pubsubTopics;defaultDecoder;static multicodec=hC[0];gossipSub;observers;constructor(O,U){if(!this.isRelayPubSub(O.services.pubsub))throw Error(`Failed to initialize Relay. libp2p.pubsub does not support ${Relay.multicodec}`);this.gossipSub=O.services.pubsub,this.pubsubTopics=new Set(U?.pubsubTopics??[sc]),this.gossipSub.isStarted()&&this.subscribeToAllTopics(),this.observers=new Map,this.defaultDecoder=new TopicOnlyDecoder}async start(){if(this.gossipSub.isStarted())throw Error("GossipSub already started.");await this.gossipSub.start(),this.subscribeToAllTopics()}async send(O,U){let $=[],{pubsubTopic:J}=O;if(!this.pubsubTopics.has(J))return hx("Failed to send waku relay: topic not configured"),{recipients:$,errors:[ef.TOPIC_NOT_CONFIGURED]};if(!isSizeValid(U.payload))return hx("Failed to send waku relay: message is bigger that 1MB"),{recipients:$,errors:[ef.SIZE_TOO_BIG]};let en=await O.toWire(U);return en?this.gossipSub.publish(J,en):(hx("Failed to encode message, aborting publish"),{recipients:$,errors:[ef.ENCODE_FAILED]})}subscribe(O,U){let $=[];for(let J of Array.isArray(O)?O:[O]){let{pubsubTopic:O}=J,en=this.observers.get(O)??new Map,es={pubsubTopic:O,decoder:J,callback:U};pushOrInitMapSet(en,J.contentTopic,es),this.observers.set(O,en),$.push([O,es])}return()=>{this.removeObservers($)}}removeObservers(O){for(let[U,$]of O){let O=this.observers.get(U);if(!O)continue;let J=$.decoder.contentTopic,en=O.get(J);en&&(en.delete($),O.set(J,en),this.observers.set(U,O))}}toSubscriptionIterator(O){return toAsyncIterator(this,O)}getActiveSubscriptions(){let O=new Map;for(let U of this.pubsubTopics)O.set(U,Array.from(this.observers.keys()));return O}getMeshPeers(O=sc){return this.gossipSub.getMeshPeers(O)}subscribeToAllTopics(){for(let O of this.pubsubTopics)this.gossipSubSubscribe(O)}async processIncomingMessage(O,U){let $=await this.defaultDecoder.fromWireToProtoObj(U);if(!$||!$.contentTopic){hx("Message does not have a content topic, skipping");return}let J=this.observers.get(O);if(!J)return;let en=J.get($.contentTopic);en&&await Promise.all(Array.from(en).map(({decoder:J,callback:en})=>(async()=>{try{let es=await J.fromWireToProtoObj(U);if(!es){hx("Internal error: message previously decoded failed on 2nd pass.");return}let eo=await J.fromProtoObj(O,es);eo?await en(eo):hx("Failed to decode messages on",$.contentTopic)}catch(O){hx("Error while decoding message:",O)}})()))}gossipSubSubscribe(O){this.gossipSub.addEventListener("gossipsub:message",U=>{U.detail.msg.topic===O&&(hx(`Message received on ${O}`),this.processIncomingMessage(U.detail.msg.topic,U.detail.msg.data).catch(O=>hx("Failed to process incoming message",O)))}),this.gossipSub.topicValidators.set(O,messageValidator),this.gossipSub.subscribe(O)}isRelayPubSub(O){return O?.multicodecs?.includes(Relay.multicodec)??!1}};var hD=$(512);let hM=Symbol.for("@libp2p/content-routing"),hO=Symbol.for("@libp2p/peer-routing"),nanoid=(O=21)=>crypto.getRandomValues(new Uint8Array(O)).reduce((O,U)=>((U&=63)<36?O+=U.toString(36):U<62?O+=(U-26).toString(36).toUpperCase():U>62?O+="-":O+="_",O),""),hL="/",hU=new TextEncoder().encode(hL),hF=hU[0];let Key=class Key{_buf;constructor(O,U){if("string"==typeof O)this._buf=(0,rJ.m)(O);else if(O instanceof Uint8Array)this._buf=O;else throw Error("Invalid key, should be String of Uint8Array");if(null==U&&(U=!0),U&&this.clean(),0===this._buf.byteLength||this._buf[0]!==hF)throw Error("Invalid key")}toString(O="utf8"){return(0,rB.B)(this._buf,O)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(O){return new Key(O.join(hL))}static random(){return new Key(nanoid().replace(/-/g,""))}static asKey(O){return O instanceof Uint8Array||"string"==typeof O?new Key(O):"function"==typeof O.uint8Array?new Key(O.uint8Array()):null}clean(){if((null==this._buf||0===this._buf.byteLength)&&(this._buf=hU),this._buf[0]!==hF){let O=new Uint8Array(this._buf.byteLength+1);O.fill(hF,0,1),O.set(this._buf,1),this._buf=O}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===hF;)this._buf=this._buf.subarray(0,-1)}less(O){let U=this.list(),$=O.list();for(let O=0;Oen)return!1}return U.length<$.length}reverse(){return Key.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let O=this.namespaces();return O[O.length-1]}list(){return this.toString().split(hL).slice(1)}type(){return namespaceType(this.baseNamespace())}name(){return namespaceValue(this.baseNamespace())}instance(O){return new Key(this.toString()+":"+O)}path(){let O=this.parent().toString();return O.endsWith(hL)||(O+=hL),O+=this.type(),new Key(O)}parent(){let O=this.list();return new Key(1===O.length?hL:O.slice(0,-1).join(hL))}child(O){return this.toString()===hL?O:O.toString()===hL?this:new Key(this.toString()+O.toString(),!1)}isAncestorOf(O){return O.toString()!==this.toString()&&O.toString().startsWith(this.toString())}isDecendantOf(O){return O.toString()!==this.toString()&&this.toString().startsWith(O.toString())}isTopLevel(){return 1===this.list().length}concat(...O){return Key.withNamespaces([...this.namespaces(),...flatten(O.map(O=>O.namespaces()))])}};function namespaceType(O){let U=O.split(":");return U.length<2?"":U.slice(0,-1).join(":")}function namespaceValue(O){let U=O.split(":");return U[U.length-1]}function flatten(O){return[].concat(...O)}var hK=$(3498),hj=$(2508);!function(O){O.ERR_INVALID_PARAMETERS="ERR_INVALID_PARAMETERS",O.ERR_INVALID_KEY_NAME="ERR_INVALID_KEY_NAME",O.ERR_INVALID_KEY_TYPE="ERR_INVALID_KEY_TYPE",O.ERR_KEY_ALREADY_EXISTS="ERR_KEY_ALREADY_EXISTS",O.ERR_INVALID_KEY_SIZE="ERR_INVALID_KEY_SIZE",O.ERR_KEY_NOT_FOUND="ERR_KEY_NOT_FOUND",O.ERR_OLD_KEY_NAME_INVALID="ERR_OLD_KEY_NAME_INVALID",O.ERR_NEW_KEY_NAME_INVALID="ERR_NEW_KEY_NAME_INVALID",O.ERR_PASSWORD_REQUIRED="ERR_PASSWORD_REQUIRED",O.ERR_PEM_REQUIRED="ERR_PEM_REQUIRED",O.ERR_CANNOT_READ_KEY="ERR_CANNOT_READ_KEY",O.ERR_MISSING_PRIVATE_KEY="ERR_MISSING_PRIVATE_KEY",O.ERR_INVALID_OLD_PASS_TYPE="ERR_INVALID_OLD_PASS_TYPE",O.ERR_INVALID_NEW_PASS_TYPE="ERR_INVALID_NEW_PASS_TYPE",O.ERR_INVALID_PASS_LENGTH="ERR_INVALID_PASS_LENGTH"}(tC||(tC={}));let hH=logger("libp2p:keychain"),hq="/pkcs8/",hz="/info/",hV=new WeakMap,hG={minKeyLength:14,minSaltLength:16,minIterationCount:1e3},h$={dek:{keyLength:64,iterationCount:1e4,salt:"you should override this value with a crypto secure random number",hash:"sha2-512"}};function validateKeyName(O){return null!=O&&"string"==typeof O&&O===hj(O.trim())&&O.length>0}async function randomDelay(){let O=200,U=1e3,$=Math.random()*(U-O)+O;await new Promise(O=>setTimeout(O,$))}function DsName(O){return new Key(hq+O)}function DsInfoName(O){return new Key(hz+O)}let DefaultKeyChain=class DefaultKeyChain{components;init;constructor(O,U){if(this.components=O,this.init=hK(h$,U),null!=this.init.pass&&this.init.pass?.length<20)throw Error("pass must be least 20 characters");if(this.init.dek?.keyLength!=null&&this.init.dek.keyLengthU.id===O);if(null==$)throw new errors_CodeError(`Key with id '${O}' does not exist.`,tC.ERR_KEY_NOT_FOUND);return $}catch(O){throw await randomDelay(),O}}async findKeyByName(O){if(!validateKeyName(O))throw await randomDelay(),new errors_CodeError(`Invalid key name '${O}'`,tC.ERR_INVALID_KEY_NAME);let U=DsInfoName(O);try{let O=await this.components.datastore.get(U);return JSON.parse((0,rB.B)(O))}catch(U){throw await randomDelay(),hH.error(U),new errors_CodeError(`Key '${O}' does not exist.`,tC.ERR_KEY_NOT_FOUND)}}async removeKey(O){if(!validateKeyName(O)||"self"===O)throw await randomDelay(),new errors_CodeError(`Invalid key name '${O}'`,tC.ERR_INVALID_KEY_NAME);let U=DsName(O),$=await this.findKeyByName(O),J=this.components.datastore.batch();return J.delete(U),J.delete(DsInfoName(O)),await J.commit(),$}async renameKey(O,U){if(!validateKeyName(O)||"self"===O)throw await randomDelay(),new errors_CodeError(`Invalid old key name '${O}'`,tC.ERR_OLD_KEY_NAME_INVALID);if(!validateKeyName(U)||"self"===U)throw await randomDelay(),new errors_CodeError(`Invalid new key name '${U}'`,tC.ERR_NEW_KEY_NAME_INVALID);let $=DsName(O),J=DsName(U),en=DsInfoName(O),es=DsInfoName(U),eo=await this.components.datastore.has(J);if(eo)throw await randomDelay(),new errors_CodeError(`Key '${U}' already exists`,tC.ERR_KEY_ALREADY_EXISTS);try{let O=await this.components.datastore.get($),eo=await this.components.datastore.get(en),ea=JSON.parse((0,rB.B)(eo));ea.name=U;let eu=this.components.datastore.batch();return eu.put(J,O),eu.put(es,(0,rJ.m)(JSON.stringify(ea))),eu.delete($),eu.delete(en),await eu.commit(),ea}catch(O){throw await randomDelay(),O}}async exportKey(O,U){if(!validateKeyName(O))throw await randomDelay(),new errors_CodeError(`Invalid key name '${O}'`,tC.ERR_INVALID_KEY_NAME);if(null==U)throw await randomDelay(),new errors_CodeError("Password is required",tC.ERR_PASSWORD_REQUIRED);let $=DsName(O);try{let O=await this.components.datastore.get($),J=(0,rB.B)(O),en=hV.get(this);if(null==en)throw new errors_CodeError("dek missing",tC.ERR_INVALID_PARAMETERS);let es=en.dek,eo=await keys_importKey(J,es),ea=await eo.export(U);return ea}catch(O){throw await randomDelay(),O}}async exportPeerId(O){let U="temporary-password",$=await this.exportKey(O,U),J=await keys_importKey($,U);return src_peerIdFromKeys(J.public.bytes,J.bytes)}async importKey(O,U,$){let J,en;if(!validateKeyName(O)||"self"===O)throw await randomDelay(),new errors_CodeError(`Invalid key name '${O}'`,tC.ERR_INVALID_KEY_NAME);if(null==U)throw await randomDelay(),new errors_CodeError("PEM encoded key is required",tC.ERR_PEM_REQUIRED);let es=DsName(O),eo=await this.components.datastore.has(es);if(eo)throw await randomDelay(),new errors_CodeError(`Key '${O}' already exists`,tC.ERR_KEY_ALREADY_EXISTS);try{J=await keys_importKey(U,$)}catch(O){throw await randomDelay(),new errors_CodeError("Cannot read the key, most likely the password is wrong",tC.ERR_CANNOT_READ_KEY)}try{en=await J.id();let O=hV.get(this);if(null==O)throw new errors_CodeError("dek missing",tC.ERR_INVALID_PARAMETERS);let $=O.dek;U=await J.export($)}catch(O){throw await randomDelay(),O}let ea={name:O,id:en},eu=this.components.datastore.batch();return eu.put(es,(0,rJ.m)(U)),eu.put(DsInfoName(O),(0,rJ.m)(JSON.stringify(ea))),await eu.commit(),ea}async importPeer(O,U){try{if(!validateKeyName(O))throw new errors_CodeError(`Invalid key name '${O}'`,tC.ERR_INVALID_KEY_NAME);if(null==U)throw new errors_CodeError("PeerId is required",tC.ERR_MISSING_PRIVATE_KEY);if(null==U.privateKey)throw new errors_CodeError("PeerId.privKey is required",tC.ERR_MISSING_PRIVATE_KEY);let $=await src_keys_unmarshalPrivateKey(U.privateKey),J=DsName(O),en=await this.components.datastore.has(J);if(en)throw await randomDelay(),new errors_CodeError(`Key '${O}' already exists`,tC.ERR_KEY_ALREADY_EXISTS);let es=hV.get(this);if(null==es)throw new errors_CodeError("dek missing",tC.ERR_INVALID_PARAMETERS);let eo=es.dek,ea=await $.export(eo),eu={name:O,id:U.toString()},ef=this.components.datastore.batch();return ef.put(J,(0,rJ.m)(ea)),ef.put(DsInfoName(O),(0,rJ.m)(JSON.stringify(eu))),await ef.commit(),eu}catch(O){throw await randomDelay(),O}}async getPrivateKey(O){if(!validateKeyName(O))throw await randomDelay(),new errors_CodeError(`Invalid key name '${O}'`,tC.ERR_INVALID_KEY_NAME);try{let U=DsName(O),$=await this.components.datastore.get(U);return(0,rB.B)($)}catch(U){throw await randomDelay(),hH.error(U),new errors_CodeError(`Key '${O}' does not exist.`,tC.ERR_KEY_NOT_FOUND)}}async rotateKeychainPass(O,U){if("string"!=typeof O)throw await randomDelay(),new errors_CodeError(`Invalid old pass type '${typeof O}'`,tC.ERR_INVALID_OLD_PASS_TYPE);if("string"!=typeof U)throw await randomDelay(),new errors_CodeError(`Invalid new pass type '${typeof U}'`,tC.ERR_INVALID_NEW_PASS_TYPE);if(U.length<20)throw await randomDelay(),new errors_CodeError(`Invalid pass length ${U.length}`,tC.ERR_INVALID_PASS_LENGTH);hH("recreating keychain");let $=hV.get(this);if(null==$)throw new errors_CodeError("dek missing",tC.ERR_INVALID_PARAMETERS);let J=$.dek;this.init.pass=U;let en=null!=U&&this.init.dek?.salt!=null?pbkdf2_pbkdf2(U,this.init.dek.salt,this.init.dek?.iterationCount,this.init.dek?.keyLength,this.init.dek?.hash):"";hV.set(this,{dek:en});let es=await this.listKeys();for(let O of es){let U=await this.components.datastore.get(DsName(O.name)),$=(0,rB.B)(U),es=await keys_importKey($,J),eo=en.toString(),ea=await es.export(eo),eu=this.components.datastore.batch(),ef={name:O.name,id:O.id};eu.put(DsName(O.name),(0,rJ.m)(ea)),eu.put(DsInfoName(O.name),(0,rJ.m)(JSON.stringify(ef))),await eu.commit()}hH("keychain reconstructed")}};function mapIterable(O,U){let $={[Symbol.iterator]:()=>$,next:()=>{let $=O.next(),J=$.value;if(!0===$.done||null==J){let O={done:!0,value:void 0};return O}return{done:!1,value:U(J)}}};return $}let PeerMap=class PeerMap{map;constructor(O){if(this.map=new Map,null!=O)for(let[U,$]of O.entries())this.map.set(U.toString(),$)}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(O){this.map.delete(O.toString())}entries(){return mapIterable(this.map.entries(),O=>[peerIdFromString(O[0]),O[1]])}forEach(O){this.map.forEach((U,$)=>{O(U,peerIdFromString($),this)})}get(O){return this.map.get(O.toString())}has(O){return this.map.has(O.toString())}set(O,U){this.map.set(O.toString(),U)}keys(){return mapIterable(this.map.keys(),O=>peerIdFromString(O))}values(){return this.map.values()}get size(){return this.map.size}};let PeerSet=class PeerSet{set;constructor(O){if(this.set=new Set,null!=O)for(let U of O)this.set.add(U.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(O){this.set.add(O.toString())}clear(){this.set.clear()}delete(O){this.set.delete(O.toString())}entries(){return mapIterable(this.set.entries(),O=>{let U=peerIdFromString(O[0]);return[U,U]})}forEach(O){this.set.forEach(U=>{let $=peerIdFromString(U);O($,$,this)})}has(O){return this.set.has(O.toString())}values(){return mapIterable(this.set.values(),O=>peerIdFromString(O))}intersection(O){let U=new PeerSet;for(let $ of O)this.has($)&&U.add($);return U}difference(O){let U=new PeerSet;for(let $ of this)O.has($)||U.add($);return U}union(O){let U=new PeerSet;for(let $ of O)U.add($);for(let O of this)U.add(O);return U}};let PeerList=class PeerList{list;constructor(O){if(this.list=[],null!=O)for(let U of O)this.list.push(U.toString())}[Symbol.iterator](){return mapIterable(this.list.entries(),O=>peerIdFromString(O[1]))}concat(O){let U=new PeerList(this);for(let $ of O)U.push($);return U}entries(){return mapIterable(this.list.entries(),O=>[O[0],peerIdFromString(O[1])])}every(O){return this.list.every((U,$)=>O(peerIdFromString(U),$,this))}filter(O){let U=new PeerList;return this.list.forEach(($,J)=>{let en=peerIdFromString($);O(en,J,this)&&U.push(en)}),U}find(O){let U=this.list.find((U,$)=>O(peerIdFromString(U),$,this));if(null!=U)return peerIdFromString(U)}findIndex(O){return this.list.findIndex((U,$)=>O(peerIdFromString(U),$,this))}forEach(O){this.list.forEach((U,$)=>{O(peerIdFromString(U),$,this)})}includes(O){return this.list.includes(O.toString())}indexOf(O){return this.list.indexOf(O.toString())}pop(){let O=this.list.pop();if(null!=O)return peerIdFromString(O)}push(...O){for(let U of O)this.list.push(U.toString())}shift(){let O=this.list.shift();if(null!=O)return peerIdFromString(O)}unshift(...O){let U=this.list.length;for(let $=O.length-1;$>-1;$--)U=this.list.unshift(O[$].toString());return U}get length(){return this.list.length}};!function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.id&&(U.uint32(10),U.bytes(O.id)),null!=O.pubKey&&(U.uint32(18),U.bytes(O.pubKey)),null!=O.privKey&&(U.uint32(26),U.bytes(O.privKey)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.id=O.bytes();break;case 2:$.pubKey=O.bytes();break;case 3:$.privKey=O.bytes();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(tB||(tB={}));let createEd25519PeerId=async()=>{let O=await src_keys_generateKeyPair("Ed25519"),U=await createFromPrivKey(O);if("Ed25519"===U.type)return U;throw Error(`Generated unexpected PeerId type "${U.type}"`)};async function createFromPrivKey(O){return src_peerIdFromKeys(src_keys_marshalPublicKey(O.public),keys_marshalPrivateKey(O))}let hW={ERR_SIGNATURE_NOT_VALID:"ERR_SIGNATURE_NOT_VALID"};!function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.publicKey&&O.publicKey.byteLength>0&&(U.uint32(10),U.bytes(O.publicKey)),null!=O.payloadType&&O.payloadType.byteLength>0&&(U.uint32(18),U.bytes(O.payloadType)),null!=O.payload&&O.payload.byteLength>0&&(U.uint32(26),U.bytes(O.payload)),null!=O.signature&&O.signature.byteLength>0&&(U.uint32(42),U.bytes(O.signature)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={publicKey:new Uint8Array(0),payloadType:new Uint8Array(0),payload:new Uint8Array(0),signature:new Uint8Array(0)},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.publicKey=O.bytes();break;case 2:$.payloadType=O.bytes();break;case 3:$.payload=O.bytes();break;case 5:$.signature=O.bytes();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(tN||(tN={}));let RecordEnvelope=class RecordEnvelope{static createFromProtobuf=async O=>{let U=tN.decode(O),$=await src_peerIdFromKeys(U.publicKey);return new RecordEnvelope({peerId:$,payloadType:U.payloadType,payload:U.payload,signature:U.signature})};static seal=async(O,U)=>{if(null==U.privateKey)throw Error("Missing private key");let $=O.domain,J=O.codec,en=O.marshal(),es=formatSignaturePayload($,J,en),eo=await src_keys_unmarshalPrivateKey(U.privateKey),ea=await eo.sign(es.subarray());return new RecordEnvelope({peerId:U,payloadType:J,payload:en,signature:ea})};static openAndCertify=async(O,U)=>{let $=await RecordEnvelope.createFromProtobuf(O),J=await $.validate(U);if(!J)throw new errors_CodeError("envelope signature is not valid for the given domain",hW.ERR_SIGNATURE_NOT_VALID);return $};peerId;payloadType;payload;signature;marshaled;constructor(O){let{peerId:U,payloadType:$,payload:J,signature:en}=O;this.peerId=U,this.payloadType=$,this.payload=J,this.signature=en}marshal(){if(null==this.peerId.publicKey)throw Error("Missing public key");return null==this.marshaled&&(this.marshaled=tN.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(O){return equals(this.marshal(),O.marshal())}async validate(O){let U=formatSignaturePayload(O,this.payloadType,this.payload);if(null==this.peerId.publicKey)throw Error("Missing public key");let $=src_keys_unmarshalPublicKey(this.peerId.publicKey);return $.verify(U.subarray(),this.signature)}};let formatSignaturePayload=(O,U,$)=>{let J=(0,rJ.m)(O),en=encode(J.byteLength),es=encode(U.length),eo=encode($.length);return new src_Uint8ArrayList(en,J,es,U,eo,$)};function arrayEquals(O,U){let sort=(O,U)=>O.toString().localeCompare(U.toString());return O.length===U.length&&(U.sort(sort),O.sort(sort).every((O,$)=>U[$].equals(O)))}let hY="libp2p-peer-record",hJ=Uint8Array.from([3,1]);!function(O){let U,$;!function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.multiaddr&&O.multiaddr.byteLength>0&&(U.uint32(10),U.bytes(O.multiaddr)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={multiaddr:new Uint8Array(0)},J=null==U?O.len:O.pos+U;for(;O.pos>>3==1?$.multiaddr=O.bytes():O.skipType(7&U)}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(U=O.AddressInfo||(O.AddressInfo={})),O.codec=()=>(null==$&&($=message((U,$,J={})=>{if(!1!==J.lengthDelimited&&$.fork(),null!=U.peerId&&U.peerId.byteLength>0&&($.uint32(10),$.bytes(U.peerId)),null!=U.seq&&0n!==U.seq&&($.uint32(16),$.uint64(U.seq)),null!=U.addresses)for(let J of U.addresses)$.uint32(26),O.AddressInfo.codec().encode(J,$);!1!==J.lengthDelimited&&$.ldelim()},(U,$)=>{let J={peerId:new Uint8Array(0),seq:0n,addresses:[]},en=null==$?U.len:U.pos+$;for(;U.pos>>3){case 1:J.peerId=U.bytes();break;case 2:J.seq=U.uint64();break;case 3:J.addresses.push(O.AddressInfo.codec().decode(U,U.uint32()));break;default:U.skipType(7&$)}}return J})),$),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(tD||(tD={}));let PeerRecord=class PeerRecord{static createFromProtobuf=O=>{let U=tD.decode(O),$=src_peerIdFromBytes(U.peerId),J=(U.addresses??[]).map(O=>src_multiaddr(O.multiaddr)),en=U.seq;return new PeerRecord({peerId:$,multiaddrs:J,seqNumber:en})};static DOMAIN=hY;static CODEC=hJ;peerId;multiaddrs;seqNumber;domain=PeerRecord.DOMAIN;codec=PeerRecord.CODEC;marshaled;constructor(O){let{peerId:U,multiaddrs:$,seqNumber:J}=O;this.peerId=U,this.multiaddrs=$??[],this.seqNumber=J??BigInt(Date.now())}marshal(){return null==this.marshaled&&(this.marshaled=tD.encode({peerId:this.peerId.toBytes(),seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map(O=>({multiaddr:O.bytes}))})),this.marshaled}equals(O){return!!(O instanceof PeerRecord&&this.peerId.equals(O.peerId)&&this.seqNumber===O.seqNumber&&arrayEquals(this.multiaddrs,O.multiaddrs))}};var hQ=$(8729);let p_timeout_TimeoutError=class p_timeout_TimeoutError extends Error{constructor(O){super(O),this.name="TimeoutError"}};let node_modules_p_timeout_AbortError=class node_modules_p_timeout_AbortError extends Error{constructor(O){super(),this.name="AbortError",this.message=O}};let p_timeout_getDOMException=O=>void 0===globalThis.DOMException?new node_modules_p_timeout_AbortError(O):new DOMException(O),p_timeout_getAbortedReason=O=>{let U=void 0===O.reason?p_timeout_getDOMException("This operation was aborted."):O.reason;return U instanceof Error?U:p_timeout_getDOMException(U)};function p_timeout_pTimeout(O,U,$,J){let en;let es=new Promise((es,eo)=>{if("number"!=typeof U||1!==Math.sign(U))throw TypeError(`Expected \`milliseconds\` to be a positive number, got \`${U}\``);if(U===Number.POSITIVE_INFINITY){es(O);return}if((J={customTimers:{setTimeout,clearTimeout},...J}).signal){let{signal:O}=J;O.aborted&&eo(p_timeout_getAbortedReason(O)),O.addEventListener("abort",()=>{eo(p_timeout_getAbortedReason(O))})}en=J.customTimers.setTimeout.call(void 0,()=>{if("function"==typeof $){try{es($())}catch(O){eo(O)}return}let J="string"==typeof $?$:`Promise timed out after ${U} milliseconds`,en=$ instanceof Error?$:new p_timeout_TimeoutError(J);"function"==typeof O.cancel&&O.cancel(),eo(en)},U),(async()=>{try{es(await O)}catch(O){eo(O)}finally{J.customTimers.clearTimeout.call(void 0,en)}})()});return es.clear=()=>{clearTimeout(en),en=void 0},es}function lowerBound(O,U,$){let J=0,en=O.length;for(;en>0;){let es=Math.trunc(en/2),eo=J+es;0>=$(O[eo],U)?(J=++eo,en-=es+1):en=es}return J}var __classPrivateFieldGet=function(O,U,$,J){if("a"===$&&!J)throw TypeError("Private accessor was defined without a getter");if("function"==typeof U?O!==U||!J:!U.has(O))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===$?J:"a"===$?J.call(O):J?J.value:U.get(O)};let PriorityQueue=class PriorityQueue{constructor(){tM.set(this,[])}enqueue(O,U){U={priority:0,...U};let $={priority:U.priority,run:O};if(this.size&&__classPrivateFieldGet(this,tM,"f")[this.size-1].priority>=U.priority){__classPrivateFieldGet(this,tM,"f").push($);return}let J=lowerBound(__classPrivateFieldGet(this,tM,"f"),$,(O,U)=>U.priority-O.priority);__classPrivateFieldGet(this,tM,"f").splice(J,0,$)}dequeue(){let O=__classPrivateFieldGet(this,tM,"f").shift();return null==O?void 0:O.run}filter(O){return __classPrivateFieldGet(this,tM,"f").filter(U=>U.priority===O.priority).map(O=>O.run)}get size(){return __classPrivateFieldGet(this,tM,"f").length}};tM=new WeakMap;var hZ=PriorityQueue,__classPrivateFieldSet=function(O,U,$,J,en){if("m"===J)throw TypeError("Private method is not writable");if("a"===J&&!en)throw TypeError("Private accessor was defined without a setter");if("function"==typeof U?O!==U||!en:!U.has(O))throw TypeError("Cannot write private member to an object whose class did not declare it");return"a"===J?en.call(O,$):en?en.value=$:U.set(O,$),$},dist_classPrivateFieldGet=function(O,U,$,J){if("a"===$&&!J)throw TypeError("Private accessor was defined without a getter");if("function"==typeof U?O!==U||!J:!U.has(O))throw TypeError("Cannot read private member from an object whose class did not declare it");return"m"===$?J:"a"===$?J.call(O):J?J.value:U.get(O)};let dist_AbortError=class dist_AbortError extends Error{};let PQueue=class PQueue extends hQ{constructor(O){var U,$,J,en;if(super(),tO.add(this),tL.set(this,void 0),tU.set(this,void 0),tF.set(this,0),tK.set(this,void 0),tj.set(this,void 0),tH.set(this,0),tq.set(this,void 0),tz.set(this,void 0),tV.set(this,void 0),tG.set(this,void 0),t$.set(this,0),tW.set(this,void 0),tY.set(this,void 0),tJ.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),!("number"==typeof(O={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:hZ,...O}).intervalCap&&O.intervalCap>=1))throw TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==($=null===(U=O.intervalCap)||void 0===U?void 0:U.toString())&&void 0!==$?$:""}\` (${typeof O.intervalCap})`);if(void 0===O.interval||!(Number.isFinite(O.interval)&&O.interval>=0))throw TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(en=null===(J=O.interval)||void 0===J?void 0:J.toString())&&void 0!==en?en:""}\` (${typeof O.interval})`);__classPrivateFieldSet(this,tL,O.carryoverConcurrencyCount,"f"),__classPrivateFieldSet(this,tU,O.intervalCap===Number.POSITIVE_INFINITY||0===O.interval,"f"),__classPrivateFieldSet(this,tK,O.intervalCap,"f"),__classPrivateFieldSet(this,tj,O.interval,"f"),__classPrivateFieldSet(this,tV,new O.queueClass,"f"),__classPrivateFieldSet(this,tG,O.queueClass,"f"),this.concurrency=O.concurrency,this.timeout=O.timeout,__classPrivateFieldSet(this,tJ,!0===O.throwOnTimeout,"f"),__classPrivateFieldSet(this,tY,!1===O.autoStart,"f")}get concurrency(){return dist_classPrivateFieldGet(this,tW,"f")}set concurrency(O){if(!("number"==typeof O&&O>=1))throw TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${O}\` (${typeof O})`);__classPrivateFieldSet(this,tW,O,"f"),dist_classPrivateFieldGet(this,tO,"m",ru).call(this)}async add(O,U={}){return U={timeout:this.timeout,throwOnTimeout:dist_classPrivateFieldGet(this,tJ,"f"),...U},new Promise(($,J)=>{dist_classPrivateFieldGet(this,tV,"f").enqueue(async()=>{var en,es,eo;__classPrivateFieldSet(this,t$,(es=dist_classPrivateFieldGet(this,t$,"f"),++es),"f"),__classPrivateFieldSet(this,tF,(eo=dist_classPrivateFieldGet(this,tF,"f"),++eo),"f");try{if(null===(en=U.signal)||void 0===en?void 0:en.aborted)throw new dist_AbortError("The task was aborted.");let J=O({signal:U.signal});U.timeout&&(J=p_timeout_pTimeout(Promise.resolve(J),U.timeout)),U.signal&&(J=Promise.race([J,dist_classPrivateFieldGet(this,tO,"m",rd).call(this,U.signal)]));let es=await J;$(es),this.emit("completed",es)}catch(O){if(O instanceof p_timeout_TimeoutError&&!U.throwOnTimeout){$();return}J(O),this.emit("error",O)}finally{dist_classPrivateFieldGet(this,tO,"m",tX).call(this)}},U),this.emit("add"),dist_classPrivateFieldGet(this,tO,"m",rn).call(this)})}async addAll(O,U){return Promise.all(O.map(async O=>this.add(O,U)))}start(){return dist_classPrivateFieldGet(this,tY,"f")&&(__classPrivateFieldSet(this,tY,!1,"f"),dist_classPrivateFieldGet(this,tO,"m",ru).call(this)),this}pause(){__classPrivateFieldSet(this,tY,!0,"f")}clear(){__classPrivateFieldSet(this,tV,new(dist_classPrivateFieldGet(this,tG,"f")),"f")}async onEmpty(){0!==dist_classPrivateFieldGet(this,tV,"f").size&&await dist_classPrivateFieldGet(this,tO,"m",rf).call(this,"empty")}async onSizeLessThan(O){dist_classPrivateFieldGet(this,tV,"f").sizedist_classPrivateFieldGet(this,tV,"f").size{dist_classPrivateFieldGet(this,tO,"m",t8).call(this)},U),"f"),!0;__classPrivateFieldSet(this,tF,dist_classPrivateFieldGet(this,tL,"f")?dist_classPrivateFieldGet(this,t$,"f"):0,"f")}return!1},rn=function(){if(0===dist_classPrivateFieldGet(this,tV,"f").size)return dist_classPrivateFieldGet(this,tq,"f")&&clearInterval(dist_classPrivateFieldGet(this,tq,"f")),__classPrivateFieldSet(this,tq,void 0,"f"),this.emit("empty"),0===dist_classPrivateFieldGet(this,t$,"f")&&this.emit("idle"),!1;if(!dist_classPrivateFieldGet(this,tY,"f")){let O=!dist_classPrivateFieldGet(this,tO,"a",t9);if(dist_classPrivateFieldGet(this,tO,"a",tQ)&&dist_classPrivateFieldGet(this,tO,"a",tZ)){let U=dist_classPrivateFieldGet(this,tV,"f").dequeue();return!!U&&(this.emit("active"),U(),O&&dist_classPrivateFieldGet(this,tO,"m",ri).call(this),!0)}}return!1},ri=function(){dist_classPrivateFieldGet(this,tU,"f")||void 0!==dist_classPrivateFieldGet(this,tq,"f")||(__classPrivateFieldSet(this,tq,setInterval(()=>{dist_classPrivateFieldGet(this,tO,"m",rc).call(this)},dist_classPrivateFieldGet(this,tj,"f")),"f"),__classPrivateFieldSet(this,tH,Date.now()+dist_classPrivateFieldGet(this,tj,"f"),"f"))},rc=function(){0===dist_classPrivateFieldGet(this,tF,"f")&&0===dist_classPrivateFieldGet(this,t$,"f")&&dist_classPrivateFieldGet(this,tq,"f")&&(clearInterval(dist_classPrivateFieldGet(this,tq,"f")),__classPrivateFieldSet(this,tq,void 0,"f")),__classPrivateFieldSet(this,tF,dist_classPrivateFieldGet(this,tL,"f")?dist_classPrivateFieldGet(this,t$,"f"):0,"f"),dist_classPrivateFieldGet(this,tO,"m",ru).call(this)},ru=function(){for(;dist_classPrivateFieldGet(this,tO,"m",rn).call(this););},rd=async function(O){return new Promise((U,$)=>{O.addEventListener("abort",()=>{$(new dist_AbortError("The task was aborted."))},{once:!0})})},rf=async function(O,U){return new Promise($=>{let listener=()=>{(!U||U())&&(this.off(O,listener),$())};this.on(O,listener)})};var hX=PQueue;let index_browser_nanoid=(O=21)=>crypto.getRandomValues(new Uint8Array(O)).reduce((O,U)=>((U&=63)<36?O+=U.toString(36):U<62?O+=(U-26).toString(36).toUpperCase():U>62?O+="-":O+="_",O),""),de="lock:worker:request-read",dr="lock:worker:release-read",dn="lock:master:grant-read",di="lock:worker:request-write",da="lock:worker:release-write",dc="lock:master:grant-write",du={},observable=O=>{O.addEventListener("message",U=>{observable.dispatchEvent("message",O,U)}),null!=O.port&&O.port.addEventListener("message",U=>{observable.dispatchEvent("message",O,U)})};observable.addEventListener=(O,U)=>{null==du[O]&&(du[O]=[]),du[O].push(U)},observable.removeEventListener=(O,U)=>{null!=du[O]&&(du[O]=du[O].filter(O=>O===U))},observable.dispatchEvent=function(O,U,$){null!=du[O]&&du[O].forEach(O=>O(U,$))};var df=observable;let handleWorkerLockRequest=(O,U,$,J,en)=>(es,eo)=>{if(eo.data.type!==$)return;let ea={type:eo.data.type,name:eo.data.name,identifier:eo.data.identifier};O.dispatchEvent(new MessageEvent(U,{data:{name:ea.name,handler:async()=>(es.postMessage({type:en,name:ea.name,identifier:ea.identifier}),await new Promise(O=>{let releaseEventListener=U=>{if(null==U||null==U.data)return;let $={type:U.data.type,name:U.data.name,identifier:U.data.identifier};$.type===J&&$.identifier===ea.identifier&&(es.removeEventListener("message",releaseEventListener),O())};es.addEventListener("message",releaseEventListener)}))}}))},makeWorkerLockRequest=(O,U,$,J)=>async()=>{let en=index_browser_nanoid();return globalThis.postMessage({type:U,identifier:en,name:O}),await new Promise(U=>{let listener=es=>{if(null==es||null==es.data)return;let eo={type:es.data.type,identifier:es.data.identifier};eo.type===$&&eo.identifier===en&&(globalThis.removeEventListener("message",listener),U(()=>{globalThis.postMessage({type:J,identifier:en,name:O})}))};globalThis.addEventListener("message",listener)})},dp={singleProcess:!1};var src_browser=O=>{O=Object.assign({},dp,O);let U=!!globalThis.document||O.singleProcess;if(U){let O=new EventTarget;return df.addEventListener("message",handleWorkerLockRequest(O,"requestReadLock",de,dr,dn)),df.addEventListener("message",handleWorkerLockRequest(O,"requestWriteLock",di,da,dc)),O}return{isWorker:!0,readLock:O=>makeWorkerLockRequest(O,de,dn,dr),writeLock:O=>makeWorkerLockRequest(O,di,dc,da)}};let dg={};async function createReleaseable(O,U){let $;let J=new Promise(O=>{$=O});return O.add(async()=>await pTimeout((async()=>await new Promise(O=>{$(()=>{O()})}))(),{milliseconds:U.timeout})),await J}let createMutex=(O,U)=>{let $;if(!0===ea.isWorker)return{readLock:ea.readLock(O,U),writeLock:ea.writeLock(O,U)};let J=new hX({concurrency:1});return{async readLock(){if(null!=$)return await createReleaseable($,U);$=new hX({concurrency:U.concurrency,autoStart:!1});let O=$,en=createReleaseable($,U);return J.add(async()=>(O.start(),await O.onIdle().then(()=>{$===O&&($=null)}))),await en},writeLock:async()=>($=null,await createReleaseable(J,U))}},d_={name:"lock",concurrency:1/0,timeout:846e5,singleProcess:!1};function createMortice(O){let U=Object.assign({},d_,O);return null==ea&&!0!==(ea=src_browser(U)).isWorker&&(ea.addEventListener("requestReadLock",O=>{null!=dg[O.data.name]&&dg[O.data.name].readLock().then(async U=>await O.data.handler().finally(()=>U()))}),ea.addEventListener("requestWriteLock",async O=>{null!=dg[O.data.name]&&dg[O.data.name].writeLock().then(async U=>await O.data.handler().finally(()=>U()))})),null==dg[U.name]&&(dg[U.name]=createMutex(U.name,U)),dg[U.name]}let dw={ERR_INVALID_PARAMETERS:"ERR_INVALID_PARAMETERS"};function bytesToPeer(O,U){let $=rp.decode(U);null!=$.publicKey&&null==O.publicKey&&(O=peerIdFromPeerId({...O,publicKey:O.publicKey}));let J=new Map,en=BigInt(Date.now());for(let[O,U]of $.tags.entries())null!=U.expiry&&U.expiry({multiaddr:src_multiaddr(O),isCertified:U??!1})),metadata:$.metadata,peerRecordEnvelope:$.peerRecordEnvelope??void 0,tags:J}}!function(O){let U,$,J;(function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.key&&""!==O.key&&(U.uint32(10),U.string(O.key)),null!=O.value&&O.value.byteLength>0&&(U.uint32(18),U.bytes(O.value)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={key:"",value:new Uint8Array(0)},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.key=O.string();break;case 2:$.value=O.bytes();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())})(U=O.Peer$metadataEntry||(O.Peer$metadataEntry={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.key&&""!==O.key&&(U.uint32(10),U.string(O.key)),null!=O.value&&(U.uint32(18),rm.codec().encode(O.value,U)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={key:""},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.key=O.string();break;case 2:$.value=rm.codec().decode(O,O.uint32());break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}($=O.Peer$tagsEntry||(O.Peer$tagsEntry={})),O.codec=()=>(null==J&&(J=message((U,$,J={})=>{if(!1!==J.lengthDelimited&&$.fork(),null!=U.addresses)for(let O of U.addresses)$.uint32(10),rg.codec().encode(O,$);if(null!=U.protocols)for(let O of U.protocols)$.uint32(18),$.string(O);if(null!=U.publicKey&&($.uint32(34),$.bytes(U.publicKey)),null!=U.peerRecordEnvelope&&($.uint32(42),$.bytes(U.peerRecordEnvelope)),null!=U.metadata&&0!==U.metadata.size)for(let[J,en]of U.metadata.entries())$.uint32(50),O.Peer$metadataEntry.codec().encode({key:J,value:en},$);if(null!=U.tags&&0!==U.tags.size)for(let[J,en]of U.tags.entries())$.uint32(58),O.Peer$tagsEntry.codec().encode({key:J,value:en},$);!1!==J.lengthDelimited&&$.ldelim()},(U,$)=>{let J={addresses:[],protocols:[],metadata:new Map,tags:new Map},en=null==$?U.len:U.pos+$;for(;U.pos>>3){case 1:J.addresses.push(rg.codec().decode(U,U.uint32()));break;case 2:J.protocols.push(U.string());break;case 4:J.publicKey=U.bytes();break;case 5:J.peerRecordEnvelope=U.bytes();break;case 6:{let $=O.Peer$metadataEntry.codec().decode(U,U.uint32());J.metadata.set($.key,$.value);break}case 7:{let $=O.Peer$tagsEntry.codec().decode(U,U.uint32());J.tags.set($.key,$.value);break}default:U.skipType(7&$)}}return J})),J),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(rp||(rp={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.multiaddr&&O.multiaddr.byteLength>0&&(U.uint32(10),U.bytes(O.multiaddr)),null!=O.isCertified&&(U.uint32(16),U.bool(O.isCertified)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={multiaddr:new Uint8Array(0)},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.multiaddr=O.bytes();break;case 2:$.isCertified=O.bool();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(rg||(rg={})),function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{!1!==$.lengthDelimited&&U.fork(),null!=O.value&&0!==O.value&&(U.uint32(8),U.uint32(O.value)),null!=O.expiry&&(U.uint32(16),U.uint64(O.expiry)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={value:0},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 1:$.value=O.uint32();break;case 2:$.expiry=O.uint64();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(rm||(rm={}));let dE="/peers/";function peerIdToDatastoreKey(O){if(!isPeerId(O)||null==O.type)throw new errors_CodeError("Invalid PeerId",dw.ERR_INVALID_PARAMETERS);let U=O.toCID().toString();return new Key(`${dE}${U}`)}async function dedupeFilterAndSortAddresses(O,U,$){let J=new Map;for(let en of $){if(null==en)continue;if(en.multiaddr instanceof Uint8Array&&(en.multiaddr=src_multiaddr(en.multiaddr)),!isMultiaddr(en.multiaddr))throw new errors_CodeError("Multiaddr was invalid",dw.ERR_INVALID_PARAMETERS);if(!await U(O,en.multiaddr))continue;let $=en.isCertified??!1,es=en.multiaddr.toString(),eo=J.get(es);null!=eo?en.isCertified=eo.isCertified||$:J.set(es,{multiaddr:en.multiaddr,isCertified:$})}return[...J.values()].sort((O,U)=>O.multiaddr.toString().localeCompare(U.multiaddr.toString())).map(({isCertified:O,multiaddr:U})=>({isCertified:O,multiaddr:U.bytes}))}async function toPeerPB(O,U,$,J){if(null==U)throw new errors_CodeError("Invalid PeerData",dw.ERR_INVALID_PARAMETERS);if(null!=U.publicKey&&null!=O.publicKey&&!equals(U.publicKey,O.publicKey))throw new errors_CodeError("publicKey bytes do not match peer id publicKey bytes",dw.ERR_INVALID_PARAMETERS);let en=J.existingPeer;if(null!=en&&!O.equals(en.id))throw new errors_CodeError("peer id did not match existing peer id",dw.ERR_INVALID_PARAMETERS);let es=en?.addresses??[],eo=new Set(en?.protocols??[]),ea=en?.metadata??new Map,eu=en?.tags??new Map,ef=en?.peerRecordEnvelope;if("patch"===$){if((null!=U.multiaddrs||null!=U.addresses)&&(es=[],null!=U.multiaddrs&&es.push(...U.multiaddrs.map(O=>({isCertified:!1,multiaddr:O}))),null!=U.addresses&&es.push(...U.addresses)),null!=U.protocols&&(eo=new Set(U.protocols)),null!=U.metadata){let O=U.metadata instanceof Map?[...U.metadata.entries()]:Object.entries(U.metadata);ea=createSortedMap(O,{validate:validateMetadata})}if(null!=U.tags){let O=U.tags instanceof Map?[...U.tags.entries()]:Object.entries(U.tags);eu=createSortedMap(O,{validate:validateTag,map:mapTag})}null!=U.peerRecordEnvelope&&(ef=U.peerRecordEnvelope)}if("merge"===$){if(null!=U.multiaddrs&&es.push(...U.multiaddrs.map(O=>({isCertified:!1,multiaddr:O}))),null!=U.addresses&&es.push(...U.addresses),null!=U.protocols&&(eo=new Set([...eo,...U.protocols])),null!=U.metadata){let O=U.metadata instanceof Map?[...U.metadata.entries()]:Object.entries(U.metadata);for(let[U,$]of O)null==$?ea.delete(U):ea.set(U,$);ea=createSortedMap([...ea.entries()],{validate:validateMetadata})}if(null!=U.tags){let O=U.tags instanceof Map?[...U.tags.entries()]:Object.entries(U.tags),$=new Map(eu);for(let[U,J]of O)null==J?$.delete(U):$.set(U,J);eu=createSortedMap([...$.entries()],{validate:validateTag,map:mapTag})}null!=U.peerRecordEnvelope&&(ef=U.peerRecordEnvelope)}let eg={addresses:await dedupeFilterAndSortAddresses(O,J.addressFilter??(async()=>!0),es),protocols:[...eo.values()].sort((O,U)=>O.localeCompare(U)),metadata:ea,tags:eu,publicKey:en?.id.publicKey??U.publicKey??O.publicKey,peerRecordEnvelope:ef};return"RSA"!==O.type&&delete eg.publicKey,eg}function createSortedMap(O,U){let $=new Map;for(let[$,J]of O)null!=J&&U.validate($,J);for(let[J,en]of O.sort(([O],[U])=>O.localeCompare(U)))null!=en&&$.set(J,U.map?.(J,en)??en);return $}function validateMetadata(O,U){if("string"!=typeof O)throw new errors_CodeError("Metadata key must be a string",dw.ERR_INVALID_PARAMETERS);if(!(U instanceof Uint8Array))throw new errors_CodeError("Metadata value must be a Uint8Array",dw.ERR_INVALID_PARAMETERS)}function validateTag(O,U){if("string"!=typeof O)throw new errors_CodeError("Tag name must be a string",dw.ERR_INVALID_PARAMETERS);if(null!=U.value){if(parseInt(`${U.value}`,10)!==U.value)throw new errors_CodeError("Tag value must be an integer",dw.ERR_INVALID_PARAMETERS);if(U.value<0||U.value>100)throw new errors_CodeError("Tag value must be between 0-100",dw.ERR_INVALID_PARAMETERS)}if(null!=U.ttl){if(parseInt(`${U.ttl}`,10)!==U.ttl)throw new errors_CodeError("Tag ttl must be an integer",dw.ERR_INVALID_PARAMETERS);if(U.ttl<0)throw new errors_CodeError("Tag ttl must be between greater than 0",dw.ERR_INVALID_PARAMETERS)}}function mapTag(O,U){let $;return null!=U.expiry&&($=U.expiry),null!=U.ttl&&($=BigInt(Date.now()+Number(U.ttl))),{value:U.value??0,expiry:$}}function decodePeer(O,U,$){let J=O.toString().split("/")[2],en=r$.base32.decode(J),es=src_peerIdFromBytes(en),eo=$.get(es);if(null!=eo)return eo;let ea=bytesToPeer(es,U);return $.set(es,ea),ea}function mapQuery(O,U){return null==O?{}:{prefix:dE,filters:(O.filters??[]).map(O=>({key:$,value:J})=>O(decodePeer($,J,U))),orders:(O.orders??[]).map(O=>($,J)=>O(decodePeer($.key,$.value,U),decodePeer(J.key,J.value,U)))}}let PersistentStore=class PersistentStore{peerId;datastore;lock;addressFilter;constructor(O,U={}){this.peerId=O.peerId,this.datastore=O.datastore,this.addressFilter=U.addressFilter,this.lock=createMortice({name:"peer-store",singleProcess:!0})}async has(O){return this.datastore.has(peerIdToDatastoreKey(O))}async delete(O){if(this.peerId.equals(O))throw new errors_CodeError("Cannot delete self peer",dw.ERR_INVALID_PARAMETERS);await this.datastore.delete(peerIdToDatastoreKey(O))}async load(O){let U=await this.datastore.get(peerIdToDatastoreKey(O));return bytesToPeer(O,U)}async save(O,U){let{existingBuf:$,existingPeer:J}=await this.#s(O),en=await toPeerPB(O,U,"patch",{addressFilter:this.addressFilter});return this.#o(O,en,$,J)}async patch(O,U){let{existingBuf:$,existingPeer:J}=await this.#s(O),en=await toPeerPB(O,U,"patch",{addressFilter:this.addressFilter,existingPeer:J});return this.#o(O,en,$,J)}async merge(O,U){let{existingBuf:$,existingPeer:J}=await this.#s(O),en=await toPeerPB(O,U,"merge",{addressFilter:this.addressFilter,existingPeer:J});return this.#o(O,en,$,J)}async *all(O){let U=new PeerMap;for await(let{key:$,value:J}of this.datastore.query(mapQuery(O??{},U))){let O=decodePeer($,J,U);O.id.equals(this.peerId)||(yield O)}}async #s(O){try{let U=await this.datastore.get(peerIdToDatastoreKey(O)),$=bytesToPeer(O,U);return{existingBuf:U,existingPeer:$}}catch(O){if("ERR_NOT_FOUND"!==O.code)throw O}return{}}async #o(O,U,$,J){let en=rp.encode(U);return null!=$&&equals(en,$)?{peer:bytesToPeer(O,en),previous:J,updated:!1}:(await this.datastore.put(peerIdToDatastoreKey(O),en),{peer:bytesToPeer(O,en),previous:J,updated:!0})}};let dS=logger("libp2p:peer-store");let PersistentPeerStore=class PersistentPeerStore{store;events;peerId;constructor(O,U={}){this.events=O.events,this.peerId=O.peerId,this.store=new PersistentStore(O,U)}async forEach(O,U){dS.trace("forEach await read lock");let $=await this.store.lock.readLock();dS.trace("forEach got read lock");try{for await(let $ of this.store.all(U))O($)}finally{dS.trace("forEach release read lock"),$()}}async all(O){dS.trace("all await read lock");let U=await this.store.lock.readLock();dS.trace("all got read lock");try{return await dist_src(this.store.all(O))}finally{dS.trace("all release read lock"),U()}}async delete(O){dS.trace("delete await write lock");let U=await this.store.lock.writeLock();dS.trace("delete got write lock");try{await this.store.delete(O)}finally{dS.trace("delete release write lock"),U()}}async has(O){dS.trace("has await read lock");let U=await this.store.lock.readLock();dS.trace("has got read lock");try{return await this.store.has(O)}finally{dS.trace("has release read lock"),U()}}async get(O){dS.trace("get await read lock");let U=await this.store.lock.readLock();dS.trace("get got read lock");try{return await this.store.load(O)}finally{dS.trace("get release read lock"),U()}}async save(O,U){dS.trace("save await write lock");let $=await this.store.lock.writeLock();dS.trace("save got write lock");try{let $=await this.store.save(O,U);return this.#a(O,$),$.peer}finally{dS.trace("save release write lock"),$()}}async patch(O,U){dS.trace("patch await write lock");let $=await this.store.lock.writeLock();dS.trace("patch got write lock");try{let $=await this.store.patch(O,U);return this.#a(O,$),$.peer}finally{dS.trace("patch release write lock"),$()}}async merge(O,U){dS.trace("merge await write lock");let $=await this.store.lock.writeLock();dS.trace("merge got write lock");try{let $=await this.store.merge(O,U);return this.#a(O,$),$.peer}finally{dS.trace("merge release write lock"),$()}}async consumePeerRecord(O,U){let $;let J=await RecordEnvelope.openAndCertify(O,PeerRecord.DOMAIN);if(U?.equals(J.peerId)===!1)return dS("envelope peer id was not the expected peer id - expected: %p received: %p",U,J.peerId),!1;let en=PeerRecord.createFromProtobuf(J.payload);try{$=await this.get(J.peerId)}catch(O){if("ERR_NOT_FOUND"!==O.code)throw O}if($?.peerRecordEnvelope!=null){let O=await RecordEnvelope.createFromProtobuf($.peerRecordEnvelope),U=PeerRecord.createFromProtobuf(O.payload);if(U.seqNumber>=en.seqNumber)return dS("sequence number was lower or equal to existing sequence number - stored: %d received: %d",U.seqNumber,en.seqNumber),!1}return await this.patch(en.peerId,{peerRecordEnvelope:O,addresses:en.multiaddrs.map(O=>({isCertified:!0,multiaddr:O}))}),!0}#a(O,U){U.updated&&(this.peerId.equals(O)?this.events.safeDispatchEvent("self:peer:update",{detail:U}):this.events.safeDispatchEvent("peer:update",{detail:U}))}};function it_drain_dist_src_isAsyncIterable(O){return null!=O[Symbol.asyncIterator]}var it_drain_dist_src=function(O){if(it_drain_dist_src_isAsyncIterable(O))return(async()=>{for await(let U of O);})();for(let U of O);},it_peekable_dist_src=function(O){let[U,$]=null!=O[Symbol.asyncIterator]?[O[Symbol.asyncIterator](),Symbol.asyncIterator]:[O[Symbol.iterator](),Symbol.iterator],J=[];return{peek:()=>U.next(),push:O=>{J.push(O)},next:()=>J.length>0?{done:!1,value:J.shift()}:U.next(),[$](){return this}}};function it_filter_dist_src_isAsyncIterable(O){return null!=O[Symbol.asyncIterator]}var it_filter_dist_src=function(O,U){if(it_filter_dist_src_isAsyncIterable(O))return async function*(){for await(let $ of O)await U($)&&(yield $)}();let $=it_peekable_dist_src(O),{value:J,done:en}=$.next();if(!0===en)return function*(){}();let es=U(J);if("function"==typeof es.then)return async function*(){for await(let O of(await es&&(yield J),$))await U(O)&&(yield O)}();let eo=U;return function*(){for(let O of(!0===es&&(yield J),$))eo(O)&&(yield O)}()};function it_sort_dist_src_isAsyncIterable(O){return null!=O[Symbol.asyncIterator]}var it_sort_dist_src=function(O,U){return it_sort_dist_src_isAsyncIterable(O)?async function*(){let $=await dist_src(O);yield*$.sort(U)}():function*(){let $=dist_src(O);yield*$.sort(U)}()};function it_take_dist_src_isAsyncIterable(O){return null!=O[Symbol.asyncIterator]}var it_take_dist_src=function(O,U){return it_take_dist_src_isAsyncIterable(O)?async function*(){let $=0;if(!(U<1)){for await(let J of O)if(yield J,++$===U)return}}():function*(){let $=0;if(!(U<1)){for(let J of O)if(yield J,++$===U)return}}()};let BaseDatastore=class BaseDatastore{put(O,U,$){return Promise.reject(Error(".put is not implemented"))}get(O,U){return Promise.reject(Error(".get is not implemented"))}has(O,U){return Promise.reject(Error(".has is not implemented"))}delete(O,U){return Promise.reject(Error(".delete is not implemented"))}async *putMany(O,U={}){for await(let{key:$,value:J}of O)await this.put($,J,U),yield $}async *getMany(O,U={}){for await(let $ of O)yield{key:$,value:await this.get($,U)}}async *deleteMany(O,U={}){for await(let $ of O)await this.delete($,U),yield $}batch(){let O=[],U=[];return{put(U,$){O.push({key:U,value:$})},delete(O){U.push(O)},commit:async $=>{await it_drain_dist_src(this.putMany(O,$)),O=[],await it_drain_dist_src(this.deleteMany(U,$)),U=[]}}}async *_all(O,U){throw Error("._all is not implemented")}async *_allKeys(O,U){throw Error("._allKeys is not implemented")}query(O,U){let $=this._all(O,U);if(null!=O.prefix){let U=O.prefix;$=it_filter_dist_src($,O=>O.key.toString().startsWith(U))}if(Array.isArray(O.filters)&&($=O.filters.reduce((O,U)=>it_filter_dist_src(O,U),$)),Array.isArray(O.orders)&&($=O.orders.reduce((O,U)=>it_sort_dist_src(O,U),$)),null!=O.offset){let U=0,J=O.offset;$=it_filter_dist_src($,()=>U++>=J)}return null!=O.limit&&($=it_take_dist_src($,O.limit)),$}queryKeys(O,U){let $=this._allKeys(O,U);if(null!=O.prefix){let U=O.prefix;$=it_filter_dist_src($,O=>O.toString().startsWith(U))}if(Array.isArray(O.filters)&&($=O.filters.reduce((O,U)=>it_filter_dist_src(O,U),$)),Array.isArray(O.orders)&&($=O.orders.reduce((O,U)=>it_sort_dist_src(O,U),$)),null!=O.offset){let U=O.offset,J=0;$=it_filter_dist_src($,()=>J++>=U)}return null!=O.limit&&($=it_take_dist_src($,O.limit)),$}};function notFoundError(O){return sC(O=O??Error("Not Found"),"ERR_NOT_FOUND")}let MemoryDatastore=class MemoryDatastore extends BaseDatastore{data;constructor(){super(),this.data=new Map}put(O,U){return this.data.set(O.toString(),U),O}get(O){let U=this.data.get(O.toString());if(null==U)throw notFoundError();return U}has(O){return this.data.has(O.toString())}delete(O){this.data.delete(O.toString())}*_all(){for(let[O,U]of this.data.entries())yield{key:new Key(O),value:U}}*_allKeys(){for(let O of this.data.keys())yield new Key(O)}};function debounce(O,U){let $;return function(){let later=function(){$=void 0,O()};clearTimeout($),$=setTimeout(later,U)}}let dA=logger("libp2p:address-manager"),defaultAddressFilter=O=>O;function stripPeerId(O,U){let $=O.getPeerId();if(null!=$){let J=peerIdFromString($);J.equals(U)&&(O=O.decapsulate(src_multiaddr(`/p2p/${U.toString()}`)))}return O}let DefaultAddressManager=class DefaultAddressManager{components;listen;announce;observed;announceFilter;constructor(O,U={}){let{listen:$=[],announce:J=[]}=U;this.components=O,this.listen=$.map(O=>O.toString()),this.announce=new Set(J.map(O=>O.toString())),this.observed=new Map,this.announceFilter=U.announceFilter??defaultAddressFilter,this._updatePeerStoreAddresses=debounce(this._updatePeerStoreAddresses.bind(this),1e3),O.events.addEventListener("transport:listening",()=>{this._updatePeerStoreAddresses()}),O.events.addEventListener("transport:close",()=>{this._updatePeerStoreAddresses()})}_updatePeerStoreAddresses(){let O=this.getAnnounceAddrs().concat(this.components.transportManager.getAddrs()).concat([...this.observed.entries()].filter(([O,U])=>U.confident).map(([O])=>src_multiaddr(O))).map(O=>O.getPeerId()===this.components.peerId.toString()?O.decapsulate(`/p2p/${this.components.peerId.toString()}`):O);this.components.peerStore.patch(this.components.peerId,{multiaddrs:O}).catch(O=>{dA.error("error updating addresses",O)})}getListenAddrs(){return Array.from(this.listen).map(O=>src_multiaddr(O))}getAnnounceAddrs(){return Array.from(this.announce).map(O=>src_multiaddr(O))}getObservedAddrs(){return Array.from(this.observed).map(([O])=>src_multiaddr(O))}addObservedAddr(O){O=stripPeerId(O,this.components.peerId);let U=O.toString();this.observed.has(U)||this.observed.set(U,{confident:!1})}confirmObservedAddr(O){O=stripPeerId(O,this.components.peerId);let U=O.toString(),$=this.observed.get(U)??{confident:!1},J=$.confident;this.observed.set(U,{confident:!0}),J||this._updatePeerStoreAddresses()}removeObservedAddr(O){O=stripPeerId(O,this.components.peerId);let U=O.toString();this.observed.delete(U)}getAddresses(){let O=this.getAnnounceAddrs().map(O=>O.toString());0===O.length&&(O=this.components.transportManager.getAddrs().map(O=>O.toString())),O=O.concat(Array.from(this.observed).filter(([O,U])=>U.confident).map(([O])=>O));let U=new Set(O);return this.announceFilter(Array.from(U).map(O=>src_multiaddr(O))).map(O=>O.protos().pop()?.path===!0||O.getPeerId()===this.components.peerId.toString()?O:O.encapsulate(`/p2p/${this.components.peerId.toString()}`))}};function isStartable(O){return null!=O&&"function"==typeof O.start&&"function"==typeof O.stop}let DefaultComponents=class DefaultComponents{components={};_started=!1;constructor(O={}){for(let[U,$]of(this.components={},Object.entries(O)))this.components[U]=$}isStarted(){return this._started}async _invokeStartableMethod(O){await Promise.all(Object.values(this.components).filter(O=>isStartable(O)).map(async U=>{await U[O]?.()}))}async beforeStart(){await this._invokeStartableMethod("beforeStart")}async start(){await this._invokeStartableMethod("start"),this._started=!0}async afterStart(){await this._invokeStartableMethod("afterStart")}async beforeStop(){await this._invokeStartableMethod("beforeStop")}async stop(){await this._invokeStartableMethod("stop"),this._started=!1}async afterStop(){await this._invokeStartableMethod("afterStop")}};let dI=["metrics","connectionProtector"],dT=["components","isStarted","beforeStart","start","afterStart","beforeStop","stop","afterStop","then","_invokeStartableMethod"];function defaultComponents(O={}){let U=new DefaultComponents(O),$=new Proxy(U,{get(O,$,J){if("string"==typeof $&&!dT.includes($)){let O=U.components[$];if(null==O&&!dI.includes($))throw new errors_CodeError(`${$} not set`,"ERR_SERVICE_MISSING");return O}return Reflect.get(O,$,J)},set:(O,$,J)=>("string"==typeof $?U.components[$]=J:Reflect.set(O,$,J),!0)});return $}var dR=$(5194);let dC="[a-fA-F\\d:]",boundry=O=>O&&O.includeBoundaries?`(?:(?<=\\s|^)(?=${dC})|(?<=${dC})(?=\\s|$))`:"",dB="(?: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}",dN="[a-fA-F\\d]{1,4}",dD=` +(?: +(?:${dN}:){7}(?:${dN}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8 +(?:${dN}:){6}(?:${dB}|:${dN}|:)| // 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 +(?:${dN}:){5}(?::${dB}|(?::${dN}){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 +(?:${dN}:){4}(?:(?::${dN}){0,1}:${dB}|(?::${dN}){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 +(?:${dN}:){3}(?:(?::${dN}){0,2}:${dB}|(?::${dN}){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 +(?:${dN}:){2}(?:(?::${dN}){0,3}:${dB}|(?::${dN}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4 +(?:${dN}:){1}(?:(?::${dN}){0,4}:${dB}|(?::${dN}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4 +(?::(?:(?::${dN}){0,5}:${dB}|(?::${dN}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4 +)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1 +`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),dM=RegExp(`(?:^${dB}$)|(?:^${dD}$)`),dO=RegExp(`^${dB}$`),dL=RegExp(`^${dD}$`),ipRegex=O=>O&&O.exact?dM:RegExp(`(?:${boundry(O)}${dB}${boundry(O)})|(?:${boundry(O)}${dD}${boundry(O)})`,"g");ipRegex.v4=O=>O&&O.exact?dO:RegExp(`${boundry(O)}${dB}${boundry(O)}`,"g"),ipRegex.v6=O=>O&&O.exact?dL:RegExp(`${boundry(O)}${dD}${boundry(O)}`,"g");var dU=ipRegex,dF=$(9173);let{isValid:dK,parse:dj}=dF,dH=["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"],dq=dH.map(O=>new dR.Netmask(O));function ipv4_check(O){for(let U of dq)if(U.contains(O))return!0;return!1}function ipv6_check(O){return/^::$/.test(O)||/^::1$/.test(O)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(O)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(O)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(O)||/^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(O)||/^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(O)||/^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(O)||/^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(O)||/^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(O)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(O)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(O)||/^ff([0-9a-fA-F]{2,2}):/i.test(O)}var private_ip=O=>{if(dK(O)){let U=dj(O);if("ipv4"===U.kind())return ipv4_check(U.toNormalizedString());if("ipv6"===U.kind())return ipv6_check(O)}else if(isIP(O)&&dU.v6().test(O))return ipv6_check(O)};function connectionGater(O={}){return{denyDialPeer:async()=>!1,denyDialMultiaddr:async O=>{let U=O.stringTuples();return(4===U[0][0]||41===U[0][0])&&!!private_ip(`${U[0][1]}`)},denyInboundConnection:async()=>!1,denyOutboundConnection:async()=>!1,denyInboundEncryptedConnection:async()=>!1,denyOutboundEncryptedConnection:async()=>!1,denyInboundUpgradedConnection:async()=>!1,denyOutboundUpgradedConnection:async()=>!1,filterMultiaddrForPeer:async()=>!0,...O}}let toParts=O=>O.toString().split("/").slice(1),func=O=>({match:U=>!(U.length<1)&&!!O(U[0])&&U.slice(1),pattern:"fn"}),literal=O=>({match:U=>func(U=>U===O).match(U),pattern:O}),src_string=()=>({match:O=>func(O=>"string"==typeof O).match(O),pattern:"{string}"}),src_number=()=>({match:O=>func(O=>!isNaN(parseInt(O))).match(O),pattern:"{number}"}),peerId=()=>({match:O=>{if(O.length<2||"p2p"!==O[0]&&"ipfs"!==O[0]||!(O[1].startsWith("Q")||O[1].startsWith("1")))return!1;try{rR.base58btc.decode(`z${O[1]}`)}catch(O){return!1}return O.slice(2)},pattern:"/p2p/{peerid}"}),certhash=()=>({match:O=>{if(O.length<2||"certhash"!==O[0])return!1;try{as.base64url.decode(O[1])}catch{return!1}return O.slice(2)},pattern:"/certhash/{certhash}"}),optional=O=>({match:U=>{let $=O.match(U);return!1===$?U:$},pattern:`optional(${O.pattern})`}),dist_src_or=(...O)=>({match:U=>{let $;for(let J of O){let O=J.match(U);!1!==O&&(null==$||O.length<$.length)&&($=O)}return null!=$&&$},pattern:`or(${O.map(O=>O.pattern).join(", ")})`}),src_and=(...O)=>({match:U=>{for(let $ of O){let O=$.match(U);if(!1===O)return!1;U=O}return U},pattern:`and(${O.map(O=>O.pattern).join(", ")})`});function fmt(...O){function match(U){let $=toParts(U);for(let U of O){let O=U.match($);if(!1===O)return!1;$=O}return $}return{matches:function(O){let U=match(O);return!1!==U},exactMatch:function(O){let U=match(O);return!1!==U&&0===U.length}}}let dz=src_and(literal("dns4"),src_string()),dV=src_and(literal("dns6"),src_string()),dG=src_and(literal("dnsaddr"),src_string()),d$=src_and(literal("dns"),src_string());fmt(dz),fmt(dV),fmt(dG),fmt(dist_src_or(d$,dG,dz,dV));let dW=src_and(literal("ip4"),func(isIPv4)),dY=src_and(literal("ip6"),func(isIPv6)),dJ=dist_src_or(dW,dY),dZ=dist_src_or(dJ,d$,dz,dV,dG);fmt(dW),fmt(dY),fmt(dJ);let dX=src_and(dZ,literal("tcp"),src_number()),ft=src_and(dZ,literal("udp"),src_number()),fr=dist_src_or(dX,ft);fmt(dX),fmt(ft);let fi=src_and(ft,literal("quic")),fo=src_and(ft,literal("quic-v1")),fa=dist_src_or(fi,fo);fmt(fi),fmt(fo);let fc=dist_src_or(dZ,dX,ft,fi,fo),fu=dist_src_or(src_and(fc,literal("ws"),optional(peerId())));fmt(fu);let fd=dist_src_or(src_and(fc,literal("wss"),optional(peerId())),src_and(fc,literal("tls"),literal("ws"),optional(peerId())));fmt(fd);let ff=src_and(fr,literal("webrtc-direct"),certhash(),optional(certhash()),optional(peerId()));fmt(ff);let fp=src_and(fo,literal("webtransport"),certhash(),certhash(),optional(peerId()));fmt(fp);let fg=dist_src_or(fu,fd,src_and(dX,optional(peerId())),src_and(fa,optional(peerId())),src_and(dZ,optional(peerId())),ff,fp,peerId());fmt(fg);let fm=src_and(fg,literal("p2p-circuit"),peerId()),fy=fmt(fm),fb=dist_src_or(src_and(fg,literal("p2p-circuit"),literal("webrtc"),peerId()),src_and(fg,literal("webrtc"),optional(peerId())),literal("webrtc"));function isPrivate(O){try{let{address:U}=O.nodeAddress();return!!private_ip(U)}catch{return!0}}function publicAddressesFirst(O,U){let $=isPrivate(O.multiaddr),J=isPrivate(U.multiaddr);return $&&!J?1:!$&&J?-1:0}function certifiedAddressesFirst(O,U){return O.isCertified&&!U.isCertified?-1:!O.isCertified&&U.isCertified?1:0}function circuitRelayAddressesLast(O,U){let $=fy.exactMatch(O.multiaddr),J=fy.exactMatch(U.multiaddr);return $&&!J?1:!$&&J?-1:0}function defaultAddressSort(O,U){let $=publicAddressesFirst(O,U);if(0!==$)return $;let J=circuitRelayAddressesLast(O,U);if(0!==J)return J;let en=certifiedAddressesFirst(O,U);return en}fmt(fb);var fv=$(6696);let f_=globalThis.fetch,fw=globalThis.Headers;function buildResource(O,U,$){return`${O}?name=${U}&type=${$}`}async function utils_request(O,U){let $=await f_(O,{headers:new fw({accept:"application/dns-json"}),signal:U}),J=await $.json();return J}function getCacheKey(O,U){return`${U}_${O}`}let fE=Object.assign(nf("dns-over-http-resolver"),{error:nf("dns-over-http-resolver:error")});let Resolver=class Resolver{_cache;_TXTcache;_servers;_request;_abortControllers;constructor(O={}){this._cache=new fv({max:O?.maxCache??100}),this._TXTcache=new fv({max:O?.maxCache??100}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"],this._request=O.request??utils_request,this._abortControllers=[]}cancel(){this._abortControllers.forEach(O=>{O.abort()})}getServers(){return this._servers}_getShuffledServers(){let O=[...this._servers];for(let U=O.length-1;U>0;U--){let $=Math.floor(Math.random()*U),J=O[U];O[U]=O[$],O[$]=J}return O}setServers(O){this._servers=O}async resolve(O,U="A"){switch(U){case"A":return this.resolve4(O);case"AAAA":return this.resolve6(O);case"TXT":return this.resolveTxt(O);default:throw Error(`${U} is not supported`)}}async resolve4(O){let U="A",$=this._cache.get(getCacheKey(O,U));if(null!=$)return $;let J=!1;for(let $ of this._getShuffledServers()){let en=new AbortController;this._abortControllers.push(en);try{let J=await this._request(buildResource($,O,U),en.signal),es=J.Answer.map(O=>O.data),eo=Math.min(...J.Answer.map(O=>O.TTL));return this._cache.set(getCacheKey(O,U),es,{ttl:eo}),es}catch(es){en.signal.aborted&&(J=!0),fE.error(`${$} could not resolve ${O} record ${U}`)}finally{this._abortControllers=this._abortControllers.filter(O=>O!==en)}}if(J)throw Object.assign(Error("queryA ECANCELLED"),{code:"ECANCELLED"});throw Error(`Could not resolve ${O} record ${U}`)}async resolve6(O){let U="AAAA",$=this._cache.get(getCacheKey(O,U));if(null!=$)return $;let J=!1;for(let $ of this._getShuffledServers()){let en=new AbortController;this._abortControllers.push(en);try{let J=await this._request(buildResource($,O,U),en.signal),es=J.Answer.map(O=>O.data),eo=Math.min(...J.Answer.map(O=>O.TTL));return this._cache.set(getCacheKey(O,U),es,{ttl:eo}),es}catch(es){en.signal.aborted&&(J=!0),fE.error(`${$} could not resolve ${O} record ${U}`)}finally{this._abortControllers=this._abortControllers.filter(O=>O!==en)}}if(J)throw Object.assign(Error("queryAaaa ECANCELLED"),{code:"ECANCELLED"});throw Error(`Could not resolve ${O} record ${U}`)}async resolveTxt(O){let U="TXT",$=this._TXTcache.get(getCacheKey(O,U));if(null!=$)return $;let J=!1;for(let $ of this._getShuffledServers()){let en=new AbortController;this._abortControllers.push(en);try{let J=await this._request(buildResource($,O,U),en.signal),es=J.Answer.map(O=>[O.data.replace(/['"]+/g,"")]),eo=Math.min(...J.Answer.map(O=>O.TTL));return this._TXTcache.set(getCacheKey(O,U),es,{ttl:eo}),es}catch(es){en.signal.aborted&&(J=!0),fE.error(`${$} could not resolve ${O} record ${U}`)}finally{this._abortControllers=this._abortControllers.filter(O=>O!==en)}}if(J)throw Object.assign(Error("queryTxt ECANCELLED"),{code:"ECANCELLED"});throw Error(`Could not resolve ${O} record ${U}`)}clearCache(){this._cache.clear(),this._TXTcache.clear()}};var fS=Resolver;let{code:fA}=protocols_table_getProtocol("dnsaddr");async function dnsaddrResolver(O,U={}){let $=new fS;null!=U.signal&&U.signal.addEventListener("abort",()=>{$.cancel()});let J=O.getPeerId(),[,en]=O.stringTuples().find(([O])=>O===fA)??[];if(null==en)throw Error("No hostname found in multiaddr");let es=await $.resolveTxt(`_dnsaddr.${en}`),eo=es.flat().map(O=>O.split("=")[1]).filter(Boolean);return null!=J&&(eo=eo.filter(O=>O.includes(J))),eo}!function(O){O.NOT_STARTED_YET="The libp2p node is not started yet",O.DHT_DISABLED="DHT is not available",O.PUBSUB_DISABLED="PubSub is not available",O.CONN_ENCRYPTION_REQUIRED="At least one connection encryption module is required",O.ERR_TRANSPORTS_REQUIRED="At least one transport module is required",O.ERR_PROTECTOR_REQUIRED="Private network is enforced, but no protector was provided",O.NOT_FOUND="Not found"}(ry||(ry={})),function(O){O.DHT_DISABLED="ERR_DHT_DISABLED",O.ERR_PUBSUB_DISABLED="ERR_PUBSUB_DISABLED",O.PUBSUB_NOT_STARTED="ERR_PUBSUB_NOT_STARTED",O.DHT_NOT_STARTED="ERR_DHT_NOT_STARTED",O.CONN_ENCRYPTION_REQUIRED="ERR_CONN_ENCRYPTION_REQUIRED",O.ERR_TRANSPORTS_REQUIRED="ERR_TRANSPORTS_REQUIRED",O.ERR_PROTECTOR_REQUIRED="ERR_PROTECTOR_REQUIRED",O.ERR_PEER_DIAL_INTERCEPTED="ERR_PEER_DIAL_INTERCEPTED",O.ERR_CONNECTION_INTERCEPTED="ERR_CONNECTION_INTERCEPTED",O.ERR_INVALID_PROTOCOLS_FOR_STREAM="ERR_INVALID_PROTOCOLS_FOR_STREAM",O.ERR_CONNECTION_ENDED="ERR_CONNECTION_ENDED",O.ERR_CONNECTION_FAILED="ERR_CONNECTION_FAILED",O.ERR_NODE_NOT_STARTED="ERR_NODE_NOT_STARTED",O.ERR_ALREADY_ABORTED="ERR_ALREADY_ABORTED",O.ERR_TOO_MANY_ADDRESSES="ERR_TOO_MANY_ADDRESSES",O.ERR_NO_VALID_ADDRESSES="ERR_NO_VALID_ADDRESSES",O.ERR_RELAYED_DIAL="ERR_RELAYED_DIAL",O.ERR_DIALED_SELF="ERR_DIALED_SELF",O.ERR_DISCOVERED_SELF="ERR_DISCOVERED_SELF",O.ERR_DUPLICATE_TRANSPORT="ERR_DUPLICATE_TRANSPORT",O.ERR_ENCRYPTION_FAILED="ERR_ENCRYPTION_FAILED",O.ERR_HOP_REQUEST_FAILED="ERR_HOP_REQUEST_FAILED",O.ERR_INVALID_KEY="ERR_INVALID_KEY",O.ERR_INVALID_MESSAGE="ERR_INVALID_MESSAGE",O.ERR_INVALID_PARAMETERS="ERR_INVALID_PARAMETERS",O.ERR_INVALID_PEER="ERR_INVALID_PEER",O.ERR_MUXER_UNAVAILABLE="ERR_MUXER_UNAVAILABLE",O.ERR_NOT_FOUND="ERR_NOT_FOUND",O.ERR_TIMEOUT="ERR_TIMEOUT",O.ERR_TRANSPORT_UNAVAILABLE="ERR_TRANSPORT_UNAVAILABLE",O.ERR_TRANSPORT_DIAL_FAILED="ERR_TRANSPORT_DIAL_FAILED",O.ERR_UNSUPPORTED_PROTOCOL="ERR_UNSUPPORTED_PROTOCOL",O.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED="ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED",O.ERR_INVALID_MULTIADDR="ERR_INVALID_MULTIADDR",O.ERR_SIGNATURE_NOT_VALID="ERR_SIGNATURE_NOT_VALID",O.ERR_FIND_SELF="ERR_FIND_SELF",O.ERR_NO_ROUTERS_AVAILABLE="ERR_NO_ROUTERS_AVAILABLE",O.ERR_CONNECTION_NOT_MULTIPLEXED="ERR_CONNECTION_NOT_MULTIPLEXED",O.ERR_NO_DIAL_TOKENS="ERR_NO_DIAL_TOKENS",O.ERR_KEYCHAIN_REQUIRED="ERR_KEYCHAIN_REQUIRED",O.ERR_INVALID_CMS="ERR_INVALID_CMS",O.ERR_MISSING_KEYS="ERR_MISSING_KEYS",O.ERR_NO_KEY="ERR_NO_KEY",O.ERR_INVALID_KEY_NAME="ERR_INVALID_KEY_NAME",O.ERR_INVALID_KEY_TYPE="ERR_INVALID_KEY_TYPE",O.ERR_KEY_ALREADY_EXISTS="ERR_KEY_ALREADY_EXISTS",O.ERR_INVALID_KEY_SIZE="ERR_INVALID_KEY_SIZE",O.ERR_KEY_NOT_FOUND="ERR_KEY_NOT_FOUND",O.ERR_OLD_KEY_NAME_INVALID="ERR_OLD_KEY_NAME_INVALID",O.ERR_NEW_KEY_NAME_INVALID="ERR_NEW_KEY_NAME_INVALID",O.ERR_PASSWORD_REQUIRED="ERR_PASSWORD_REQUIRED",O.ERR_PEM_REQUIRED="ERR_PEM_REQUIRED",O.ERR_CANNOT_READ_KEY="ERR_CANNOT_READ_KEY",O.ERR_MISSING_PRIVATE_KEY="ERR_MISSING_PRIVATE_KEY",O.ERR_MISSING_PUBLIC_KEY="ERR_MISSING_PUBLIC_KEY",O.ERR_INVALID_OLD_PASS_TYPE="ERR_INVALID_OLD_PASS_TYPE",O.ERR_INVALID_NEW_PASS_TYPE="ERR_INVALID_NEW_PASS_TYPE",O.ERR_INVALID_PASS_LENGTH="ERR_INVALID_PASS_LENGTH",O.ERR_NOT_IMPLEMENTED="ERR_NOT_IMPLEMENTED",O.ERR_WRONG_PING_ACK="ERR_WRONG_PING_ACK",O.ERR_INVALID_RECORD="ERR_INVALID_RECORD",O.ERR_ALREADY_SUCCEEDED="ERR_ALREADY_SUCCEEDED",O.ERR_NO_HANDLER_FOR_PROTOCOL="ERR_NO_HANDLER_FOR_PROTOCOL",O.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS",O.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS",O.ERR_CONNECTION_DENIED="ERR_CONNECTION_DENIED",O.ERR_TRANSFER_LIMIT_EXCEEDED="ERR_TRANSFER_LIMIT_EXCEEDED"}(rv||(rv={}));let fI={addresses:{listen:[],announce:[],noAnnounce:[],announceFilter:O=>O},connectionManager:{resolvers:{dnsaddr:dnsaddrResolver},addressSorter:defaultAddressSort},transportManager:{faultTolerance:tp.FATAL_ALL}};function validateConfig(O){let U=hK(fI,O);if(null==U.transports||U.transports.length<1)throw new errors_CodeError(ry.ERR_TRANSPORTS_REQUIRED,rv.ERR_TRANSPORTS_REQUIRED);if(null===U.connectionProtector&&globalThis.process?.env?.LIBP2P_FORCE_PNET!=null)throw new errors_CodeError(ry.ERR_PROTECTOR_REQUIRED,rv.ERR_PROTECTOR_REQUIRED);return U}let fP="keep-alive",fk=logger("libp2p:get-peer");function getPeerAddress(O){let U;if(isPeerId(O))return{peerId:O,multiaddrs:[]};if(Array.isArray(O)||(O=[O]),O.length>0){let $=O[0].getPeerId();U=null==$?void 0:peerIdFromString($),O.forEach(O=>{if(!isMultiaddr(O))throw fk.error("multiaddr %s was invalid",O),new errors_CodeError("Invalid Multiaddr",rv.ERR_INVALID_MULTIADDR);let $=O.getPeerId();if(null==$){if(null!=U)throw new errors_CodeError("Multiaddrs must all have the same peer id or have no peer id",rv.ERR_INVALID_PARAMETERS)}else{let O=peerIdFromString($);if(null==U||!U.equals(O))throw new errors_CodeError("Multiaddrs must all have the same peer id or have no peer id",rv.ERR_INVALID_PARAMETERS)}})}return{peerId:U,multiaddrs:O}}function peer_job_queue_lowerBound(O,U,$){let J=0,en=O.length;for(;en>0;){let es=Math.trunc(en/2),eo=J+es;0>=$(O[eo],U)?(J=++eo,en-=es+1):en=es}return J}let PeerPriorityQueue=class PeerPriorityQueue{#l=[];enqueue(O,U){let $=U?.peerId,J=U?.priority??0;if(null==$)throw new errors_CodeError("missing peer id",rv.ERR_INVALID_PARAMETERS);let en={priority:J,peerId:$,run:O};if(this.size>0&&this.#l[this.size-1].priority>=J){this.#l.push(en);return}let es=peer_job_queue_lowerBound(this.#l,en,(O,U)=>U.priority-O.priority);this.#l.splice(es,0,en)}dequeue(){let O=this.#l.shift();return O?.run}filter(O){if(null!=O.peerId){let U=O.peerId;return this.#l.filter(O=>U.equals(O.peerId)).map(O=>O.run)}return this.#l.filter(U=>U.priority===O.priority).map(O=>O.run)}get size(){return this.#l.length}};let PeerJobQueue=class PeerJobQueue extends hX{constructor(O={}){super({...O,queueClass:PeerPriorityQueue})}hasJob(O){return this.sizeBy({peerId:O})>0}};let fT=5,fR=100,fC=50,fB=42e4,fN=3e4,fx=3e4,fD=25,fM=1,fO=5e3,fL=25,fU=0,fF=100,fK=10,fj=5,fH=10,fq="last-dial-failure",fz=logger("libp2p:connection-manager:auto-dial"),fV={minConnections:fT,maxQueueLength:fF,autoDialConcurrency:fL,autoDialPriority:fU,autoDialInterval:fO,autoDialPeerRetryThreshold:fB,autoDialDiscoveredPeersDebounce:fK};let AutoDial=class AutoDial{connectionManager;peerStore;queue;minConnections;autoDialPriority;autoDialIntervalMs;autoDialMaxQueueLength;autoDialPeerRetryThresholdMs;autoDialDiscoveredPeersDebounce;autoDialInterval;started;running;constructor(O,U){let $;this.connectionManager=O.connectionManager,this.peerStore=O.peerStore,this.minConnections=U.minConnections??fV.minConnections,this.autoDialPriority=U.autoDialPriority??fV.autoDialPriority,this.autoDialIntervalMs=U.autoDialInterval??fV.autoDialInterval,this.autoDialMaxQueueLength=U.maxQueueLength??fV.maxQueueLength,this.autoDialPeerRetryThresholdMs=U.autoDialPeerRetryThreshold??fV.autoDialPeerRetryThreshold,this.autoDialDiscoveredPeersDebounce=U.autoDialDiscoveredPeersDebounce??fV.autoDialDiscoveredPeersDebounce,this.started=!1,this.running=!1,this.queue=new PeerJobQueue({concurrency:U.autoDialConcurrency??fV.autoDialConcurrency}),this.queue.addListener("error",O=>{fz.error("error during auto-dial",O)}),O.events.addEventListener("connection:close",()=>{this.autoDial().catch(O=>{fz.error(O)})}),O.events.addEventListener("peer:discovery",()=>{clearTimeout($),$=setTimeout(()=>{this.autoDial().catch(O=>{fz.error(O)})},this.autoDialDiscoveredPeersDebounce)})}isStarted(){return this.started}start(){this.autoDialInterval=setTimeout(()=>{this.autoDial().catch(O=>{fz.error("error while autodialing",O)})},this.autoDialIntervalMs),this.started=!0}afterStart(){this.autoDial().catch(O=>{fz.error("error while autodialing",O)})}stop(){this.queue.clear(),clearTimeout(this.autoDialInterval),this.started=!1,this.running=!1}async autoDial(){if(!this.started)return;let O=this.connectionManager.getConnectionsMap(),U=O.size;if(U>=this.minConnections){this.minConnections>0&&fz.trace("have enough connections %d/%d",U,this.minConnections);return}if(this.queue.size>this.autoDialMaxQueueLength){fz("not enough connections %d/%d but auto dial queue is full",U,this.minConnections);return}if(this.running){fz("not enough connections %d/%d - but skipping autodial as it is already running",U,this.minConnections);return}this.running=!0,fz("not enough connections %d/%d - will dial peers to increase the number of connections",U,this.minConnections);let $=new PeerSet(this.connectionManager.getDialQueue().map(O=>O.peerId).filter(Boolean)),J=await this.peerStore.all({filters:[U=>0===U.addresses.length?(fz.trace("not autodialing %p because they have no addresses",U.id),!1):O.has(U.id)?(fz.trace("not autodialing %p because they are already connected",U.id),!1):$.has(U.id)?(fz.trace("not autodialing %p because they are already being dialed",U.id),!1):!this.queue.hasJob(U.id)||(fz.trace("not autodialing %p because they are already being autodialed",U.id),!1)]}),en=J.sort(()=>Math.random()>.5?1:-1),es=new PeerMap;for(let O of en)es.has(O.id)||es.set(O.id,[...O.tags.values()].reduce((O,U)=>O+U.value,0));let eo=en.sort((O,U)=>{let $=es.get(O.id)??0,J=es.get(U.id)??0;return $>J?-1:${let U=O.metadata.get(fq);if(null==U)return!0;let $=parseInt((0,rB.B)(U));return!!isNaN($)||Date.now()-$>this.autoDialPeerRetryThresholdMs});for(let O of(fz("selected %d/%d peers to dial",ea.length,J.length),ea))this.queue.add(async()=>{let U=this.connectionManager.getConnectionsMap().size;if(U>=this.minConnections){fz("got enough connections now %d/%d",U,this.minConnections),this.queue.clear();return}fz("connecting to a peerStore stored peer %p",O.id),await this.connectionManager.openConnection(O.id,{priority:this.autoDialPriority})},{peerId:O.id}).catch(O=>{fz.error("could not connect to peerStore stored peer",O)});this.running=!1,this.started&&(this.autoDialInterval=setTimeout(()=>{this.autoDial().catch(O=>{fz.error("error while autodialing",O)})},this.autoDialIntervalMs))}};let fG=logger("libp2p:connection-manager:connection-pruner"),f$={maxConnections:fR,allow:[]};let ConnectionPruner=class ConnectionPruner{maxConnections;connectionManager;peerStore;allow;events;constructor(O,U={}){this.maxConnections=U.maxConnections??f$.maxConnections,this.allow=U.allow??f$.allow,this.connectionManager=O.connectionManager,this.peerStore=O.peerStore,this.events=O.events,O.events.addEventListener("connection:open",()=>{this.maybePruneConnections().catch(O=>{fG.error(O)})})}async maybePruneConnections(){let O=this.connectionManager.getConnections(),U=O.length,$=Math.max(U-this.maxConnections,0);if(fG("checking max connections limit %d/%d",U,this.maxConnections),U<=this.maxConnections)return;fG("max connections limit exceeded %d/%d, pruning %d connection(s)",U,this.maxConnections,$);let J=new PeerMap;for(let U of O){let O=U.remotePeer;if(!J.has(O)){J.set(O,0);try{let U=await this.peerStore.get(O);J.set(O,[...U.tags.values()].reduce((O,U)=>O+U.value,0))}catch(O){"ERR_NOT_FOUND"!==O.code&&fG.error("error loading peer tags",O)}}}let en=O.sort((O,U)=>{let $=J.get(O.remotePeer)??0,en=J.get(U.remotePeer)??0;if($>en)return 1;if($eo?-1:0}),es=[];for(let O of en){fG("too many connections open - closing a connection to %p",O.remotePeer);let U=this.allow.some(U=>O.remoteAddr.toString().startsWith(U.toString()));if(U||es.push(O),es.length===$)break}await Promise.all(es.map(async O=>{try{await O.close()}catch(O){fG.error(O)}})),this.events.safeDispatchEvent("connection:prune",{detail:es})}};function anySignal(O){let U=new globalThis.AbortController;function onAbort(){for(let $ of(U.abort(),O))$?.removeEventListener!=null&&$.removeEventListener("abort",onAbort)}for(let U of O){if(U?.aborted===!0){onAbort();break}U?.addEventListener!=null&&U.addEventListener("abort",onAbort)}function clear(){for(let U of O)U?.removeEventListener!=null&&U.removeEventListener("abort",onAbort)}let $=U.signal;return $.clear=clear,$}let fW=logger("libp2p:connection-manager:utils");async function resolveMultiaddrs(O,U){let $=O.protoNames().includes("dnsaddr");if(!$)return[O];let J=await resolveRecord(O,U),en=await Promise.all(J.map(async O=>resolveMultiaddrs(O,U))),es=en.flat(),eo=es.reduce((O,U)=>(null==O.find(O=>O.equals(U))&&O.push(U),O),[]);return fW("resolved %s to",O,eo.map(O=>O.toString())),eo}async function resolveRecord(O,U){try{O=src_multiaddr(O.toString());let $=await O.resolve(U);return $}catch(U){return fW.error(`multiaddr ${O.toString()} could not be resolved`,U),[]}}function combineSignals(...O){let U=[];for(let $ of O)if(null!=$){try{hD.setMaxListeners?.(1/0,$)}catch{}U.push($)}let $=anySignal(U);try{hD.setMaxListeners?.(1/0,$)}catch{}return $}let fY=logger("libp2p:connection-manager:dial-queue"),fJ={addressSorter:defaultAddressSort,maxParallelDials:fC,maxPeerAddrsToDial:fD,maxParallelDialsPerPeer:fM,dialTimeout:fN};let DialQueue=class DialQueue{pendingDials;queue;peerId;peerStore;connectionGater;transportManager;addressSorter;maxPeerAddrsToDial;maxParallelDialsPerPeer;dialTimeout;inProgressDialCount;pendingDialCount;shutDownController;constructor(O,U={}){this.addressSorter=U.addressSorter??fJ.addressSorter,this.maxPeerAddrsToDial=U.maxPeerAddrsToDial??fJ.maxPeerAddrsToDial,this.maxParallelDialsPerPeer=U.maxParallelDialsPerPeer??fJ.maxParallelDialsPerPeer,this.dialTimeout=U.dialTimeout??fJ.dialTimeout,this.peerId=O.peerId,this.peerStore=O.peerStore,this.connectionGater=O.connectionGater,this.transportManager=O.transportManager,this.shutDownController=new AbortController;try{hD.setMaxListeners?.(1/0,this.shutDownController.signal)}catch{}for(let[$,J]of(this.pendingDialCount=O.metrics?.registerMetric("libp2p_dialler_pending_dials"),this.inProgressDialCount=O.metrics?.registerMetric("libp2p_dialler_in_progress_dials"),this.pendingDials=[],Object.entries(U.resolvers??{})))nh.set($,J);this.queue=new hX({concurrency:U.maxParallelDials??fJ.maxParallelDials}),this.queue.on("add",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("active",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("completed",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("error",O=>{fY.error("error in dial queue",O),this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("empty",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)}),this.queue.on("idle",()=>{this.pendingDialCount?.update(this.queue.size),this.inProgressDialCount?.update(this.queue.pending)})}stop(){this.shutDownController.abort()}async dial(O,U={}){let $;let{peerId:J,multiaddrs:en}=getPeerAddress(O),es=en.map(O=>({multiaddr:O,isCertified:!1})),eo=this.createDialAbortControllers(U.signal);try{$=await this.calculateMultiaddrs(J,es,{...U,signal:eo})}catch(O){throw eo.clear(),O}let ea=this.pendingDials.find(O=>!!(null!=O.peerId&&null!=J&&O.peerId.equals(J))||$.map(({multiaddr:O})=>O.toString()).join()===O.multiaddrs.map(O=>O.toString()).join());if(null!=ea)return fY("joining existing dial target for %p",J),eo.clear(),ea.promise;fY("creating dial target for",$.map(({multiaddr:O})=>O.toString()));let eu={id:randomId(),status:"queued",peerId:J,multiaddrs:$.map(({multiaddr:O})=>O)};return eu.promise=this.performDial(eu,{...U,signal:eo}).finally(()=>{this.pendingDials=this.pendingDials.filter(O=>O.id!==eu.id),eo.clear()}).catch(async O=>{if(fY.error("dial failed to %s",eu.multiaddrs.map(O=>O.toString()).join(", "),O),null!=J)try{await this.peerStore.patch(J,{metadata:{[fq]:(0,rJ.m)(Date.now().toString())}})}catch(O){fY.error("could not update last dial failure key for %p",J,O)}if(eo.aborted){let U=new errors_CodeError(O.message,rv.ERR_TIMEOUT);throw U}throw O}),this.pendingDials.push(eu),eu.promise}createDialAbortControllers(O){let U=anySignal([AbortSignal.timeout(this.dialTimeout),this.shutDownController.signal,O]);try{hD.setMaxListeners?.(1/0,U)}catch{}return U}async calculateMultiaddrs(O,U=[],$={}){if(null!=O){if(this.peerId.equals(O))throw new errors_CodeError("Tried to dial self",rv.ERR_DIALED_SELF);if(await this.connectionGater.denyDialPeer?.(O)===!0)throw new errors_CodeError("The dial request is blocked by gater.allowDialPeer",rv.ERR_PEER_DIAL_INTERCEPTED);if(0===U.length){fY("loading multiaddrs for %p",O);try{let $=await this.peerStore.get(O);U.push(...$.addresses),fY("loaded multiaddrs for %p",O,U.map(({multiaddr:O})=>O.toString()))}catch(O){if(O.code!==rv.ERR_NOT_FOUND)throw O}}}let J=(await Promise.all(U.map(async O=>{let U=await resolveMultiaddrs(O.multiaddr,$);return 1===U.length&&U[0].equals(O.multiaddr)?O:U.map(O=>({multiaddr:O,isCertified:!1}))}))).flat(),en=J.filter(U=>{if(null==this.transportManager.transportForMultiaddr(U.multiaddr))return!1;let $=U.multiaddr.getPeerId();return null==O||null==$||O.equals($)}),es=new Map;for(let O of en){let U=O.multiaddr.toString(),$=es.get(U);if(null!=$){$.isCertified=$.isCertified||O.isCertified||!1;continue}es.set(U,O)}let eo=[...es.values()];if((0===eo.length||eo.length>this.maxPeerAddrsToDial)&&(fY("addresses for %p before filtering",O??"unknown peer",J.map(({multiaddr:O})=>O.toString())),fY("addresses for %p after filtering",O??"unknown peer",eo.map(({multiaddr:O})=>O.toString()))),0===eo.length)throw new errors_CodeError("The dial request has no valid addresses",rv.ERR_NO_VALID_ADDRESSES);if(eo.length>this.maxPeerAddrsToDial)throw new errors_CodeError("dial with more addresses than allowed",rv.ERR_TOO_MANY_ADDRESSES);if(null!=O){let U=`/p2p/${O.toString()}`;eo=eo.map($=>{let J=$.multiaddr.getPeerId(),en=$.multiaddr.protos().pop();return en?.path===!0?$:J!==O.toString()?{multiaddr:$.multiaddr.encapsulate(U),isCertified:$.isCertified}:$})}let ea=[];for(let O of eo)null!=this.connectionGater.denyDialMultiaddr&&await this.connectionGater.denyDialMultiaddr(O.multiaddr)||ea.push(O);let eu=ea.sort(this.addressSorter);if(0===eu.length)throw new errors_CodeError("The connection gater denied all addresses in the dial request",rv.ERR_NO_VALID_ADDRESSES);return eu}async performDial(O,U={}){let $=O.multiaddrs.map(()=>new AbortController);try{let J=new hX({concurrency:this.maxParallelDialsPerPeer});J.on("error",O=>{fY.error("error dialling",O)});let en=await Promise.any(O.multiaddrs.map(async(en,es)=>{let eo=$[es];if(null==eo)throw new errors_CodeError("dialAction did not come with an AbortController",rv.ERR_INVALID_PARAMETERS);let ea=combineSignals(eo.signal,U.signal);ea.addEventListener("abort",()=>{fY("dial to %a aborted",en)});let eu=pDefer();return await J.add(async()=>{if(ea.aborted){fY("dial to %a was aborted before reaching the head of the peer dial queue",en),eu.reject(new AbortError);return}await this.queue.add(async()=>{try{if(ea.aborted){fY("dial to %a was aborted before reaching the head of the dial queue",en),eu.reject(new AbortError);return}O.status="active";let J=await this.transportManager.dial(en,{...U,signal:ea});if(eo.signal.aborted){fY("multiple dials succeeded, closing superfluous connection"),J.close().catch(O=>{fY.error("error closing superfluous connection",O)}),eu.reject(new AbortError);return}$[es]=void 0,$.forEach(O=>{void 0!==O&&O.abort()}),fY("dial to %a succeeded",en),eu.resolve(J)}catch(O){fY.error("error during dial of %a",en,O),eu.reject(O)}},{...U,signal:ea}).catch(O=>{eu.reject(O)})},{signal:ea}).catch(O=>{eu.reject(O)}).finally(()=>{ea.clear()}),eu.promise}));if(null==en)throw new errors_CodeError("successful dial led to empty object returned from peer dial queue",rv.ERR_TRANSPORT_DIAL_FAILED);return O.status="success",en}catch(U){if(O.status="error",1===O.multiaddrs.length&&"AggregateError"===U.name)throw U.errors[0];throw U}}};function randomId(){return`${parseInt(String(1e9*Math.random()),10).toString()}${Date.now()}`}let fQ=logger("libp2p:connection-manager"),fZ=50,fX={minConnections:fT,maxConnections:fR,inboundConnectionThreshold:fj,maxIncomingPendingConnections:fH,autoDialConcurrency:fL,autoDialPriority:fU,autoDialMaxQueueLength:fF};let DefaultConnectionManager=class DefaultConnectionManager{started;connections;allow;deny;maxIncomingPendingConnections;incomingPendingConnections;maxConnections;dialQueue;autoDial;connectionPruner;inboundConnectionRateLimiter;peerStore;metrics;events;constructor(O,U={}){this.maxConnections=U.maxConnections??fX.maxConnections;let $=U.minConnections??fX.minConnections;if(this.maxConnections<$)throw new errors_CodeError("Connection Manager maxConnections must be greater than minConnections",rv.ERR_INVALID_PARAMETERS);this.connections=new PeerMap,this.started=!1,this.peerStore=O.peerStore,this.metrics=O.metrics,this.events=O.events,this.onConnect=this.onConnect.bind(this),this.onDisconnect=this.onDisconnect.bind(this),this.events.addEventListener("connection:open",this.onConnect),this.events.addEventListener("connection:close",this.onDisconnect),this.allow=(U.allow??[]).map(O=>src_multiaddr(O)),this.deny=(U.deny??[]).map(O=>src_multiaddr(O)),this.incomingPendingConnections=0,this.maxIncomingPendingConnections=U.maxIncomingPendingConnections??fX.maxIncomingPendingConnections,this.inboundConnectionRateLimiter=new aK.RateLimiterMemory({points:U.inboundConnectionThreshold??fX.inboundConnectionThreshold,duration:1}),this.autoDial=new AutoDial({connectionManager:this,peerStore:O.peerStore,events:O.events},{minConnections:$,autoDialConcurrency:U.autoDialConcurrency??fX.autoDialConcurrency,autoDialPriority:U.autoDialPriority??fX.autoDialPriority,maxQueueLength:U.autoDialMaxQueueLength??fX.autoDialMaxQueueLength}),this.connectionPruner=new ConnectionPruner({connectionManager:this,peerStore:O.peerStore,events:O.events},{maxConnections:this.maxConnections,allow:this.allow}),this.dialQueue=new DialQueue({peerId:O.peerId,metrics:O.metrics,peerStore:O.peerStore,transportManager:O.transportManager,connectionGater:O.connectionGater},{addressSorter:U.addressSorter??defaultAddressSort,maxParallelDials:U.maxParallelDials??fC,maxPeerAddrsToDial:U.maxPeerAddrsToDial??fD,maxParallelDialsPerPeer:U.maxParallelDialsPerPeer??fM,dialTimeout:U.dialTimeout??fN,resolvers:U.resolvers??{dnsaddr:dnsaddrResolver}})}isStarted(){return this.started}async start(){this.metrics?.registerMetricGroup("libp2p_connection_manager_connections",{calculate:()=>{let O={inbound:0,outbound:0};for(let U of this.connections.values())for(let $ of U)"inbound"===$.direction?O.inbound++:O.outbound++;return O}}),this.metrics?.registerMetricGroup("libp2p_protocol_streams_total",{label:"protocol",calculate:()=>{let O={};for(let U of this.connections.values())for(let $ of U)for(let U of $.streams){let $=`${U.direction} ${U.protocol??"unnegotiated"}`;O[$]=(O[$]??0)+1}return O}}),this.metrics?.registerMetricGroup("libp2p_connection_manager_protocol_streams_per_connection_90th_percentile",{label:"protocol",calculate:()=>{let O={};for(let U of this.connections.values())for(let $ of U){let U={};for(let O of $.streams){let $=`${O.direction} ${O.protocol??"unnegotiated"}`;U[$]=(U[$]??0)+1}for(let[$,J]of Object.entries(U))O[$]=O[$]??[],O[$].push(J)}let U={};for(let[$,J]of Object.entries(O)){J=J.sort((O,U)=>O-U);let O=Math.floor(.9*J.length);U[$]=J[O]}return U}}),this.autoDial.start(),this.started=!0,fQ("started")}async afterStart(){Promise.resolve().then(async()=>{let O=await this.peerStore.all({filters:[O=>O.tags.has(fP)]});await Promise.all(O.map(async O=>{await this.openConnection(O.id).catch(O=>{fQ.error(O)})}))}).catch(O=>{fQ.error(O)}),this.autoDial.afterStart()}async stop(){this.dialQueue.stop(),this.autoDial.stop();let O=[];for(let U of this.connections.values())for(let $ of U)O.push((async()=>{try{await $.close()}catch(O){fQ.error(O)}})());fQ("closing %d connections",O.length),await Promise.all(O),this.connections.clear(),fQ("stopped")}onConnect(O){this._onConnect(O).catch(O=>{fQ.error(O)})}async _onConnect(O){let{detail:U}=O;if(!this.started){await U.close();return}let $=U.remotePeer,J=this.connections.get($),en=!1;null!=J?J.push(U):(en=!0,this.connections.set($,[U])),null!=$.publicKey&&"RSA"===$.type&&await this.peerStore.patch($,{publicKey:$.publicKey}),en&&this.events.safeDispatchEvent("peer:connect",{detail:U.remotePeer})}onDisconnect(O){let{detail:U}=O;if(!this.started)return;let $=U.remotePeer,J=this.connections.get($);null!=J&&J.length>1?(J=J.filter(O=>O.id!==U.id),this.connections.set($,J)):null!=J&&(this.connections.delete($),this.events.safeDispatchEvent("peer:disconnect",{detail:U.remotePeer}))}getConnections(O){if(null!=O)return this.connections.get(O)??[];let U=[];for(let O of this.connections.values())U=U.concat(O);return U}getConnectionsMap(){return this.connections}async openConnection(O,U={}){if(!this.isStarted())throw new errors_CodeError("Not started",rv.ERR_NODE_NOT_STARTED);U.signal?.throwIfAborted();let{peerId:$}=getPeerAddress(O);if(null!=$&&!0!==U.force){fQ("dial %p",$);let O=this.getConnections($);if(O.length>0)return fQ("had an existing connection to %p",$),O[0]}let J=await this.dialQueue.dial(O,{...U,priority:U.priority??fZ}),en=this.connections.get(J.remotePeer);null==en&&(en=[],this.connections.set(J.remotePeer,en));let es=!1;for(let O of en)O.id===J.id&&(es=!0);return es||en.push(J),J}async closeConnections(O,U={}){let $=this.connections.get(O)??[];await Promise.all($.map(async O=>{try{await O.close(U)}catch(U){O.abort(U)}}))}async acceptIncomingConnection(O){let U=this.deny.some(U=>O.remoteAddr.toString().startsWith(U.toString()));if(U)return fQ("connection from %a refused - connection remote address was in deny list",O.remoteAddr),!1;let $=this.allow.some(U=>O.remoteAddr.toString().startsWith(U.toString()));if($)return this.incomingPendingConnections++,!0;if(this.incomingPendingConnections===this.maxIncomingPendingConnections)return fQ("connection from %a refused - incomingPendingConnections exceeded by host",O.remoteAddr),!1;if(O.remoteAddr.isThinWaistAddress()){let U=O.remoteAddr.nodeAddress().address;try{await this.inboundConnectionRateLimiter.consume(U,1)}catch{return fQ("connection from %a refused - inboundConnectionThreshold exceeded by host %s",O.remoteAddr,U),!1}}return this.getConnections().length(await U.merge(O.id,{multiaddrs:O.multiaddrs}),O))}function uniquePeers(O){let U=new Set;return it_filter_dist_src(O,O=>!U.has(O.id.toString())&&(U.add(O.id.toString()),!0))}async function*requirePeers(O,U=1){let $=0;for await(let U of O)$++,yield U;if($$.findProviders(O,U))),O=>storeAddresses(O,this.components.peerStore),O=>uniquePeers(O),O=>requirePeers(O))}async provide(O,U={}){if(0===this.routers.length)throw new errors_CodeError("No content routers available",rv.ERR_NO_ROUTERS_AVAILABLE);await Promise.all(this.routers.map(async $=>{await $.provide(O,U)}))}async put(O,U,$){if(!this.isStarted())throw new errors_CodeError(ry.NOT_STARTED_YET,rv.DHT_NOT_STARTED);await Promise.all(this.routers.map(async J=>{await J.put(O,U,$)}))}async get(O,U){if(!this.isStarted())throw new errors_CodeError(ry.NOT_STARTED_YET,rv.DHT_NOT_STARTED);return Promise.any(this.routers.map(async $=>$.get(O,U)))}};function it_first_dist_src_isAsyncIterable(O){return null!=O[Symbol.asyncIterator]}var it_first_dist_src=function(O){if(it_first_dist_src_isAsyncIterable(O))return(async()=>{for await(let U of O)return U})();for(let U of O)return U};let f0=logger("libp2p:peer-routing");let DefaultPeerRouting=class DefaultPeerRouting{components;routers;constructor(O,U){this.components=O,this.routers=U.routers??[]}async findPeer(O,U){if(0===this.routers.length)throw new errors_CodeError("No peer routers available",rv.ERR_NO_ROUTERS_AVAILABLE);if(O.toString()===this.components.peerId.toString())throw new errors_CodeError("Should not try to find self",rv.ERR_FIND_SELF);let $=await pipe(it_merge_dist_src(...this.routers.map($=>(async function*(){try{yield await $.findPeer(O,U)}catch(O){f0.error(O)}})())),O=>it_filter_dist_src(O,Boolean),O=>storeAddresses(O,this.components.peerStore),async O=>it_first_dist_src(O));if(null!=$)return $;throw new errors_CodeError(ry.NOT_FOUND,rv.ERR_NOT_FOUND)}async *getClosestPeers(O,U){if(0===this.routers.length)throw new errors_CodeError("No peer routers available",rv.ERR_NO_ROUTERS_AVAILABLE);yield*pipe(it_merge_dist_src(...this.routers.map($=>$.getClosestPeers(O,U))),O=>storeAddresses(O,this.components.peerStore),O=>uniquePeers(O),O=>requirePeers(O))}};let f1=logger("libp2p:registrar"),f2=32,f3=64;let DefaultRegistrar=class DefaultRegistrar{topologies;handlers;components;constructor(O){this.topologies=new Map,this.handlers=new Map,this.components=O,this._onDisconnect=this._onDisconnect.bind(this),this._onPeerUpdate=this._onPeerUpdate.bind(this),this._onConnect=this._onConnect.bind(this),this.components.events.addEventListener("peer:disconnect",this._onDisconnect),this.components.events.addEventListener("peer:connect",this._onConnect),this.components.events.addEventListener("peer:update",this._onPeerUpdate)}getProtocols(){return Array.from(new Set([...this.handlers.keys()])).sort()}getHandler(O){let U=this.handlers.get(O);if(null==U)throw new errors_CodeError(`No handler registered for protocol ${O}`,rv.ERR_NO_HANDLER_FOR_PROTOCOL);return U}getTopologies(O){let U=this.topologies.get(O);return null==U?[]:[...U.values()]}async handle(O,U,$){if(this.handlers.has(O))throw new errors_CodeError(`Handler already registered for protocol ${O}`,rv.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED);let J=hK.bind({ignoreUndefined:!0})({maxInboundStreams:f2,maxOutboundStreams:f3},$);this.handlers.set(O,{handler:U,options:J}),await this.components.peerStore.merge(this.components.peerId,{protocols:[O]})}async unhandle(O){let U=Array.isArray(O)?O:[O];U.forEach(O=>{this.handlers.delete(O)}),await this.components.peerStore.patch(this.components.peerId,{protocols:this.getProtocols()})}async register(O,U){if(null==U)throw new errors_CodeError("invalid topology",rv.ERR_INVALID_PARAMETERS);let $=`${(1e9*Math.random()).toString(36)}${Date.now()}`,J=this.topologies.get(O);return null==J&&(J=new Map,this.topologies.set(O,J)),J.set($,U),$}unregister(O){for(let[U,$]of this.topologies.entries())$.has(O)&&($.delete(O),0===$.size&&this.topologies.delete(U))}_onDisconnect(O){let U=O.detail;this.components.peerStore.get(U).then(O=>{for(let $ of O.protocols){let O=this.topologies.get($);if(null!=O)for(let $ of O.values())$.onDisconnect?.(U)}}).catch(O=>{O.code!==rv.ERR_NOT_FOUND&&f1.error("could not inform topologies of disconnecting peer %p",U,O)})}_onConnect(O){let U=O.detail;this.components.peerStore.get(U).then(O=>{let $=this.components.connectionManager.getConnections(O.id)[0];if(null==$){f1("peer %p connected but the connection manager did not have a connection",O);return}for(let J of O.protocols){let O=this.topologies.get(J);if(null!=O)for(let J of O.values())J.onConnect?.(U,$)}}).catch(O=>{O.code!==rv.ERR_NOT_FOUND&&f1.error("could not inform topologies of connecting peer %p",U,O)})}_onPeerUpdate(O){let{peer:U,previous:$}=O.detail,J=($?.protocols??[]).filter(O=>!U.protocols.includes(O)),en=U.protocols.filter(O=>!($?.protocols??[]).includes(O));for(let O of J){let $=this.topologies.get(O);if(null!=$)for(let O of $.values())O.onDisconnect?.(U.id)}for(let O of en){let $=this.topologies.get(O);if(null!=$)for(let O of $.values()){let $=this.components.connectionManager.getConnections(U.id)[0];null!=$&&O.onConnect?.(U.id,$)}}}};let TrackedMap=class TrackedMap extends Map{metric;constructor(O){super();let{name:U,metrics:$}=O;this.metric=$.registerMetric(U),this.updateComponentMetric()}set(O,U){return super.set(O,U),this.updateComponentMetric(),this}delete(O){let U=super.delete(O);return this.updateComponentMetric(),U}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function trackedMap(O){let{name:U,metrics:$}=O;return null!=$?new TrackedMap({name:U,metrics:$}):new Map}let f6=logger("libp2p:transports");let DefaultTransportManager=class DefaultTransportManager{components;transports;listeners;faultTolerance;started;constructor(O,U={}){this.components=O,this.started=!1,this.transports=new Map,this.listeners=trackedMap({name:"libp2p_transport_manager_listeners",metrics:this.components.metrics}),this.faultTolerance=U.faultTolerance??tp.FATAL_ALL}add(O){let U=O[Symbol.toStringTag];if(null==U)throw new errors_CodeError("Transport must have a valid tag",rv.ERR_INVALID_KEY);if(this.transports.has(U))throw new errors_CodeError(`There is already a transport with the tag ${U}`,rv.ERR_DUPLICATE_TRANSPORT);f6("adding transport %s",U),this.transports.set(U,O),this.listeners.has(U)||this.listeners.set(U,[])}isStarted(){return this.started}start(){this.started=!0}async afterStart(){let O=this.components.addressManager.getListenAddrs();await this.listen(O)}async stop(){let O=[];for(let[U,$]of this.listeners)for(f6("closing listeners for %s",U);$.length>0;){let U=$.pop();null!=U&&O.push(U.close())}for(let U of(await Promise.all(O),f6("all listeners closed"),this.listeners.keys()))this.listeners.set(U,[]);this.started=!1}async dial(O,U){let $=this.transportForMultiaddr(O);if(null==$)throw new errors_CodeError(`No transport available for address ${String(O)}`,rv.ERR_TRANSPORT_UNAVAILABLE);try{return await $.dial(O,{...U,upgrader:this.components.upgrader})}catch(O){throw null==O.code&&(O.code=rv.ERR_TRANSPORT_DIAL_FAILED),O}}getAddrs(){let O=[];for(let U of this.listeners.values())for(let $ of U)O=[...O,...$.getAddrs()];return O}getTransports(){return Array.of(...this.transports.values())}getListeners(){return Array.of(...this.listeners.values()).flat()}transportForMultiaddr(O){for(let U of this.transports.values()){let $=U.filter([O]);if($.length>0)return U}}async listen(O){if(!this.isStarted())throw new errors_CodeError("Not started",rv.ERR_NODE_NOT_STARTED);if(null==O||0===O.length){f6("no addresses were provided for listening, this node is dial only");return}let U=[];for(let[$,J]of this.transports.entries()){let en=J.filter(O),es=[];for(let O of en){f6("creating listener for %s on %a",$,O);let U=J.createListener({upgrader:this.components.upgrader}),en=this.listeners.get($)??[];null==en&&(en=[],this.listeners.set($,en)),en.push(U),U.addEventListener("listening",()=>{this.components.events.safeDispatchEvent("transport:listening",{detail:U})}),U.addEventListener("close",()=>{let O=en.findIndex(O=>O===U);en.splice(O,1),this.components.events.safeDispatchEvent("transport:close",{detail:U})}),es.push(U.listen(O))}if(0===es.length){U.push($);continue}let eo=await Promise.allSettled(es),ea=eo.find(O=>"fulfilled"===O.status);if(null==ea&&this.faultTolerance!==tp.NO_FATAL)throw new errors_CodeError(`Transport (${$}) could not listen on any available address`,rv.ERR_NO_VALID_ADDRESSES)}if(U.length===this.transports.size){let O=`no valid addresses were provided for transports [${U.join(", ")}]`;if(this.faultTolerance===tp.FATAL_ALL)throw new errors_CodeError(O,rv.ERR_NO_VALID_ADDRESSES);f6(`libp2p in dial mode only: ${O}`)}}async remove(O){let U=this.listeners.get(O)??[];f6.trace("removing transport %s",O);let $=[];for(f6.trace("closing listeners for %s",O);U.length>0;){let O=U.pop();null!=O&&$.push(O.close())}await Promise.all($),this.transports.delete(O),this.listeners.delete(O)}async removeAll(){let O=[];for(let U of this.transports.keys())O.push(this.remove(U));await Promise.all(O)}};let f4="/multistream/1.0.0",f5=1024;function src_reader(O){let U=async function*(){let U=yield,$=new src_Uint8ArrayList;for await(let J of O){if(null==U){$.append(J),U=yield $,$=new src_Uint8ArrayList;continue}for($.append(J);$.length>=U;){let O=$.sublist(0,U);if($.consume(U),null==(U=yield O)){$.length>0&&(U=yield $,$=new src_Uint8ArrayList);break}}}if(null!=U)throw Object.assign(Error(`stream ended before ${U} bytes became available`),{code:"ERR_UNDER_READ",buffer:$})}();return U.next(),U}function handshake(O){let U;let $=src_pushable(),J=src_reader(O.source),en=pDefer(),es=O.sink(async function*(){yield*$;let O=await en.promise;yield*O}());es.catch(O=>{U=O});let eo={sink:async O=>{if(null!=U){await Promise.reject(U);return}en.resolve(O),await es},source:J};return{reader:J,writer:$,stream:eo,rest:()=>$.end(),write:$.push,read:async()=>{let O=await J.next();if(null!=O.value)return O.value}}}let f8=logger("libp2p:mss"),f9=(0,rJ.m)("\n");function multistream_encode(O){let U=new src_Uint8ArrayList(O,f9);return encode_encode.single(U)}function multistream_write(O,U,$={}){let J=multistream_encode(U);!0===$.writeBytes?O.push(J.subarray()):O.push(J)}function writeAll(O,U,$={}){let J=new src_Uint8ArrayList;for(let O of U)J.append(multistream_encode(O));!0===$.writeBytes?O.push(J.subarray()):O.push(J)}async function multistream_read(O,U){let $=1,J={[Symbol.asyncIterator]:()=>J,next:async()=>O.next($)},en=J;U?.signal!=null&&(en=abortableSource(J,U.signal));let onLength=O=>{$=O},es=await pipe(en,O=>decode_decode(O,{onLength,maxDataLength:f5}),async O=>it_first_dist_src(O));if(null==es||0===es.length)throw new errors_CodeError("no buffer returned","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");if(es.get(es.byteLength-1)!==f9[0])throw f8.error("Invalid mss message - missing newline - %s",es.subarray()),new errors_CodeError("missing newline","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return es.sublist(0,-1)}async function readString(O,U){let $=await multistream_read(O,U);return(0,rB.B)($.subarray())}let f7=logger("libp2p:mss:select");async function select_select(O,U,$={}){U=Array.isArray(U)?[...U]:[U];let{reader:J,writer:en,rest:es,stream:eo}=handshake(O),ea=U.shift();if(null==ea)throw Error("At least one protocol must be specified");f7.trace('select: write ["%s", "%s"]',f4,ea);let eu=(0,rJ.m)(f4),ef=(0,rJ.m)(ea);writeAll(en,[eu,ef],$);let eg=await readString(J,$);if(f7.trace('select: read "%s"',eg),eg===f4&&(eg=await readString(J,$),f7.trace('select: read "%s"',eg)),eg===ea)return es(),{stream:eo,protocol:ea};for(let O of U){f7.trace('select: write "%s"',O),multistream_write(en,(0,rJ.m)(O),$);let U=await readString(J,$);if(f7.trace('select: read "%s" for "%s"',U,O),U===O)return es(),{stream:eo,protocol:O}}throw es(),new errors_CodeError("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL")}let pe=logger("libp2p:mss:handle");async function handle(O,U,$){U=Array.isArray(U)?U:[U];let{writer:J,reader:en,rest:es,stream:eo}=handshake(O);for(;;){let O=await readString(en,$);if(pe.trace('read "%s"',O),O===f4){pe.trace('respond with "%s" for "%s"',f4,O),multistream_write(J,(0,rJ.m)(f4),$);continue}if(U.includes(O))return multistream_write(J,(0,rJ.m)(O),$),pe.trace('respond with "%s" for "%s"',O,O),es(),{stream:eo,protocol:O};if("ls"===O){multistream_write(J,new src_Uint8ArrayList(...U.map(O=>multistream_encode((0,rJ.m)(O)))),$),pe.trace('respond with "%s" for %s',U,O);continue}multistream_write(J,(0,rJ.m)("na"),$),pe('respond with "na" for "%s"',O)}}let pr=Symbol.for("@libp2p/connection"),pn=logger("libp2p:connection"),ps=500;let ConnectionImpl=class ConnectionImpl{id;remoteAddr;remotePeer;direction;timeline;multiplexer;encryption;status;transient;tags;_newStream;_close;_abort;_getStreams;constructor(O){let{remoteAddr:U,remotePeer:$,newStream:J,close:en,abort:es,getStreams:eo}=O;this.id=`${parseInt(String(1e9*Math.random())).toString(36)}${Date.now()}`,this.remoteAddr=U,this.remotePeer=$,this.direction=O.direction,this.status="open",this.timeline=O.timeline,this.multiplexer=O.multiplexer,this.encryption=O.encryption,this.transient=O.transient??!1,this._newStream=J,this._close=en,this._abort=es,this._getStreams=eo,this.tags=[]}[Symbol.toStringTag]="Connection";[pr]=!0;get streams(){return this._getStreams()}async newStream(O,U){if("closing"===this.status)throw new errors_CodeError("the connection is being closed","ERR_CONNECTION_BEING_CLOSED");if("closed"===this.status)throw new errors_CodeError("the connection is closed","ERR_CONNECTION_CLOSED");if(Array.isArray(O)||(O=[O]),this.transient&&U?.runOnTransientConnection!==!0)throw new errors_CodeError("Cannot open protocol stream on transient connection","ERR_TRANSIENT_CONNECTION");let $=await this._newStream(O,U);return $.direction="outbound",$}async close(O={}){if("closed"!==this.status&&"closing"!==this.status){pn("closing connection to %a",this.remoteAddr),this.status="closing",O.signal=O?.signal??AbortSignal.timeout(ps);try{hD.setMaxListeners?.(1/0,O.signal)}catch{}try{pn.trace("closing all streams"),await Promise.all(this.streams.map(async U=>U.close(O))),pn.trace("closing underlying transport"),await this._close(O),pn.trace("updating timeline with close time"),this.status="closed",this.timeline.close=Date.now()}catch(O){pn.error("error encountered during graceful close of connection to %a",this.remoteAddr,O),this.abort(O)}}}abort(O){pn.error("aborting connection to %a due to error",this.remoteAddr,O),this.status="closing",this.streams.forEach(U=>{U.abort(O)}),pn.error("all streams aborted",this.streams.length),this._abort(O),this.timeline.close=Date.now(),this.status="closed"}};function createConnection(O){return new ConnectionImpl(O)}let po=logger("libp2p:upgrader");function findIncomingStreamLimit(O,U){try{let{options:$}=U.getHandler(O);return $.maxInboundStreams}catch(O){if(O.code!==rv.ERR_NO_HANDLER_FOR_PROTOCOL)throw O}return f2}function findOutgoingStreamLimit(O,U,$={}){try{let{options:$}=U.getHandler(O);if(null!=$.maxOutboundStreams)return $.maxOutboundStreams}catch(O){if(O.code!==rv.ERR_NO_HANDLER_FOR_PROTOCOL)throw O}return $.maxOutboundStreams??f3}function countStreams(O,U,$){let J=0;return $.streams.forEach($=>{$.direction===U&&$.protocol===O&&J++}),J}let DefaultUpgrader=class DefaultUpgrader{components;connectionEncryption;muxers;inboundUpgradeTimeout;events;constructor(O,U){this.components=O,this.connectionEncryption=new Map,U.connectionEncryption.forEach(O=>{this.connectionEncryption.set(O.protocol,O)}),this.muxers=new Map,U.muxers.forEach(O=>{this.muxers.set(O.protocol,O)}),this.inboundUpgradeTimeout=U.inboundUpgradeTimeout??fx,this.events=O.events}async shouldBlockConnection(O,U,$){let J=this.components.connectionGater[$];if(void 0!==J&&await J(O,U))throw new errors_CodeError(`The multiaddr connection is blocked by gater.${$}`,rv.ERR_CONNECTION_INTERCEPTED)}async upgradeInbound(O,U){let $,J,en,es,eo;let ea=await this.components.connectionManager.acceptIncomingConnection(O);if(!ea)throw new errors_CodeError("connection denied",rv.ERR_CONNECTION_DENIED);let eu=AbortSignal.timeout(this.inboundUpgradeTimeout),onAbort=()=>{O.abort(new errors_CodeError("inbound upgrade timeout",rv.ERR_TIMEOUT))};eu.addEventListener("abort",onAbort,{once:!0});try{hD.setMaxListeners?.(1/0,eu)}catch{}try{if(await this.components.connectionGater.denyInboundConnection?.(O)===!0)throw new errors_CodeError("The multiaddr connection is blocked by gater.acceptConnection",rv.ERR_CONNECTION_INTERCEPTED);this.components.metrics?.trackMultiaddrConnection(O),po("starting the inbound connection upgrade");let ea=O;if(U?.skipProtection!==!0){let U=this.components.connectionProtector;null!=U&&(po("protecting the inbound connection"),ea=await U.protect(O))}try{if($=ea,U?.skipEncryption!==!0){({conn:$,remotePeer:J,protocol:eo}=await this._encryptInbound(ea));let O={...ea,...$};await this.shouldBlockConnection(J,O,"denyInboundEncryptedConnection")}else{let U=O.remoteAddr.getPeerId();if(null==U)throw new errors_CodeError("inbound connection that skipped encryption must have a peer id",rv.ERR_INVALID_MULTIADDR);let $=peerIdFromString(U);eo="native",J=$}if(en=$,U?.muxerFactory!=null)es=U.muxerFactory;else if(this.muxers.size>0){let O=await this._multiplexInbound({...ea,...$},this.muxers);es=O.muxerFactory,en=O.stream}}catch(O){throw po.error("Failed to upgrade inbound connection",O),O}return await this.shouldBlockConnection(J,O,"denyInboundUpgradedConnection"),po("Successfully upgraded inbound connection"),this._createConnection({cryptoProtocol:eo,direction:"inbound",maConn:O,upgradedConn:en,muxerFactory:es,remotePeer:J,transient:U?.transient})}finally{eu.removeEventListener("abort",onAbort),this.components.connectionManager.afterUpgradeInbound()}}async upgradeOutbound(O,U){let $,J,en,es,eo,ea;let eu=O.remoteAddr.getPeerId();null!=eu&&($=peerIdFromString(eu),await this.shouldBlockConnection($,O,"denyOutboundConnection")),this.components.metrics?.trackMultiaddrConnection(O),po("Starting the outbound connection upgrade");let ef=O;if(U?.skipProtection!==!0){let U=this.components.connectionProtector;null!=U&&(ef=await U.protect(O))}try{if(J=ef,U?.skipEncryption!==!0){({conn:J,remotePeer:en,protocol:eo}=await this._encryptOutbound(ef,$));let O={...ef,...J};await this.shouldBlockConnection(en,O,"denyOutboundEncryptedConnection")}else{if(null==$)throw new errors_CodeError("Encryption was skipped but no peer id was passed",rv.ERR_INVALID_PEER);eo="native",en=$}if(es=J,U?.muxerFactory!=null)ea=U.muxerFactory;else if(this.muxers.size>0){let O=await this._multiplexOutbound({...ef,...J},this.muxers);ea=O.muxerFactory,es=O.stream}}catch(U){throw po.error("Failed to upgrade outbound connection",U),await O.close(U),U}return await this.shouldBlockConnection(en,O,"denyOutboundUpgradedConnection"),po("Successfully upgraded outbound connection"),this._createConnection({cryptoProtocol:eo,direction:"outbound",maConn:O,upgradedConn:es,muxerFactory:ea,remotePeer:en,transient:U?.transient})}_createConnection(O){let U,$,J;let{cryptoProtocol:en,direction:es,maConn:eo,upgradedConn:ea,remotePeer:eu,muxerFactory:ef,transient:eg}=O;null!=ef&&(U=ef.createStreamMuxer({direction:es,onIncomingStream:O=>{null!=J&&Promise.resolve().then(async()=>{let U=this.components.registrar.getProtocols(),{stream:$,protocol:en}=await handle(O,U);if(po("%s: incoming stream opened on %s",es,en),null==J)return;let eo=findIncomingStreamLimit(en,this.components.registrar),ea=countStreams(en,"inbound",J);if(ea===eo){let U=new errors_CodeError(`Too many inbound protocol streams for protocol "${en}" - limit ${eo}`,rv.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS);throw O.abort(U),U}O.source=$.source,O.sink=$.sink,O.protocol=en,await this.components.peerStore.merge(eu,{protocols:[en]}),this.components.metrics?.trackProtocolStream(O,J),this._onStream({connection:J,stream:O,protocol:en})}).catch(async U=>{po.error(U),null==O.timeline.close&&await O.close()})}}),$=async(O,$={})=>{if(null==U)throw new errors_CodeError("Stream is not multiplexed",rv.ERR_MUXER_UNAVAILABLE);po("%s: starting new stream on %s",es,O);let en=await U.newStream();try{if(null==$.signal){po("No abort signal was passed while trying to negotiate protocols %s falling back to default timeout",O),$.signal=AbortSignal.timeout(3e4);try{hD.setMaxListeners?.(1/0,$.signal)}catch{}}let{stream:U,protocol:es}=await select_select(en,O,$),eo=findOutgoingStreamLimit(es,this.components.registrar,$),ea=countStreams(es,"outbound",J);if(ea>=eo){let O=new errors_CodeError(`Too many outbound protocol streams for protocol "${es}" - limit ${eo}`,rv.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);throw en.abort(O),O}return await this.components.peerStore.merge(eu,{protocols:[es]}),en.source=U.source,en.sink=U.sink,en.protocol=es,this.components.metrics?.trackProtocolStream(en,J),en}catch(U){if(po.error("could not create new stream for protocols %s on connection with address %a",O,J.remoteAddr,U),null==en.timeline.close&&en.abort(U),null!=U.code)throw U;throw new errors_CodeError(String(U),rv.ERR_UNSUPPORTED_PROTOCOL)}},Promise.all([U.sink(ea.source),ea.sink(U.source)]).catch(O=>{po.error(O)}));let ev=eo.timeline;eo.timeline=new Proxy(ev,{set:(...O)=>(null!=J&&"close"===O[1]&&null!=O[2]&&null==ev.close&&(async()=>{try{"open"===J.status&&await J.close()}catch(O){po.error(O)}finally{this.events.safeDispatchEvent("connection:close",{detail:J})}})().catch(O=>{po.error(O)}),Reflect.set(...O))}),eo.timeline.upgraded=Date.now();let errConnectionNotMultiplexed=()=>{throw new errors_CodeError("connection is not multiplexed",rv.ERR_CONNECTION_NOT_MULTIPLEXED)};return J=createConnection({remoteAddr:eo.remoteAddr,remotePeer:eu,status:"open",direction:es,timeline:eo.timeline,multiplexer:U?.protocol,encryption:en,transient:eg,newStream:$??errConnectionNotMultiplexed,getStreams:()=>null!=U?U.streams:[],close:async O=>{null!=U&&(po.trace("close muxer"),await U.close(O)),po.trace("close maconn"),await eo.close(O),po.trace("closed maconn")},abort:O=>{eo.abort(O),null!=U&&U.abort(O)}}),this.events.safeDispatchEvent("connection:open",{detail:J}),J}_onStream(O){let{connection:U,stream:$,protocol:J}=O,{handler:en,options:es}=this.components.registrar.getHandler(J);if(U.transient&&!0!==es.runOnTransientConnection)throw new errors_CodeError("Cannot open protocol stream on transient connection","ERR_TRANSIENT_CONNECTION");en({connection:U,stream:$})}async _encryptInbound(O){let U=Array.from(this.connectionEncryption.keys());po("handling inbound crypto protocol selection",U);try{let{stream:$,protocol:J}=await handle(O,U,{writeBytes:!0}),en=this.connectionEncryption.get(J);if(null==en)throw Error(`no crypto module found for ${J}`);return po("encrypting inbound connection..."),{...await en.secureInbound(this.components.peerId,$),protocol:J}}catch(O){throw new errors_CodeError(String(O),rv.ERR_ENCRYPTION_FAILED)}}async _encryptOutbound(O,U){let $=Array.from(this.connectionEncryption.keys());po("selecting outbound crypto protocol",$);try{let{stream:J,protocol:en}=await select_select(O,$,{writeBytes:!0}),es=this.connectionEncryption.get(en);if(null==es)throw Error(`no crypto module found for ${en}`);return po("encrypting outbound connection to %p",U),{...await es.secureOutbound(this.components.peerId,J,U),protocol:en}}catch(O){throw new errors_CodeError(String(O),rv.ERR_ENCRYPTION_FAILED)}}async _multiplexOutbound(O,U){let $=Array.from(U.keys());po("outbound selecting muxer %s",$);try{let{stream:J,protocol:en}=await select_select(O,$,{writeBytes:!0});po("%s selected as muxer protocol",en);let es=U.get(en);return{stream:J,muxerFactory:es}}catch(O){throw po.error("error multiplexing outbound stream",O),new errors_CodeError(String(O),rv.ERR_MUXER_UNAVAILABLE)}}async _multiplexInbound(O,U){let $=Array.from(U.keys());po("inbound handling muxers %s",$);try{let{stream:J,protocol:en}=await handle(O,$,{writeBytes:!0}),es=U.get(en);return{stream:J,muxerFactory:es}}catch(O){throw po.error("error multiplexing inbound stream",O),new errors_CodeError(String(O),rv.ERR_MUXER_UNAVAILABLE)}}};let pa=logger("libp2p");let Libp2pNode=class Libp2pNode extends TypedEventEmitter{peerId;peerStore;contentRouting;peerRouting;keychain;metrics;services;components;#c;constructor(O){super();let U=new TypedEventEmitter,$=U.dispatchEvent.bind(U);U.dispatchEvent=O=>{let U=$(O),J=this.dispatchEvent(new l3(O.type,{detail:O.detail}));return U||J};try{hD.setMaxListeners?.(1/0,U)}catch{}this.#c=!1,this.peerId=O.peerId,this.services={};let J=this.components=defaultComponents({peerId:O.peerId,events:U,datastore:O.datastore??new MemoryDatastore,connectionGater:connectionGater(O.connectionGater)});this.peerStore=this.configureComponent("peerStore",new PersistentPeerStore(J,{addressFilter:this.components.connectionGater.filterMultiaddrForPeer,...O.peerStore})),null!=O.metrics&&(this.metrics=this.configureComponent("metrics",O.metrics(this.components))),J.events.addEventListener("peer:update",O=>{if(null==O.detail.previous){let U={id:O.detail.peer.id,multiaddrs:O.detail.peer.addresses.map(O=>O.multiaddr),protocols:O.detail.peer.protocols};J.events.safeDispatchEvent("peer:discovery",{detail:U})}}),null!=O.connectionProtector&&this.configureComponent("connectionProtector",O.connectionProtector(J)),this.components.upgrader=new DefaultUpgrader(this.components,{connectionEncryption:(O.connectionEncryption??[]).map((O,U)=>this.configureComponent(`connection-encryption-${U}`,O(this.components))),muxers:(O.streamMuxers??[]).map((O,U)=>this.configureComponent(`stream-muxers-${U}`,O(this.components))),inboundUpgradeTimeout:O.connectionManager.inboundUpgradeTimeout}),this.configureComponent("transportManager",new DefaultTransportManager(this.components,O.transportManager)),this.configureComponent("connectionManager",new DefaultConnectionManager(this.components,O.connectionManager)),this.configureComponent("registrar",new DefaultRegistrar(this.components)),this.configureComponent("addressManager",new DefaultAddressManager(this.components,O.addresses));let en=DefaultKeyChain.generateOptions();this.keychain=this.configureComponent("keyChain",new DefaultKeyChain(this.components,{...en,...O.keychain}));let es=(O.peerRouters??[]).map((O,U)=>this.configureComponent(`peer-router-${U}`,O(this.components)));this.peerRouting=this.components.peerRouting=this.configureComponent("peerRouting",new DefaultPeerRouting(this.components,{routers:es}));let eo=(O.contentRouters??[]).map((O,U)=>this.configureComponent(`content-router-${U}`,O(this.components)));if(this.contentRouting=this.components.contentRouting=this.configureComponent("contentRouting",new CompoundContentRouting(this.components,{routers:eo})),(O.peerDiscovery??[]).forEach((O,U)=>{let $=this.configureComponent(`peer-discovery-${U}`,O(this.components));$.addEventListener("peer",O=>{this.#u(O)})}),O.transports.forEach((O,U)=>{this.components.transportManager.add(this.configureComponent(`transport-${U}`,O(this.components)))}),null!=O.services)for(let U of Object.keys(O.services)){let $=O.services[U],J=$(this.components);if(null==J){pa.error("service factory %s returned null or undefined instance",U);continue}this.services[U]=J,this.configureComponent(U,J),null!=J[hM]&&(pa("registering service %s for content routing",U),eo.push(J[hM])),null!=J[hO]&&(pa("registering service %s for peer routing",U),es.push(J[hO])),null!=J[l6]&&(pa("registering service %s for peer discovery",U),J[l6].addEventListener("peer",O=>{this.#u(O)}))}}configureComponent(O,U){return null==U&&pa.error("component %s was null or undefined",O),this.components[O]=U,U}async start(){if(this.#c)return;this.#c=!0,pa("libp2p is starting");let O=await this.keychain.listKeys();null==O.find(O=>"self"===O.name)&&(pa("importing self key into keychain"),await this.keychain.importPeer("self",this.components.peerId));try{await this.components.beforeStart?.(),await this.components.start(),await this.components.afterStart?.(),this.safeDispatchEvent("start",{detail:this}),pa("libp2p has started")}catch(O){throw pa.error("An error occurred starting libp2p",O),await this.stop(),O}}async stop(){this.#c&&(pa("libp2p is stopping"),this.#c=!1,await this.components.beforeStop?.(),await this.components.stop(),await this.components.afterStop?.(),this.safeDispatchEvent("stop",{detail:this}),pa("libp2p has stopped"))}isStarted(){return this.#c}getConnections(O){return this.components.connectionManager.getConnections(O)}getDialQueue(){return this.components.connectionManager.getDialQueue()}getPeers(){let O=new PeerSet;for(let U of this.components.connectionManager.getConnections())O.add(U.remotePeer);return Array.from(O)}async dial(O,U={}){return this.components.connectionManager.openConnection(O,U)}async dialProtocol(O,U,$={}){if(null==U||0===(U=Array.isArray(U)?U:[U]).length)throw new errors_CodeError("no protocols were provided to open a stream",rv.ERR_INVALID_PROTOCOLS_FOR_STREAM);let J=await this.dial(O,$);return J.newStream(U,$)}getMultiaddrs(){return this.components.addressManager.getAddresses()}getProtocols(){return this.components.registrar.getProtocols()}async hangUp(O,U={}){isMultiaddr(O)&&(O=peerIdFromString(O.getPeerId()??"")),await this.components.connectionManager.closeConnections(O,U)}async getPublicKey(O,U={}){if(pa("getPublicKey %p",O),null!=O.publicKey)return O.publicKey;let $=await this.peerStore.get(O);if(null!=$.id.publicKey)return $.id.publicKey;let J=concat_concat([(0,rJ.m)("/pk/"),O.multihash.digest]),en=await this.contentRouting.get(J,U);return src_keys_unmarshalPublicKey(en),await this.peerStore.patch(O,{publicKey:en}),en}async handle(O,U,$){Array.isArray(O)||(O=[O]),await Promise.all(O.map(async O=>{await this.components.registrar.handle(O,U,$)}))}async unhandle(O){Array.isArray(O)||(O=[O]),await Promise.all(O.map(async O=>{await this.components.registrar.unhandle(O)}))}async register(O,U){return this.components.registrar.register(O,U)}unregister(O){this.components.registrar.unregister(O)}#u(O){let{detail:U}=O;if(U.id.toString()===this.peerId.toString()){pa.error(Error(rv.ERR_DISCOVERED_SELF));return}this.components.peerStore.merge(U.id,{multiaddrs:U.multiaddrs,protocols:U.protocols}).catch(O=>{pa.error(O)})}};async function createLibp2pNode(O){if(null==O.peerId){let U=O.datastore;if(null!=U)try{let $=new DefaultKeyChain({datastore:U},hK(DefaultKeyChain.generateOptions(),O.keychain));O.peerId=await $.exportPeerId("self")}catch(O){if("ERR_NOT_FOUND"!==O.code)throw O}}return null==O.peerId&&(O.peerId=await createEd25519PeerId()),new Libp2pNode(validateConfig(O))}async function createLibp2p(O){let U=await createLibp2pNode(O);return!1!==O.start&&await U.start(),U}let pl="0.46.16",pc=`js-libp2p/${pl}`,pd="0.1.0",pf="id",pp="id/push",pg="1.0.0",pv="1.0.0";function pbStream(O,U){let $=lpStream(O,U),J={read:async(O,U)=>{let J=await $.read(U);return O.decode(J)},write:async(O,U,J)=>{await $.write(U.encode(O),J)},pb:O=>({read:async U=>J.read(O,U),write:async(U,$)=>J.write(U,O,$),unwrap:()=>J}),unwrap:()=>$.unwrap()};return J}!function(O){let U;O.codec=()=>(null==U&&(U=message((O,U,$={})=>{if(!1!==$.lengthDelimited&&U.fork(),null!=O.protocolVersion&&(U.uint32(42),U.string(O.protocolVersion)),null!=O.agentVersion&&(U.uint32(50),U.string(O.agentVersion)),null!=O.publicKey&&(U.uint32(10),U.bytes(O.publicKey)),null!=O.listenAddrs)for(let $ of O.listenAddrs)U.uint32(18),U.bytes($);if(null!=O.observedAddr&&(U.uint32(34),U.bytes(O.observedAddr)),null!=O.protocols)for(let $ of O.protocols)U.uint32(26),U.string($);null!=O.signedPeerRecord&&(U.uint32(66),U.bytes(O.signedPeerRecord)),!1!==$.lengthDelimited&&U.ldelim()},(O,U)=>{let $={listenAddrs:[],protocols:[]},J=null==U?O.len:O.pos+U;for(;O.pos>>3){case 5:$.protocolVersion=O.string();break;case 6:$.agentVersion=O.string();break;case 1:$.publicKey=O.bytes();break;case 2:$.listenAddrs.push(O.bytes());break;case 4:$.observedAddr=O.bytes();break;case 3:$.protocols.push(O.string());break;case 8:$.signedPeerRecord=O.bytes();break;default:O.skipType(7&U)}}return $})),U),O.encode=U=>encodeMessage(U,O.codec()),O.decode=U=>decodeMessage(U,O.codec())}(r_||(r_={}));let p_=logger("libp2p:identify"),pw=8192,pE={protocolPrefix:"ipfs",agentVersion:pc,timeout:6e4,maxInboundStreams:1,maxOutboundStreams:1,maxPushIncomingStreams:1,maxPushOutgoingStreams:1,maxObservedAddresses:10,maxIdentifyMessageSize:8192,runOnConnectionOpen:!0,runOnTransientConnection:!0};let DefaultIdentifyService=class DefaultIdentifyService{identifyProtocolStr;identifyPushProtocolStr;host;started;timeout;peerId;peerStore;registrar;connectionManager;addressManager;maxInboundStreams;maxOutboundStreams;maxPushIncomingStreams;maxPushOutgoingStreams;maxIdentifyMessageSize;maxObservedAddresses;events;runOnTransientConnection;constructor(O,U){this.started=!1,this.peerId=O.peerId,this.peerStore=O.peerStore,this.registrar=O.registrar,this.addressManager=O.addressManager,this.connectionManager=O.connectionManager,this.events=O.events,this.identifyProtocolStr=`/${U.protocolPrefix??pE.protocolPrefix}/${pf}/${pg}`,this.identifyPushProtocolStr=`/${U.protocolPrefix??pE.protocolPrefix}/${pp}/${pv}`,this.timeout=U.timeout??pE.timeout,this.maxInboundStreams=U.maxInboundStreams??pE.maxInboundStreams,this.maxOutboundStreams=U.maxOutboundStreams??pE.maxOutboundStreams,this.maxPushIncomingStreams=U.maxPushIncomingStreams??pE.maxPushIncomingStreams,this.maxPushOutgoingStreams=U.maxPushOutgoingStreams??pE.maxPushOutgoingStreams,this.maxIdentifyMessageSize=U.maxIdentifyMessageSize??pE.maxIdentifyMessageSize,this.maxObservedAddresses=U.maxObservedAddresses??pE.maxObservedAddresses,this.runOnTransientConnection=U.runOnTransientConnection??pE.runOnTransientConnection,this.host={protocolVersion:`${U.protocolPrefix??pE.protocolPrefix}/${pd}`,agentVersion:U.agentVersion??pE.agentVersion},(U.runOnConnectionOpen??pE.runOnConnectionOpen)&&O.events.addEventListener("connection:open",O=>{let U=O.detail;this.identify(U).catch(O=>{p_.error("error during identify trigged by connection:open",O)})}),O.events.addEventListener("self:peer:update",O=>{this.push().catch(O=>{p_.error(O)})}),this.host.agentVersion===pc&&(lS||lw?this.host.agentVersion+=` UserAgent=${globalThis.process.version}`:(l_||lA||lE||lI)&&(this.host.agentVersion+=` UserAgent=${globalThis.navigator.userAgent}`))}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:(0,rJ.m)(this.host.agentVersion),ProtocolVersion:(0,rJ.m)(this.host.protocolVersion)}}),await this.registrar.handle(this.identifyProtocolStr,O=>{this._handleIdentify(O).catch(O=>{p_.error(O)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnTransientConnection:this.runOnTransientConnection}),await this.registrar.handle(this.identifyPushProtocolStr,O=>{this._handlePush(O).catch(O=>{p_.error(O)})},{maxInboundStreams:this.maxPushIncomingStreams,maxOutboundStreams:this.maxPushOutgoingStreams,runOnTransientConnection:this.runOnTransientConnection}),this.started=!0)}async stop(){await this.registrar.unhandle(this.identifyProtocolStr),await this.registrar.unhandle(this.identifyPushProtocolStr),this.started=!1}async pushToConnections(O){let U=this.addressManager.getAddresses().map(O=>O.decapsulateCode(protocols_table_getProtocol("p2p").code)),$=new PeerRecord({peerId:this.peerId,multiaddrs:U}),J=await RecordEnvelope.seal($,this.peerId),en=this.registrar.getProtocols(),es=await this.peerStore.get(this.peerId),eo=(0,rB.B)(es.metadata.get("AgentVersion")??(0,rJ.m)(this.host.agentVersion)),ea=(0,rB.B)(es.metadata.get("ProtocolVersion")??(0,rJ.m)(this.host.protocolVersion)),eu=O.map(async O=>{let $;let es=AbortSignal.timeout(this.timeout);try{hD.setMaxListeners?.(1/0,es)}catch{}try{$=await O.newStream([this.identifyPushProtocolStr],{signal:es,runOnTransientConnection:this.runOnTransientConnection});let eu=pbStream($,{maxDataLength:this.maxIdentifyMessageSize??pw}).pb(r_);await eu.write({listenAddrs:U.map(O=>O.bytes),signedPeerRecord:J.marshal(),protocols:en,agentVersion:eo,protocolVersion:ea},{signal:es}),await $.close({signal:es})}catch(O){p_.error("could not push identify update to peer",O),$?.abort(O)}});await Promise.all(eu)}async push(){if(!this.isStarted())return;let O=[];await Promise.all(this.connectionManager.getConnections().map(async U=>{try{let $=await this.peerStore.get(U.remotePeer);if(!$.protocols.includes(this.identifyPushProtocolStr))return;O.push(U)}catch(O){if(O.code!==rv.ERR_NOT_FOUND)throw O}})),await this.pushToConnections(O)}async _identify(O,U={}){let $;U.signal=U.signal??AbortSignal.timeout(this.timeout);try{$=await O.newStream([this.identifyProtocolStr],{...U,runOnTransientConnection:this.runOnTransientConnection});let J=pbStream($,{maxDataLength:this.maxIdentifyMessageSize??pw}).pb(r_),en=await J.read(U);return await $.close(U),en}catch(O){throw p_.error("error while reading identify message",O),$?.abort(O),O}}async identify(O,U={}){let $=await this._identify(O,U),{publicKey:J,protocols:en,observedAddr:es}=$;if(null==J)throw new errors_CodeError("public key was missing from identify message",rv.ERR_MISSING_PUBLIC_KEY);let eo=await src_peerIdFromKeys(J);if(!O.remotePeer.equals(eo))throw new errors_CodeError("identified peer does not match the expected peer",rv.ERR_INVALID_PEER);if(this.peerId.equals(eo))throw new errors_CodeError("identified peer is our own peer id?",rv.ERR_INVALID_PEER);let ea=getCleanMultiaddr(es);p_("identify completed for peer %p and protocols %o",eo,en),p_("our observed address is %a",ea),null!=ea&&this.addressManager.getObservedAddrs().length<(this.maxObservedAddresses??1/0)&&(p_("storing our observed address %a",ea),this.addressManager.addObservedAddr(ea));let eu=await this.#h(O.remotePeer,$),ef={peerId:eo,protocolVersion:$.protocolVersion,agentVersion:$.agentVersion,publicKey:$.publicKey,listenAddrs:$.listenAddrs.map(O=>src_multiaddr(O)),observedAddr:null==$.observedAddr?void 0:src_multiaddr($.observedAddr),protocols:$.protocols,signedPeerRecord:eu};return this.events.safeDispatchEvent("peer:identify",{detail:ef}),ef}async _handleIdentify(O){let{connection:U,stream:$}=O,J=AbortSignal.timeout(this.timeout);try{hD.setMaxListeners?.(1/0,J)}catch{}try{let O=this.peerId.publicKey??new Uint8Array(0),en=await this.peerStore.get(this.peerId),es=this.addressManager.getAddresses().map(O=>O.decapsulateCode(protocols_table_getProtocol("p2p").code)),eo=en.peerRecordEnvelope;if(es.length>0&&null==eo){let O=new PeerRecord({peerId:this.peerId,multiaddrs:es}),U=await RecordEnvelope.seal(O,this.peerId);eo=U.marshal().subarray()}let ea=pbStream($).pb(r_);await ea.write({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:O,listenAddrs:es.map(O=>O.bytes),signedPeerRecord:eo,observedAddr:U.remoteAddr.bytes,protocols:en.protocols},{signal:J}),await $.close({signal:J})}catch(O){p_.error("could not respond to identify request",O),$.abort(O)}}async _handlePush(O){let{connection:U,stream:$}=O;try{if(this.peerId.equals(U.remotePeer))throw Error("received push from ourselves?");let O={signal:AbortSignal.timeout(this.timeout)},J=pbStream($,{maxDataLength:this.maxIdentifyMessageSize??pw}).pb(r_),en=await J.read(O);await $.close(O),await this.#h(U.remotePeer,en)}catch(O){p_.error("received invalid message",O),$.abort(O);return}p_("handled push from %p",U.remotePeer)}async #h(O,U){let $;if(p_("received identify from %p",O),null==U)throw Error("Message was null or undefined");let J={addresses:U.listenAddrs.map(O=>({isCertified:!1,multiaddr:src_multiaddr(O)})),protocols:U.protocols,metadata:new Map,peerRecordEnvelope:U.signedPeerRecord};if(null!=U.signedPeerRecord){let en;p_("received signedPeerRecord in push from %p",O);let es=U.signedPeerRecord,eo=await RecordEnvelope.openAndCertify(es,PeerRecord.DOMAIN),ea=PeerRecord.createFromProtobuf(eo.payload);if(!ea.peerId.equals(eo.peerId))throw Error("signing key does not match PeerId in the PeerRecord");if(!O.equals(ea.peerId))throw Error("signing key does not match remote PeerId");try{en=await this.peerStore.get(ea.peerId)}catch(O){if("ERR_NOT_FOUND"!==O.code)throw O}if(null!=en&&(J.metadata=en.metadata,null!=en.peerRecordEnvelope)){let O=await RecordEnvelope.createFromProtobuf(en.peerRecordEnvelope),U=PeerRecord.createFromProtobuf(O.payload);U.seqNumber>=ea.seqNumber&&(p_("sequence number was lower or equal to existing sequence number - stored: %d received: %d",U.seqNumber,ea.seqNumber),ea=U,es=en.peerRecordEnvelope)}J.peerRecordEnvelope=es,J.addresses=ea.multiaddrs.map(O=>({isCertified:!0,multiaddr:O})),$={seq:ea.seqNumber,addresses:ea.multiaddrs}}else p_("%p did not send a signed peer record",O);return null!=U.agentVersion&&J.metadata.set("AgentVersion",(0,rJ.m)(U.agentVersion)),null!=U.protocolVersion&&J.metadata.set("ProtocolVersion",(0,rJ.m)(U.protocolVersion)),await this.peerStore.patch(O,J),$}};function getCleanMultiaddr(O){if(null!=O&&O.length>0)try{return src_multiaddr(O)}catch{}}function identifyService(O={}){return U=>new DefaultIdentifyService(U,O)}let pS=32,pA="1.0.0",pI="ping",pP="ipfs",pT=1e4,pR=2,pC=1,pB=logger("libp2p:ping");let DefaultPingService=class DefaultPingService{protocol;components;started;timeout;maxInboundStreams;maxOutboundStreams;runOnTransientConnection;constructor(O,U){this.components=O,this.started=!1,this.protocol=`/${U.protocolPrefix??pP}/${pI}/${pA}`,this.timeout=U.timeout??pT,this.maxInboundStreams=U.maxInboundStreams??pR,this.maxOutboundStreams=U.maxOutboundStreams??pC,this.runOnTransientConnection=U.runOnTransientConnection??!0}async start(){await this.components.registrar.handle(this.protocol,this.handleMessage,{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnTransientConnection:this.runOnTransientConnection}),this.started=!0}async stop(){await this.components.registrar.unhandle(this.protocol),this.started=!1}isStarted(){return this.started}handleMessage(O){pB("incoming ping from %p",O.connection.remotePeer);let{stream:U}=O,$=Date.now();pipe(U,U).catch(U=>{pB.error("incoming ping from %p failed with error",O.connection.remotePeer,U)}).finally(()=>{let U=Date.now()-$;pB("incoming ping from %p complete in %dms",O.connection.remotePeer,U)})}async ping(O,U={}){let $;pB("pinging %p",O);let J=Date.now(),en=src_random_bytes_randomBytes(pS),es=await this.components.connectionManager.openConnection(O,U),onAbort=()=>{};U.signal=U.signal??AbortSignal.timeout(this.timeout);try{$=await es.newStream(this.protocol,{...U,runOnTransientConnection:this.runOnTransientConnection}),onAbort=()=>{$?.abort(new errors_CodeError("ping timeout",rv.ERR_TIMEOUT))},U.signal.addEventListener("abort",onAbort,{once:!0});let O=await pipe([en],$,async O=>it_first_dist_src(O)),eo=Date.now()-J;if(null==O)throw new errors_CodeError(`Did not receive a ping ack after ${eo}ms`,rv.ERR_WRONG_PING_ACK);if(!equals(en,O.subarray()))throw new errors_CodeError(`Received wrong ping ack after ${eo}ms`,rv.ERR_WRONG_PING_ACK);return pB("ping %p complete in %dms",es.remotePeer,eo),eo}catch(O){throw pB.error("error while pinging %p",es.remotePeer,O),$?.abort(O),O}finally{U.signal.removeEventListener("abort",onAbort),null!=$&&await $.close()}}};function pingService(O={}){return U=>new DefaultPingService(U,O)}let pN={lightPush:1,filter:1,store:1};async function createLightNode(O){(O=O??{}).pubsubTopics||(O.pubsubTopics=[sc]);let U=O?.libp2p??{},$=U.peerDiscovery??[];O?.defaultBootstrap&&($.push(...defaultPeerDiscoveries()),Object.assign(U,{peerDiscovery:$}));let J=await defaultLibp2p(void 0,U,O?.userAgent),en=store_wakuStore(O),es=light_push_wakuLightPush(O),eo=filter_wakuFilter(O);return new waku_WakuNode(O??{},O.pubsubTopics,J,en,es,eo)}function defaultPeerDiscoveries(){let O=[wakuDnsDiscovery(["enrtree://ANEDLO25QVUGJOUTQFRYKWX6P4Z4GKVESBMHML7DZ6YK4LGS5FC5O@prod.wakuv2.nodes.status.im"],pN),wakuPeerExchangeDiscovery()];return O}async function defaultLibp2p(O,U,$){let J=O?{pubsub:O}:{};return createLibp2p({connectionManager:{minConnections:1},transports:[webSockets({filter:filters_all})],streamMuxers:[mplex()],connectionEncryption:[noise()],...U,services:{identify:identifyService({agentVersion:$??sP}),ping:pingService(),...J,...U?.services}})}},9710:function(O,U,$){"use strict";$.d(U,{Md:function(){return bytesToUtf8},ci:function(){return bytesToHex},iY:function(){return utf8ToBytes},nr:function(){return hexToBytes}});var J=$(2223),en=$(7519);function hexToBytes(O){if("string"==typeof O){let U=O.replace(/^0x/i,"");return(0,J.m)(U.toLowerCase(),"base16")}return O}let bytesToHex=O=>(0,en.B)(O,"base16"),bytesToUtf8=O=>(0,en.B)(O,"utf8"),utf8ToBytes=O=>(0,J.m)(O,"utf8")},2905:function(O,U,$){"use strict";$.d(U,{kU:function(){return baseX},Dp:function(){return from},ET:function(){return rfc4648}});var base_x=function(O,U){if(O.length>=255)throw TypeError("Alphabet too long");for(var $=new Uint8Array(256),J=0;J<$.length;J++)$[J]=255;for(var en=0;en>>0,eo=new Uint8Array(es);O[U];){var eg=$[O.charCodeAt(U)];if(255===eg)return;for(var ev=0,e_=es-1;(0!==eg||ev>>0,eo[e_]=eg%256>>>0,eg=eg/256>>>0;if(0!==eg)throw Error("Non-zero carry");en=ev,U++}if(" "!==O[U]){for(var ew=es-en;ew!==es&&0===eo[ew];)ew++;for(var eE=new Uint8Array(J+(es-ew)),eS=J;ew!==es;)eE[eS++]=eo[ew++];return eE}}}function decode(O){var $=decodeUnsafe(O);if($)return $;throw Error(`Non-${U} character`)}return{encode:function(U){if(U instanceof Uint8Array||(ArrayBuffer.isView(U)?U=new Uint8Array(U.buffer,U.byteOffset,U.byteLength):Array.isArray(U)&&(U=Uint8Array.from(U))),!(U instanceof Uint8Array))throw TypeError("Expected Uint8Array");if(0===U.length)return"";for(var $=0,J=0,en=0,es=U.length;en!==es&&0===U[en];)en++,$++;for(var eo=(es-en)*eg+1>>>0,ef=new Uint8Array(eo);en!==es;){for(var ev=U[en],e_=0,ew=eo-1;(0!==ev||e_>>0,ef[ew]=ev%ea>>>0,ev=ev/ea>>>0;if(0!==ev)throw Error("Non-zero carry");J=e_,en++}for(var eE=eo-J;eE!==eo&&0===ef[eE];)eE++;for(var eS=eu.repeat($);eEnew ComposedDecoder({...O.decoders||{[O.prefix]:O},...U.decoders||{[U.prefix]:U}});let Codec=class Codec{constructor(O,U,$,J){this.name=O,this.prefix=U,this.baseEncode=$,this.baseDecode=J,this.encoder=new Encoder(O,U,$),this.decoder=new Decoder(O,U,J)}encode(O){return this.encoder.encode(O)}decode(O){return this.decoder.decode(O)}};let from=({name:O,prefix:U,encode:$,decode:J})=>new Codec(O,U,$,J),baseX=({prefix:O,name:U,alphabet:$})=>{let{encode:en,decode:es}=base_x($,U);return from({prefix:O,name:U,encode:en,decode:O=>(0,J.oQ)(es(O))})},decode=(O,U,$,J)=>{let en={};for(let O=0;O=8&&(ea-=8,eo[ef++]=255&eu>>ea)}if(ea>=$||255&eu<<8-ea)throw SyntaxError("Unexpected end of data");return eo},encode=(O,U,$)=>{let J="="===U[U.length-1],en=(1<<$)-1,es="",eo=0,ea=0;for(let J=0;J$;)eo-=$,es+=U[en&ea>>eo];if(eo&&(es+=U[en&ea<<$-eo]),J)for(;es.length*$&7;)es+="=";return es},rfc4648=({name:O,prefix:U,bitsPerChar:$,alphabet:J})=>from({prefix:U,name:O,encode:O=>encode(O,J,$),decode:U=>decode(U,J,$,O)})},5700:function(O,U,$){"use strict";$.r(U),$.d(U,{base32:function(){return en},base32hex:function(){return eu},base32hexpad:function(){return eg},base32hexpadupper:function(){return ev},base32hexupper:function(){return ef},base32pad:function(){return eo},base32padupper:function(){return ea},base32upper:function(){return es},base32z:function(){return e_}});var J=$(2905);let en=(0,J.ET)({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),es=(0,J.ET)({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),eo=(0,J.ET)({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ea=(0,J.ET)({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),eu=(0,J.ET)({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ef=(0,J.ET)({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),eg=(0,J.ET)({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ev=(0,J.ET)({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),e_=(0,J.ET)({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5})},7954:function(O,U,$){"use strict";$.r(U),$.d(U,{base58btc:function(){return en},base58flickr:function(){return es}});var J=$(2905);let en=(0,J.kU)({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),es=(0,J.kU)({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"})},8862:function(O,U,$){"use strict";$.r(U),$.d(U,{base64:function(){return en},base64pad:function(){return es},base64url:function(){return eo},base64urlpad:function(){return ea}});var J=$(2905);let en=(0,J.ET)({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),es=(0,J.ET)({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),eo=(0,J.ET)({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ea=(0,J.ET)({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6})},9180:function(O,U,$){"use strict";$.d(U,{gh:function(){return e$}});var J={};$.r(J),$.d(J,{base10:function(){return ew}});var en={};$.r(en),$.d(en,{base16:function(){return eE},base16upper:function(){return eS}});var es={};$.r(es),$.d(es,{base2:function(){return eA}});var eo={};$.r(eo),$.d(eo,{base256emoji:function(){return eT}});var ea={};$.r(ea),$.d(ea,{base36:function(){return eC},base36upper:function(){return eB}});var eu={};$.r(eu),$.d(eu,{base8:function(){return eM}});var ef={};$.r(ef),$.d(ef,{identity:function(){return eL}});var eg={};$.r(eg),$.d(eg,{code:function(){return ej},decode:function(){return json_decode},encode:function(){return json_encode},name:function(){return eK}});var ev={};$.r(ev),$.d(ev,{code:function(){return eq},decode:function(){return raw_decode},encode:function(){return raw_encode},name:function(){return eH}});var e_=$(2905);let ew=(0,e_.kU)({prefix:"9",name:"base10",alphabet:"0123456789"}),eE=(0,e_.ET)({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),eS=(0,e_.ET)({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),eA=(0,e_.ET)({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),eI=Array.from("\uD83D\uDE80\uD83E\uDE90☄\uD83D\uDEF0\uD83C\uDF0C\uD83C\uDF11\uD83C\uDF12\uD83C\uDF13\uD83C\uDF14\uD83C\uDF15\uD83C\uDF16\uD83C\uDF17\uD83C\uDF18\uD83C\uDF0D\uD83C\uDF0F\uD83C\uDF0E\uD83D\uDC09☀\uD83D\uDCBB\uD83D\uDDA5\uD83D\uDCBE\uD83D\uDCBF\uD83D\uDE02❤\uD83D\uDE0D\uD83E\uDD23\uD83D\uDE0A\uD83D\uDE4F\uD83D\uDC95\uD83D\uDE2D\uD83D\uDE18\uD83D\uDC4D\uD83D\uDE05\uD83D\uDC4F\uD83D\uDE01\uD83D\uDD25\uD83E\uDD70\uD83D\uDC94\uD83D\uDC96\uD83D\uDC99\uD83D\uDE22\uD83E\uDD14\uD83D\uDE06\uD83D\uDE44\uD83D\uDCAA\uD83D\uDE09☺\uD83D\uDC4C\uD83E\uDD17\uD83D\uDC9C\uD83D\uDE14\uD83D\uDE0E\uD83D\uDE07\uD83C\uDF39\uD83E\uDD26\uD83C\uDF89\uD83D\uDC9E✌✨\uD83E\uDD37\uD83D\uDE31\uD83D\uDE0C\uD83C\uDF38\uD83D\uDE4C\uD83D\uDE0B\uD83D\uDC97\uD83D\uDC9A\uD83D\uDE0F\uD83D\uDC9B\uD83D\uDE42\uD83D\uDC93\uD83E\uDD29\uD83D\uDE04\uD83D\uDE00\uD83D\uDDA4\uD83D\uDE03\uD83D\uDCAF\uD83D\uDE48\uD83D\uDC47\uD83C\uDFB6\uD83D\uDE12\uD83E\uDD2D❣\uD83D\uDE1C\uD83D\uDC8B\uD83D\uDC40\uD83D\uDE2A\uD83D\uDE11\uD83D\uDCA5\uD83D\uDE4B\uD83D\uDE1E\uD83D\uDE29\uD83D\uDE21\uD83E\uDD2A\uD83D\uDC4A\uD83E\uDD73\uD83D\uDE25\uD83E\uDD24\uD83D\uDC49\uD83D\uDC83\uD83D\uDE33✋\uD83D\uDE1A\uD83D\uDE1D\uD83D\uDE34\uD83C\uDF1F\uD83D\uDE2C\uD83D\uDE43\uD83C\uDF40\uD83C\uDF37\uD83D\uDE3B\uD83D\uDE13⭐✅\uD83E\uDD7A\uD83C\uDF08\uD83D\uDE08\uD83E\uDD18\uD83D\uDCA6✔\uD83D\uDE23\uD83C\uDFC3\uD83D\uDC90☹\uD83C\uDF8A\uD83D\uDC98\uD83D\uDE20☝\uD83D\uDE15\uD83C\uDF3A\uD83C\uDF82\uD83C\uDF3B\uD83D\uDE10\uD83D\uDD95\uD83D\uDC9D\uD83D\uDE4A\uD83D\uDE39\uD83D\uDDE3\uD83D\uDCAB\uD83D\uDC80\uD83D\uDC51\uD83C\uDFB5\uD83E\uDD1E\uD83D\uDE1B\uD83D\uDD34\uD83D\uDE24\uD83C\uDF3C\uD83D\uDE2B⚽\uD83E\uDD19☕\uD83C\uDFC6\uD83E\uDD2B\uD83D\uDC48\uD83D\uDE2E\uD83D\uDE46\uD83C\uDF7B\uD83C\uDF43\uD83D\uDC36\uD83D\uDC81\uD83D\uDE32\uD83C\uDF3F\uD83E\uDDE1\uD83C\uDF81⚡\uD83C\uDF1E\uD83C\uDF88❌✊\uD83D\uDC4B\uD83D\uDE30\uD83E\uDD28\uD83D\uDE36\uD83E\uDD1D\uD83D\uDEB6\uD83D\uDCB0\uD83C\uDF53\uD83D\uDCA2\uD83E\uDD1F\uD83D\uDE41\uD83D\uDEA8\uD83D\uDCA8\uD83E\uDD2C✈\uD83C\uDF80\uD83C\uDF7A\uD83E\uDD13\uD83D\uDE19\uD83D\uDC9F\uD83C\uDF31\uD83D\uDE16\uD83D\uDC76\uD83E\uDD74▶➡❓\uD83D\uDC8E\uD83D\uDCB8⬇\uD83D\uDE28\uD83C\uDF1A\uD83E\uDD8B\uD83D\uDE37\uD83D\uDD7A⚠\uD83D\uDE45\uD83D\uDE1F\uD83D\uDE35\uD83D\uDC4E\uD83E\uDD32\uD83E\uDD20\uD83E\uDD27\uD83D\uDCCC\uD83D\uDD35\uD83D\uDC85\uD83E\uDDD0\uD83D\uDC3E\uD83C\uDF52\uD83D\uDE17\uD83E\uDD11\uD83C\uDF0A\uD83E\uDD2F\uD83D\uDC37☎\uD83D\uDCA7\uD83D\uDE2F\uD83D\uDC86\uD83D\uDC46\uD83C\uDFA4\uD83D\uDE47\uD83C\uDF51❄\uD83C\uDF34\uD83D\uDCA3\uD83D\uDC38\uD83D\uDC8C\uD83D\uDCCD\uD83E\uDD40\uD83E\uDD22\uD83D\uDC45\uD83D\uDCA1\uD83D\uDCA9\uD83D\uDC50\uD83D\uDCF8\uD83D\uDC7B\uD83E\uDD10\uD83E\uDD2E\uD83C\uDFBC\uD83E\uDD75\uD83D\uDEA9\uD83C\uDF4E\uD83C\uDF4A\uD83D\uDC7C\uD83D\uDC8D\uD83D\uDCE3\uD83E\uDD42"),eP=eI.reduce((O,U,$)=>(O[$]=U,O),[]),ek=eI.reduce((O,U,$)=>(O[U.codePointAt(0)]=$,O),[]);function encode(O){return O.reduce((O,U)=>O+=eP[U],"")}function decode(O){let U=[];for(let $ of O){let O=ek[$.codePointAt(0)];if(void 0===O)throw Error(`Non-base256emoji character: ${$}`);U.push(O)}return new Uint8Array(U)}let eT=(0,e_.Dp)({prefix:"\uD83D\uDE80",name:"base256emoji",encode,decode});var eR=$(5700);let eC=(0,e_.kU)({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),eB=(0,e_.kU)({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var eN=$(7954),eD=$(8862);let eM=(0,e_.ET)({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var eO=$(8883);let eL=(0,e_.Dp)({prefix:"\x00",name:"identity",encode:O=>(0,eO.BB)(O),decode:O=>(0,eO.mL)(O)}),eU=new TextEncoder,eF=new TextDecoder,eK="json",ej=512,json_encode=O=>eU.encode(JSON.stringify(O)),json_decode=O=>JSON.parse(eF.decode(O)),eH="raw",eq=85,raw_encode=O=>(0,eO.oQ)(O),raw_decode=O=>(0,eO.oQ)(O);var eV=$(6831),eG=$(3062);$(5807),$(1453),$(933),$(424);let e$={...ef,...es,...eu,...J,...en,...eR,...ea,...eN,...eD,...eo};({...eG,...eV})},8883:function(O,U,$){"use strict";$.d(U,{BB:function(){return toString},fS:function(){return equals},mL:function(){return fromString},oQ:function(){return coerce}}),new Uint8Array(0);let equals=(O,U)=>{if(O===U)return!0;if(O.byteLength!==U.byteLength)return!1;for(let $=0;${if(O instanceof Uint8Array&&"Uint8Array"===O.constructor.name)return O;if(O instanceof ArrayBuffer)return new Uint8Array(O);if(ArrayBuffer.isView(O))return new Uint8Array(O.buffer,O.byteOffset,O.byteLength);throw Error("Unknown type, must be binary type")},fromString=O=>new TextEncoder().encode(O),toString=O=>new TextDecoder().decode(O)},5807:function(O,U,$){"use strict";$.d(U,{k0:function(){return CID}});var J=$(5700),en=$(7954),es=$(8883),eo=$(1453),ea=$(424);let format=(O,U)=>{let{bytes:$,version:es}=O;return 0===es?toStringV0($,baseCache(O),U||en.base58btc.encoder):toStringV1($,baseCache(O),U||J.base32.encoder)},eu=new WeakMap,baseCache=O=>{let U=eu.get(O);if(null==U){let U=new Map;return eu.set(O,U),U}return U};let CID=class CID{constructor(O,U,$,J){this.code=U,this.version=O,this.multihash=$,this.bytes=J,this["/"]=J}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:O,multihash:U}=this;if(O!==ef)throw Error("Cannot convert a non dag-pb CID to CIDv0");if(U.code!==eg)throw Error("Cannot convert non sha2-256 multihash CID to CIDv0");return CID.createV0(U)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:O,digest:U}=this.multihash,$=eo.Ue(O,U);return CID.createV1(this.code,$)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(O){return CID.equals(this,O)}static equals(O,U){let $=U;return $&&O.code===$.code&&O.version===$.version&&eo.fS(O.multihash,$.multihash)}toString(O){return format(this,O)}toJSON(){return{"/":format(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(O){if(null==O)return null;let U=O;if(U instanceof CID)return U;if(null!=U["/"]&&U["/"]===U.bytes||U.asCID===U){let{version:O,code:$,multihash:J,bytes:en}=U;return new CID(O,$,J,en||encodeCID(O,$,J.bytes))}if(!0!==U[ev])return null;{let{version:O,multihash:$,code:J}=U,en=eo.Jx($);return CID.create(O,J,en)}}static create(O,U,$){if("number"!=typeof U)throw Error("String codecs are no longer supported");if(!($.bytes instanceof Uint8Array))throw Error("Invalid digest");switch(O){case 0:if(U===ef)return new CID(O,U,$,$.bytes);throw Error(`Version 0 CID must use dag-pb (code: ${ef}) block encoding`);case 1:{let J=encodeCID(O,U,$.bytes);return new CID(O,U,$,J)}default:throw Error("Invalid version")}}static createV0(O){return CID.create(0,ef,O)}static createV1(O,U){return CID.create(1,O,U)}static decode(O){let[U,$]=CID.decodeFirst(O);if($.length)throw Error("Incorrect length");return U}static decodeFirst(O){let U=CID.inspectBytes(O),$=U.size-U.multihashSize,J=(0,es.oQ)(O.subarray($,$+U.multihashSize));if(J.byteLength!==U.multihashSize)throw Error("Incorrect length");let en=J.subarray(U.multihashSize-U.digestSize),ea=new eo.zZ(U.multihashCode,U.digestSize,en,J),eu=0===U.version?CID.createV0(ea):CID.createV1(U.codec,ea);return[eu,O.subarray(U.size)]}static inspectBytes(O){let U=0,next=()=>{let[$,J]=ea.Jx(O.subarray(U));return U+=J,$},$=next(),J=ef;if(18===$?($=0,U=0):J=next(),0!==$&&1!==$)throw RangeError(`Invalid CID version ${$}`);let en=U,es=next(),eo=next(),eu=U+eo,eg=eu-en;return{version:$,codec:J,multihashCode:es,digestSize:eo,multihashSize:eg,size:eu}}static parse(O,U){let[$,J]=parseCIDtoBytes(O,U),en=CID.decode(J);if(0===en.version&&"Q"!==O[0])throw Error("Version 0 CID string must not include multibase prefix");return baseCache(en).set($,O),en}};let parseCIDtoBytes=(O,U)=>{switch(O[0]){case"Q":{let $=U||en.base58btc;return[en.base58btc.prefix,$.decode(`${en.base58btc.prefix}${O}`)]}case en.base58btc.prefix:{let $=U||en.base58btc;return[en.base58btc.prefix,$.decode(O)]}case J.base32.prefix:{let $=U||J.base32;return[J.base32.prefix,$.decode(O)]}default:if(null==U)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[O[0],U.decode(O)]}},toStringV0=(O,U,$)=>{let{prefix:J}=$;if(J!==en.base58btc.prefix)throw Error(`Cannot string encode V0 in ${$.name} encoding`);let es=U.get(J);if(null!=es)return es;{let en=$.encode(O).slice(1);return U.set(J,en),en}},toStringV1=(O,U,$)=>{let{prefix:J}=$,en=U.get(J);if(null!=en)return en;{let en=$.encode(O);return U.set(J,en),en}},ef=112,eg=18,encodeCID=(O,U,$)=>{let J=ea.P$(O),en=J+ea.P$(U),es=new Uint8Array(en+$.byteLength);return ea.mL(O,es,0),ea.mL(U,es,J),es.set($,en),es},ev=Symbol.for("@ipld/js-cid/CID")},1453:function(O,U,$){"use strict";$.d(U,{Jx:function(){return decode},Ue:function(){return create},fS:function(){return equals},zZ:function(){return Digest}});var J=$(8883),en=$(424);let create=(O,U)=>{let $=U.byteLength,J=en.P$(O),es=J+en.P$($),eo=new Uint8Array(es+$);return en.mL(O,eo,0),en.mL($,eo,J),eo.set(U,es),new Digest(O,$,U,eo)},decode=O=>{let U=(0,J.oQ)(O),[$,es]=en.Jx(U),[eo,ea]=en.Jx(U.subarray(es)),eu=U.subarray(es+ea);if(eu.byteLength!==eo)throw Error("Incorrect length");return new Digest($,eo,eu,U)},equals=(O,U)=>{if(O===U)return!0;{let $=U;return O.code===$.code&&O.size===$.size&&$.bytes instanceof Uint8Array&&(0,J.fS)(O.bytes,$.bytes)}};let Digest=class Digest{constructor(O,U,$,J){this.code=O,this.size=U,this.digest=$,this.bytes=J}}},933:function(O,U,$){"use strict";$.d(U,{D:function(){return from}});var J=$(1453);let from=({name:O,code:U,encode:$})=>new Hasher(O,U,$);let Hasher=class Hasher{constructor(O,U,$){this.name=O,this.code=U,this.encode=$}digest(O){if(O instanceof Uint8Array){let U=this.encode(O);return U instanceof Uint8Array?J.Ue(this.code,U):U.then(O=>J.Ue(this.code,O))}throw Error("Unknown type, must be binary type")}}},6831:function(O,U,$){"use strict";$.r(U),$.d(U,{identity:function(){return eu}});var J=$(8883),en=$(1453);let es=0,eo="identity",ea=J.oQ,digest=O=>en.Ue(es,ea(O)),eu={code:es,name:eo,encode:ea,digest}},3062:function(O,U,$){"use strict";$.r(U),$.d(U,{sha256:function(){return en},sha512:function(){return es}});var J=$(933);let sha=O=>async U=>new Uint8Array(await crypto.subtle.digest(O,U)),en=(0,J.D)({name:"sha2-256",code:18,encode:sha("SHA-256")}),es=(0,J.D)({name:"sha2-512",code:19,encode:sha("SHA-512")})},424:function(O,U,$){"use strict";$.d(U,{Jx:function(){return varint_decode},mL:function(){return encodeTo},P$:function(){return encodingLength}});var J=128,en=-128,es=2147483648;function encode(O,U,$){U=U||[];for(var eo=$=$||0;O>=es;)U[$++]=255&O|J,O/=128;for(;O&en;)U[$++]=255&O|J,O>>>=7;return U[$]=0|O,encode.bytes=$-eo+1,U}var eo=128,ea=127;function read(O,U){var $,J=0,U=U||0,en=0,es=U,eu=O.length;do{if(es>=eu)throw read.bytes=0,RangeError("Could not decode varint");$=O[es++],J+=en<28?($&ea)<=eo);return read.bytes=es-U,J}var eu=128,ef=16384,eg=2097152,ev=268435456,e_=34359738368,ew=4398046511104,eE=562949953421312,eS=72057594037927940,eA=0x7fffffffffffffff,eI={encode:encode,decode:read,encodingLength:function(O){return O{let $=eI.decode(O,U);return[$,eI.decode.bytes]},encodeTo=(O,U,$=0)=>(eI.encode(O,U,$),U),encodingLength=O=>eI.encodingLength(O)},9425:function(O,U,$){"use strict";$.d(U,{E:function(){return allocUnsafe},u:function(){return alloc}});var J=$(5943);function alloc(O=0){return globalThis.Buffer?.alloc!=null?(0,J.P)(globalThis.Buffer.alloc(O)):new Uint8Array(O)}function allocUnsafe(O=0){return globalThis.Buffer?.allocUnsafe!=null?(0,J.P)(globalThis.Buffer.allocUnsafe(O)):new Uint8Array(O)}},2223:function(O,U,$){"use strict";$.d(U,{m:function(){return fromString}});var J=$(5943),en=$(4264);function fromString(O,U="utf8"){let $=en.Z[U];if(null==$)throw Error(`Unsupported encoding "${U}"`);return("utf8"===U||"utf-8"===U)&&null!=globalThis.Buffer&&null!=globalThis.Buffer.from?(0,J.P)(globalThis.Buffer.from(O,"utf-8")):$.decoder.decode(`${$.prefix}${O}`)}},7519:function(O,U,$){"use strict";$.d(U,{B:function(){return toString}});var J=$(4264);function toString(O,U="utf8"){let $=J.Z[U];if(null==$)throw Error(`Unsupported encoding "${U}"`);return("utf8"===U||"utf-8"===U)&&null!=globalThis.Buffer&&null!=globalThis.Buffer.from?globalThis.Buffer.from(O.buffer,O.byteOffset,O.byteLength).toString("utf8"):$.encoder.encode(O).substring(1)}},5943:function(O,U,$){"use strict";function asUint8Array(O){return null!=globalThis.Buffer?new Uint8Array(O.buffer,O.byteOffset,O.byteLength):O}$.d(U,{P:function(){return asUint8Array}})},4264:function(O,U,$){"use strict";var J=$(9180),en=$(9425);function createCodec(O,U,$,J){return{name:O,prefix:U,encoder:{name:O,prefix:U,encode:$},decoder:{decode:J}}}let es=createCodec("utf8","u",O=>{let U=new TextDecoder("utf8");return"u"+U.decode(O)},O=>{let U=new TextEncoder;return U.encode(O.substring(1))}),eo=createCodec("ascii","a",O=>{let U="a";for(let $=0;${O=O.substring(1);let U=(0,en.E)(O.length);for(let $=0;${let U;let $=new Set,setState=(O,J)=>{let en="function"==typeof O?O(U):O;if(!Object.is(en,U)){let O=U;U=(null!=J?J:"object"!=typeof en)?en:Object.assign({},U,en),$.forEach($=>$(U,O))}},getState=()=>U,subscribe=O=>($.add(O),()=>$.delete(O)),destroy=()=>{console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),$.clear()},J={setState,getState,subscribe,destroy};return U=O(setState,getState,J),J},createStore=O=>O?createStoreImpl(O):createStoreImpl;var J=$(2265),en=$(5401);let{useSyncExternalStoreWithSelector:es}=en,eo=!1;function useStore(O,U=O.getState,$){$&&!eo&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),eo=!0);let en=es(O.subscribe,O.getState,O.getServerState||O.getState,U,$);return(0,J.useDebugValue)(en),en}let createImpl=O=>{"function"!=typeof O&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");let U="function"==typeof O?createStore(O):O,useBoundStore=(O,$)=>useStore(U,O,$);return Object.assign(useBoundStore,U),useBoundStore},create=O=>O?createImpl(O):createImpl}}]); \ No newline at end of file diff --git a/rln-js/_next/static/chunks/app/_not-found-9deaecba2dd6ebe3.js b/rln-js/_next/static/chunks/app/_not-found-9deaecba2dd6ebe3.js new file mode 100644 index 0000000..c2ef014 --- /dev/null +++ b/rln-js/_next/static/chunks/app/_not-found-9deaecba2dd6ebe3.js @@ -0,0 +1 @@ +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[165],{3155:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/_not-found",function(){return n(1038)}])},1038:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return NotFound}});let l=n(1024),o=l._(n(2265)),r={error:{fontFamily:'system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"',height:"100vh",textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},desc:{display:"inline-block"},h1:{display:"inline-block",margin:"0 20px 0 0",padding:"0 23px 0 0",fontSize:24,fontWeight:500,verticalAlign:"top",lineHeight:"49px"},h2:{fontSize:14,fontWeight:400,lineHeight:"49px",margin:0}};function NotFound(){return o.default.createElement(o.default.Fragment,null,o.default.createElement("title",null,"404: This page could not be found."),o.default.createElement("div",{style:r.error},o.default.createElement("div",null,o.default.createElement("style",{dangerouslySetInnerHTML:{__html:"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}),o.default.createElement("h1",{className:"next-error-h1",style:r.h1},"404"),o.default.createElement("div",{style:r.desc},o.default.createElement("h2",{style:r.h2},"This page could not be found.")))))}("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)}},function(e){e.O(0,[971,472,744],function(){return e(e.s=3155)}),_N_E=e.O()}]); \ No newline at end of file diff --git a/rln-js/_next/static/chunks/app/home/page-82ca4f4399f6aaa4.js b/rln-js/_next/static/chunks/app/home/page-82ca4f4399f6aaa4.js new file mode 100644 index 0000000..73ec3c3 --- /dev/null +++ b/rln-js/_next/static/chunks/app/home/page-82ca4f4399f6aaa4.js @@ -0,0 +1 @@ +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[951],{},function(n){n.O(0,[866,822,240,971,472,744],function(){return n(n.s=4280)}),_N_E=n.O()}]); \ No newline at end of file diff --git a/rln-js/_next/static/chunks/app/layout-1e6746e653af2bee.js b/rln-js/_next/static/chunks/app/layout-1e6746e653af2bee.js new file mode 100644 index 0000000..522a56f --- /dev/null +++ b/rln-js/_next/static/chunks/app/layout-1e6746e653af2bee.js @@ -0,0 +1 @@ +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[185],{2659:function(e,n,t){Promise.resolve().then(t.t.bind(t,2489,23)),Promise.resolve().then(t.t.bind(t,1654,23))},2489:function(){},1654:function(e){e.exports={style:{fontFamily:"'__Inter_e66fe9', '__Inter_Fallback_e66fe9'",fontStyle:"normal"},className:"__className_e66fe9"}}},function(e){e.O(0,[971,472,744],function(){return e(e.s=2659)}),_N_E=e.O()}]); \ No newline at end of file diff --git a/rln-js/_next/static/chunks/app/page-8d29b29e326404e2.js b/rln-js/_next/static/chunks/app/page-8d29b29e326404e2.js new file mode 100644 index 0000000..00bc407 --- /dev/null +++ b/rln-js/_next/static/chunks/app/page-8d29b29e326404e2.js @@ -0,0 +1 @@ +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{},function(n){n.O(0,[866,822,240,971,472,744],function(){return n(n.s=4280)}),_N_E=n.O()}]); \ No newline at end of file diff --git a/rln-js/_next/static/chunks/e37a0b60-269ef973f827543e.js b/rln-js/_next/static/chunks/e37a0b60-269ef973f827543e.js new file mode 100644 index 0000000..2f54cd8 --- /dev/null +++ b/rln-js/_next/static/chunks/e37a0b60-269ef973f827543e.js @@ -0,0 +1 @@ +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[866],{2890:function(e,t,r){var n;e=r.nmd(e),(function(){var a,o="Expected a function",i="__lodash_hash_undefined__",s="__lodash_placeholder__",u=1/0,c=0/0,l=[["ary",128],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",32],["partialRight",64],["rearg",256]],f="[object Arguments]",h="[object Array]",p="[object Boolean]",d="[object Date]",g="[object Error]",y="[object Function]",b="[object GeneratorFunction]",v="[object Map]",_="[object Number]",m="[object Object]",I="[object Promise]",A="[object RegExp]",S="[object Set]",O="[object String]",w="[object Symbol]",k="[object WeakMap]",j="[object ArrayBuffer]",L="[object DataView]",x="[object Float32Array]",R="[object Float64Array]",C="[object Int8Array]",F="[object Int16Array]",z="[object Int32Array]",W="[object Uint8Array]",E="[object Uint8ClampedArray]",T="[object Uint16Array]",M="[object Uint32Array]",P=/\b__p \+= '';/g,U=/\b(__p \+=) '' \+/g,N=/(__e\(.*?\)|\b__t\)) \+\n'';/g,B=/&(?:amp|lt|gt|quot|#39);/g,D=/[&<>"']/g,q=RegExp(B.source),K=RegExp(D.source),H=/<%-([\s\S]+?)%>/g,G=/<%([\s\S]+?)%>/g,V=/<%=([\s\S]+?)%>/g,$=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Z=/^\w*$/,X=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,J=/[\\^$.*+?()[\]{}|]/g,Y=RegExp(J.source),Q=/^\s+/,ee=/\s/,et=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,er=/\{\n\/\* \[wrapped with (.+)\] \*/,en=/,? & /,ea=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,eo=/[()=,{}\[\]\/\s]/,ei=/\\(\\)?/g,es=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,eu=/\w*$/,ec=/^[-+]0x[0-9a-f]+$/i,el=/^0b[01]+$/i,ef=/^\[object .+?Constructor\]$/,eh=/^0o[0-7]+$/i,ep=/^(?:0|[1-9]\d*)$/,ed=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,eg=/($^)/,ey=/['\n\r\u2028\u2029\\]/g,eb="\ud800-\udfff",ev="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",e_="\\u2700-\\u27bf",em="a-z\\xdf-\\xf6\\xf8-\\xff",eI="A-Z\\xc0-\\xd6\\xd8-\\xde",eA="\\ufe0e\\ufe0f",eS="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",eO="['’]",ew="["+eS+"]",ek="["+ev+"]",ej="["+em+"]",eL="[^"+eb+eS+"\\d+"+e_+em+eI+"]",ex="\ud83c[\udffb-\udfff]",eR="[^"+eb+"]",eC="(?:\ud83c[\udde6-\uddff]){2}",eF="[\ud800-\udbff][\udc00-\udfff]",ez="["+eI+"]",eW="\\u200d",eE="(?:"+ej+"|"+eL+")",eT="(?:"+eO+"(?:d|ll|m|re|s|t|ve))?",eM="(?:"+eO+"(?:D|LL|M|RE|S|T|VE))?",eP="(?:"+ek+"|"+ex+")?",eU="["+eA+"]?",eN="(?:"+eW+"(?:"+[eR,eC,eF].join("|")+")"+eU+eP+")*",eB=eU+eP+eN,eD="(?:"+["["+e_+"]",eC,eF].join("|")+")"+eB,eK="(?:"+[eR+ek+"?",ek,eC,eF,"["+eb+"]"].join("|")+")",eH=RegExp(eO,"g"),eG=RegExp(ek,"g"),eV=RegExp(ex+"(?="+ex+")|"+eK+eB,"g"),e$=RegExp([ez+"?"+ej+"+"+eT+"(?="+[ew,ez,"$"].join("|")+")","(?:"+ez+"|"+eL+")+"+eM+"(?="+[ew,ez+eE,"$"].join("|")+")",ez+"?"+eE+"+"+eT,ez+"+"+eM,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])","\\d+",eD].join("|"),"g"),eZ=RegExp("["+eW+eb+ev+eA+"]"),eX=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,eJ=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],eY=-1,eQ={};eQ[x]=eQ[R]=eQ[C]=eQ[F]=eQ[z]=eQ[W]=eQ[E]=eQ[T]=eQ[M]=!0,eQ[f]=eQ[h]=eQ[j]=eQ[p]=eQ[L]=eQ[d]=eQ[g]=eQ[y]=eQ[v]=eQ[_]=eQ[m]=eQ[A]=eQ[S]=eQ[O]=eQ[k]=!1;var e0={};e0[f]=e0[h]=e0[j]=e0[L]=e0[p]=e0[d]=e0[x]=e0[R]=e0[C]=e0[F]=e0[z]=e0[v]=e0[_]=e0[m]=e0[A]=e0[S]=e0[O]=e0[w]=e0[W]=e0[E]=e0[T]=e0[M]=!0,e0[g]=e0[y]=e0[k]=!1;var e1={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},e2=parseFloat,e9=parseInt,e3="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g,e4="object"==typeof self&&self&&self.Object===Object&&self,e6=e3||e4||Function("return this")(),e7=t&&!t.nodeType&&t,e8=e7&&e&&!e.nodeType&&e,e5=e8&&e8.exports===e7,te=e5&&e3.process,tt=function(){try{var e=e8&&e8.require&&e8.require("util").types;if(e)return e;return te&&te.binding&&te.binding("util")}catch(e){}}(),tr=tt&&tt.isArrayBuffer,tn=tt&&tt.isDate,ta=tt&&tt.isMap,to=tt&&tt.isRegExp,ti=tt&&tt.isSet,ts=tt&&tt.isTypedArray;function apply(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}function arrayAggregator(e,t,r,n){for(var a=-1,o=null==e?0:e.length;++a-1}function arrayIncludesWith(e,t,r){for(var n=-1,a=null==e?0:e.length;++n-1;);return r}function charsEndIndex(e,t){for(var r=e.length;r--&&baseIndexOf(t,e[r],0)>-1;);return r}var tc=basePropertyOf({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"}),tl=basePropertyOf({"&":"&","<":"<",">":">",'"':""","'":"'"});function escapeStringChar(e){return"\\"+e1[e]}function hasUnicode(e){return eZ.test(e)}function mapToArray(e){var t=-1,r=Array(e.size);return e.forEach(function(e,n){r[++t]=[n,e]}),r}function overArg(e,t){return function(r){return e(t(r))}}function replaceHolders(e,t){for(var r=-1,n=e.length,a=0,o=[];++r",""":'"',"'":"'"}),th=function runInContext(e){var t,r,n,ee,eb=(e=null==e?e6:th.defaults(e6.Object(),e,th.pick(e6,eJ))).Array,ev=e.Date,e_=e.Error,em=e.Function,eI=e.Math,eA=e.Object,eS=e.RegExp,eO=e.String,ew=e.TypeError,ek=eb.prototype,ej=em.prototype,eL=eA.prototype,ex=e["__core-js_shared__"],eR=ej.toString,eC=eL.hasOwnProperty,eF=0,ez=(t=/[^.]+$/.exec(ex&&ex.keys&&ex.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"",eW=eL.toString,eE=eR.call(eA),eT=e6._,eM=eS("^"+eR.call(eC).replace(J,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),eP=e5?e.Buffer:a,eU=e.Symbol,eN=e.Uint8Array,eB=eP?eP.allocUnsafe:a,eD=overArg(eA.getPrototypeOf,eA),eK=eA.create,eV=eL.propertyIsEnumerable,eZ=ek.splice,e1=eU?eU.isConcatSpreadable:a,e3=eU?eU.iterator:a,e4=eU?eU.toStringTag:a,e7=function(){try{var e=getNative(eA,"defineProperty");return e({},"",{}),e}catch(e){}}(),e8=e.clearTimeout!==e6.clearTimeout&&e.clearTimeout,te=ev&&ev.now!==e6.Date.now&&ev.now,tt=e.setTimeout!==e6.setTimeout&&e.setTimeout,tu=eI.ceil,tp=eI.floor,td=eA.getOwnPropertySymbols,tg=eP?eP.isBuffer:a,ty=e.isFinite,tb=ek.join,tv=overArg(eA.keys,eA),t_=eI.max,tm=eI.min,tI=ev.now,tA=e.parseInt,tS=eI.random,tO=ek.reverse,tw=getNative(e,"DataView"),tk=getNative(e,"Map"),tj=getNative(e,"Promise"),tL=getNative(e,"Set"),tx=getNative(e,"WeakMap"),tR=getNative(eA,"create"),tC=tx&&new tx,tF={},tz=toSource(tw),tW=toSource(tk),tE=toSource(tj),tT=toSource(tL),tM=toSource(tx),tP=eU?eU.prototype:a,tU=tP?tP.valueOf:a,tN=tP?tP.toString:a;function lodash(e){if(isObjectLike(e)&&!rz(e)&&!(e instanceof LazyWrapper)){if(e instanceof LodashWrapper)return e;if(eC.call(e,"__wrapped__"))return wrapperClone(e)}return new LodashWrapper(e)}var tB=function(){function object(){}return function(e){if(!isObject(e))return{};if(eK)return eK(e);object.prototype=e;var t=new object;return object.prototype=a,t}}();function baseLodash(){}function LodashWrapper(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=a}function LazyWrapper(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=4294967295,this.__views__=[]}function Hash(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function baseClone(e,t,r,n,o,i){var s,u=1&t,c=2&t,l=4&t;if(r&&(s=o?r(e,n,o,i):r(e)),a!==s)return s;if(!isObject(e))return e;var h=rz(e);if(h){if(g=e.length,I=new e.constructor(g),g&&"string"==typeof e[0]&&eC.call(e,"index")&&(I.index=e.index,I.input=e.input),s=I,!u)return copyArray(e,s)}else{var g,I,k,P,U,N=tQ(e),B=N==y||N==b;if(rE(e))return cloneBuffer(e,u);if(N==m||N==f||B&&!o){if(s=c||B?{}:initCloneObject(e),!u)return c?(k=(U=s)&©Object(e,keysIn(e),U),copyObject(e,tY(e),k)):(P=baseAssign(s,e),copyObject(e,tJ(e),P))}else{if(!e0[N])return o?e:{};s=function(e,t,r){var n,a,o=e.constructor;switch(t){case j:return cloneArrayBuffer(e);case p:case d:return new o(+e);case L:return n=r?cloneArrayBuffer(e.buffer):e.buffer,new e.constructor(n,e.byteOffset,e.byteLength);case x:case R:case C:case F:case z:case W:case E:case T:case M:return cloneTypedArray(e,r);case v:return new o;case _:case O:return new o(e);case A:return(a=new e.constructor(e.source,eu.exec(e))).lastIndex=e.lastIndex,a;case S:return new o;case w:return tU?eA(tU.call(e)):{}}}(e,N,u)}}i||(i=new Stack);var D=i.get(e);if(D)return D;i.set(e,s),rU(e)?e.forEach(function(n){s.add(baseClone(n,t,r,n,e,i))}):rM(e)&&e.forEach(function(n,a){s.set(a,baseClone(n,t,r,a,e,i))});var q=l?c?getAllKeysIn:getAllKeys:c?keysIn:keys,K=h?a:q(e);return arrayEach(K||e,function(n,a){K&&(n=e[a=n]),assignValue(s,a,baseClone(n,t,r,a,e,i))}),s}function baseConformsTo(e,t,r){var n=r.length;if(null==e)return!n;for(e=eA(e);n--;){var o=r[n],i=t[o],s=e[o];if(a===s&&!(o in e)||!i(s))return!1}return!0}function baseDelay(e,t,r){if("function"!=typeof e)throw new ew(o);return t2(function(){e.apply(a,r)},t)}function baseDifference(e,t,r,n){var a=-1,o=arrayIncludes,i=!0,s=e.length,u=[],c=t.length;if(!s)return u;r&&(t=arrayMap(t,baseUnary(r))),n?(o=arrayIncludesWith,i=!1):t.length>=200&&(o=cacheHas,i=!1,t=new SetCache(t));e:for(;++a-1},ListCache.prototype.set=function(e,t){var r=this.__data__,n=assocIndexOf(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},MapCache.prototype.clear=function(){this.size=0,this.__data__={hash:new Hash,map:new(tk||ListCache),string:new Hash}},MapCache.prototype.delete=function(e){var t=getMapData(this,e).delete(e);return this.size-=t?1:0,t},MapCache.prototype.get=function(e){return getMapData(this,e).get(e)},MapCache.prototype.has=function(e){return getMapData(this,e).has(e)},MapCache.prototype.set=function(e,t){var r=getMapData(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},SetCache.prototype.add=SetCache.prototype.push=function(e){return this.__data__.set(e,i),this},SetCache.prototype.has=function(e){return this.__data__.has(e)},Stack.prototype.clear=function(){this.__data__=new ListCache,this.size=0},Stack.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Stack.prototype.get=function(e){return this.__data__.get(e)},Stack.prototype.has=function(e){return this.__data__.has(e)},Stack.prototype.set=function(e,t){var r=this.__data__;if(r instanceof ListCache){var n=r.__data__;if(!tk||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new MapCache(n)}return r.set(e,t),this.size=r.size,this};var tD=createBaseEach(baseForOwn),tq=createBaseEach(baseForOwnRight,!0);function baseEvery(e,t){var r=!0;return tD(e,function(e,n,a){return r=!!t(e,n,a)}),r}function baseExtremum(e,t,r){for(var n=-1,o=e.length;++n0&&r(s)?t>1?baseFlatten(s,t-1,r,n,a):arrayPush(a,s):n||(a[a.length]=s)}return a}var tK=createBaseFor(),tH=createBaseFor(!0);function baseForOwn(e,t){return e&&tK(e,t,keys)}function baseForOwnRight(e,t){return e&&tH(e,t,keys)}function baseFunctions(e,t){return arrayFilter(t,function(t){return isFunction(e[t])})}function baseGet(e,t){t=castPath(t,e);for(var r=0,n=t.length;null!=e&&rt}function baseHas(e,t){return null!=e&&eC.call(e,t)}function baseHasIn(e,t){return null!=e&&t in eA(e)}function baseIntersection(e,t,r){for(var n=r?arrayIncludesWith:arrayIncludes,o=e[0].length,i=e.length,s=i,u=eb(i),c=1/0,l=[];s--;){var f=e[s];s&&t&&(f=arrayMap(f,baseUnary(t))),c=tm(f.length,c),u[s]=!r&&(t||o>=120&&f.length>=120)?new SetCache(s&&f):a}f=e[0];var h=-1,p=u[0];e:for(;++h=s)return u;return u*("desc"==r[n]?-1:1)}}return e.index-t.index}(e,t,r)})}function basePickBy(e,t,r){for(var n=-1,a=t.length,o={};++n-1;)s!==e&&eZ.call(s,u,1),eZ.call(e,u,1);return e}function basePullAt(e,t){for(var r=e?t.length:0,n=r-1;r--;){var a=t[r];if(r==n||a!==o){var o=a;isIndex(a)?eZ.call(e,a,1):baseUnset(e,a)}}return e}function baseRandom(e,t){return e+tp(tS()*(t-e+1))}function baseRepeat(e,t){var r="";if(!e||t<1||t>9007199254740991)return r;do t%2&&(r+=e),(t=tp(t/2))&&(e+=e);while(t);return r}function baseRest(e,t){return t9(overRest(e,t,identity),e+"")}function baseSet(e,t,r,n){if(!isObject(e))return e;t=castPath(t,e);for(var o=-1,i=t.length,s=i-1,u=e;null!=u&&++oa?0:a+t),(r=r>a?a:r)<0&&(r+=a),a=t>r?0:r-t>>>0,t>>>=0;for(var o=eb(a);++n>>1,i=e[o];null!==i&&!isSymbol(i)&&(r?i<=t:i=200){var c=t?null:tZ(e);if(c)return setToArray(c);i=!1,a=cacheHas,u=new SetCache}else u=t?[]:s;e:for(;++n=n?e:baseSlice(e,t,r)}var t$=e8||function(e){return e6.clearTimeout(e)};function cloneBuffer(e,t){if(t)return e.slice();var r=e.length,n=eB?eB(r):new e.constructor(r);return e.copy(n),n}function cloneArrayBuffer(e){var t=new e.constructor(e.byteLength);return new eN(t).set(new eN(e)),t}function cloneTypedArray(e,t){var r=t?cloneArrayBuffer(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function compareAscending(e,t){if(e!==t){var r=a!==e,n=null===e,o=e==e,i=isSymbol(e),s=a!==t,u=null===t,c=t==t,l=isSymbol(t);if(!u&&!l&&!i&&e>t||i&&s&&c&&!u&&!l||n&&s&&c||!r&&c||!o)return 1;if(!n&&!i&&!l&&e1?r[o-1]:a,s=o>2?r[2]:a;for(i=e.length>3&&"function"==typeof i?(o--,i):a,s&&isIterateeCall(r[0],r[1],s)&&(i=o<3?a:i,o=1),t=eA(t);++n-1?o[i?t[s]:s]:a}}function createFlow(e){return flatRest(function(t){var r=t.length,n=r,i=LodashWrapper.prototype.thru;for(e&&t.reverse();n--;){var s=t[n];if("function"!=typeof s)throw new ew(o);if(i&&!u&&"wrapper"==getFuncName(s))var u=new LodashWrapper([],!0)}for(n=u?n:r;++n1&&v.reverse(),f&&cu))return!1;var l=i.get(e),f=i.get(t);if(l&&f)return l==t&&f==e;var h=-1,p=!0,d=2&r?new SetCache:a;for(i.set(e,t),i.set(t,e);++h-1&&e%1==0&&e1?"& ":"")+t[n],t=t.join(r>2?", ":" "),e.replace(et,"{\n/* [wrapped with "+t+"] */\n")}(o,(n=(a=o.match(er))?a[1].split(en):[],arrayEach(l,function(e){var t="_."+e[0];r&e[1]&&!arrayIncludes(n,t)&&n.push(t)}),n.sort())))}function shortOut(e){var t=0,r=0;return function(){var n=tI(),o=16-(n-r);if(r=n,o>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(a,arguments)}}function shuffleSelf(e,t){var r=-1,n=e.length,o=n-1;for(t=a===t?n:t;++r1?e[t-1]:a;return r="function"==typeof r?(e.pop(),r):a,unzipWith(e,r)});function chain(e){var t=lodash(e);return t.__chain__=!0,t}function thru(e,t){return t(e)}var rh=flatRest(function(e){var t=e.length,r=t?e[0]:0,n=this.__wrapped__,interceptor=function(t){return baseAt(t,e)};return!(t>1)&&!this.__actions__.length&&n instanceof LazyWrapper&&isIndex(r)?((n=n.slice(r,+r+(t?1:0))).__actions__.push({func:thru,args:[interceptor],thisArg:a}),new LodashWrapper(n,this.__chain__).thru(function(e){return t&&!e.length&&e.push(a),e})):this.thru(interceptor)}),rp=createAggregator(function(e,t,r){eC.call(e,r)?++e[r]:baseAssignValue(e,r,1)}),rd=createFind(findIndex),rg=createFind(findLastIndex);function forEach(e,t){return(rz(e)?arrayEach:tD)(e,getIteratee(t,3))}function forEachRight(e,t){return(rz(e)?function(e,t){for(var r=null==e?0:e.length;r--&&!1!==t(e[r],r,e););return e}:tq)(e,getIteratee(t,3))}var ry=createAggregator(function(e,t,r){eC.call(e,r)?e[r].push(t):baseAssignValue(e,r,[t])}),rb=baseRest(function(e,t,r){var n=-1,a="function"==typeof t,o=isArrayLike(e)?eb(e.length):[];return tD(e,function(e){o[++n]=a?apply(t,e,r):baseInvoke(e,t,r)}),o}),rv=createAggregator(function(e,t,r){baseAssignValue(e,r,t)});function map(e,t){return(rz(e)?arrayMap:baseMap)(e,getIteratee(t,3))}var r_=createAggregator(function(e,t,r){e[r?0:1].push(t)},function(){return[[],[]]}),rm=baseRest(function(e,t){if(null==e)return[];var r=t.length;return r>1&&isIterateeCall(e,t[0],t[1])?t=[]:r>2&&isIterateeCall(t[0],t[1],t[2])&&(t=[t[0]]),baseOrderBy(e,baseFlatten(t,1),[])}),rI=te||function(){return e6.Date.now()};function ary(e,t,r){return t=r?a:t,t=e&&null==t?e.length:t,createWrap(e,128,a,a,a,a,t)}function before(e,t){var r;if("function"!=typeof t)throw new ew(o);return e=toInteger(e),function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=a),r}}var rA=baseRest(function(e,t,r){var n=1;if(r.length){var a=replaceHolders(r,getHolder(rA));n|=32}return createWrap(e,n,t,r,a)}),rS=baseRest(function(e,t,r){var n=3;if(r.length){var a=replaceHolders(r,getHolder(rS));n|=32}return createWrap(t,n,e,r,a)});function debounce(e,t,r){var n,i,s,u,c,l,f=0,h=!1,p=!1,d=!0;if("function"!=typeof e)throw new ew(o);function invokeFunc(t){var r=n,o=i;return n=i=a,f=t,u=e.apply(o,r)}function shouldInvoke(e){var r=e-l,n=e-f;return a===l||r>=t||r<0||p&&n>=s}function timerExpired(){var e,r,n,a=rI();if(shouldInvoke(a))return trailingEdge(a);c=t2(timerExpired,(e=a-l,r=a-f,n=t-e,p?tm(n,s-r):n))}function trailingEdge(e){return(c=a,d&&n)?invokeFunc(e):(n=i=a,u)}function debounced(){var e,r=rI(),o=shouldInvoke(r);if(n=arguments,i=this,l=r,o){if(a===c)return f=e=l,c=t2(timerExpired,t),h?invokeFunc(e):u;if(p)return t$(c),c=t2(timerExpired,t),invokeFunc(l)}return a===c&&(c=t2(timerExpired,t)),u}return t=toNumber(t)||0,isObject(r)&&(h=!!r.leading,s=(p="maxWait"in r)?t_(toNumber(r.maxWait)||0,t):s,d="trailing"in r?!!r.trailing:d),debounced.cancel=function(){a!==c&&t$(c),f=0,n=l=i=c=a},debounced.flush=function(){return a===c?u:trailingEdge(rI())},debounced}var rO=baseRest(function(e,t){return baseDelay(e,1,t)}),rw=baseRest(function(e,t,r){return baseDelay(e,toNumber(t)||0,r)});function memoize(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new ew(o);var memoized=function(){var r=arguments,n=t?t.apply(this,r):r[0],a=memoized.cache;if(a.has(n))return a.get(n);var o=e.apply(this,r);return memoized.cache=a.set(n,o)||a,o};return memoized.cache=new(memoize.Cache||MapCache),memoized}function negate(e){if("function"!=typeof e)throw new ew(o);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}memoize.Cache=MapCache;var rk=baseRest(function(e,t){var r=(t=1==t.length&&rz(t[0])?arrayMap(t[0],baseUnary(getIteratee())):arrayMap(baseFlatten(t,1),baseUnary(getIteratee()))).length;return baseRest(function(n){for(var a=-1,o=tm(n.length,r);++a=t}),rF=baseIsArguments(function(){return arguments}())?baseIsArguments:function(e){return isObjectLike(e)&&eC.call(e,"callee")&&!eV.call(e,"callee")},rz=eb.isArray,rW=tr?baseUnary(tr):function(e){return isObjectLike(e)&&baseGetTag(e)==j};function isArrayLike(e){return null!=e&&isLength(e.length)&&!isFunction(e)}function isArrayLikeObject(e){return isObjectLike(e)&&isArrayLike(e)}var rE=tg||stubFalse,rT=tn?baseUnary(tn):function(e){return isObjectLike(e)&&baseGetTag(e)==d};function isError(e){if(!isObjectLike(e))return!1;var t=baseGetTag(e);return t==g||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!isPlainObject(e)}function isFunction(e){if(!isObject(e))return!1;var t=baseGetTag(e);return t==y||t==b||"[object AsyncFunction]"==t||"[object Proxy]"==t}function isInteger(e){return"number"==typeof e&&e==toInteger(e)}function isLength(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function isObject(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function isObjectLike(e){return null!=e&&"object"==typeof e}var rM=ta?baseUnary(ta):function(e){return isObjectLike(e)&&tQ(e)==v};function isNumber(e){return"number"==typeof e||isObjectLike(e)&&baseGetTag(e)==_}function isPlainObject(e){if(!isObjectLike(e)||baseGetTag(e)!=m)return!1;var t=eD(e);if(null===t)return!0;var r=eC.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&eR.call(r)==eE}var rP=to?baseUnary(to):function(e){return isObjectLike(e)&&baseGetTag(e)==A},rU=ti?baseUnary(ti):function(e){return isObjectLike(e)&&tQ(e)==S};function isString(e){return"string"==typeof e||!rz(e)&&isObjectLike(e)&&baseGetTag(e)==O}function isSymbol(e){return"symbol"==typeof e||isObjectLike(e)&&baseGetTag(e)==w}var rN=ts?baseUnary(ts):function(e){return isObjectLike(e)&&isLength(e.length)&&!!eQ[baseGetTag(e)]},rB=createRelationalOperation(baseLt),rD=createRelationalOperation(function(e,t){return e<=t});function toArray(e){if(!e)return[];if(isArrayLike(e))return isString(e)?stringToArray(e):copyArray(e);if(e3&&e[e3])return function(e){for(var t,r=[];!(t=e.next()).done;)r.push(t.value);return r}(e[e3]());var t=tQ(e);return(t==v?mapToArray:t==S?setToArray:values)(e)}function toFinite(e){return e?(e=toNumber(e))===u||e===-u?(e<0?-1:1)*17976931348623157e292:e==e?e:0:0===e?e:0}function toInteger(e){var t=toFinite(e),r=t%1;return t==t?r?t-r:t:0}function toLength(e){return e?baseClamp(toInteger(e),0,4294967295):0}function toNumber(e){if("number"==typeof e)return e;if(isSymbol(e))return c;if(isObject(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=isObject(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=baseTrim(e);var r=el.test(e);return r||eh.test(e)?e9(e.slice(2),r?2:8):ec.test(e)?c:+e}function toPlainObject(e){return copyObject(e,keysIn(e))}function toString(e){return null==e?"":baseToString(e)}var rq=createAssigner(function(e,t){if(isPrototype(t)||isArrayLike(t)){copyObject(t,keys(t),e);return}for(var r in t)eC.call(t,r)&&assignValue(e,r,t[r])}),rK=createAssigner(function(e,t){copyObject(t,keysIn(t),e)}),rH=createAssigner(function(e,t,r,n){copyObject(t,keysIn(t),e,n)}),rG=createAssigner(function(e,t,r,n){copyObject(t,keys(t),e,n)}),rV=flatRest(baseAt),r$=baseRest(function(e,t){e=eA(e);var r=-1,n=t.length,o=n>2?t[2]:a;for(o&&isIterateeCall(t[0],t[1],o)&&(n=1);++r1),t}),copyObject(e,getAllKeysIn(e),r),n&&(r=baseClone(r,7,customOmitClone));for(var a=t.length;a--;)baseUnset(r,t[a]);return r}),r2=flatRest(function(e,t){return null==e?{}:basePickBy(e,t,function(t,r){return hasIn(e,r)})});function pickBy(e,t){if(null==e)return{};var r=arrayMap(getAllKeysIn(e),function(e){return[e]});return t=getIteratee(t),basePickBy(e,r,function(e,r){return t(e,r[0])})}var r9=createToPairs(keys),r3=createToPairs(keysIn);function values(e){return null==e?[]:baseValues(e,keys(e))}var r4=createCompounder(function(e,t,r){return t=t.toLowerCase(),e+(r?capitalize(t):t)});function capitalize(e){return nr(toString(e).toLowerCase())}function deburr(e){return(e=toString(e))&&e.replace(ed,tc).replace(eG,"")}var r6=createCompounder(function(e,t,r){return e+(r?"-":"")+t.toLowerCase()}),r7=createCompounder(function(e,t,r){return e+(r?" ":"")+t.toLowerCase()}),r8=createCaseFirst("toLowerCase"),r5=createCompounder(function(e,t,r){return e+(r?"_":"")+t.toLowerCase()}),ne=createCompounder(function(e,t,r){return e+(r?" ":"")+nr(t)}),nt=createCompounder(function(e,t,r){return e+(r?" ":"")+t.toUpperCase()}),nr=createCaseFirst("toUpperCase");function words(e,t,r){if(e=toString(e),t=r?a:t,a===t){var n;return(n=e,eX.test(n))?e.match(e$)||[]:e.match(ea)||[]}return e.match(t)||[]}var nn=baseRest(function(e,t){try{return apply(e,a,t)}catch(e){return isError(e)?e:new e_(e)}}),na=flatRest(function(e,t){return arrayEach(t,function(t){baseAssignValue(e,t=toKey(t),rA(e[t],e))}),e});function constant(e){return function(){return e}}var no=createFlow(),ni=createFlow(!0);function identity(e){return e}function iteratee(e){return baseIteratee("function"==typeof e?e:baseClone(e,1))}var ns=baseRest(function(e,t){return function(r){return baseInvoke(r,e,t)}}),nu=baseRest(function(e,t){return function(r){return baseInvoke(e,r,t)}});function mixin(e,t,r){var n=keys(t),a=baseFunctions(t,n);null!=r||isObject(t)&&(a.length||!n.length)||(r=t,t=e,e=this,a=baseFunctions(t,keys(t)));var o=!(isObject(r)&&"chain"in r)||!!r.chain,i=isFunction(e);return arrayEach(a,function(r){var n=t[r];e[r]=n,i&&(e.prototype[r]=function(){var t=this.__chain__;if(o||t){var r=e(this.__wrapped__);return(r.__actions__=copyArray(this.__actions__)).push({func:n,args:arguments,thisArg:e}),r.__chain__=t,r}return n.apply(e,arrayPush([this.value()],arguments))})}),e}function noop(){}var nc=createOver(arrayMap),nl=createOver(arrayEvery),nf=createOver(arraySome);function property(e){return isKey(e)?baseProperty(toKey(e)):function(t){return baseGet(t,e)}}var nh=createRange(),np=createRange(!0);function stubArray(){return[]}function stubFalse(){return!1}var nd=createMathOperation(function(e,t){return e+t},0),ng=createRound("ceil"),ny=createMathOperation(function(e,t){return e/t},1),nb=createRound("floor"),nv=createMathOperation(function(e,t){return e*t},1),n_=createRound("round"),nm=createMathOperation(function(e,t){return e-t},0);return lodash.after=function(e,t){if("function"!=typeof t)throw new ew(o);return e=toInteger(e),function(){if(--e<1)return t.apply(this,arguments)}},lodash.ary=ary,lodash.assign=rq,lodash.assignIn=rK,lodash.assignInWith=rH,lodash.assignWith=rG,lodash.at=rV,lodash.before=before,lodash.bind=rA,lodash.bindAll=na,lodash.bindKey=rS,lodash.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return rz(e)?e:[e]},lodash.chain=chain,lodash.chunk=function(e,t,r){t=(r?isIterateeCall(e,t,r):a===t)?1:t_(toInteger(t),0);var n=null==e?0:e.length;if(!n||t<1)return[];for(var o=0,i=0,s=eb(tu(n/t));oo?0:o+r),(n=a===n||n>o?o:toInteger(n))<0&&(n+=o),n=r>n?0:toLength(n);r>>0)?(e=toString(e))&&("string"==typeof t||null!=t&&!rP(t))&&!(t=baseToString(t))&&hasUnicode(e)?castSlice(stringToArray(e),0,r):e.split(t,r):[]},lodash.spread=function(e,t){if("function"!=typeof e)throw new ew(o);return t=null==t?0:t_(toInteger(t),0),baseRest(function(r){var n=r[t],a=castSlice(r,0,t);return n&&arrayPush(a,n),apply(e,this,a)})},lodash.tail=function(e){var t=null==e?0:e.length;return t?baseSlice(e,1,t):[]},lodash.take=function(e,t,r){return e&&e.length?baseSlice(e,0,(t=r||a===t?1:toInteger(t))<0?0:t):[]},lodash.takeRight=function(e,t,r){var n=null==e?0:e.length;return n?baseSlice(e,(t=n-(t=r||a===t?1:toInteger(t)))<0?0:t,n):[]},lodash.takeRightWhile=function(e,t){return e&&e.length?baseWhile(e,getIteratee(t,3),!1,!0):[]},lodash.takeWhile=function(e,t){return e&&e.length?baseWhile(e,getIteratee(t,3)):[]},lodash.tap=function(e,t){return t(e),e},lodash.throttle=function(e,t,r){var n=!0,a=!0;if("function"!=typeof e)throw new ew(o);return isObject(r)&&(n="leading"in r?!!r.leading:n,a="trailing"in r?!!r.trailing:a),debounce(e,t,{leading:n,maxWait:t,trailing:a})},lodash.thru=thru,lodash.toArray=toArray,lodash.toPairs=r9,lodash.toPairsIn=r3,lodash.toPath=function(e){return rz(e)?arrayMap(e,toKey):isSymbol(e)?[e]:copyArray(t3(toString(e)))},lodash.toPlainObject=toPlainObject,lodash.transform=function(e,t,r){var n=rz(e),a=n||rE(e)||rN(e);if(t=getIteratee(t,4),null==r){var o=e&&e.constructor;r=a?n?new o:[]:isObject(e)&&isFunction(o)?tB(eD(e)):{}}return(a?arrayEach:baseForOwn)(e,function(e,n,a){return t(r,e,n,a)}),r},lodash.unary=function(e){return ary(e,1)},lodash.union=rn,lodash.unionBy=ra,lodash.unionWith=ro,lodash.uniq=function(e){return e&&e.length?baseUniq(e):[]},lodash.uniqBy=function(e,t){return e&&e.length?baseUniq(e,getIteratee(t,2)):[]},lodash.uniqWith=function(e,t){return t="function"==typeof t?t:a,e&&e.length?baseUniq(e,a,t):[]},lodash.unset=function(e,t){return null==e||baseUnset(e,t)},lodash.unzip=unzip,lodash.unzipWith=unzipWith,lodash.update=function(e,t,r){return null==e?e:baseUpdate(e,t,castFunction(r))},lodash.updateWith=function(e,t,r,n){return n="function"==typeof n?n:a,null==e?e:baseUpdate(e,t,castFunction(r),n)},lodash.values=values,lodash.valuesIn=function(e){return null==e?[]:baseValues(e,keysIn(e))},lodash.without=ri,lodash.words=words,lodash.wrap=function(e,t){return rj(castFunction(t),e)},lodash.xor=rs,lodash.xorBy=ru,lodash.xorWith=rc,lodash.zip=rl,lodash.zipObject=function(e,t){return baseZipObject(e||[],t||[],assignValue)},lodash.zipObjectDeep=function(e,t){return baseZipObject(e||[],t||[],baseSet)},lodash.zipWith=rf,lodash.entries=r9,lodash.entriesIn=r3,lodash.extend=rK,lodash.extendWith=rH,mixin(lodash,lodash),lodash.add=nd,lodash.attempt=nn,lodash.camelCase=r4,lodash.capitalize=capitalize,lodash.ceil=ng,lodash.clamp=function(e,t,r){return a===r&&(r=t,t=a),a!==r&&(r=(r=toNumber(r))==r?r:0),a!==t&&(t=(t=toNumber(t))==t?t:0),baseClamp(toNumber(e),t,r)},lodash.clone=function(e){return baseClone(e,4)},lodash.cloneDeep=function(e){return baseClone(e,5)},lodash.cloneDeepWith=function(e,t){return baseClone(e,5,t="function"==typeof t?t:a)},lodash.cloneWith=function(e,t){return baseClone(e,4,t="function"==typeof t?t:a)},lodash.conformsTo=function(e,t){return null==t||baseConformsTo(e,t,keys(t))},lodash.deburr=deburr,lodash.defaultTo=function(e,t){return null==e||e!=e?t:e},lodash.divide=ny,lodash.endsWith=function(e,t,r){e=toString(e),t=baseToString(t);var n=e.length,o=r=a===r?n:baseClamp(toInteger(r),0,n);return(r-=t.length)>=0&&e.slice(r,o)==t},lodash.eq=eq,lodash.escape=function(e){return(e=toString(e))&&K.test(e)?e.replace(D,tl):e},lodash.escapeRegExp=function(e){return(e=toString(e))&&Y.test(e)?e.replace(J,"\\$&"):e},lodash.every=function(e,t,r){var n=rz(e)?arrayEvery:baseEvery;return r&&isIterateeCall(e,t,r)&&(t=a),n(e,getIteratee(t,3))},lodash.find=rd,lodash.findIndex=findIndex,lodash.findKey=function(e,t){return baseFindKey(e,getIteratee(t,3),baseForOwn)},lodash.findLast=rg,lodash.findLastIndex=findLastIndex,lodash.findLastKey=function(e,t){return baseFindKey(e,getIteratee(t,3),baseForOwnRight)},lodash.floor=nb,lodash.forEach=forEach,lodash.forEachRight=forEachRight,lodash.forIn=function(e,t){return null==e?e:tK(e,getIteratee(t,3),keysIn)},lodash.forInRight=function(e,t){return null==e?e:tH(e,getIteratee(t,3),keysIn)},lodash.forOwn=function(e,t){return e&&baseForOwn(e,getIteratee(t,3))},lodash.forOwnRight=function(e,t){return e&&baseForOwnRight(e,getIteratee(t,3))},lodash.get=get,lodash.gt=rR,lodash.gte=rC,lodash.has=function(e,t){return null!=e&&hasPath(e,t,baseHas)},lodash.hasIn=hasIn,lodash.head=head,lodash.identity=identity,lodash.includes=function(e,t,r,n){e=isArrayLike(e)?e:values(e),r=r&&!n?toInteger(r):0;var a=e.length;return r<0&&(r=t_(a+r,0)),isString(e)?r<=a&&e.indexOf(t,r)>-1:!!a&&baseIndexOf(e,t,r)>-1},lodash.indexOf=function(e,t,r){var n=null==e?0:e.length;if(!n)return -1;var a=null==r?0:toInteger(r);return a<0&&(a=t_(n+a,0)),baseIndexOf(e,t,a)},lodash.inRange=function(e,t,r){var n,o,i;return t=toFinite(t),a===r?(r=t,t=0):r=toFinite(r),(n=e=toNumber(e))>=tm(o=t,i=r)&&n=-9007199254740991&&e<=9007199254740991},lodash.isSet=rU,lodash.isString=isString,lodash.isSymbol=isSymbol,lodash.isTypedArray=rN,lodash.isUndefined=function(e){return a===e},lodash.isWeakMap=function(e){return isObjectLike(e)&&tQ(e)==k},lodash.isWeakSet=function(e){return isObjectLike(e)&&"[object WeakSet]"==baseGetTag(e)},lodash.join=function(e,t){return null==e?"":tb.call(e,t)},lodash.kebabCase=r6,lodash.last=last,lodash.lastIndexOf=function(e,t,r){var n=null==e?0:e.length;if(!n)return -1;var o=n;return a!==r&&(o=(o=toInteger(r))<0?t_(n+o,0):tm(o,n-1)),t==t?function(e,t,r){for(var n=r+1;n--&&e[n]!==t;);return n}(e,t,o):baseFindIndex(e,baseIsNaN,o,!0)},lodash.lowerCase=r7,lodash.lowerFirst=r8,lodash.lt=rB,lodash.lte=rD,lodash.max=function(e){return e&&e.length?baseExtremum(e,identity,baseGt):a},lodash.maxBy=function(e,t){return e&&e.length?baseExtremum(e,getIteratee(t,2),baseGt):a},lodash.mean=function(e){return baseMean(e,identity)},lodash.meanBy=function(e,t){return baseMean(e,getIteratee(t,2))},lodash.min=function(e){return e&&e.length?baseExtremum(e,identity,baseLt):a},lodash.minBy=function(e,t){return e&&e.length?baseExtremum(e,getIteratee(t,2),baseLt):a},lodash.stubArray=stubArray,lodash.stubFalse=stubFalse,lodash.stubObject=function(){return{}},lodash.stubString=function(){return""},lodash.stubTrue=function(){return!0},lodash.multiply=nv,lodash.nth=function(e,t){return e&&e.length?baseNth(e,toInteger(t)):a},lodash.noConflict=function(){return e6._===this&&(e6._=eT),this},lodash.noop=noop,lodash.now=rI,lodash.pad=function(e,t,r){e=toString(e);var n=(t=toInteger(t))?stringSize(e):0;if(!t||n>=t)return e;var a=(t-n)/2;return createPadding(tp(a),r)+e+createPadding(tu(a),r)},lodash.padEnd=function(e,t,r){e=toString(e);var n=(t=toInteger(t))?stringSize(e):0;return t&&nt){var n=e;e=t,t=n}if(r||e%1||t%1){var o=tS();return tm(e+o*(t-e+e2("1e-"+((o+"").length-1))),t)}return baseRandom(e,t)},lodash.reduce=function(e,t,r){var n=rz(e)?arrayReduce:baseReduce,a=arguments.length<3;return n(e,getIteratee(t,4),r,a,tD)},lodash.reduceRight=function(e,t,r){var n=rz(e)?arrayReduceRight:baseReduce,a=arguments.length<3;return n(e,getIteratee(t,4),r,a,tq)},lodash.repeat=function(e,t,r){return t=(r?isIterateeCall(e,t,r):a===t)?1:toInteger(t),baseRepeat(toString(e),t)},lodash.replace=function(){var e=arguments,t=toString(e[0]);return e.length<3?t:t.replace(e[1],e[2])},lodash.result=function(e,t,r){t=castPath(t,e);var n=-1,o=t.length;for(o||(o=1,e=a);++n9007199254740991)return[];var r=4294967295,n=tm(e,4294967295);t=getIteratee(t),e-=4294967295;for(var a=baseTimes(n,t);++r=i)return e;var u=r-stringSize(n);if(u<1)return n;var c=s?castSlice(s,0,u).join(""):e.slice(0,u);if(a===o)return c+n;if(s&&(u+=c.length-u),rP(o)){if(e.slice(u).search(o)){var l,f=c;for(o.global||(o=eS(o.source,toString(eu.exec(o))+"g")),o.lastIndex=0;l=o.exec(f);)var h=l.index;c=c.slice(0,a===h?u:h)}}else if(e.indexOf(baseToString(o),u)!=u){var p=c.lastIndexOf(o);p>-1&&(c=c.slice(0,p))}return c+n},lodash.unescape=function(e){return(e=toString(e))&&q.test(e)?e.replace(B,tf):e},lodash.uniqueId=function(e){var t=++eF;return toString(e)+t},lodash.upperCase=nt,lodash.upperFirst=nr,lodash.each=forEach,lodash.eachRight=forEachRight,lodash.first=head,mixin(lodash,(ee={},baseForOwn(lodash,function(e,t){eC.call(lodash.prototype,t)||(ee[t]=e)}),ee),{chain:!1}),lodash.VERSION="4.17.21",arrayEach(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){lodash[e].placeholder=lodash}),arrayEach(["drop","take"],function(e,t){LazyWrapper.prototype[e]=function(r){r=a===r?1:t_(toInteger(r),0);var n=this.__filtered__&&!t?new LazyWrapper(this):this.clone();return n.__filtered__?n.__takeCount__=tm(r,n.__takeCount__):n.__views__.push({size:tm(r,4294967295),type:e+(n.__dir__<0?"Right":"")}),n},LazyWrapper.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}}),arrayEach(["filter","map","takeWhile"],function(e,t){var r=t+1,n=1==r||3==r;LazyWrapper.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:getIteratee(e,3),type:r}),t.__filtered__=t.__filtered__||n,t}}),arrayEach(["head","last"],function(e,t){var r="take"+(t?"Right":"");LazyWrapper.prototype[e]=function(){return this[r](1).value()[0]}}),arrayEach(["initial","tail"],function(e,t){var r="drop"+(t?"":"Right");LazyWrapper.prototype[e]=function(){return this.__filtered__?new LazyWrapper(this):this[r](1)}}),LazyWrapper.prototype.compact=function(){return this.filter(identity)},LazyWrapper.prototype.find=function(e){return this.filter(e).head()},LazyWrapper.prototype.findLast=function(e){return this.reverse().find(e)},LazyWrapper.prototype.invokeMap=baseRest(function(e,t){return"function"==typeof e?new LazyWrapper(this):this.map(function(r){return baseInvoke(r,e,t)})}),LazyWrapper.prototype.reject=function(e){return this.filter(negate(getIteratee(e)))},LazyWrapper.prototype.slice=function(e,t){e=toInteger(e);var r=this;return r.__filtered__&&(e>0||t<0)?new LazyWrapper(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),a!==t&&(r=(t=toInteger(t))<0?r.dropRight(-t):r.take(t-e)),r)},LazyWrapper.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},LazyWrapper.prototype.toArray=function(){return this.take(4294967295)},baseForOwn(LazyWrapper.prototype,function(e,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),n=/^(?:head|last)$/.test(t),o=lodash[n?"take"+("last"==t?"Right":""):t],i=n||/^find/.test(t);o&&(lodash.prototype[t]=function(){var t=this.__wrapped__,s=n?[1]:arguments,u=t instanceof LazyWrapper,c=s[0],l=u||rz(t),interceptor=function(e){var t=o.apply(lodash,arrayPush([e],s));return n&&f?t[0]:t};l&&r&&"function"==typeof c&&1!=c.length&&(u=l=!1);var f=this.__chain__,h=!!this.__actions__.length,p=i&&!f,d=u&&!h;if(!i&&l){t=d?t:new LazyWrapper(this);var g=e.apply(t,s);return g.__actions__.push({func:thru,args:[interceptor],thisArg:a}),new LodashWrapper(g,f)}return p&&d?e.apply(this,s):(g=this.thru(interceptor),p?n?g.value()[0]:g.value():g)})}),arrayEach(["pop","push","shift","sort","splice","unshift"],function(e){var t=ek[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",n=/^(?:pop|shift)$/.test(e);lodash.prototype[e]=function(){var e=arguments;if(n&&!this.__chain__){var a=this.value();return t.apply(rz(a)?a:[],e)}return this[r](function(r){return t.apply(rz(r)?r:[],e)})}}),baseForOwn(LazyWrapper.prototype,function(e,t){var r=lodash[t];if(r){var n=r.name+"";eC.call(tF,n)||(tF[n]=[]),tF[n].push({name:t,func:r})}}),tF[createHybrid(a,2).name]=[{name:"wrapper",func:a}],LazyWrapper.prototype.clone=function(){var e=new LazyWrapper(this.__wrapped__);return e.__actions__=copyArray(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=copyArray(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=copyArray(this.__views__),e},LazyWrapper.prototype.reverse=function(){if(this.__filtered__){var e=new LazyWrapper(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e},LazyWrapper.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,r=rz(e),n=t<0,a=r?e.length:0,o=function(e,t,r){for(var n=-1,a=r.length;++n=this.__values__.length,t=e?a:this.__values__[this.__index__++];return{done:e,value:t}},lodash.prototype.plant=function(e){for(var t,r=this;r instanceof baseLodash;){var n=wrapperClone(r);n.__index__=0,n.__values__=a,t?o.__wrapped__=n:t=n;var o=n;r=r.__wrapped__}return o.__wrapped__=e,t},lodash.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof LazyWrapper){var t=e;return this.__actions__.length&&(t=new LazyWrapper(this)),(t=t.reverse()).__actions__.push({func:thru,args:[reverse],thisArg:a}),new LodashWrapper(t,this.__chain__)}return this.thru(reverse)},lodash.prototype.toJSON=lodash.prototype.valueOf=lodash.prototype.value=function(){return baseWrapperValue(this.__wrapped__,this.__actions__)},lodash.prototype.first=lodash.prototype.head,e3&&(lodash.prototype[e3]=function(){return this}),lodash}();e6._=th,a!==(n=(function(){return th}).call(t,r,t,e))&&(e.exports=n)}).call(this)}}]); \ No newline at end of file diff --git a/rln-js/_next/static/chunks/fd9d1056-2e1538a3c044e0bb.js b/rln-js/_next/static/chunks/fd9d1056-2e1538a3c044e0bb.js new file mode 100644 index 0000000..c5c27ee --- /dev/null +++ b/rln-js/_next/static/chunks/fd9d1056-2e1538a3c044e0bb.js @@ -0,0 +1,9 @@ +"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[971],{4417:function(n,l,a){/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var i,o=a(2265),s=a(8261),y={usingClientEntryPoint:!1,Events:null,Dispatcher:{current:null}};function t(n){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+n,a=1;ax||(n.current=C[x],C[x]=null,x--)}function E(n,l){C[++x]=n.current,n.current=l}var z=Symbol.for("react.element"),P=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),j=Symbol.for("react.provider"),M=Symbol.for("react.context"),F=Symbol.for("react.server_context"),O=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),A=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),H=Symbol.for("react.scope");Symbol.for("react.debug_trace_mode");var Q=Symbol.for("react.offscreen"),$=Symbol.for("react.legacy_hidden"),B=Symbol.for("react.cache");Symbol.for("react.tracing_marker");var Y=Symbol.for("react.default_value"),G=Symbol.iterator;function Ca(n){return null===n||"object"!=typeof n?null:"function"==typeof(n=G&&n[G]||n["@@iterator"])?n:null}var K=ia(null),J=ia(null),X=ia(null);function Ga(n,l){switch(E(X,l),E(J,n),E(K,null),n=l.nodeType){case 9:case 11:l=(l=l.documentElement)&&(l=l.namespaceURI)?Ha(l):0;break;default:if(l=(n=8===n?l.parentNode:l).tagName,n=n.namespaceURI)l=Ia(n=Ha(n),l);else switch(l){case"svg":l=1;break;case"math":l=2;break;default:l=0}}D(K),E(K,l)}function Ja(){D(K),D(J),D(X)}function Ka(n){var l=K.current,a=Ia(l,n.type);l!==a&&(E(J,n),E(K,a))}function La(n){J.current===n&&(D(K),D(J))}var et=s.unstable_scheduleCallback,en=s.unstable_cancelCallback,er=s.unstable_shouldYield,el=s.unstable_requestPaint,ea=s.unstable_now,eo=s.unstable_getCurrentPriorityLevel,eu=s.unstable_ImmediatePriority,ec=s.unstable_UserBlockingPriority,es=s.unstable_NormalPriority,ed=s.unstable_LowPriority,ep=s.unstable_IdlePriority,em=null,eb=null,ey=Math.clz32?Math.clz32:function(n){return 0==(n>>>=0)?32:31-(ev(n)/ew|0)|0},ev=Math.log,ew=Math.LN2,eS=128,eE=8388608;function fb(n){switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:return 8388480&n;case 8388608:case 16777216:case 33554432:case 67108864:return 125829120&n;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return n}}function gb(n,l){var a=n.pendingLanes;if(0===a)return 0;var i=0,o=n.suspendedLanes,s=n.pingedLanes,y=268435455&a;if(0!==y){var v=y&~o;0!==v?i=fb(v):0!=(s&=y)&&(i=fb(s))}else 0!=(y=a&~o)?i=fb(y):0!==s&&(i=fb(s));if(0===i)return 0;if(0!==l&&l!==i&&0==(l&o)&&((o=i&-i)>=(s=l&-l)||32===o&&0!=(8388480&s)))return l;if(0!=(8&i)&&(i|=32&a),0!==(l=n.entangledLanes))for(n=n.entanglements,l&=i;0a;a++)l.push(n);return l}function mb(n,l){n.pendingLanes|=l,536870912!==l&&(n.suspendedLanes=0,n.pingedLanes=0)}function ob(n,l){var a=n.entangledLanes|=l;for(n=n.entanglements;a;){var i=31-ey(a),o=1<--k||s[v]!==y[k]){var C="\n"+s[v].replace(" at new "," at ");return n.displayName&&C.includes("")&&(C=C.replace("",n.displayName)),C}while(1<=v&&0<=k);break}}}finally{eU=!1,Error.prepareStackTrace=a}return(n=n?n.displayName||n.name:"")?Xb(n):""}function cc(n){switch(typeof n){case"boolean":case"number":case"string":case"undefined":case"object":return n;default:return""}}function dc(n){var l=n.type;return(n=n.nodeName)&&"input"===n.toLowerCase()&&("checkbox"===l||"radio"===l)}function fc(n){n._valueTracker||(n._valueTracker=function(n){var l=dc(n)?"checked":"value",a=Object.getOwnPropertyDescriptor(n.constructor.prototype,l),i=""+n[l];if(!n.hasOwnProperty(l)&&void 0!==a&&"function"==typeof a.get&&"function"==typeof a.set){var o=a.get,s=a.set;return Object.defineProperty(n,l,{configurable:!0,get:function(){return o.call(this)},set:function(n){i=""+n,s.call(this,n)}}),Object.defineProperty(n,l,{enumerable:a.enumerable}),{getValue:function(){return i},setValue:function(n){i=""+n},stopTracking:function(){n._valueTracker=null,delete n[l]}}}}(n))}function gc(n){if(!n)return!1;var l=n._valueTracker;if(!l)return!0;var a=l.getValue(),i="";return n&&(i=dc(n)?n.checked?"true":"false":n.value),(n=i)!==a&&(l.setValue(n),!0)}function hc(n){if(void 0===(n=n||("undefined"!=typeof document?document:void 0)))return null;try{return n.activeElement||n.body}catch(l){return n.body}}var eq=/[\n"\\]/g;function jc(n){return n.replace(eq,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function kc(n,l,a,i,o,s,y,v){n.name="",null!=y&&"function"!=typeof y&&"symbol"!=typeof y&&"boolean"!=typeof y?n.type=y:n.removeAttribute("type"),null!=l?"number"===y?(0===l&&""===n.value||n.value!=l)&&(n.value=""+cc(l)):n.value!==""+cc(l)&&(n.value=""+cc(l)):"submit"!==y&&"reset"!==y||n.removeAttribute("value"),null!=l?lc(n,y,cc(l)):null!=a?lc(n,y,cc(a)):null!=i&&n.removeAttribute("value"),null==o&&null!=s&&(n.defaultChecked=!!s),null!=o&&!!o!==n.checked&&(n.checked=o),null!=v&&"function"!=typeof v&&"symbol"!=typeof v&&"boolean"!=typeof v?n.name=""+cc(v):n.removeAttribute("name")}function mc(n,l,a,i,o,s,y,v){if(null!=s&&"function"!=typeof s&&"symbol"!=typeof s&&"boolean"!=typeof s&&(n.type=s),null!=l||null!=a){if(!("submit"!==s&&"reset"!==s||null!=l))return;a=null!=a?""+cc(a):"",l=null!=l?""+cc(l):a,v||l===n.value||(n.value=l),n.defaultValue=l}i="function"!=typeof(i=null!=i?i:o)&&"symbol"!=typeof i&&!!i,v||(n.checked=!!i),n.defaultChecked=!!i,null!=y&&"function"!=typeof y&&"symbol"!=typeof y&&"boolean"!=typeof y&&(n.name=y)}function lc(n,l,a){"number"===l&&hc(n.ownerDocument)===n||n.defaultValue===""+a||(n.defaultValue=""+a)}var eH=Array.isArray;function oc(n,l,a,i){if(n=n.options,l){l={};for(var o=0;o"+l.valueOf().toString()+"",l=n9.firstChild;n.firstChild;)n.removeChild(n.firstChild);for(;l.firstChild;)n.appendChild(l.firstChild)}}var eQ=sc;"undefined"!=typeof MSApp&&MSApp.execUnsafeLocalFunction&&(eQ=function(n,l){return MSApp.execUnsafeLocalFunction(function(){return sc(n,l)})});var e$=eQ;function vc(n,l){if(l){var a=n.firstChild;if(a&&a===n.lastChild&&3===a.nodeType){a.nodeValue=l;return}}n.textContent=l}var eB=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function xc(n,l,a){var i=0===l.indexOf("--");null==a||"boolean"==typeof a||""===a?i?n.setProperty(l,""):"float"===l?n.cssFloat="":n[l]="":i?n.setProperty(l,a):"number"!=typeof a||0===a||eB.has(l)?"float"===l?n.cssFloat=a:n[l]=(""+a).trim():n[l]=a+"px"}function yc(n,l,a){if(null!=l&&"object"!=typeof l)throw Error(t(62));if(n=n.style,null!=a){for(var i in a)!a.hasOwnProperty(i)||null!=l&&l.hasOwnProperty(i)||(0===i.indexOf("--")?n.setProperty(i,""):"float"===i?n.cssFloat="":n[i]="");for(var o in l)i=l[o],l.hasOwnProperty(o)&&a[o]!==i&&xc(n,o,i)}else for(var s in l)l.hasOwnProperty(s)&&xc(n,s,l[s])}function zc(n){if(-1===n.indexOf("-"))return!1;switch(n){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var eZ=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),eY=null;function Cc(n){return(n=n.target||n.srcElement||window).correspondingUseElement&&(n=n.correspondingUseElement),3===n.nodeType?n.parentNode:n}var eG=null,eK=null;function Fc(n){var l=Fb(n);if(l&&(n=l.stateNode)){var a=Hb(n);switch(n=l.stateNode,l.type){case"input":if(kc(n,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),l=a.name,"radio"===a.type&&null!=l){for(a=n;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+jc(""+l)+'"][type="radio"]'),l=0;l>=y,o-=y,tt=1<<32-ey(l)+o|a<k?(C=v,v=null):C=v.sibling;var x=r(l,v,i[k],o);if(null===x){null===v&&(v=C);break}n&&v&&null===x.alternate&&b(l,v),a=f(x,a,k),null===y?s=x:y.sibling=x,y=x,v=C}if(k===i.length)return c(l,v),to&&jd(l,k),s;if(null===v){for(;kk?(C=v,v=null):C=v.sibling;var z=r(l,v,x.value,o);if(null===z){null===v&&(v=C);break}n&&v&&null===z.alternate&&b(l,v),a=f(z,a,k),null===y?s=z:y.sibling=z,y=z,v=C}if(x.done)return c(l,v),to&&jd(l,k),s;if(null===v){for(;!x.done;k++,x=i.next())null!==(x=w(l,x.value,o))&&(a=f(x,a,k),null===y?s=x:y.sibling=x,y=x);return to&&jd(l,k),s}for(v=d(l,v);!x.done;k++,x=i.next())null!==(x=u(v,l,k,x.value,o))&&(n&&null!==x.alternate&&v.delete(null===x.key?k:x.key),a=f(x,a,k),null===y?s=x:y.sibling=x,y=x);return n&&v.forEach(function(n){return b(l,n)}),to&&jd(l,k),s}(l,a,i,o);if("function"==typeof i.then)return S(l,a,le(i),o);if(i.$$typeof===M||i.$$typeof===F)return S(l,a,ve(l,i,o),o);ne(l,i)}return"string"==typeof i&&""!==i||"number"==typeof i?(i=""+i,null!==a&&6===a.tag?(c(l,a.sibling),(a=e(a,i)).return=l):(c(l,a),(a=re(i,l.mode,o)).return=l),g(l=a)):c(l,a)}(l,a,i,o),tw=null,l}}var tE=pe(!0),tC=pe(!1),tx=ia(null),tz=ia(0);function Ae(n,l){E(tz,n=nR),E(tx,l),nR=n|l.baseLanes}function Ce(){E(tz,nR),E(tx,tx.current)}function De(){nR=tz.current,D(tx),D(tz)}var tP=ia(null),tN=null;function Ge(n){var l=n.alternate;E(tL,1&tL.current),E(tP,n),null===tN&&(null===l||null!==tx.current?tN=n:null!==l.memoizedState&&(tN=n))}function Ie(n){if(22===n.tag){if(E(tL,tL.current),E(tP,n),null===tN){var l=n.alternate;null!==l&&null!==l.memoizedState&&(tN=n)}}else Je(n)}function Je(){E(tL,tL.current),E(tP,tP.current)}function Ke(n){D(tP),tN===n&&(tN=null),D(tL)}var tL=ia(0);function Le(n){for(var l=n;null!==l;){if(13===l.tag){var a=l.memoizedState;if(null!==a&&(null===(a=a.dehydrated)||"$?"===a.data||"$!"===a.data))return l}else if(19===l.tag&&void 0!==l.memoizedProps.revealOrder){if(0!=(128&l.flags))return l}else if(null!==l.child){l.child.return=l,l=l.child;continue}if(l===n)break;for(;null===l.sibling;){if(null===l.return||l.return===n)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var tT=null,t_=null,tD=!1,tM=!1,tF=!1,tO=0;function Se(n){n!==t_&&null===n.next&&(null===t_?tT=t_=n:t_=t_.next=n),tM=!0,tD||(tD=!0,Te(Ue))}function Ve(n){if(!tF&&tM){var l=null;tF=!0;do for(var a=!1,i=tT;null!==i;){if(!n||0===i.tag){var o=nM,s=gb(i,i===n_?o:0);if(0!=(3&s))try{if(a=!0,o=i,0!=(6&nT))throw Error(t(327));if(!We()){var y=Xe(o,s);if(0!==o.tag&&2===y){var v=s,k=ib(o,v);0!==k&&(s=k,y=Ye(o,v,k))}if(1===y)throw v=nA,$e(o,0),af(o,s),Se(o),v;6===y?af(o,s):(o.finishedWork=o.current.alternate,o.finishedLanes=s,bf(o,nQ,nZ))}Se(o)}catch(n){null===l?l=[n]:l.push(n)}}i=i.next}while(a);if(tF=!1,null!==l){if(1s?s:8;var y=tR.transition;tR.transition=null,mg(n,l,a),tR.transition={};try{mg(n,l,i),o()}catch(n){throw n}finally{eC=s,tR.transition=y}}function ng(){return Hf().memoizedState}function og(){return Hf().memoizedState}function pg(n){for(var l=n.return;null!==l;){switch(l.tag){case 24:case 3:var a=qg(l),i=Ud(l,n=Td(a),a);null!==i&&(Yf(i,l,a),Vd(i,l,a)),l={cache:rg()},n.payload=l;return}l=l.return}}function sg(n,l,a){var i=qg(n);a={lane:i,revertLane:0,action:a,hasEagerState:!1,eagerState:null,next:null},tg(n)?ug(l,a):(Ld(n,l,a,i),null!==(a=Nd(n))&&(Yf(a,n,i),vg(a,l,i)))}function mg(n,l,a){var i=qg(n),o={lane:i,revertLane:0,action:a,hasEagerState:!1,eagerState:null,next:null};if(tg(n))ug(l,o);else{var s=n.alternate;if(0===n.lanes&&(null===s||0===s.lanes)&&null!==(s=l.lastRenderedReducer))try{var y=l.lastRenderedState,v=s(y,a);if(o.hasEagerState=!0,o.eagerState=v,e2(v,y)){Ld(n,l,o,0),null===n_&&Jd();return}}catch(n){}finally{}Ld(n,l,o,i),null!==(a=Nd(n))&&(Yf(a,n,i),vg(a,l,i))}}function tg(n){var l=n.alternate;return n===tA||null!==l&&l===tA}function ug(n,l){tH=tq=!0;var a=n.pending;null===a?l.next=l:(l.next=a.next,a.next=l),n.pending=l}function vg(n,l,a){if(0!=(8388480&a)){var i=l.lanes;i&=n.pendingLanes,a|=i,l.lanes=a,ob(n,a)}}rt=function(){return{lastEffect:null,events:null,stores:null}};var tG={readContext:Lf,use:Kf,useCallback:uf,useContext:uf,useEffect:uf,useImperativeHandle:uf,useInsertionEffect:uf,useLayoutEffect:uf,useMemo:uf,useReducer:uf,useRef:uf,useState:uf,useDebugValue:uf,useDeferredValue:uf,useTransition:uf,useSyncExternalStore:uf,useId:uf};tG.useCacheRefresh=uf;var tK={readContext:Lf,use:Kf,useCallback:function(n,l){return Gf().memoizedState=[n,void 0===l?null:l],n},useContext:Lf,useEffect:cg,useImperativeHandle:function(n,l,a){a=null!=a?a.concat([n]):null,ag(4194308,4,fg.bind(null,l,n),a)},useLayoutEffect:function(n,l){return ag(4194308,4,n,l)},useInsertionEffect:function(n,l){ag(4,2,n,l)},useMemo:function(n,l){var a=Gf();return l=void 0===l?null:l,tQ&&n(),n=n(),a.memoizedState=[n,l],n},useReducer:function(n,l,a){var i=Gf();return l=void 0!==a?a(l):l,i.memoizedState=i.baseState=l,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:l},i.queue=n,n=n.dispatch=sg.bind(null,tA,n),[i.memoizedState,n]},useRef:function(n){return n={current:n},Gf().memoizedState=n},useState:function(n){var l=(n=Zf(n)).queue,a=mg.bind(null,tA,l);return l.dispatch=a,[n.memoizedState,a]},useDebugValue:hg,useDeferredValue:function(n){return Gf().memoizedState=n},useTransition:function(){var n=Zf(!1);return n=lg.bind(null,tA,n.queue,!0,!1),Gf().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,l,a){var i=tA,o=Gf();if(to){if(void 0===a)throw Error(t(407));a=a()}else{if(a=l(),null===n_)throw Error(t(349));0!=(60&tV)||Vf(i,l,a)}o.memoizedState=a;var s={value:a,getSnapshot:l};return o.queue=s,cg(Sf.bind(null,i,s,n),[n]),i.flags|=2048,Tf(9,Uf.bind(null,i,s,a,l),{destroy:void 0},null),a},useId:function(){var n=Gf(),l=n_.identifierPrefix;if(to){var a=tr,i=tt;l=":"+l+"R"+(a=(i&~(1<<32-ey(i)-1)).toString(32)+a),0<(a=t$++)&&(l+="H"+a.toString(32)),l+=":"}else l=":"+l+"r"+(a=tY++).toString(32)+":";return n.memoizedState=l},useCacheRefresh:function(){return Gf().memoizedState=pg.bind(null,tA)}},tJ={readContext:Lf,use:Kf,useCallback:ig,useContext:Lf,useEffect:Rf,useImperativeHandle:gg,useInsertionEffect:dg,useLayoutEffect:eg,useMemo:jg,useReducer:Nf,useRef:$f,useState:function(){return Nf(Mf)},useDebugValue:hg,useDeferredValue:function(n){return kg(Hf(),tW.memoizedState,n)},useTransition:function(){var n=Nf(Mf)[0],l=Hf().memoizedState;return["boolean"==typeof n?n:Jf(n),l]},useSyncExternalStore:Qf,useId:ng};tJ.useCacheRefresh=og;var tX={readContext:Lf,use:Kf,useCallback:ig,useContext:Lf,useEffect:Rf,useImperativeHandle:gg,useInsertionEffect:dg,useLayoutEffect:eg,useMemo:jg,useReducer:Pf,useRef:$f,useState:function(){return Pf(Mf)},useDebugValue:hg,useDeferredValue:function(n){var l=Hf();return null===tW?l.memoizedState=n:kg(l,tW.memoizedState,n)},useTransition:function(){var n=Pf(Mf)[0],l=Hf().memoizedState;return["boolean"==typeof n?n:Jf(n),l]},useSyncExternalStore:Qf,useId:ng};function wg(n,l){if(n&&n.defaultProps)for(var a in l=v({},l),n=n.defaultProps)void 0===l[a]&&(l[a]=n[a]);return l}function xg(n,l,a,i){a=null==(a=a(i,l=n.memoizedState))?l:v({},l,a),n.memoizedState=a,0===n.lanes&&(n.updateQueue.baseState=a)}tX.useCacheRefresh=og;var t0={isMounted:function(n){return!!(n=n._reactInternals)&&Ic(n)===n},enqueueSetState:function(n,l,a){var i=qg(n=n._reactInternals),o=Td(i);o.payload=l,null!=a&&(o.callback=a),null!==(l=Ud(n,o,i))&&(Yf(l,n,i),Vd(l,n,i))},enqueueReplaceState:function(n,l,a){var i=qg(n=n._reactInternals),o=Td(i);o.tag=1,o.payload=l,null!=a&&(o.callback=a),null!==(l=Ud(n,o,i))&&(Yf(l,n,i),Vd(l,n,i))},enqueueForceUpdate:function(n,l){var a=qg(n=n._reactInternals),i=Td(a);i.tag=2,null!=l&&(i.callback=l),null!==(l=Ud(n,i,a))&&(Yf(l,n,a),Vd(l,n,a))}};function zg(n,l,a,i,o,s,y){return"function"==typeof(n=n.stateNode).shouldComponentUpdate?n.shouldComponentUpdate(i,s,y):!l.prototype||!l.prototype.isPureReactComponent||!ae(a,i)||!ae(o,s)}function Ag(n,l,a){var i=!1,o=eJ,s=l.contextType;return"object"==typeof s&&null!==s?s=Lf(s):(o=Tc(l)?e1:eX.current,s=(i=null!=(i=l.contextTypes))?Sc(n,o):eJ),l=new l(a,s),n.memoizedState=null!==l.state&&void 0!==l.state?l.state:null,l.updater=t0,n.stateNode=l,l._reactInternals=n,i&&((n=n.stateNode).__reactInternalMemoizedUnmaskedChildContext=o,n.__reactInternalMemoizedMaskedChildContext=s),l}function Bg(n,l,a,i){n=l.state,"function"==typeof l.componentWillReceiveProps&&l.componentWillReceiveProps(a,i),"function"==typeof l.UNSAFE_componentWillReceiveProps&&l.UNSAFE_componentWillReceiveProps(a,i),l.state!==n&&t0.enqueueReplaceState(l,l.state,null)}function Cg(n,l,a,i){var o=n.stateNode;o.props=a,o.state=n.memoizedState,o.refs={},Rd(n);var s=l.contextType;"object"==typeof s&&null!==s?o.context=Lf(s):(s=Tc(l)?e1:eX.current,o.context=Sc(n,s)),o.state=n.memoizedState,"function"==typeof(s=l.getDerivedStateFromProps)&&(xg(n,l,s,a),o.state=n.memoizedState),"function"==typeof l.getDerivedStateFromProps||"function"==typeof o.getSnapshotBeforeUpdate||"function"!=typeof o.UNSAFE_componentWillMount&&"function"!=typeof o.componentWillMount||(l=o.state,"function"==typeof o.componentWillMount&&o.componentWillMount(),"function"==typeof o.UNSAFE_componentWillMount&&o.UNSAFE_componentWillMount(),l!==o.state&&t0.enqueueReplaceState(o,o.state,null),Xd(n,a,o,i),o.state=n.memoizedState),"function"==typeof o.componentDidMount&&(n.flags|=4194308)}function Dg(n,l){try{var a="",i=l;do a+=function(n){switch(n.tag){case 26:case 27:case 5:return Xb(n.type);case 16:return Xb("Lazy");case 13:return Xb("Suspense");case 19:return Xb("SuspenseList");case 0:case 2:case 15:return n=Zb(n.type,!1);case 11:return n=Zb(n.type.render,!1);case 1:return n=Zb(n.type,!0);default:return""}}(i),i=i.return;while(i);var o=a}catch(n){o="\nError generating stack: "+n.message+"\n"+n.stack}return{value:n,source:l,stack:o,digest:null}}function Eg(n,l,a){return{value:n,source:null,stack:null!=a?a:null,digest:null!=l?l:null}}function Fg(n,l){try{console.error(l.value)}catch(n){setTimeout(function(){throw n})}}function Gg(n,l,a){(a=Td(a)).tag=3,a.payload={element:null};var i=l.value;return a.callback=function(){nY||(nY=!0,nG=i),Fg(n,l)},a}function Jg(n,l,a){(a=Td(a)).tag=3;var i=n.type.getDerivedStateFromError;if("function"==typeof i){var o=l.value;a.payload=function(){return i(o)},a.callback=function(){Fg(n,l)}}var s=n.stateNode;return null!==s&&"function"==typeof s.componentDidCatch&&(a.callback=function(){Fg(n,l),"function"!=typeof i&&(null===nK?nK=new Set([this]):nK.add(this));var a=l.stack;this.componentDidCatch(l.value,{componentStack:null!==a?a:""})}),a}function Lg(n,l,a,i,o){return 0==(1&n.mode)?n===l?n.flags|=65536:(n.flags|=128,a.flags|=131072,a.flags&=-52805,1===a.tag&&(null===a.alternate?a.tag=17:((l=Td(2)).tag=2,Ud(a,l,2))),a.lanes|=2):(n.flags|=65536,n.lanes=o),n}var t1=k.ReactCurrentOwner,t2=Error(t(461)),t3=!1;function Tg(n,l,a,i){l.child=null===n?tC(l,null,a,i):tE(l,n.child,a,i)}function Ug(n,l,a,i,o){a=a.render;var s=l.ref;return(Vg(l,o),i=wf(n,l,a,i,s,o),a=Df(),null===n||t3)?(to&&a&&ld(l),l.flags|=1,Tg(n,l,i,o),l.child):(Ef(n,l,o),Wg(n,l,o))}function Xg(n,l,a,i,o){if(null===n){var s=a.type;return"function"!=typeof s||Yg(s)||void 0!==s.defaultProps||null!==a.compare||void 0!==a.defaultProps?((n=se(a.type,null,i,null,l,l.mode,o)).ref=l.ref,n.return=l,l.child=n):(l.tag=15,l.type=s,Zg(n,l,s,i,o))}if(s=n.child,0==(n.lanes&o)){var y=s.memoizedProps;if((a=null!==(a=a.compare)?a:ae)(y,i)&&n.ref===l.ref)return Wg(n,l,o)}return l.flags|=1,(n=qe(s,i)).ref=l.ref,n.return=l,l.child=n}function Zg(n,l,a,i,o){if(null!==n){var s=n.memoizedProps;if(ae(s,i)&&n.ref===l.ref){if(t3=!1,l.pendingProps=i=s,0==(n.lanes&o))return l.lanes=n.lanes,Wg(n,l,o);0!=(131072&n.flags)&&(t3=!0)}}return $g(n,l,a,i,o)}function ah(n,l,a){var i=l.pendingProps,o=i.children,s=0!=(2&l.stateNode._pendingVisibility),y=null!==n?n.memoizedState:null;if(bh(n,l),"hidden"===i.mode||s){if(0!=(128&l.flags)){if(a=null!==y?y.baseLanes|a:a,null!==n){for(o=0,i=l.child=n.child;null!==i;)o=o|i.lanes|i.childLanes,i=i.sibling;l.childLanes=o&~a}else l.childLanes=0,l.child=null;return ch(n,l,a)}if(0==(1&l.mode))l.memoizedState={baseLanes:0,cachePool:null},null!==n&&dh(l,null),Ce(),Ie(l);else{if(0==(1073741824&a))return l.lanes=l.childLanes=1073741824,ch(n,l,null!==y?y.baseLanes|a:a);l.memoizedState={baseLanes:0,cachePool:null},null!==n&&dh(l,null!==y?y.cachePool:null),null!==y?Ae(l,y):Ce(),Ie(l)}}else null!==y?(dh(l,y.cachePool),Ae(l,y),Je(l),l.memoizedState=null):(null!==n&&dh(l,null),Ce(),Je(l));return Tg(n,l,o,a),l.child}function ch(n,l,a){var i=eh();return i=null===i?null:{parent:nr._currentValue,pool:i},l.memoizedState={baseLanes:a,cachePool:i},null!==n&&dh(l,null),Ce(),Ie(l),null}function bh(n,l){var a=l.ref;(null===n&&null!==a||null!==n&&n.ref!==a)&&(l.flags|=512,l.flags|=2097152)}function $g(n,l,a,i,o){var s=Tc(a)?e1:eX.current;return(s=Sc(l,s),Vg(l,o),a=wf(n,l,a,i,s,o),i=Df(),null===n||t3)?(to&&i&&ld(l),l.flags|=1,Tg(n,l,a,o),l.child):(Ef(n,l,o),Wg(n,l,o))}function fh(n,l,a,i,o,s){return(Vg(l,s),a=zf(l,i,a,o),Af(),i=Df(),null===n||t3)?(to&&i&&ld(l),l.flags|=1,Tg(n,l,a,s),l.child):(Ef(n,l,s),Wg(n,l,s))}function gh(n,l,a,i,o){if(Tc(a)){var s=!0;Xc(l)}else s=!1;if(Vg(l,o),null===l.stateNode)hh(n,l),Ag(l,a,i),Cg(l,a,i,o),i=!0;else if(null===n){var y=l.stateNode,v=l.memoizedProps;y.props=v;var k=y.context,C=a.contextType;C="object"==typeof C&&null!==C?Lf(C):Sc(l,C=Tc(a)?e1:eX.current);var x=a.getDerivedStateFromProps,z="function"==typeof x||"function"==typeof y.getSnapshotBeforeUpdate;z||"function"!=typeof y.UNSAFE_componentWillReceiveProps&&"function"!=typeof y.componentWillReceiveProps||(v!==i||k!==C)&&Bg(l,y,i,C),tp=!1;var P=l.memoizedState;y.state=P,Xd(l,i,y,o),k=l.memoizedState,v!==i||P!==k||e0.current||tp?("function"==typeof x&&(xg(l,a,x,i),k=l.memoizedState),(v=tp||zg(l,a,v,i,P,k,C))?(z||"function"!=typeof y.UNSAFE_componentWillMount&&"function"!=typeof y.componentWillMount||("function"==typeof y.componentWillMount&&y.componentWillMount(),"function"==typeof y.UNSAFE_componentWillMount&&y.UNSAFE_componentWillMount()),"function"==typeof y.componentDidMount&&(l.flags|=4194308)):("function"==typeof y.componentDidMount&&(l.flags|=4194308),l.memoizedProps=i,l.memoizedState=k),y.props=i,y.state=k,y.context=C,i=v):("function"==typeof y.componentDidMount&&(l.flags|=4194308),i=!1)}else{y=l.stateNode,Sd(n,l),v=l.memoizedProps,C=l.type===l.elementType?v:wg(l.type,v),y.props=C,z=l.pendingProps,P=y.context,k="object"==typeof(k=a.contextType)&&null!==k?Lf(k):Sc(l,k=Tc(a)?e1:eX.current);var N=a.getDerivedStateFromProps;(x="function"==typeof N||"function"==typeof y.getSnapshotBeforeUpdate)||"function"!=typeof y.UNSAFE_componentWillReceiveProps&&"function"!=typeof y.componentWillReceiveProps||(v!==z||P!==k)&&Bg(l,y,i,k),tp=!1,P=l.memoizedState,y.state=P,Xd(l,i,y,o);var L=l.memoizedState;v!==z||P!==L||e0.current||tp?("function"==typeof N&&(xg(l,a,N,i),L=l.memoizedState),(C=tp||zg(l,a,C,i,P,L,k)||!1)?(x||"function"!=typeof y.UNSAFE_componentWillUpdate&&"function"!=typeof y.componentWillUpdate||("function"==typeof y.componentWillUpdate&&y.componentWillUpdate(i,L,k),"function"==typeof y.UNSAFE_componentWillUpdate&&y.UNSAFE_componentWillUpdate(i,L,k)),"function"==typeof y.componentDidUpdate&&(l.flags|=4),"function"==typeof y.getSnapshotBeforeUpdate&&(l.flags|=1024)):("function"!=typeof y.componentDidUpdate||v===n.memoizedProps&&P===n.memoizedState||(l.flags|=4),"function"!=typeof y.getSnapshotBeforeUpdate||v===n.memoizedProps&&P===n.memoizedState||(l.flags|=1024),l.memoizedProps=i,l.memoizedState=L),y.props=i,y.state=L,y.context=k,i=C):("function"!=typeof y.componentDidUpdate||v===n.memoizedProps&&P===n.memoizedState||(l.flags|=4),"function"!=typeof y.getSnapshotBeforeUpdate||v===n.memoizedProps&&P===n.memoizedState||(l.flags|=1024),i=!1)}return ih(n,l,a,i,s,o)}function ih(n,l,a,i,o,s){bh(n,l);var y=0!=(128&l.flags);if(!i&&!y)return o&&Yc(l,a,!1),Wg(n,l,s);i=l.stateNode,t1.current=l;var v=y&&"function"!=typeof a.getDerivedStateFromError?null:i.render();return l.flags|=1,null!==n&&y?(l.child=tE(l,n.child,null,s),l.child=tE(l,null,v,s)):Tg(n,l,v,s),l.memoizedState=i.state,o&&Yc(l,a,!0),l.child}function jh(n){var l=n.stateNode;l.pendingContext?Vc(n,l.pendingContext,l.pendingContext!==l.context):l.context&&Vc(n,l.context,!1),Ga(n,l.containerInfo)}function kh(n,l,a,i,o){return Ed(),Fd(o),l.flags|=256,Tg(n,l,a,i),l.child}var t4={dehydrated:null,treeContext:null,retryLane:0};function mh(n){return{baseLanes:n,cachePool:nh()}}function oh(n,l,a){var i,o=l.pendingProps,s=!1,y=0!=(128&l.flags);if((i=y)||(i=(null===n||null!==n.memoizedState)&&0!=(2&tL.current)),i&&(s=!0,l.flags&=-129),null===n){if(to){if(s?Ge(l):Je(l),to&&((y=n=ta)?xd(l,y)||(yd(l)&&zd(),ta=ud(y.nextSibling),i=tl,ta&&xd(l,ta)?pd(i,y):(rd(tl,l),to=!1,tl=l,ta=n)):(yd(l)&&zd(),rd(tl,l),to=!1,tl=l,ta=n)),null!==(n=l.memoizedState)&&null!==(n=n.dehydrated))return 0==(1&l.mode)?l.lanes=2:"$!"===n.data?l.lanes=16:l.lanes=1073741824,null;Ke(l)}return(y=o.children,n=o.fallback,s)?(Je(l),o=l.mode,s=l.child,y={mode:"hidden",children:y},0==(1&o)&&null!==s?(s.childLanes=0,s.pendingProps=y):s=ph(y,o,0,null),n=ue(n,o,a,null),s.return=l,n.return=l,s.sibling=n,l.child=s,l.child.memoizedState=mh(a),l.memoizedState=t4,n):(Ge(l),qh(l,y))}if(null!==(i=n.memoizedState)){var v=i.dehydrated;if(null!==v)return function(n,l,a,i,o,s,y){if(a)return 256&l.flags?(Ge(l),l.flags&=-257,sh(n,l,y,o=Eg(Error(t(422))))):null!==l.memoizedState?(Je(l),l.child=n.child,l.flags|=128,null):(Je(l),o=i.fallback,s=l.mode,i=ph({mode:"visible",children:i.children},s,0,null),o=ue(o,s,y,null),o.flags|=2,i.return=l,o.return=l,i.sibling=o,l.child=i,0!=(1&l.mode)&&tE(l,n.child,null,y),l.child.memoizedState=mh(y),l.memoizedState=t4,o);if(Ge(l),0==(1&l.mode))return sh(n,l,y,null);if("$!"===o.data){if(o=o.nextSibling&&o.nextSibling.dataset)var v=o.dgst;return o=v,(i=Error(t(419))).digest=o,sh(n,l,y,o=Eg(i,o,void 0))}if(v=0!=(y&n.childLanes),t3||v){if(null!==(i=n_)){switch(y&-y){case 2:v=1;break;case 8:v=4;break;case 32:v=16;break;case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:v=64;break;case 536870912:v=268435456;break;default:v=0}if(0!==(v=0!=(v&(i.suspendedLanes|y))?0:v)&&v!==s.retryLane)throw s.retryLane=v,Md(n,v),Yf(i,n,v),t2}return"$?"!==o.data&&Ng(),sh(n,l,y,null)}return"$?"===o.data?(l.flags|=128,l.child=n.child,l=th.bind(null,n),o._reactRetry=l,null):(n=s.treeContext,ta=ud(o.nextSibling),tl=l,to=!0,tu=null,tc=!1,null!==n&&(e5[e7++]=tt,e5[e7++]=tr,e5[e7++]=e9,tt=n.id,tr=n.overflow,e9=l),l=qh(l,i.children),l.flags|=4096,l)}(n,l,y,o,v,i,a)}if(s){Je(l),s=o.fallback,y=l.mode,v=(i=n.child).sibling;var k={mode:"hidden",children:o.children};return 0==(1&y)&&l.child!==i?((o=l.child).childLanes=0,o.pendingProps=k,l.deletions=null):(o=qe(i,k)).subtreeFlags=31457280&i.subtreeFlags,null!==v?s=qe(v,s):(s=ue(s,y,a,null),s.flags|=2),s.return=l,o.return=l,o.sibling=s,l.child=o,o=s,s=l.child,null===(y=n.child.memoizedState)?y=mh(a):(null!==(i=y.cachePool)?(v=nr._currentValue,i=i.parent!==v?{parent:v,pool:v}:i):i=nh(),y={baseLanes:y.baseLanes|a,cachePool:i}),s.memoizedState=y,s.childLanes=n.childLanes&~a,l.memoizedState=t4,o}return Ge(l),n=(s=n.child).sibling,o=qe(s,{mode:"visible",children:o.children}),0==(1&l.mode)&&(o.lanes=a),o.return=l,o.sibling=null,null!==n&&(null===(a=l.deletions)?(l.deletions=[n],l.flags|=16):a.push(n)),l.child=o,l.memoizedState=null,o}function qh(n,l){return(l=ph({mode:"visible",children:l},n.mode,0,null)).return=n,n.child=l}function sh(n,l,a,i){return null!==i&&Fd(i),tE(l,n.child,null,a),n=qh(l,l.pendingProps.children),n.flags|=2,l.memoizedState=null,n}function uh(n,l,a){n.lanes|=l;var i=n.alternate;null!==i&&(i.lanes|=l),vh(n.return,l,a)}function wh(n,l,a,i,o){var s=n.memoizedState;null===s?n.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:i,tail:a,tailMode:o}:(s.isBackwards=l,s.rendering=null,s.renderingStartTime=0,s.last=i,s.tail=a,s.tailMode=o)}function xh(n,l,a){var i=l.pendingProps,o=i.revealOrder,s=i.tail;if(Tg(n,l,i.children,a),0!=(2&(i=tL.current)))i=1&i|2,l.flags|=128;else{if(null!==n&&0!=(128&n.flags))e:for(n=l.child;null!==n;){if(13===n.tag)null!==n.memoizedState&&uh(n,a,l);else if(19===n.tag)uh(n,a,l);else if(null!==n.child){n.child.return=n,n=n.child;continue}if(n===l)break;for(;null===n.sibling;){if(null===n.return||n.return===l)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}i&=1}if(E(tL,i),0==(1&l.mode))l.memoizedState=null;else switch(o){case"forwards":for(o=null,a=l.child;null!==a;)null!==(n=a.alternate)&&null===Le(n)&&(o=a),a=a.sibling;null===(a=o)?(o=l.child,l.child=null):(o=a.sibling,a.sibling=null),wh(l,!1,o,a,s);break;case"backwards":for(a=null,o=l.child,l.child=null;null!==o;){if(null!==(n=o.alternate)&&null===Le(n)){l.child=o;break}n=o.sibling,o.sibling=a,a=o,o=n}wh(l,!0,a,null,s);break;case"together":wh(l,!1,null,null,void 0);break;default:l.memoizedState=null}return l.child}function hh(n,l){0==(1&l.mode)&&null!==n&&(n.alternate=null,l.alternate=null,l.flags|=2)}function Wg(n,l,a){if(null!==n&&(l.dependencies=n.dependencies),nW|=l.lanes,0==(a&l.childLanes))return null;if(null!==n&&l.child!==n.child)throw Error(t(153));if(null!==l.child){for(a=qe(n=l.child,n.pendingProps),l.child=a,a.return=l;null!==n.sibling;)n=n.sibling,(a=a.sibling=qe(n,n.pendingProps)).return=l;a.sibling=null}return l.child}var t8=ia(null),t6=null,t5=null,t7=null;function Eh(){t7=t5=t6=null}function zh(n,l,a){E(t8,l._currentValue),l._currentValue=a}function Fh(n){var l=t8.current;n._currentValue=l===Y?n._defaultValue:l,D(t8)}function vh(n,l,a){for(;null!==n;){var i=n.alternate;if((n.childLanes&l)!==l?(n.childLanes|=l,null!==i&&(i.childLanes|=l)):null!==i&&(i.childLanes&l)!==l&&(i.childLanes|=l),n===a)break;n=n.return}}function Gh(n,l,a){var i=n.child;for(null!==i&&(i.return=n);null!==i;){var o=i.dependencies;if(null!==o)for(var s=i.child,y=o.firstContext;null!==y;){if(y.context===l){if(1===i.tag){(y=Td(a&-a)).tag=2;var v=i.updateQueue;if(null!==v){var k=(v=v.shared).pending;null===k?y.next=y:(y.next=k.next,k.next=y),v.pending=y}}i.lanes|=a,null!==(y=i.alternate)&&(y.lanes|=a),vh(i.return,a,n),o.lanes|=a;break}y=y.next}else if(10===i.tag)s=i.type===n.type?null:i.child;else if(18===i.tag){if(null===(s=i.return))throw Error(t(341));s.lanes|=a,null!==(o=s.alternate)&&(o.lanes|=a),vh(s,a,n),s=i.sibling}else s=i.child;if(null!==s)s.return=i;else for(s=i;null!==s;){if(s===n){s=null;break}if(null!==(i=s.sibling)){i.return=s.return,s=i;break}s=s.return}i=s}}function Vg(n,l){t6=n,t7=t5=null,null!==(n=n.dependencies)&&null!==n.firstContext&&(0!=(n.lanes&l)&&(t3=!0),n.firstContext=null)}function Lf(n){return Hh(t6,n)}function ve(n,l,a){return null===t6&&Vg(n,a),Hh(n,l)}function Hh(n,l){var a=l._currentValue;if(t7!==l){if(l={context:l,memoizedValue:a,next:null},null===t5){if(null===n)throw Error(t(308));t5=l,n.dependencies={lanes:0,firstContext:l}}else t5=t5.next=l}return a}var t9="undefined"!=typeof AbortController?AbortController:function(){var n=[],l=this.signal={aborted:!1,addEventListener:function(l,a){n.push(a)}};this.abort=function(){l.aborted=!0,n.forEach(function(n){return n()})}},nt=s.unstable_scheduleCallback,nn=s.unstable_NormalPriority,nr={$$typeof:M,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0,_defaultValue:null,_globalName:null};function rg(){return{controller:new t9,data:new Map,refCount:0}}function Lh(n){n.refCount--,0===n.refCount&&nt(nn,function(){n.controller.abort()})}var na=k.ReactCurrentBatchConfig,ni=ia(null);function eh(){var n=ni.current;return null!==n?n:n_.pooledCache}function dh(n,l){null===l?E(ni,ni.current):E(ni,l.pool)}function nh(){var n=eh();return null===n?null:{parent:nr._currentValue,pool:n}}function Oh(n){n.flags|=4}function Ph(n){n.flags|=2097664}function Qh(n,l){if("stylesheet"!==l.type||0!=(4&l.state.loading))n.flags&=-16777217;else if(n.flags|=16777216,0==(42&nM)&&!(l="stylesheet"!==l.type||0!=(3&l.state.loading))){if(Rh())n.flags|=8192;else throw tk=tv,ty}}function Sh(n,l){null!==l?n.flags|=4:16384&n.flags&&(l=22!==n.tag?kb():1073741824,n.lanes|=l)}function Th(n,l){if(!to)switch(n.tailMode){case"hidden":l=n.tail;for(var a=null;null!==l;)null!==l.alternate&&(a=l),l=l.sibling;null===a?n.tail=null:a.sibling=null;break;case"collapsed":a=n.tail;for(var i=null;null!==a;)null!==a.alternate&&(i=a),a=a.sibling;null===i?l||null===n.tail?n.tail=null:n.tail.sibling=null:i.sibling=null}}function V(n){var l=null!==n.alternate&&n.alternate.child===n.child,a=0,i=0;if(l)for(var o=n.child;null!==o;)a|=o.lanes|o.childLanes,i|=31457280&o.subtreeFlags,i|=31457280&o.flags,o.return=n,o=o.sibling;else for(o=n.child;null!==o;)a|=o.lanes|o.childLanes,i|=o.subtreeFlags,i|=o.flags,o.return=n,o=o.sibling;return n.subtreeFlags|=i,n.childLanes=a,l}function ei(n,l){switch(md(l),l.tag){case 1:null!=(n=l.type.childContextTypes)&&Uc();break;case 3:Fh(nr),Ja(),D(e0),D(eX);break;case 26:case 27:case 5:La(l);break;case 4:Ja();break;case 13:Ke(l);break;case 19:D(tL);break;case 10:Fh(l.type._context);break;case 22:case 23:Ke(l),De(),null!==n&&D(ni);break;case 24:Fh(nr)}}function fi(n,l,a){var i=Array.prototype.slice.call(arguments,3);try{l.apply(a,i)}catch(n){this.onError(n)}}var no=!1,nu=null,nc=!1,ns=null,nf={onError:function(n){no=!0,nu=n}};function li(n,l,a,i,o,s,y,v,k){no=!1,nu=null,fi.apply(nf,arguments)}var nd=!1,np=!1,nb="function"==typeof WeakSet?WeakSet:Set,ny=null;function ri(n,l){try{var a=n.ref;if(null!==a){var i=n.stateNode;switch(n.tag){case 26:case 27:case 5:var o=i;break;default:o=i}"function"==typeof a?n.refCleanup=a(o):a.current=o}}catch(a){W(n,l,a)}}function si(n,l){var a=n.ref,i=n.refCleanup;if(null!==a){if("function"==typeof i)try{i()}catch(a){W(n,l,a)}finally{n.refCleanup=null,null!=(n=n.alternate)&&(n.refCleanup=null)}else if("function"==typeof a)try{a(null)}catch(a){W(n,l,a)}else a.current=null}}function ti(n,l,a){try{a()}catch(a){W(n,l,a)}}var nv=!1;function Ci(n,l,a){var i=l.updateQueue;if(null!==(i=null!==i?i.lastEffect:null)){var o=i=i.next;do{if((o.tag&n)===n){var s=o.inst,y=s.destroy;void 0!==y&&(s.destroy=void 0,ti(l,a,y))}o=o.next}while(o!==i)}}function Di(n,l){if(null!==(l=null!==(l=l.updateQueue)?l.lastEffect:null)){var a=l=l.next;do{if((a.tag&n)===n){var i=a.create,o=a.inst;i=i(),o.destroy=i}a=a.next}while(a!==l)}}function Ei(n,l){try{Di(l,n)}catch(l){W(n,n.return,l)}}function Fi(n){var l=n.updateQueue;if(null!==l){var a=n.stateNode;try{$d(l,a)}catch(l){W(n,n.return,l)}}}function Gi(n){var l=n.type,a=n.memoizedProps,i=n.stateNode;try{switch(l){case"button":case"input":case"select":case"textarea":a.autoFocus&&i.focus();break;case"img":a.src&&(i.src=a.src)}}catch(l){W(n,n.return,l)}}function Hi(n,l,a){var i=a.flags;switch(a.tag){case 0:case 11:case 15:Ii(n,a),4&i&&Ei(a,5);break;case 1:if(Ii(n,a),4&i){if(n=a.stateNode,null===l)try{n.componentDidMount()}catch(n){W(a,a.return,n)}else{var o=a.elementType===a.type?l.memoizedProps:wg(a.type,l.memoizedProps);l=l.memoizedState;try{n.componentDidUpdate(o,l,n.__reactInternalSnapshotBeforeUpdate)}catch(n){W(a,a.return,n)}}}64&i&&Fi(a),512&i&&ri(a,a.return);break;case 3:if(Ii(n,a),64&i&&null!==(i=a.updateQueue)){if(n=null,null!==a.child)switch(a.child.tag){case 27:case 5:case 1:n=a.child.stateNode}try{$d(i,n)}catch(n){W(a,a.return,n)}}break;case 26:Ii(n,a),512&i&&ri(a,a.return);break;case 27:case 5:Ii(n,a),null===l&&4&i&&Gi(a),512&i&&ri(a,a.return);break;case 12:default:Ii(n,a);break;case 13:Ii(n,a),4&i&&Ji(n,a);break;case 22:if(0!=(1&a.mode)){if(!(o=null!==a.memoizedState||nd)){l=null!==l&&null!==l.memoizedState||np;var s=nd,y=np;nd=o,(np=l)&&!y?function Ki(n,l,a){for(a=a&&0!=(8772&l.subtreeFlags),l=l.child;null!==l;){var i=l.alternate,o=n,s=l,y=s.flags;switch(s.tag){case 0:case 11:case 15:Ki(o,s,a),Ei(s,4);break;case 1:if(Ki(o,s,a),"function"==typeof(o=s.stateNode).componentDidMount)try{o.componentDidMount()}catch(n){W(s,s.return,n)}if(null!==(i=s.updateQueue)){var v=i.shared.hiddenCallbacks;if(null!==v)for(i.shared.hiddenCallbacks=null,i=0;i title"))),Zh(o,a,i),o[eP]=n,Jb(o),a=o;break e;case"link":var s=cj("link","href",l).get(a+(i.href||""));if(s){for(var y=0;y",n=n.removeChild(n.firstChild);break;case"select":n="string"==typeof i.is?o.createElement("select",{is:i.is}):o.createElement("select"),i.multiple?n.multiple=!0:i.size&&(n.size=i.size);break;default:n="string"==typeof i.is?o.createElement(a,{is:i.is}):o.createElement(a)}}n[eP]=l,n[eN]=i;e:for(o=l.child;null!==o;){if(5===o.tag||6===o.tag)n.appendChild(o.stateNode);else if(4!==o.tag&&27!==o.tag&&null!==o.child){o.child.return=o,o=o.child;continue}if(o===l)break;for(;null===o.sibling;){if(null===o.return||o.return===l)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}switch(l.stateNode=n,Zh(n,a,i),a){case"button":case"input":case"select":case"textarea":n=!!i.autoFocus;break;case"img":n=!0;break;default:n=!1}n&&Oh(l)}null!==l.ref&&Ph(l)}return V(l),l.flags&=-16777217,null;case 6:if(n&&null!=l.stateNode)n.memoizedProps!==i&&Oh(l);else{if("string"!=typeof i&&null===l.stateNode)throw Error(t(166));if(n=X.current,Bd(l)){e:{if(n=l.stateNode,a=l.memoizedProps,n[eP]=l,(i=n.nodeValue!==a)&&null!==(o=tl))switch(o.tag){case 3:if(o=0!=(1&o.mode),$h(n.nodeValue,a,o),o){n=!1;break e}break;case 27:case 5:var s=0!=(1&o.mode);if(!0!==o.memoizedProps.suppressHydrationWarning&&$h(n.nodeValue,a,s),s){n=!1;break e}}n=i}n&&Oh(l)}else(n=Yh(n).createTextNode(i))[eP]=l,l.stateNode=n}return V(l),null;case 13:if(Ke(l),i=l.memoizedState,null===n||null!==n.memoizedState&&null!==n.memoizedState.dehydrated){if(to&&null!==ta&&0!=(1&l.mode)&&0==(128&l.flags))Dd(),Ed(),l.flags|=384,o=!1;else if(o=Bd(l),null!==i&&null!==i.dehydrated){if(null===n){if(!o)throw Error(t(318));if(!(o=null!==(o=l.memoizedState)?o.dehydrated:null))throw Error(t(317));o[eP]=l}else Ed(),0==(128&l.flags)&&(l.memoizedState=null),l.flags|=4;V(l),o=!1}else null!==tu&&(Vh(tu),tu=null),o=!0;if(!o)return 256&l.flags?l:null}if(0!=(128&l.flags))return l.lanes=a,l;return a=null!==i,n=null!==n&&null!==n.memoizedState,a&&(i=l.child,o=null,null!==i.alternate&&null!==i.alternate.memoizedState&&null!==i.alternate.memoizedState.cachePool&&(o=i.alternate.memoizedState.cachePool.pool),s=null,null!==i.memoizedState&&null!==i.memoizedState.cachePool&&(s=i.memoizedState.cachePool.pool),s!==o&&(i.flags|=2048)),a!==n&&a&&(l.child.flags|=8192),Sh(l,l.updateQueue),V(l),null;case 4:return Ja(),null===n&&ai(l.stateNode.containerInfo),V(l),null;case 10:return Fh(l.type._context),V(l),null;case 19:if(D(tL),null===(o=l.memoizedState))return V(l),null;if(i=0!=(128&l.flags),null===(s=o.rendering)){if(i)Th(o,!1);else{if(0!==nV||null!==n&&0!=(128&n.flags))for(n=l.child;null!==n;){if(null!==(s=Le(n))){for(l.flags|=128,Th(o,!1),n=s.updateQueue,l.updateQueue=n,Sh(l,n),l.subtreeFlags=0,n=a,a=l.child;null!==a;)bi(a,n),a=a.sibling;return E(tL,1&tL.current|2),l.child}n=n.sibling}null!==o.tail&&ea()>nB&&(l.flags|=128,i=!0,Th(o,!1),l.lanes=8388608)}}else{if(!i){if(null!==(n=Le(s))){if(l.flags|=128,i=!0,n=n.updateQueue,l.updateQueue=n,Sh(l,n),Th(o,!0),null===o.tail&&"hidden"===o.tailMode&&!s.alternate&&!to)return V(l),null}else 2*ea()-o.renderingStartTime>nB&&1073741824!==a&&(l.flags|=128,i=!0,Th(o,!1),l.lanes=8388608)}o.isBackwards?(s.sibling=l.child,l.child=s):(null!==(n=o.last)?n.sibling=s:l.child=s,o.last=s)}if(null!==o.tail)return l=o.tail,o.rendering=l,o.tail=l.sibling,o.renderingStartTime=ea(),l.sibling=null,n=tL.current,E(tL,i?1&n|2:1&n),l;return V(l),null;case 22:case 23:return Ke(l),De(),i=null!==l.memoizedState,null!==n?null!==n.memoizedState!==i&&(l.flags|=8192):i&&(l.flags|=8192),i&&0!=(1&l.mode)?0!=(1073741824&a)&&0==(128&l.flags)&&(V(l),6&l.subtreeFlags&&(l.flags|=8192)):V(l),null!==(a=l.updateQueue)&&Sh(l,a.retryQueue),a=null,null!==n&&null!==n.memoizedState&&null!==n.memoizedState.cachePool&&(a=n.memoizedState.cachePool.pool),i=null,null!==l.memoizedState&&null!==l.memoizedState.cachePool&&(i=l.memoizedState.cachePool.pool),i!==a&&(l.flags|=2048),null!==n&&D(ni),null;case 24:return a=null,null!==n&&(a=n.memoizedState.cache),l.memoizedState.cache!==a&&(l.flags|=2048),Fh(nr),V(l),null;case 25:return null}throw Error(t(156,l.tag))}(l.alternate,l,nR);if(null!==a){nD=a;return}if(null!==(l=l.sibling)){nD=l;return}nD=l=n}while(null!==l);0===nV&&(nV=5)}function bf(n,l,a){var i=eC,o=nL.transition;try{nL.transition=null,eC=2,function(n,l,a,i){do We();while(null!==nX);if(0!=(6&nT))throw Error(t(327));var o=n.finishedWork,s=n.finishedLanes;if(null!==o){if(n.finishedWork=null,n.finishedLanes=0,o===n.current)throw Error(t(177));n.callbackNode=null,n.callbackPriority=0,n.cancelPendingCommit=null;var y=o.lanes|o.childLanes;if(function(n,l){var a=n.pendingLanes&~l;n.pendingLanes=l,n.suspendedLanes=0,n.pingedLanes=0,n.expiredLanes&=l,n.entangledLanes&=l,n.errorRecoveryDisabledLanes&=l,n.shellSuspendCounter=0,l=n.entanglements;var i=n.expirationTimes;for(n=n.hiddenUpdates;0i&&(o=i,i=s,s=o),o=Gm(a,s);var y=Gm(a,i);o&&y&&(1!==n.rangeCount||n.anchorNode!==o.node||n.anchorOffset!==o.offset||n.focusNode!==y.node||n.focusOffset!==y.offset)&&((l=l.createRange()).setStart(o.node,o.offset),n.removeAllRanges(),s>i?(n.addRange(l),n.extend(y.node,y.offset)):(l.setEnd(y.node,y.offset),n.addRange(l)))}}for(l=[],n=a;n=n.parentNode;)1===n.nodeType&&l.push({element:n,left:n.scrollLeft,top:n.scrollTop});for("function"==typeof a.focus&&a.focus(),a=0;aa?32:a;a=nL.transition;var o=eC;try{if(nL.transition=null,eC=i,null===nX)var s=!1;else{i=n2,n2=null;var y=nX,v=n0;if(nX=null,n0=0,0!=(6&nT))throw Error(t(331));var k=nT;if(nT|=4,yj(y.current),oj(y,y.current,v,i),nT=k,Ve(!1),eb&&"function"==typeof eb.onPostCommitFiberRoot)try{eb.onPostCommitFiberRoot(em,y)}catch(n){}s=!0}return s}finally{eC=o,nL.transition=a,ok(n,l)}}return!1}function pk(n,l,a){l=Gg(n,l=Dg(a,l),2),null!==(n=Ud(n,l,2))&&(mb(n,2),Se(n))}function W(n,l,a){if(3===n.tag)pk(n,n,a);else for(;null!==l;){if(3===l.tag){pk(l,n,a);break}if(1===l.tag){var i=l.stateNode;if("function"==typeof l.type.getDerivedStateFromError||"function"==typeof i.componentDidCatch&&(null===nK||!nK.has(i))){n=Jg(l,n=Dg(a,n),2),null!==(l=Ud(l,n,2))&&(mb(l,2),Se(l));break}}l=l.return}}function Pg(n,l,a){var i=n.pingCache;if(null===i){i=n.pingCache=new nx;var o=new Set;i.set(l,o)}else void 0===(o=i.get(l))&&(o=new Set,i.set(l,o));o.has(a)||(nI=!0,o.add(a),n=qk.bind(null,n,l,a),l.then(n,n))}function qk(n,l,a){var i=n.pingCache;null!==i&&i.delete(l),n.pingedLanes|=n.suspendedLanes&a,n_===n&&(nM&a)===a&&(4===nV||3===nV&&(125829120&nM)===nM&&300>ea()-n$?0==(2&nT)&&$e(n,0):nq|=a),Se(n)}function rk(n,l){0===l&&(l=0==(1&n.mode)?2:kb()),null!==(n=Md(n,l))&&(mb(n,l),Se(n))}function th(n){var l=n.memoizedState,a=0;null!==l&&(a=l.retryLane),rk(n,a)}function Yi(n,l){var a=0;switch(n.tag){case 13:var i=n.stateNode,o=n.memoizedState;null!==o&&(a=o.retryLane);break;case 19:i=n.stateNode;break;case 22:i=n.stateNode._retryCache;break;default:throw Error(t(314))}null!==i&&i.delete(l),rk(n,a)}function uk(n,l,a,i){this.tag=n,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function qd(n,l,a,i){return new uk(n,l,a,i)}function Yg(n){return!(!(n=n.prototype)||!n.isReactComponent)}function qe(n,l){var a=n.alternate;return null===a?((a=qd(n.tag,l,n.key,n.mode)).elementType=n.elementType,a.type=n.type,a.stateNode=n.stateNode,a.alternate=n,n.alternate=a):(a.pendingProps=l,a.type=n.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=31457280&n.flags,a.childLanes=n.childLanes,a.lanes=n.lanes,a.child=n.child,a.memoizedProps=n.memoizedProps,a.memoizedState=n.memoizedState,a.updateQueue=n.updateQueue,l=n.dependencies,a.dependencies=null===l?null:{lanes:l.lanes,firstContext:l.firstContext},a.sibling=n.sibling,a.index=n.index,a.ref=n.ref,a.refCleanup=n.refCleanup,a}function bi(n,l){n.flags&=31457282;var a=n.alternate;return null===a?(n.childLanes=0,n.lanes=l,n.child=null,n.subtreeFlags=0,n.memoizedProps=null,n.memoizedState=null,n.updateQueue=null,n.dependencies=null,n.stateNode=null):(n.childLanes=a.childLanes,n.lanes=a.lanes,n.child=a.child,n.subtreeFlags=0,n.deletions=null,n.memoizedProps=a.memoizedProps,n.memoizedState=a.memoizedState,n.updateQueue=a.updateQueue,n.type=a.type,l=a.dependencies,n.dependencies=null===l?null:{lanes:l.lanes,firstContext:l.firstContext}),n}function se(n,l,a,i,o,s,y){if(o=2,i=n,"function"==typeof n)Yg(n)&&(o=1);else if("string"==typeof n)o=!function(n,l,a){if(1===a||null!=l.itemProp)return!1;switch(n){case"meta":case"title":return!0;case"style":if("string"!=typeof l.precedence||"string"!=typeof l.href||""===l.href)break;return!0;case"link":if("string"!=typeof l.rel||"string"!=typeof l.href||""===l.href||l.onLoad||l.onError)break;if("stylesheet"===l.rel)return n=l.disabled,"string"==typeof l.precedence&&null==n;return!0;case"script":if(!0===l.async&&!l.onLoad&&!l.onError&&"string"==typeof l.src&&l.src)return!0}return!1}(n,a,K.current)?"html"===n||"head"===n||"body"===n?27:5:26;else e:switch(n){case N:return ue(a.children,s,y,l);case L:o=8,0!=(1&(s|=8))&&(s|=16);break;case _:return(n=qd(12,a,l,2|s)).elementType=_,n.lanes=y,n;case I:return(n=qd(13,a,l,s)).elementType=I,n.lanes=y,n;case R:return(n=qd(19,a,l,s)).elementType=R,n.lanes=y,n;case Q:return ph(a,s,y,l);case $:case H:case B:return(n=qd(24,a,l,s)).elementType=B,n.lanes=y,n;default:if("object"==typeof n&&null!==n)switch(n.$$typeof){case j:o=10;break e;case M:o=9;break e;case O:o=11;break e;case A:o=14;break e;case U:o=16,i=null;break e}throw Error(t(130,null==n?n:typeof n,""))}return(l=qd(o,a,l,s)).elementType=n,l.type=i,l.lanes=y,l}function ue(n,l,a,i){return(n=qd(7,n,i,l)).lanes=a,n}function ph(n,l,a,i){(n=qd(22,n,i,l)).elementType=Q,n.lanes=a;var o={_visibility:1,_pendingVisibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null,_current:null,detach:function(){var n=o._current;if(null===n)throw Error(t(456));if(0==(2&o._pendingVisibility)){var l=Md(n,2);null!==l&&(o._pendingVisibility|=2,Yf(l,n,2))}},attach:function(){var n=o._current;if(null===n)throw Error(t(456));if(0!=(2&o._pendingVisibility)){var l=Md(n,2);null!==l&&(o._pendingVisibility&=-3,Yf(l,n,2))}}};return n.stateNode=o,n}function re(n,l,a){return(n=qd(6,n,null,l)).lanes=a,n}function te(n,l,a){return(l=qd(4,null!==n.children?n.children:[],n.key,l)).lanes=a,l.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},l}function wk(n,l,a,i,o,s){this.tag=l,this.containerInfo=n,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=lb(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.finishedLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=lb(0),this.hiddenUpdates=lb(null),this.identifierPrefix=i,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=s,this.incompleteTransitions=new Map}function xk(n,l,a,i,o,s,y,v,k,C,x){return n=new wk(n,l,a,v,k,x),1===l?(l=1,!0===s&&(l|=24)):l=0,s=qd(3,null,null,l),n.current=s,s.stateNode=n,l=rg(),l.refCount++,n.pooledCache=l,l.refCount++,s.memoizedState={element:i,isDehydrated:a,cache:l},Rd(s),n}function zk(n){if(!n)return eJ;n=n._reactInternals;e:{if(Ic(n)!==n||1!==n.tag)throw Error(t(170));var l=n;do{switch(l.tag){case 3:l=l.stateNode.context;break e;case 1:if(Tc(l.type)){l=l.stateNode.__reactInternalMemoizedMergedChildContext;break e}}l=l.return}while(null!==l);throw Error(t(171))}if(1===n.tag){var a=n.type;if(Tc(a))return Wc(n,a,l)}return l}function Ak(n,l,a,i,o,s,y,v,k,C,x){return(n=xk(a,i,!0,n,o,s,y,v,k,C,x)).context=zk(null),(o=Td(i=qg(a=n.current))).callback=null!=l?l:null,Ud(a,o,i),n.current.lanes=i,mb(n,i),Se(n),n}function Bk(n,l,a,i){var o=l.current,s=qg(o);return a=zk(a),null===l.context?l.context=a:l.pendingContext=a,(l=Td(s)).payload={element:n},null!==(i=void 0===i?null:i)&&(l.callback=i),null!==(n=Ud(o,l,s))&&(Yf(n,o,s),Vd(n,o,s)),s}function Ck(n){return(n=n.current).child?(n.child.tag,n.child.stateNode):null}function Fk(n,l){if(null!==(n=n.memoizedState)&&null!==n.dehydrated){var a=n.retryLane;n.retryLane=0!==a&&a=rB),rG=!1;function fm(n,l){switch(n){case"keyup":return -1!==rQ.indexOf(l.keyCode);case"keydown":return 229!==l.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function hm(n){return"object"==typeof(n=n.detail)&&"data"in n?n.data:null}var rK=!1,rJ={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function mm(n){var l=n&&n.nodeName&&n.nodeName.toLowerCase();return"input"===l?!!rJ[n.type]:"textarea"===l}function nm(n,l,a,i){Gc(i),0<(l=om(l,"onChange")).length&&(a=new rc("onChange","change",null,a,i),n.push({event:a,listeners:l}))}var rX=null,r0=null;function rm(n){sm(n,0)}function tm(n){if(gc(Gb(n)))return n}function um(n,l){if("change"===n)return l}var r1=!1;if(eR){if(eR){var r2="oninput"in document;if(!r2){var r3=document.createElement("div");r3.setAttribute("oninput","return;"),r2="function"==typeof r3.oninput}i=r2}else i=!1;r1=i&&(!document.documentMode||9=l)return{node:i,offset:l-n};n=a}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Fm(i)}}function yi(){for(var n=window,l=hc();l instanceof n.HTMLIFrameElement;){try{var a="string"==typeof l.contentWindow.location.href}catch(n){a=!1}if(a)n=l.contentWindow;else break;l=hc(n.document)}return l}function zi(n){var l=n&&n.nodeName&&n.nodeName.toLowerCase();return l&&("input"===l&&("text"===n.type||"search"===n.type||"tel"===n.type||"url"===n.type||"password"===n.type)||"textarea"===l||"true"===n.contentEditable)}var r4=eR&&"documentMode"in document&&11>=document.documentMode,r8=null,r6=null,r5=null,r7=!1;function Nm(n,l,a){var i=a.window===a?a.document:9===a.nodeType?a:a.ownerDocument;r7||null==r8||r8!==hc(i)||(i="selectionStart"in(i=r8)&&zi(i)?{start:i.selectionStart,end:i.selectionEnd}:{anchorNode:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset},r5&&ae(r5,i)||(r5=i,0<(i=om(r6,"onSelect")).length&&(l=new rc("onSelect","select",null,l,a),n.push({event:l,listeners:i}),l.target=r8)))}function Om(n,l){var a={};return a[n.toLowerCase()]=l.toLowerCase(),a["Webkit"+n]="webkit"+l,a["Moz"+n]="moz"+l,a}var r9={animationend:Om("Animation","AnimationEnd"),animationiteration:Om("Animation","AnimationIteration"),animationstart:Om("Animation","AnimationStart"),transitionend:Om("Transition","TransitionEnd")},lt={},lr={};function Sm(n){if(lt[n])return lt[n];if(!r9[n])return n;var l,a=r9[n];for(l in a)if(a.hasOwnProperty(l)&&l in lr)return lt[n]=a[l];return n}eR&&(lr=document.createElement("div").style,"AnimationEvent"in window||(delete r9.animationend.animation,delete r9.animationiteration.animation,delete r9.animationstart.animation),"TransitionEvent"in window||delete r9.transitionend.transition);var ll=Sm("animationend"),la=Sm("animationiteration"),lo=Sm("animationstart"),lu=Sm("transitionend"),ls=new Map,lf="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Zm(n,l){ls.set(n,l),Mb(l,[n])}for(var lp=0;lp title"):null)}var lD=null;function Vj(){}function Pn(){if(this.count--,0===this.count){if(this.stylesheets)Qn(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var lM=null;function Qn(n,l){n.stylesheets=null,null!==n.unsuspend&&(n.count++,lM=new Map,l.forEach(Sn,n),lM=null,Pn.call(n))}function Sn(n,l){if(!(4&l.state.loading)){var a=lM.get(n);if(a)var i=a.get("last");else{a=new Map,lM.set(n,a);for(var o=n.querySelectorAll("link[data-precedence],style[data-precedence]"),s=0;s